-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
gh-115685: Type/values propagate for TO_BOOL in tier 2 #115686
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 5 commits
1c6517f
7dba454
8c4d253
6d35c16
e909451
3315ac5
6c92d35
2c9e9d1
6018440
7a480e8
5212231
f0a7fdf
4c9c97b
7025620
6ddc97c
cdd15bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4072,6 +4072,11 @@ dummy_func( | |
| TIER_TWO_ONLY | ||
| value = ptr; | ||
| } | ||
| pure op (_POP_TOP_LOAD_CONST_INLINE_BORROW, (ptr/4, pop -- value)) { | ||
| TIER_TWO_ONLY; | ||
| DECREF_INPUTS(); | ||
| value = ptr; | ||
| } | ||
|
||
|
|
||
| pure op(_LOAD_CONST_INLINE_WITH_NULL, (ptr/4 -- value, null)) { | ||
| TIER_TWO_ONLY | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,9 +84,7 @@ dummy_func(void) { | |
| assert(PyLong_CheckExact(get_const(right))); | ||
| PyObject *temp = _PyLong_Add((PyLongObject *)get_const(left), | ||
| (PyLongObject *)get_const(right)); | ||
|
||
| if (temp == NULL) { | ||
| goto error; | ||
| } | ||
| ERROR_IF(temp == NULL, error); | ||
| OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp)); | ||
| // TODO gh-115506: | ||
| // replace opcode with constant propagated one and add tests! | ||
|
|
@@ -102,9 +100,7 @@ dummy_func(void) { | |
| assert(PyLong_CheckExact(get_const(right))); | ||
| PyObject *temp = _PyLong_Subtract((PyLongObject *)get_const(left), | ||
| (PyLongObject *)get_const(right)); | ||
| if (temp == NULL) { | ||
| goto error; | ||
| } | ||
| ERROR_IF(temp == NULL, error); | ||
| OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp)); | ||
| // TODO gh-115506: | ||
| // replace opcode with constant propagated one and add tests! | ||
|
|
@@ -120,9 +116,7 @@ dummy_func(void) { | |
| assert(PyLong_CheckExact(get_const(right))); | ||
| PyObject *temp = _PyLong_Multiply((PyLongObject *)get_const(left), | ||
| (PyLongObject *)get_const(right)); | ||
| if (temp == NULL) { | ||
| goto error; | ||
| } | ||
| ERROR_IF(temp == NULL, error); | ||
| OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp)); | ||
| // TODO gh-115506: | ||
| // replace opcode with constant propagated one and add tests! | ||
|
|
@@ -139,9 +133,7 @@ dummy_func(void) { | |
| PyObject *temp = PyFloat_FromDouble( | ||
| PyFloat_AS_DOUBLE(get_const(left)) + | ||
| PyFloat_AS_DOUBLE(get_const(right))); | ||
| if (temp == NULL) { | ||
| goto error; | ||
| } | ||
| ERROR_IF(temp == NULL, error); | ||
| res = sym_new_const(ctx, temp); | ||
| // TODO gh-115506: | ||
| // replace opcode with constant propagated one and update tests! | ||
|
|
@@ -158,9 +150,7 @@ dummy_func(void) { | |
| PyObject *temp = PyFloat_FromDouble( | ||
| PyFloat_AS_DOUBLE(get_const(left)) - | ||
| PyFloat_AS_DOUBLE(get_const(right))); | ||
| if (temp == NULL) { | ||
| goto error; | ||
| } | ||
| ERROR_IF(temp == NULL, error); | ||
| res = sym_new_const(ctx, temp); | ||
| // TODO gh-115506: | ||
| // replace opcode with constant propagated one and update tests! | ||
|
|
@@ -177,9 +167,7 @@ dummy_func(void) { | |
| PyObject *temp = PyFloat_FromDouble( | ||
| PyFloat_AS_DOUBLE(get_const(left)) * | ||
| PyFloat_AS_DOUBLE(get_const(right))); | ||
| if (temp == NULL) { | ||
| goto error; | ||
| } | ||
| ERROR_IF(temp == NULL, error); | ||
| res = sym_new_const(ctx, temp); | ||
| // TODO gh-115506: | ||
| // replace opcode with constant propagated one and update tests! | ||
|
|
@@ -189,6 +177,58 @@ dummy_func(void) { | |
| } | ||
| } | ||
|
|
||
| op(_TO_BOOL, (value -- res)) { | ||
| (void)value; | ||
| OUT_OF_SPACE_IF_NULL(res = sym_new_known_type(ctx, &PyBool_Type)); | ||
Fidget-Spinner marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| op(_TO_BOOL_BOOL, (value -- value)) { | ||
| if (sym_matches_type(value, &PyBool_Type)) { | ||
| REPLACE_OP(this_instr, _NOP, 0, 0); | ||
| } | ||
| else { | ||
| sym_set_type(value, &PyBool_Type); | ||
| } | ||
| } | ||
|
|
||
| op(_TO_BOOL_INT, (value -- res)) { | ||
| sym_set_type(value, &PyLong_Type); | ||
| if (is_const(value)) { | ||
| PyObject *load = _PyLong_IsZero((PyLongObject *)get_const(value)) | ||
| ? Py_False : Py_True; | ||
| REPLACE_OP(this_instr, _POP_TOP_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)load); | ||
| OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, load)); | ||
| } | ||
| else { | ||
| OUT_OF_SPACE_IF_NULL(res = sym_new_known_type(ctx, &PyBool_Type)); | ||
| } | ||
| } | ||
|
|
||
| op(_TO_BOOL_LIST, (value -- res)) { | ||
| sym_set_type(value, &PyList_Type); | ||
| OUT_OF_SPACE_IF_NULL(res = sym_new_known_type(ctx, &PyBool_Type)); | ||
| } | ||
|
|
||
| op(_TO_BOOL_NONE, (value -- res)) { | ||
| if (get_const(value) == Py_None) { | ||
| REPLACE_OP(this_instr, _POP_TOP_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)Py_None); | ||
Fidget-Spinner marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
gvanrossum marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| sym_set_type(value, &_PyNone_Type); | ||
gvanrossum marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Fidget-Spinner marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, Py_False)); | ||
Fidget-Spinner marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| op(_TO_BOOL_STR, (value -- res)) { | ||
| sym_set_type(value, &PyUnicode_Type); | ||
gvanrossum marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (is_const(value)) { | ||
| PyObject *load = get_const(value) == &_Py_STR(empty) ? Py_False : Py_True; | ||
| REPLACE_OP(this_instr, _POP_TOP_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)load); | ||
| OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, load)); | ||
| } | ||
| else { | ||
| OUT_OF_SPACE_IF_NULL(res = sym_new_known_type(ctx, &PyBool_Type)); | ||
| } | ||
| } | ||
|
|
||
| op(_LOAD_CONST, (-- value)) { | ||
| // There should be no LOAD_CONST. It should be all | ||
| // replaced by peephole_opt. | ||
|
|
@@ -270,9 +310,7 @@ dummy_func(void) { | |
| (void)callable; | ||
|
|
||
| PyFunctionObject *func = (PyFunctionObject *)(this_instr + 2)->operand; | ||
| if (func == NULL) { | ||
| goto error; | ||
| } | ||
| ERROR_IF(func == NULL, error); | ||
| PyCodeObject *co = (PyCodeObject *)func->func_code; | ||
|
|
||
| assert(self_or_null != NULL); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.