-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-144145: Track nullness of properties in the Tier 2 JIT optimizer #144122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
dfd99d7
7bb2c20
20920fc
2e9c5a6
5b4bd5f
6a828d7
90e4800
bf29c13
b80bce1
ec50130
da39868
7c0c815
873ca91
8bd0ff9
0a7cb9a
2f8c2ce
ddbb9c5
9c91e86
f74096b
a7f00bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,10 @@ extern "C" { | |||||||||||
|
|
||||||||||||
| #define TY_ARENA_SIZE (UOP_MAX_TRACE_LENGTH * 5) | ||||||||||||
|
|
||||||||||||
| // Maximum slots per object tracked symbolically | ||||||||||||
| #define MAX_SYMBOLIC_SLOTS_SIZE 16 | ||||||||||||
| #define SLOTS_ARENA_SIZE (MAX_SYMBOLIC_SLOTS_SIZE * 100) | ||||||||||||
|
|
||||||||||||
| // Need extras for root frame and for overflow frame (see TRACE_STACK_PUSH()) | ||||||||||||
| #define MAX_ABSTRACT_FRAME_DEPTH (16) | ||||||||||||
|
|
||||||||||||
|
|
@@ -41,6 +45,7 @@ typedef enum _JitSymType { | |||||||||||
| JIT_SYM_TRUTHINESS_TAG = 9, | ||||||||||||
| JIT_SYM_COMPACT_INT = 10, | ||||||||||||
| JIT_SYM_PREDICATE_TAG = 11, | ||||||||||||
| JIT_SYM_SLOTS_TAG = 12, | ||||||||||||
| } JitSymType; | ||||||||||||
|
|
||||||||||||
| typedef struct _jit_opt_known_class { | ||||||||||||
|
|
@@ -89,6 +94,19 @@ typedef struct { | |||||||||||
| uint8_t tag; | ||||||||||||
| } JitOptCompactInt; | ||||||||||||
|
|
||||||||||||
| typedef struct { | ||||||||||||
| uint16_t slot_index; | ||||||||||||
| uint16_t symbol; | ||||||||||||
| } JitOptDescrMapping; | ||||||||||||
|
Comment on lines
+111
to
+114
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it safe to use this for both normal objects and objects with Basically I'm asking if it's possible for an object to both have STORE_ATTR_INSTANCE_VALUE and STORE_ATTR_SLOT, as this will cause a index collision between the slots and offset. It it safe also with If you think of an answer, please let me know, and we can add it as a comment in the code. otherwise, this is kind of scary.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two never appear on the same object type because: Lines 665 to 669 in 5f57f69
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However, conflicts between
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we track
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No lets ignore with hint for now. |
||||||||||||
|
|
||||||||||||
|
cocolato marked this conversation as resolved.
|
||||||||||||
| typedef struct _jit_opt_slots { | ||||||||||||
| uint8_t tag; | ||||||||||||
| uint8_t num_slots; | ||||||||||||
| uint16_t last_modified_index; // Index in out_buffer when this object was last modified | ||||||||||||
| uint32_t type_version; | ||||||||||||
| JitOptDescrMapping *slots; | ||||||||||||
| } JitOptSlotsObject; | ||||||||||||
|
|
||||||||||||
| typedef union _jit_opt_symbol { | ||||||||||||
| uint8_t tag; | ||||||||||||
| JitOptKnownClass cls; | ||||||||||||
|
|
@@ -97,6 +115,7 @@ typedef union _jit_opt_symbol { | |||||||||||
| JitOptTuple tuple; | ||||||||||||
| JitOptTruthiness truthiness; | ||||||||||||
| JitOptCompactInt compact; | ||||||||||||
| JitOptSlotsObject slots; | ||||||||||||
| JitOptPredicate predicate; | ||||||||||||
| } JitOptSymbol; | ||||||||||||
|
|
||||||||||||
|
|
@@ -126,6 +145,11 @@ typedef struct ty_arena { | |||||||||||
| JitOptSymbol arena[TY_ARENA_SIZE]; | ||||||||||||
| } ty_arena; | ||||||||||||
|
|
||||||||||||
| typedef struct slots_arena { | ||||||||||||
| int slots_curr_number; | ||||||||||||
| int slots_max_number; | ||||||||||||
| JitOptDescrMapping arena[SLOTS_ARENA_SIZE]; | ||||||||||||
| } slots_arena; | ||||||||||||
|
|
||||||||||||
| #ifdef __cplusplus | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -247,6 +247,9 @@ add_op(JitOptContext *ctx, _PyUOpInstruction *this_instr, | |
| #define sym_is_compact_int _Py_uop_sym_is_compact_int | ||
| #define sym_new_compact_int _Py_uop_sym_new_compact_int | ||
| #define sym_new_truthiness _Py_uop_sym_new_truthiness | ||
| #define sym_new_slots_object _Py_uop_sym_new_slots_object | ||
| #define sym_slots_getattr _Py_uop_sym_slots_getattr | ||
| #define sym_slots_setattr _Py_uop_sym_slots_setattr | ||
| #define sym_new_predicate _Py_uop_sym_new_predicate | ||
| #define sym_apply_predicate_narrowing _Py_uop_sym_apply_predicate_narrowing | ||
|
|
||
|
|
@@ -506,6 +509,10 @@ optimize_uops( | |
| if (ctx->out_buffer.next == out_ptr) { | ||
| *(ctx->out_buffer.next++) = *this_instr; | ||
| } | ||
| // Track escapes | ||
| if (_PyUop_Flags[out_ptr->opcode] & HAS_ESCAPES_FLAG) { | ||
| ctx->last_escape_index = uop_buffer_length(&ctx->out_buffer); | ||
| } | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Fidget-Spinner If we use this method to detect escapes, then each |
||
| assert(ctx->frame != NULL); | ||
| if (!CURRENT_FRAME_IS_INIT_SHIM()) { | ||
| DPRINTF(3, " stack_level %d\n", STACK_LEVEL()); | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need to adjust this arena_size.