| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -33,6 +33,8 @@ struct _Py_UopsSymbol { | |
| int flags; // 0 bits: Top; 2 or more bits: Bottom | ||
| PyTypeObject *typ; // Borrowed reference | ||
| PyObject *const_val; // Owned reference (!) | ||
| int tuple_count; | ||
| struct _Py_UopsSymbol **tuple_val; | ||
|
Comment thread
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCan you use indexes, rather than pointers? We can fit 6 10-bit indexes into a 64 bit int. Would it be possible to use a union, and overlap this field with const_val?
Sorry, something went wrong.
All reactions
|
||
| }; | ||
|
|
||
| #define UOP_FORMAT_TARGET 0 | ||
| Expand Down Expand Up | @@ -92,6 +94,12 @@ typedef struct ty_arena { | |
| _Py_UopsSymbol arena[TY_ARENA_SIZE]; | ||
| } ty_arena; | ||
|
|
||
| typedef struct tup_arena { | ||
|
Comment thread
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis shouldn't be necessary, if we use indexes into the arena, instead of pointers.
Sorry, something went wrong.
All reactions
|
||
| int tup_curr_number; | ||
| int tup_max_number; | ||
| _Py_UopsSymbol *arena[TY_ARENA_SIZE]; | ||
| } tup_arena; | ||
|
|
||
| struct _Py_UOpsContext { | ||
| char done; | ||
| char out_of_space; | ||
| Expand All | @@ -104,6 +112,9 @@ struct _Py_UOpsContext { | |
| // Arena for the symbolic types. | ||
| ty_arena t_arena; | ||
|
|
||
| // Arena for the symbolic tuple objects. | ||
| tup_arena tup_arena; | ||
|
|
||
| _Py_UopsSymbol **n_consumed; | ||
| _Py_UopsSymbol **limit; | ||
| _Py_UopsSymbol *locals_and_stack[MAX_ABSTRACT_INTERP_SIZE]; | ||
| Expand All | @@ -119,6 +130,8 @@ extern _Py_UopsSymbol *_Py_uop_sym_new_unknown(_Py_UOpsContext *ctx); | |
| extern _Py_UopsSymbol *_Py_uop_sym_new_not_null(_Py_UOpsContext *ctx); | ||
| extern _Py_UopsSymbol *_Py_uop_sym_new_type( | ||
| _Py_UOpsContext *ctx, PyTypeObject *typ); | ||
| extern _Py_UopsSymbol *_Py_uop_sym_new_tuple(_Py_UOpsContext *ctx, int count); | ||
| extern _Py_UopsSymbol *_Py_uop_sym_tuple_at(_Py_UopsSymbol *sym, int idx); | ||
|
Comment thread
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCan you use get_item, not at, for consistency with the rest of the code base?
Sorry, something went wrong.
All reactions
|
||
| extern _Py_UopsSymbol *_Py_uop_sym_new_const(_Py_UOpsContext *ctx, PyObject *const_val); | ||
| extern _Py_UopsSymbol *_Py_uop_sym_new_null(_Py_UOpsContext *ctx); | ||
| extern bool _Py_uop_sym_has_type(_Py_UopsSymbol *sym); | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -20,6 +20,8 @@ typedef struct _Py_UOpsAbstractFrame _Py_UOpsAbstractFrame; | |
| #define sym_is_null _Py_uop_sym_is_null | ||
| #define sym_new_const _Py_uop_sym_new_const | ||
| #define sym_new_null _Py_uop_sym_new_null | ||
| #define sym_new_tuple _Py_uop_sym_new_tuple | ||
| #define sym_tuple_at _Py_uop_sym_tuple_at | ||
| #define sym_matches_type _Py_uop_sym_matches_type | ||
| #define sym_get_type _Py_uop_sym_get_type | ||
| #define sym_has_type _Py_uop_sym_has_type | ||
| Expand Down Expand Up | @@ -762,6 +764,25 @@ dummy_func(void) { | |
| ctx->done = true; | ||
| } | ||
|
|
||
| op(_BUILD_TUPLE, (values[oparg] -- tup)) { | ||
| tup = sym_new_tuple(ctx, oparg); | ||
| assert(tup != NULL); | ||
| assert(!ctx->out_of_space); | ||
| for (int i = 0; i < oparg; i++) { | ||
| tup->tuple_val[i] = values[i]; | ||
|
Comment thread
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityUse sym_tuple_set_item(tup, i, values[i]) for better encapsulation.
Sorry, something went wrong.
All reactions
|
||
| } | ||
| } | ||
|
|
||
| op(_BINARY_SUBSCR_TUPLE_INT, (tuple, sub -- res)) { | ||
|
Comment thread
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis optimization applies to all BINARY_SUBSCR variants, although it is much more likely to apply here.
Sorry, something went wrong.
All reactions
|
||
| if (sym_has_type(tuple) && sym_matches_type(tuple, &PyTuple_Type) && sym_is_const(sub) ) { | ||
| PyObject* value = sym_get_const(sub); | ||
| Py_ssize_t index = ((PyLongObject*)value)->long_value.ob_digit[0]; | ||
|
Comment thread
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThere is no guarantee that value is an int.
Sorry, something went wrong.
All reactions
|
||
| res = sym_tuple_at(tuple, index); | ||
| } else { | ||
| res = sym_new_unknown(ctx); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| // END BYTECODES // | ||
|
|
||
| Expand Down | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCan you move this after the flags, and it doesn't need 32 bits.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.