-
Notifications
You must be signed in to change notification settings - Fork 4
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
Partially implemented type propagation #48
Conversation
Python/optimizer_analysis.c
Outdated
// bitmask of types | ||
uint32_t types; | ||
// auxillary data for the types | ||
uint32_t aux[MAX_TYPE + 1]; |
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.
Is this due to the fact that a single thing could be of multiple positive types?
Would it be possible to not have this, and only have something identify as a single positive type?
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.
Nope, its bcuz multiple guards has to pass for some cases inorder to fully eliminate the entire guard region. I dont see whats the disadvantage of doing this either
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.
Every time we add a new type, all sym expressions become 32 bits bigger. I would like to save memory somehow. But ok lets go with this for now.
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.
Just one code nit from me, thank you.
Python/optimizer_analysis.c
Outdated
static void | ||
symtype_set_from_const(_Py_UOpsSymType* sym_type, PyObject* obj) | ||
{ | ||
PyTypeObject *tp = obj->ob_type; |
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.
Usually these are accessed through macros
PyTypeObject *tp = obj->ob_type; | |
PyTypeObject *tp = Py_TYPE(obj); |
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.
Also bunch of whitespaces are failing the CI
Python/optimizer_analysis.c
Outdated
|
||
/* | ||
static _Py_UOpsSymExprTypeEnum | ||
symtype_guard_to_type_enum(int guard_opcde) |
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.
symtype_guard_to_type_enum(int guard_opcde) | |
symtype_guard_to_type_enum(int guard_opcde) |
Python/optimizer_analysis.c
Outdated
} | ||
|
||
static bool | ||
symtype_passes_guard(_Py_UOpsSymType* sym_type, int guard_opcode, uint32_t aux) |
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.
symtype_passes_guard(_Py_UOpsSymType* sym_type, int guard_opcode, uint32_t aux) | |
symtype_passes_guard(_Py_UOpsSymType* sym_type, int guard_opcode, uint32_t aux) |
Python/optimizer_analysis.c
Outdated
*/ | ||
|
||
static void | ||
symtype_set_type(_Py_UOpsSymType* sym_type, _Py_UOpsSymExprTypeEnum typ, uint32_t aux) |
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.
symtype_set_type(_Py_UOpsSymType* sym_type, _Py_UOpsSymExprTypeEnum typ, uint32_t aux) | |
symtype_set_type(_Py_UOpsSymType* sym_type, _Py_UOpsSymExprTypeEnum typ, uint32_t aux) |
Python/optimizer_analysis.c
Outdated
|
||
if (tp == &PyLong_Type) { | ||
sym_type->types |= 1 << PYINT_TYPE; | ||
} |
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.
} | |
} |
Python/optimizer_analysis.c
Outdated
if (_PyDictOrValues_IsValues(*dorv) || | ||
_PyObject_MakeInstanceAttributesFromDict(obj, dorv)) { | ||
sym_type->types |= 1 << GUARD_DORV_VALUES_INST_ATTR_FROM_DICT_TYPE; | ||
|
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.
Tools/cases_generator/stacking.py
Outdated
self.peeks.append( | ||
StackItem(offset=self.final_offset.clone(), effect=eff)) |
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.
Lets reduce the diff
self.peeks.append( | |
StackItem(offset=self.final_offset.clone(), effect=eff)) | |
self.peeks.append(StackItem(offset=self.final_offset.clone(), effect=eff)) |
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.
Ah I didn't realise but at some point during the buggy vscode fiasco it ran the autoformatter
Tools/cases_generator/stacking.py
Outdated
self.pokes.append( | ||
StackItem(offset=self.final_offset.clone(), effect=eff)) |
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.
self.pokes.append( | |
StackItem(offset=self.final_offset.clone(), effect=eff)) | |
self.pokes.append(StackItem(offset=self.final_offset.clone(), effect=eff)) |
Tools/cases_generator/parsing.py
Outdated
@@ -262,14 +270,24 @@ def cache_effect(self) -> CacheEffect | None: | |||
|
|||
@contextual | |||
def stack_effect(self) -> StackEffect | None: | |||
# IDENTIFIER [':' IDENTIFIER [TIMES]] ['if' '(' expression ')'] | |||
# IDENTIFIER [':' [IDENTIFIER [TIMES]] ['~' '(' IDENTIFIER [',' IDENTIFIER] ')']] ['if' '(' expression ')'] |
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.
The MINUS
isn't documented.
Thanks for all your work on this. |
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.
PEP 7 nits
Python/optimizer_analysis.c
Outdated
} _Py_UOpsSymType; | ||
|
||
static void | ||
symtype_set_type(_Py_UOpsSymType* sym_type, _Py_UOpsSymExprTypeEnum typ, uint32_t aux) |
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.
symtype_set_type(_Py_UOpsSymType* sym_type, _Py_UOpsSymExprTypeEnum typ, uint32_t aux) | |
symtype_set_type(_Py_UOpsSymType *sym_type, _Py_UOpsSymExprTypeEnum typ, uint32_t aux) |
Python/optimizer_analysis.c
Outdated
} | ||
|
||
static void | ||
symtype_set_from_const(_Py_UOpsSymType* sym_type, PyObject* obj) |
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.
symtype_set_from_const(_Py_UOpsSymType* sym_type, PyObject* obj) | |
symtype_set_from_const(_Py_UOpsSymType *sym_type, PyObject *obj) |
# Conflicts: # Python/abstract_interp_cases.c.h # Python/bytecodes.c # Tools/cases_generator/stacking.py
dfe515c
to
29995a9
Compare
This branch will be continually updated until it is convenient to merge with
ssa_graphs