2024-02-26 12:42:53 -04:00
|
|
|
// This file is generated by Tools/cases_generator/optimizer_generator.py
|
2024-02-13 09:24:48 -04:00
|
|
|
// from:
|
2024-02-26 12:42:53 -04:00
|
|
|
// Python/optimizer_bytecodes.c
|
2024-02-13 09:24:48 -04:00
|
|
|
// Do not edit!
|
|
|
|
|
|
|
|
case _NOP: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-08-14 08:04:05 -03:00
|
|
|
case _CHECK_PERIODIC: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_PERIODIC_IF_NOT_YIELD_FROM: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* _QUICKEN_RESUME is not a viable micro-op for tier 2 */
|
|
|
|
|
2024-02-13 09:24:48 -04:00
|
|
|
case _RESUME_CHECK: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-08-14 08:04:05 -03:00
|
|
|
/* _MONITOR_RESUME is not a viable micro-op for tier 2 */
|
2024-02-13 09:24:48 -04:00
|
|
|
|
|
|
|
case _LOAD_FAST_CHECK: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-02-13 09:24:48 -04:00
|
|
|
value = GETLOCAL(oparg);
|
|
|
|
// We guarantee this will error - just bail and don't optimize it.
|
2024-02-27 09:25:02 -04:00
|
|
|
if (sym_is_null(value)) {
|
2024-05-10 13:43:23 -03:00
|
|
|
ctx->done = true;
|
2024-02-13 09:24:48 -04:00
|
|
|
}
|
|
|
|
stack_pointer[0] = value;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_FAST: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-02-13 09:24:48 -04:00
|
|
|
value = GETLOCAL(oparg);
|
|
|
|
stack_pointer[0] = value;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_FAST_AND_CLEAR: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-02-13 09:24:48 -04:00
|
|
|
value = GETLOCAL(oparg);
|
2024-05-10 13:43:23 -03:00
|
|
|
_Py_UopsSymbol *temp = sym_new_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
GETLOCAL(oparg) = temp;
|
|
|
|
stack_pointer[0] = value;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_CONST: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-04-18 07:09:30 -03:00
|
|
|
PyObject *val = PyTuple_GET_ITEM(co->co_consts, this_instr->oparg);
|
|
|
|
int opcode = _Py_IsImmortal(val) ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE;
|
|
|
|
REPLACE_OP(this_instr, opcode, 0, (uintptr_t)val);
|
2024-05-10 13:43:23 -03:00
|
|
|
value = sym_new_const(ctx, val);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = value;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _STORE_FAST: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-02-13 09:24:48 -04:00
|
|
|
value = stack_pointer[-1];
|
|
|
|
GETLOCAL(oparg) = value;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _POP_TOP: {
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _PUSH_NULL: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
|
|
|
res = sym_new_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = res;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _END_SEND: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-03-13 09:57:48 -03:00
|
|
|
value = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = value;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _UNARY_NEGATIVE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = res;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _UNARY_NOT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = res;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _TO_BOOL: {
|
2024-02-29 18:13:38 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-02-29 18:13:38 -04:00
|
|
|
value = stack_pointer[-1];
|
2024-05-10 13:43:23 -03:00
|
|
|
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
|
2024-03-05 07:23:46 -04:00
|
|
|
res = sym_new_type(ctx, &PyBool_Type);
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = res;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _TO_BOOL_BOOL: {
|
2024-02-29 18:13:38 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-03-05 07:23:46 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-02-29 18:13:38 -04:00
|
|
|
value = stack_pointer[-1];
|
2024-05-10 13:43:23 -03:00
|
|
|
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
|
|
|
|
sym_set_type(value, &PyBool_Type);
|
2024-03-05 07:23:46 -04:00
|
|
|
res = value;
|
2024-02-29 18:13:38 -04:00
|
|
|
}
|
2024-03-05 07:23:46 -04:00
|
|
|
stack_pointer[-1] = res;
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _TO_BOOL_INT: {
|
2024-02-29 18:13:38 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-02-29 18:13:38 -04:00
|
|
|
value = stack_pointer[-1];
|
2024-05-10 13:43:23 -03:00
|
|
|
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
|
|
|
|
sym_set_type(value, &PyLong_Type);
|
|
|
|
res = sym_new_type(ctx, &PyBool_Type);
|
2024-02-29 18:13:38 -04:00
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = res;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _TO_BOOL_LIST: {
|
2024-02-29 18:13:38 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-02-29 18:13:38 -04:00
|
|
|
value = stack_pointer[-1];
|
2024-05-10 13:43:23 -03:00
|
|
|
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
|
|
|
|
sym_set_type(value, &PyList_Type);
|
|
|
|
res = sym_new_type(ctx, &PyBool_Type);
|
2024-02-29 18:13:38 -04:00
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = res;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _TO_BOOL_NONE: {
|
2024-02-29 18:13:38 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-02-29 18:13:38 -04:00
|
|
|
value = stack_pointer[-1];
|
2024-05-10 13:43:23 -03:00
|
|
|
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
|
|
|
|
sym_set_const(value, Py_None);
|
|
|
|
res = sym_new_const(ctx, Py_False);
|
2024-02-29 18:13:38 -04:00
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = res;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _TO_BOOL_STR: {
|
2024-02-29 18:13:38 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-02-29 18:13:38 -04:00
|
|
|
value = stack_pointer[-1];
|
2024-05-10 13:43:23 -03:00
|
|
|
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
|
|
|
|
res = sym_new_type(ctx, &PyBool_Type);
|
|
|
|
sym_set_type(value, &PyUnicode_Type);
|
2024-02-29 18:13:38 -04:00
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = res;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-03-05 11:23:08 -04:00
|
|
|
case _REPLACE_WITH_TRUE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = res;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _UNARY_INVERT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = res;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GUARD_BOTH_INT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
2024-02-13 09:24:48 -04:00
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
2024-04-22 09:34:06 -03:00
|
|
|
if (sym_matches_type(left, &PyLong_Type)) {
|
|
|
|
if (sym_matches_type(right, &PyLong_Type)) {
|
|
|
|
REPLACE_OP(this_instr, _NOP, 0, 0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
REPLACE_OP(this_instr, _GUARD_TOS_INT, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (sym_matches_type(right, &PyLong_Type)) {
|
|
|
|
REPLACE_OP(this_instr, _GUARD_NOS_INT, 0, 0);
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
}
|
2024-05-10 13:43:23 -03:00
|
|
|
sym_set_type(left, &PyLong_Type);
|
|
|
|
sym_set_type(right, &PyLong_Type);
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-04-22 09:34:06 -03:00
|
|
|
case _GUARD_NOS_INT: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GUARD_TOS_INT: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-13 09:24:48 -04:00
|
|
|
case _BINARY_OP_MULTIPLY_INT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
|
|
|
_Py_UopsSymbol *res;
|
2024-02-15 02:02:18 -04:00
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
2024-02-28 18:38:01 -04:00
|
|
|
if (sym_is_const(left) && sym_is_const(right) &&
|
|
|
|
sym_matches_type(left, &PyLong_Type) && sym_matches_type(right, &PyLong_Type))
|
|
|
|
{
|
2024-02-27 09:25:02 -04:00
|
|
|
assert(PyLong_CheckExact(sym_get_const(left)));
|
|
|
|
assert(PyLong_CheckExact(sym_get_const(right)));
|
|
|
|
PyObject *temp = _PyLong_Multiply((PyLongObject *)sym_get_const(left),
|
|
|
|
(PyLongObject *)sym_get_const(right));
|
2024-02-15 02:02:18 -04:00
|
|
|
if (temp == NULL) {
|
|
|
|
goto error;
|
|
|
|
}
|
2024-02-28 18:38:01 -04:00
|
|
|
res = sym_new_const(ctx, temp);
|
|
|
|
Py_DECREF(temp);
|
2024-02-16 10:59:43 -04:00
|
|
|
// TODO gh-115506:
|
|
|
|
// replace opcode with constant propagated one and add tests!
|
2024-02-15 02:02:18 -04:00
|
|
|
}
|
|
|
|
else {
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_type(ctx, &PyLong_Type);
|
2024-02-15 02:02:18 -04:00
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _BINARY_OP_ADD_INT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
|
|
|
_Py_UopsSymbol *res;
|
2024-02-13 09:24:48 -04:00
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
2024-02-28 18:38:01 -04:00
|
|
|
if (sym_is_const(left) && sym_is_const(right) &&
|
|
|
|
sym_matches_type(left, &PyLong_Type) && sym_matches_type(right, &PyLong_Type))
|
|
|
|
{
|
2024-02-27 09:25:02 -04:00
|
|
|
assert(PyLong_CheckExact(sym_get_const(left)));
|
|
|
|
assert(PyLong_CheckExact(sym_get_const(right)));
|
|
|
|
PyObject *temp = _PyLong_Add((PyLongObject *)sym_get_const(left),
|
|
|
|
(PyLongObject *)sym_get_const(right));
|
2024-02-15 02:02:18 -04:00
|
|
|
if (temp == NULL) {
|
|
|
|
goto error;
|
|
|
|
}
|
2024-02-28 18:38:01 -04:00
|
|
|
res = sym_new_const(ctx, temp);
|
|
|
|
Py_DECREF(temp);
|
2024-02-16 10:59:43 -04:00
|
|
|
// TODO gh-115506:
|
|
|
|
// replace opcode with constant propagated one and add tests!
|
2024-02-15 02:02:18 -04:00
|
|
|
}
|
|
|
|
else {
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_type(ctx, &PyLong_Type);
|
2024-02-13 09:24:48 -04:00
|
|
|
}
|
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _BINARY_OP_SUBTRACT_INT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
|
|
|
_Py_UopsSymbol *res;
|
2024-02-15 02:02:18 -04:00
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
2024-02-28 18:38:01 -04:00
|
|
|
if (sym_is_const(left) && sym_is_const(right) &&
|
|
|
|
sym_matches_type(left, &PyLong_Type) && sym_matches_type(right, &PyLong_Type))
|
|
|
|
{
|
2024-02-27 09:25:02 -04:00
|
|
|
assert(PyLong_CheckExact(sym_get_const(left)));
|
|
|
|
assert(PyLong_CheckExact(sym_get_const(right)));
|
|
|
|
PyObject *temp = _PyLong_Subtract((PyLongObject *)sym_get_const(left),
|
|
|
|
(PyLongObject *)sym_get_const(right));
|
2024-02-15 02:02:18 -04:00
|
|
|
if (temp == NULL) {
|
|
|
|
goto error;
|
|
|
|
}
|
2024-02-28 18:38:01 -04:00
|
|
|
res = sym_new_const(ctx, temp);
|
|
|
|
Py_DECREF(temp);
|
2024-02-16 10:59:43 -04:00
|
|
|
// TODO gh-115506:
|
|
|
|
// replace opcode with constant propagated one and add tests!
|
2024-02-15 02:02:18 -04:00
|
|
|
}
|
|
|
|
else {
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_type(ctx, &PyLong_Type);
|
2024-02-15 02:02:18 -04:00
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GUARD_BOTH_FLOAT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
2024-02-13 09:24:48 -04:00
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
2024-04-22 09:34:06 -03:00
|
|
|
if (sym_matches_type(left, &PyFloat_Type)) {
|
|
|
|
if (sym_matches_type(right, &PyFloat_Type)) {
|
|
|
|
REPLACE_OP(this_instr, _NOP, 0, 0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
REPLACE_OP(this_instr, _GUARD_TOS_FLOAT, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (sym_matches_type(right, &PyFloat_Type)) {
|
|
|
|
REPLACE_OP(this_instr, _GUARD_NOS_FLOAT, 0, 0);
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
}
|
2024-05-10 13:43:23 -03:00
|
|
|
sym_set_type(left, &PyFloat_Type);
|
|
|
|
sym_set_type(right, &PyFloat_Type);
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-04-22 09:34:06 -03:00
|
|
|
case _GUARD_NOS_FLOAT: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GUARD_TOS_FLOAT: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-13 09:24:48 -04:00
|
|
|
case _BINARY_OP_MULTIPLY_FLOAT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
|
|
|
_Py_UopsSymbol *res;
|
2024-02-16 14:02:48 -04:00
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
2024-02-28 18:38:01 -04:00
|
|
|
if (sym_is_const(left) && sym_is_const(right) &&
|
|
|
|
sym_matches_type(left, &PyFloat_Type) && sym_matches_type(right, &PyFloat_Type))
|
|
|
|
{
|
2024-02-27 09:25:02 -04:00
|
|
|
assert(PyFloat_CheckExact(sym_get_const(left)));
|
|
|
|
assert(PyFloat_CheckExact(sym_get_const(right)));
|
2024-02-16 14:02:48 -04:00
|
|
|
PyObject *temp = PyFloat_FromDouble(
|
2024-02-27 09:25:02 -04:00
|
|
|
PyFloat_AS_DOUBLE(sym_get_const(left)) *
|
|
|
|
PyFloat_AS_DOUBLE(sym_get_const(right)));
|
2024-02-16 14:02:48 -04:00
|
|
|
if (temp == NULL) {
|
|
|
|
goto error;
|
|
|
|
}
|
2024-02-27 09:25:02 -04:00
|
|
|
res = sym_new_const(ctx, temp);
|
2024-02-28 18:38:01 -04:00
|
|
|
Py_DECREF(temp);
|
2024-02-16 14:02:48 -04:00
|
|
|
// TODO gh-115506:
|
|
|
|
// replace opcode with constant propagated one and update tests!
|
|
|
|
}
|
|
|
|
else {
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_type(ctx, &PyFloat_Type);
|
2024-02-16 14:02:48 -04:00
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _BINARY_OP_ADD_FLOAT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
|
|
|
_Py_UopsSymbol *res;
|
2024-02-16 14:02:48 -04:00
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
2024-02-28 18:38:01 -04:00
|
|
|
if (sym_is_const(left) && sym_is_const(right) &&
|
|
|
|
sym_matches_type(left, &PyFloat_Type) && sym_matches_type(right, &PyFloat_Type))
|
|
|
|
{
|
2024-02-27 09:25:02 -04:00
|
|
|
assert(PyFloat_CheckExact(sym_get_const(left)));
|
|
|
|
assert(PyFloat_CheckExact(sym_get_const(right)));
|
2024-02-16 14:02:48 -04:00
|
|
|
PyObject *temp = PyFloat_FromDouble(
|
2024-02-27 09:25:02 -04:00
|
|
|
PyFloat_AS_DOUBLE(sym_get_const(left)) +
|
|
|
|
PyFloat_AS_DOUBLE(sym_get_const(right)));
|
2024-02-16 14:02:48 -04:00
|
|
|
if (temp == NULL) {
|
|
|
|
goto error;
|
|
|
|
}
|
2024-02-27 09:25:02 -04:00
|
|
|
res = sym_new_const(ctx, temp);
|
2024-02-28 18:38:01 -04:00
|
|
|
Py_DECREF(temp);
|
2024-02-16 14:02:48 -04:00
|
|
|
// TODO gh-115506:
|
|
|
|
// replace opcode with constant propagated one and update tests!
|
|
|
|
}
|
|
|
|
else {
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_type(ctx, &PyFloat_Type);
|
2024-02-16 14:02:48 -04:00
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _BINARY_OP_SUBTRACT_FLOAT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
|
|
|
_Py_UopsSymbol *res;
|
2024-02-16 14:02:48 -04:00
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
2024-02-28 18:38:01 -04:00
|
|
|
if (sym_is_const(left) && sym_is_const(right) &&
|
|
|
|
sym_matches_type(left, &PyFloat_Type) && sym_matches_type(right, &PyFloat_Type))
|
|
|
|
{
|
2024-02-27 09:25:02 -04:00
|
|
|
assert(PyFloat_CheckExact(sym_get_const(left)));
|
|
|
|
assert(PyFloat_CheckExact(sym_get_const(right)));
|
2024-02-16 14:02:48 -04:00
|
|
|
PyObject *temp = PyFloat_FromDouble(
|
2024-02-27 09:25:02 -04:00
|
|
|
PyFloat_AS_DOUBLE(sym_get_const(left)) -
|
|
|
|
PyFloat_AS_DOUBLE(sym_get_const(right)));
|
2024-02-16 14:02:48 -04:00
|
|
|
if (temp == NULL) {
|
|
|
|
goto error;
|
|
|
|
}
|
2024-02-27 09:25:02 -04:00
|
|
|
res = sym_new_const(ctx, temp);
|
2024-02-28 18:38:01 -04:00
|
|
|
Py_DECREF(temp);
|
2024-02-16 14:02:48 -04:00
|
|
|
// TODO gh-115506:
|
|
|
|
// replace opcode with constant propagated one and update tests!
|
|
|
|
}
|
|
|
|
else {
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_type(ctx, &PyFloat_Type);
|
2024-02-16 14:02:48 -04:00
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GUARD_BOTH_UNICODE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
2024-02-20 07:30:49 -04:00
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
2024-02-27 09:25:02 -04:00
|
|
|
if (sym_matches_type(left, &PyUnicode_Type) &&
|
|
|
|
sym_matches_type(right, &PyUnicode_Type)) {
|
2024-02-20 07:30:49 -04:00
|
|
|
REPLACE_OP(this_instr, _NOP, 0 ,0);
|
|
|
|
}
|
2024-05-10 13:43:23 -03:00
|
|
|
sym_set_type(left, &PyUnicode_Type);
|
|
|
|
sym_set_type(left, &PyUnicode_Type);
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _BINARY_OP_ADD_UNICODE: {
|
2024-03-01 15:40:04 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-01 15:40:04 -04:00
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
|
|
|
if (sym_is_const(left) && sym_is_const(right) &&
|
|
|
|
sym_matches_type(left, &PyUnicode_Type) && sym_matches_type(right, &PyUnicode_Type)) {
|
|
|
|
PyObject *temp = PyUnicode_Concat(sym_get_const(left), sym_get_const(right));
|
|
|
|
if (temp == NULL) {
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
res = sym_new_const(ctx, temp);
|
|
|
|
Py_DECREF(temp);
|
|
|
|
}
|
|
|
|
else {
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_type(ctx, &PyUnicode_Type);
|
2024-03-01 15:40:04 -04:00
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-07-25 18:45:07 -03:00
|
|
|
case _BINARY_OP_INPLACE_ADD_UNICODE: {
|
|
|
|
stack_pointer += -2;
|
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-13 09:24:48 -04:00
|
|
|
case _BINARY_SUBSCR: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _BINARY_SLICE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-3] = res;
|
|
|
|
stack_pointer += -2;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _STORE_SLICE: {
|
|
|
|
stack_pointer += -4;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _BINARY_SUBSCR_LIST_INT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _BINARY_SUBSCR_STR_INT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _BINARY_SUBSCR_TUPLE_INT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _BINARY_SUBSCR_DICT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-08-01 20:19:05 -03:00
|
|
|
case _BINARY_SUBSCR_CHECK_FUNC: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _BINARY_SUBSCR_INIT_CALL: {
|
2024-08-12 14:35:52 -03:00
|
|
|
_Py_UopsSymbol *sub;
|
|
|
|
_Py_UopsSymbol *container;
|
|
|
|
_Py_UOpsAbstractFrame *new_frame;
|
|
|
|
sub = stack_pointer[-1];
|
|
|
|
container = stack_pointer[-2];
|
|
|
|
(void)container;
|
|
|
|
(void)sub;
|
|
|
|
new_frame = NULL;
|
|
|
|
ctx->done = true;
|
2024-08-01 20:19:05 -03:00
|
|
|
stack_pointer[-2] = (_Py_UopsSymbol *)new_frame;
|
|
|
|
stack_pointer += -1;
|
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
|
|
|
break;
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
|
|
|
|
case _LIST_APPEND: {
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _SET_ADD: {
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _STORE_SUBSCR: {
|
|
|
|
stack_pointer += -3;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _STORE_SUBSCR_LIST_INT: {
|
|
|
|
stack_pointer += -3;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _STORE_SUBSCR_DICT: {
|
|
|
|
stack_pointer += -3;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _DELETE_SUBSCR: {
|
|
|
|
stack_pointer += -2;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_INTRINSIC_1: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = res;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_INTRINSIC_2: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-06-17 10:40:11 -03:00
|
|
|
case _RETURN_VALUE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *retval;
|
|
|
|
_Py_UopsSymbol *res;
|
2024-02-13 09:24:48 -04:00
|
|
|
retval = stack_pointer[-1];
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
ctx->frame->stack_pointer = stack_pointer;
|
2024-02-27 09:25:02 -04:00
|
|
|
frame_pop(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer = ctx->frame->stack_pointer;
|
|
|
|
res = retval;
|
2024-04-18 07:09:30 -03:00
|
|
|
/* Stack space handling */
|
|
|
|
assert(corresponding_check_stack == NULL);
|
|
|
|
assert(co != NULL);
|
|
|
|
int framesize = co->co_framesize;
|
|
|
|
assert(framesize > 0);
|
|
|
|
assert(framesize <= curr_space);
|
|
|
|
curr_space -= framesize;
|
|
|
|
co = get_code(this_instr);
|
|
|
|
if (co == NULL) {
|
|
|
|
// might be impossible, but bailing is still safe
|
2024-05-10 13:43:23 -03:00
|
|
|
ctx->done = true;
|
2024-04-18 07:09:30 -03:00
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = res;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GET_AITER: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *iter;
|
2024-03-13 09:57:48 -03:00
|
|
|
iter = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = iter;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GET_ANEXT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *awaitable;
|
2024-03-13 09:57:48 -03:00
|
|
|
awaitable = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = awaitable;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GET_AWAITABLE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *iter;
|
2024-03-13 09:57:48 -03:00
|
|
|
iter = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = iter;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* _SEND is not a viable micro-op for tier 2 */
|
|
|
|
|
2024-07-18 18:24:58 -03:00
|
|
|
case _SEND_GEN_FRAME: {
|
|
|
|
// We are about to hit the end of the trace:
|
|
|
|
ctx->done = true;
|
|
|
|
break;
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
|
2024-04-30 07:33:13 -03:00
|
|
|
case _YIELD_VALUE: {
|
|
|
|
_Py_UopsSymbol *res;
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_unknown(ctx);
|
2024-04-30 07:33:13 -03:00
|
|
|
stack_pointer[-1] = res;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-13 09:24:48 -04:00
|
|
|
case _POP_EXCEPT: {
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-05-21 21:46:39 -03:00
|
|
|
case _LOAD_COMMON_CONSTANT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-03-13 09:57:48 -03:00
|
|
|
value = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = value;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_BUILD_CLASS: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *bc;
|
2024-03-13 09:57:48 -03:00
|
|
|
bc = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = bc;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _STORE_NAME: {
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _DELETE_NAME: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _UNPACK_SEQUENCE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *seq;
|
|
|
|
_Py_UopsSymbol **values;
|
2024-02-13 09:24:48 -04:00
|
|
|
seq = stack_pointer[-1];
|
|
|
|
values = &stack_pointer[-1];
|
|
|
|
/* This has to be done manually */
|
|
|
|
(void)seq;
|
|
|
|
for (int i = 0; i < oparg; i++) {
|
2024-05-10 13:43:23 -03:00
|
|
|
values[i] = sym_new_unknown(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
}
|
|
|
|
stack_pointer += -1 + oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _UNPACK_SEQUENCE_TWO_TUPLE: {
|
2024-03-11 06:30:15 -03:00
|
|
|
_Py_UopsSymbol *val1;
|
|
|
|
_Py_UopsSymbol *val0;
|
2024-03-13 09:57:48 -03:00
|
|
|
val1 = sym_new_not_null(ctx);
|
|
|
|
val0 = sym_new_not_null(ctx);
|
2024-03-11 06:30:15 -03:00
|
|
|
stack_pointer[-1] = val1;
|
|
|
|
stack_pointer[0] = val0;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _UNPACK_SEQUENCE_TUPLE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol **values;
|
2024-02-13 09:24:48 -04:00
|
|
|
values = &stack_pointer[-1];
|
|
|
|
for (int _i = oparg; --_i >= 0;) {
|
2024-03-13 09:57:48 -03:00
|
|
|
values[_i] = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
}
|
|
|
|
stack_pointer += -1 + oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _UNPACK_SEQUENCE_LIST: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol **values;
|
2024-02-13 09:24:48 -04:00
|
|
|
values = &stack_pointer[-1];
|
|
|
|
for (int _i = oparg; --_i >= 0;) {
|
2024-03-13 09:57:48 -03:00
|
|
|
values[_i] = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
}
|
|
|
|
stack_pointer += -1 + oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _UNPACK_EX: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *seq;
|
|
|
|
_Py_UopsSymbol **values;
|
2024-02-13 09:24:48 -04:00
|
|
|
seq = stack_pointer[-1];
|
|
|
|
values = &stack_pointer[-1];
|
|
|
|
/* This has to be done manually */
|
|
|
|
(void)seq;
|
|
|
|
int totalargs = (oparg & 0xFF) + (oparg >> 8) + 1;
|
|
|
|
for (int i = 0; i < totalargs; i++) {
|
2024-05-10 13:43:23 -03:00
|
|
|
values[i] = sym_new_unknown(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
}
|
2024-08-01 05:27:26 -03:00
|
|
|
stack_pointer += (oparg & 0xFF) + (oparg >> 8);
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _STORE_ATTR: {
|
|
|
|
stack_pointer += -2;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _DELETE_ATTR: {
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _STORE_GLOBAL: {
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _DELETE_GLOBAL: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_LOCALS: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *locals;
|
2024-03-13 09:57:48 -03:00
|
|
|
locals = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = locals;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-05-31 18:05:24 -03:00
|
|
|
/* _LOAD_FROM_DICT_OR_GLOBALS is not a viable micro-op for tier 2 */
|
2024-02-13 09:24:48 -04:00
|
|
|
|
2024-07-18 18:24:58 -03:00
|
|
|
case _LOAD_NAME: {
|
|
|
|
_Py_UopsSymbol *v;
|
|
|
|
v = sym_new_not_null(ctx);
|
|
|
|
stack_pointer[0] = v;
|
|
|
|
stack_pointer += 1;
|
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
|
|
|
break;
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
|
|
|
|
case _LOAD_GLOBAL: {
|
2024-09-13 13:23:51 -03:00
|
|
|
_Py_UopsSymbol **res;
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *null = NULL;
|
2024-09-13 13:23:51 -03:00
|
|
|
res = &stack_pointer[0];
|
|
|
|
for (int _i = 1; --_i >= 0;) {
|
|
|
|
res[_i] = sym_new_not_null(ctx);
|
|
|
|
}
|
2024-02-28 20:05:53 -04:00
|
|
|
null = sym_new_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
if (oparg & 1) stack_pointer[1] = null;
|
|
|
|
stack_pointer += 1 + (oparg & 1);
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GUARD_GLOBALS_VERSION: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GUARD_BUILTINS_VERSION: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_GLOBAL_MODULE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
|
|
|
_Py_UopsSymbol *null = NULL;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-28 20:05:53 -04:00
|
|
|
null = sym_new_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = res;
|
|
|
|
if (oparg & 1) stack_pointer[1] = null;
|
|
|
|
stack_pointer += 1 + (oparg & 1);
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_GLOBAL_BUILTINS: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
|
|
|
_Py_UopsSymbol *null = NULL;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-28 20:05:53 -04:00
|
|
|
null = sym_new_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = res;
|
|
|
|
if (oparg & 1) stack_pointer[1] = null;
|
|
|
|
stack_pointer += 1 + (oparg & 1);
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _DELETE_FAST: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _MAKE_CELL: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _DELETE_DEREF: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_FROM_DICT_OR_DEREF: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-03-13 09:57:48 -03:00
|
|
|
value = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_DEREF: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-03-13 09:57:48 -03:00
|
|
|
value = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = value;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _STORE_DEREF: {
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _COPY_FREE_VARS: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _BUILD_STRING: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *str;
|
2024-03-13 09:57:48 -03:00
|
|
|
str = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-oparg] = str;
|
|
|
|
stack_pointer += 1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _BUILD_TUPLE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *tup;
|
2024-03-13 09:57:48 -03:00
|
|
|
tup = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-oparg] = tup;
|
|
|
|
stack_pointer += 1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _BUILD_LIST: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *list;
|
2024-03-13 09:57:48 -03:00
|
|
|
list = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-oparg] = list;
|
|
|
|
stack_pointer += 1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LIST_EXTEND: {
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _SET_UPDATE: {
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-07-18 18:24:58 -03:00
|
|
|
case _BUILD_SET: {
|
|
|
|
_Py_UopsSymbol *set;
|
|
|
|
set = sym_new_not_null(ctx);
|
|
|
|
stack_pointer[-oparg] = set;
|
|
|
|
stack_pointer += 1 - oparg;
|
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
|
|
|
break;
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
|
|
|
|
case _BUILD_MAP: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *map;
|
2024-03-13 09:57:48 -03:00
|
|
|
map = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-oparg*2] = map;
|
|
|
|
stack_pointer += 1 - oparg*2;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _SETUP_ANNOTATIONS: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _DICT_UPDATE: {
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _DICT_MERGE: {
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _MAP_ADD: {
|
|
|
|
stack_pointer += -2;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* _INSTRUMENTED_LOAD_SUPER_ATTR is not a viable micro-op for tier 2 */
|
|
|
|
|
|
|
|
case _LOAD_SUPER_ATTR_ATTR: {
|
2024-06-26 16:10:43 -03:00
|
|
|
_Py_UopsSymbol *attr_st;
|
|
|
|
attr_st = sym_new_not_null(ctx);
|
|
|
|
stack_pointer[-3] = attr_st;
|
2024-02-20 06:50:59 -04:00
|
|
|
stack_pointer += -2;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_SUPER_ATTR_METHOD: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *attr;
|
|
|
|
_Py_UopsSymbol *self_or_null;
|
2024-03-13 09:57:48 -03:00
|
|
|
attr = sym_new_not_null(ctx);
|
|
|
|
self_or_null = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-3] = attr;
|
|
|
|
stack_pointer[-2] = self_or_null;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_ATTR: {
|
2024-03-13 09:57:48 -03:00
|
|
|
_Py_UopsSymbol *owner;
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *attr;
|
|
|
|
_Py_UopsSymbol *self_or_null = NULL;
|
2024-03-13 09:57:48 -03:00
|
|
|
owner = stack_pointer[-1];
|
|
|
|
(void)owner;
|
2024-05-10 13:43:23 -03:00
|
|
|
attr = sym_new_not_null(ctx);
|
2024-03-13 09:57:48 -03:00
|
|
|
if (oparg & 1) {
|
2024-05-10 13:43:23 -03:00
|
|
|
self_or_null = sym_new_unknown(ctx);
|
2024-03-13 09:57:48 -03:00
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = attr;
|
|
|
|
if (oparg & 1) stack_pointer[0] = self_or_null;
|
|
|
|
stack_pointer += (oparg & 1);
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GUARD_TYPE_VERSION: {
|
2024-06-08 06:41:45 -03:00
|
|
|
_Py_UopsSymbol *owner;
|
|
|
|
owner = stack_pointer[-1];
|
|
|
|
uint32_t type_version = (uint32_t)this_instr->operand;
|
|
|
|
assert(type_version);
|
|
|
|
if (sym_matches_type_version(owner, type_version)) {
|
|
|
|
REPLACE_OP(this_instr, _NOP, 0, 0);
|
|
|
|
} else {
|
|
|
|
// add watcher so that whenever the type changes we invalidate this
|
|
|
|
PyTypeObject *type = _PyType_LookupByVersion(type_version);
|
|
|
|
// if the type is null, it was not found in the cache (there was a conflict)
|
|
|
|
// with the key, in which case we can't trust the version
|
|
|
|
if (type) {
|
|
|
|
// if the type version was set properly, then add a watcher
|
|
|
|
// if it wasn't this means that the type version was previously set to something else
|
|
|
|
// and we set the owner to bottom, so we don't need to add a watcher because we must have
|
|
|
|
// already added one earlier.
|
|
|
|
if (sym_set_type_version(owner, type_version)) {
|
|
|
|
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type);
|
|
|
|
_Py_BloomFilter_Add(dependencies, type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_MANAGED_OBJECT_HAS_VALUES: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_ATTR_INSTANCE_VALUE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *owner;
|
|
|
|
_Py_UopsSymbol *attr;
|
|
|
|
_Py_UopsSymbol *null = NULL;
|
2024-02-13 09:24:48 -04:00
|
|
|
owner = stack_pointer[-1];
|
2024-08-21 11:52:04 -03:00
|
|
|
uint16_t offset = (uint16_t)this_instr->operand;
|
2024-05-10 13:43:23 -03:00
|
|
|
attr = sym_new_not_null(ctx);
|
|
|
|
null = sym_new_null(ctx);
|
2024-08-21 11:52:04 -03:00
|
|
|
(void)offset;
|
2024-02-13 09:24:48 -04:00
|
|
|
(void)owner;
|
|
|
|
stack_pointer[-1] = attr;
|
|
|
|
if (oparg & 1) stack_pointer[0] = null;
|
|
|
|
stack_pointer += (oparg & 1);
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_ATTR_MODULE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *owner;
|
2024-02-22 10:48:25 -04:00
|
|
|
owner = stack_pointer[-1];
|
|
|
|
uint32_t dict_version = (uint32_t)this_instr->operand;
|
|
|
|
(void)dict_version;
|
2024-02-27 09:25:02 -04:00
|
|
|
if (sym_is_const(owner)) {
|
|
|
|
PyObject *cnst = sym_get_const(owner);
|
2024-02-22 10:48:25 -04:00
|
|
|
if (PyModule_CheckExact(cnst)) {
|
|
|
|
PyModuleObject *mod = (PyModuleObject *)cnst;
|
|
|
|
PyObject *dict = mod->md_dict;
|
|
|
|
uint64_t watched_mutations = get_mutations(dict);
|
|
|
|
if (watched_mutations < _Py_MAX_ALLOWED_GLOBALS_MODIFICATIONS) {
|
|
|
|
PyDict_Watch(GLOBALS_WATCHER_ID, dict);
|
|
|
|
_Py_BloomFilter_Add(dependencies, dict);
|
|
|
|
this_instr->opcode = _NOP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_ATTR_MODULE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *owner;
|
|
|
|
_Py_UopsSymbol *attr;
|
|
|
|
_Py_UopsSymbol *null = NULL;
|
2024-02-13 09:24:48 -04:00
|
|
|
owner = stack_pointer[-1];
|
|
|
|
uint16_t index = (uint16_t)this_instr->operand;
|
|
|
|
(void)index;
|
2024-05-10 13:43:23 -03:00
|
|
|
null = sym_new_null(ctx);
|
2024-02-22 10:48:25 -04:00
|
|
|
attr = NULL;
|
|
|
|
if (this_instr[-1].opcode == _NOP) {
|
|
|
|
// Preceding _CHECK_ATTR_MODULE was removed: mod is const and dict is watched.
|
2024-02-27 09:25:02 -04:00
|
|
|
assert(sym_is_const(owner));
|
|
|
|
PyModuleObject *mod = (PyModuleObject *)sym_get_const(owner);
|
2024-02-22 10:48:25 -04:00
|
|
|
assert(PyModule_CheckExact(mod));
|
|
|
|
PyObject *dict = mod->md_dict;
|
|
|
|
PyObject *res = convert_global_to_const(this_instr, dict);
|
|
|
|
if (res != NULL) {
|
|
|
|
this_instr[-1].opcode = _POP_TOP;
|
2024-05-10 13:43:23 -03:00
|
|
|
attr = sym_new_const(ctx, res);
|
2024-02-22 10:48:25 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (attr == NULL) {
|
|
|
|
/* No conversion made. We don't know what `attr` is. */
|
2024-05-10 13:43:23 -03:00
|
|
|
attr = sym_new_not_null(ctx);
|
2024-02-22 10:48:25 -04:00
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = attr;
|
|
|
|
if (oparg & 1) stack_pointer[0] = null;
|
|
|
|
stack_pointer += (oparg & 1);
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_ATTR_WITH_HINT: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_ATTR_WITH_HINT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *owner;
|
|
|
|
_Py_UopsSymbol *attr;
|
|
|
|
_Py_UopsSymbol *null = NULL;
|
2024-02-13 09:24:48 -04:00
|
|
|
owner = stack_pointer[-1];
|
|
|
|
uint16_t hint = (uint16_t)this_instr->operand;
|
2024-05-10 13:43:23 -03:00
|
|
|
attr = sym_new_not_null(ctx);
|
|
|
|
null = sym_new_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
(void)hint;
|
|
|
|
(void)owner;
|
|
|
|
stack_pointer[-1] = attr;
|
|
|
|
if (oparg & 1) stack_pointer[0] = null;
|
|
|
|
stack_pointer += (oparg & 1);
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_ATTR_SLOT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *owner;
|
|
|
|
_Py_UopsSymbol *attr;
|
|
|
|
_Py_UopsSymbol *null = NULL;
|
2024-02-13 09:24:48 -04:00
|
|
|
owner = stack_pointer[-1];
|
|
|
|
uint16_t index = (uint16_t)this_instr->operand;
|
2024-05-10 13:43:23 -03:00
|
|
|
attr = sym_new_not_null(ctx);
|
|
|
|
null = sym_new_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
(void)index;
|
|
|
|
(void)owner;
|
|
|
|
stack_pointer[-1] = attr;
|
|
|
|
if (oparg & 1) stack_pointer[0] = null;
|
|
|
|
stack_pointer += (oparg & 1);
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_ATTR_CLASS: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_ATTR_CLASS: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *owner;
|
|
|
|
_Py_UopsSymbol *attr;
|
|
|
|
_Py_UopsSymbol *null = NULL;
|
2024-02-13 09:24:48 -04:00
|
|
|
owner = stack_pointer[-1];
|
|
|
|
PyObject *descr = (PyObject *)this_instr->operand;
|
2024-05-10 13:43:23 -03:00
|
|
|
attr = sym_new_not_null(ctx);
|
|
|
|
null = sym_new_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
(void)descr;
|
|
|
|
(void)owner;
|
|
|
|
stack_pointer[-1] = attr;
|
|
|
|
if (oparg & 1) stack_pointer[0] = null;
|
|
|
|
stack_pointer += (oparg & 1);
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-07-25 14:45:28 -03:00
|
|
|
case _LOAD_ATTR_PROPERTY_FRAME: {
|
2024-08-12 14:35:52 -03:00
|
|
|
_Py_UopsSymbol *owner;
|
|
|
|
_Py_UOpsAbstractFrame *new_frame;
|
|
|
|
owner = stack_pointer[-1];
|
|
|
|
PyObject *fget = (PyObject *)this_instr->operand;
|
|
|
|
(void)fget;
|
|
|
|
(void)owner;
|
|
|
|
new_frame = NULL;
|
|
|
|
ctx->done = true;
|
2024-07-25 14:45:28 -03:00
|
|
|
stack_pointer[-1] = (_Py_UopsSymbol *)new_frame;
|
|
|
|
break;
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
|
|
|
|
/* _LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN is not a viable micro-op for tier 2 */
|
|
|
|
|
2024-04-02 07:59:21 -03:00
|
|
|
case _GUARD_DORV_NO_DICT: {
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _STORE_ATTR_INSTANCE_VALUE: {
|
|
|
|
stack_pointer += -2;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-05-28 16:47:54 -03:00
|
|
|
case _STORE_ATTR_WITH_HINT: {
|
|
|
|
stack_pointer += -2;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-05-28 16:47:54 -03:00
|
|
|
break;
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
|
|
|
|
case _STORE_ATTR_SLOT: {
|
|
|
|
stack_pointer += -2;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _COMPARE_OP: {
|
2024-03-06 06:46:42 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-06 06:46:42 -04:00
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
2024-03-07 12:19:59 -04:00
|
|
|
(void)left;
|
|
|
|
(void)right;
|
2024-03-06 06:46:42 -04:00
|
|
|
if (oparg & 16) {
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_type(ctx, &PyBool_Type);
|
2024-03-06 06:46:42 -04:00
|
|
|
}
|
|
|
|
else {
|
2024-05-10 13:43:23 -03:00
|
|
|
res = _Py_uop_sym_new_not_null(ctx);
|
2024-03-06 06:46:42 -04:00
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _COMPARE_OP_FLOAT: {
|
2024-03-06 06:46:42 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-06 06:46:42 -04:00
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
2024-03-07 12:19:59 -04:00
|
|
|
(void)left;
|
|
|
|
(void)right;
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_type(ctx, &PyBool_Type);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _COMPARE_OP_INT: {
|
2024-03-06 06:46:42 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-06 06:46:42 -04:00
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
2024-03-07 12:19:59 -04:00
|
|
|
(void)left;
|
|
|
|
(void)right;
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_type(ctx, &PyBool_Type);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _COMPARE_OP_STR: {
|
2024-03-06 06:46:42 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-06 06:46:42 -04:00
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
2024-03-07 12:19:59 -04:00
|
|
|
(void)left;
|
|
|
|
(void)right;
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_type(ctx, &PyBool_Type);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _IS_OP: {
|
2024-03-06 06:46:42 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
|
|
|
_Py_UopsSymbol *res;
|
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
2024-03-07 12:19:59 -04:00
|
|
|
(void)left;
|
|
|
|
(void)right;
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_type(ctx, &PyBool_Type);
|
2024-03-06 06:46:42 -04:00
|
|
|
stack_pointer[-2] = res;
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CONTAINS_OP: {
|
2024-03-06 06:46:42 -04:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
|
|
|
_Py_UopsSymbol *res;
|
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
2024-03-07 12:19:59 -04:00
|
|
|
(void)left;
|
|
|
|
(void)right;
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_type(ctx, &PyBool_Type);
|
2024-03-06 06:46:42 -04:00
|
|
|
stack_pointer[-2] = res;
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-03-06 15:30:11 -04:00
|
|
|
case _CONTAINS_OP_SET: {
|
|
|
|
_Py_UopsSymbol *b;
|
2024-03-13 09:57:48 -03:00
|
|
|
b = sym_new_not_null(ctx);
|
2024-03-06 15:30:11 -04:00
|
|
|
stack_pointer[-2] = b;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-03-06 15:30:11 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CONTAINS_OP_DICT: {
|
|
|
|
_Py_UopsSymbol *b;
|
2024-03-13 09:57:48 -03:00
|
|
|
b = sym_new_not_null(ctx);
|
2024-03-06 15:30:11 -04:00
|
|
|
stack_pointer[-2] = b;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-03-06 15:30:11 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-13 09:24:48 -04:00
|
|
|
case _CHECK_EG_MATCH: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *rest;
|
|
|
|
_Py_UopsSymbol *match;
|
2024-03-13 09:57:48 -03:00
|
|
|
rest = sym_new_not_null(ctx);
|
|
|
|
match = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = rest;
|
|
|
|
stack_pointer[-1] = match;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_EXC_MATCH: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *b;
|
2024-03-13 09:57:48 -03:00
|
|
|
b = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = b;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-07-18 18:24:58 -03:00
|
|
|
case _IMPORT_NAME: {
|
|
|
|
_Py_UopsSymbol *res;
|
|
|
|
res = sym_new_not_null(ctx);
|
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _IMPORT_FROM: {
|
|
|
|
_Py_UopsSymbol *res;
|
|
|
|
res = sym_new_not_null(ctx);
|
|
|
|
stack_pointer[0] = res;
|
|
|
|
stack_pointer += 1;
|
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-13 09:24:48 -04:00
|
|
|
/* _POP_JUMP_IF_FALSE is not a viable micro-op for tier 2 */
|
|
|
|
|
|
|
|
/* _POP_JUMP_IF_TRUE is not a viable micro-op for tier 2 */
|
|
|
|
|
|
|
|
case _IS_NONE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *b;
|
2024-03-13 09:57:48 -03:00
|
|
|
b = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = b;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GET_LEN: {
|
2024-06-26 16:10:43 -03:00
|
|
|
_Py_UopsSymbol *len;
|
|
|
|
len = sym_new_not_null(ctx);
|
|
|
|
stack_pointer[0] = len;
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _MATCH_CLASS: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *attrs;
|
2024-03-13 09:57:48 -03:00
|
|
|
attrs = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-3] = attrs;
|
|
|
|
stack_pointer += -2;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _MATCH_MAPPING: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = res;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _MATCH_SEQUENCE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = res;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _MATCH_KEYS: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *values_or_none;
|
2024-03-13 09:57:48 -03:00
|
|
|
values_or_none = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = values_or_none;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GET_ITER: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *iter;
|
2024-03-13 09:57:48 -03:00
|
|
|
iter = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = iter;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GET_YIELD_FROM_ITER: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *iter;
|
2024-03-13 09:57:48 -03:00
|
|
|
iter = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = iter;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* _FOR_ITER is not a viable micro-op for tier 2 */
|
|
|
|
|
|
|
|
case _FOR_ITER_TIER_TWO: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *next;
|
2024-03-13 09:57:48 -03:00
|
|
|
next = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = next;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* _INSTRUMENTED_FOR_ITER is not a viable micro-op for tier 2 */
|
|
|
|
|
|
|
|
case _ITER_CHECK_LIST: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* _ITER_JUMP_LIST is not a viable micro-op for tier 2 */
|
|
|
|
|
|
|
|
case _GUARD_NOT_EXHAUSTED_LIST: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _ITER_NEXT_LIST: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *next;
|
2024-03-13 09:57:48 -03:00
|
|
|
next = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = next;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _ITER_CHECK_TUPLE: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* _ITER_JUMP_TUPLE is not a viable micro-op for tier 2 */
|
|
|
|
|
|
|
|
case _GUARD_NOT_EXHAUSTED_TUPLE: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _ITER_NEXT_TUPLE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *next;
|
2024-03-13 09:57:48 -03:00
|
|
|
next = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = next;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _ITER_CHECK_RANGE: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* _ITER_JUMP_RANGE is not a viable micro-op for tier 2 */
|
|
|
|
|
|
|
|
case _GUARD_NOT_EXHAUSTED_RANGE: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _ITER_NEXT_RANGE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *iter;
|
|
|
|
_Py_UopsSymbol *next;
|
2024-02-13 09:24:48 -04:00
|
|
|
iter = stack_pointer[-1];
|
2024-05-10 13:43:23 -03:00
|
|
|
next = sym_new_type(ctx, &PyLong_Type);
|
2024-02-13 09:24:48 -04:00
|
|
|
(void)iter;
|
|
|
|
stack_pointer[0] = next;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-04-26 14:08:50 -03:00
|
|
|
case _FOR_ITER_GEN_FRAME: {
|
2024-04-30 07:33:13 -03:00
|
|
|
/* We are about to hit the end of the trace */
|
2024-05-10 13:43:23 -03:00
|
|
|
ctx->done = true;
|
2024-04-26 14:08:50 -03:00
|
|
|
break;
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
|
2024-06-18 08:17:46 -03:00
|
|
|
case _LOAD_SPECIAL: {
|
|
|
|
_Py_UopsSymbol *owner;
|
|
|
|
_Py_UopsSymbol *attr;
|
|
|
|
_Py_UopsSymbol *self_or_null;
|
|
|
|
owner = stack_pointer[-1];
|
|
|
|
(void)owner;
|
|
|
|
attr = sym_new_not_null(ctx);
|
|
|
|
self_or_null = sym_new_unknown(ctx);
|
|
|
|
stack_pointer[-1] = attr;
|
|
|
|
stack_pointer[0] = self_or_null;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-06-18 08:17:46 -03:00
|
|
|
break;
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
|
|
|
|
case _WITH_EXCEPT_START: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = res;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _PUSH_EXC_INFO: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *prev_exc;
|
|
|
|
_Py_UopsSymbol *new_exc;
|
2024-03-13 09:57:48 -03:00
|
|
|
prev_exc = sym_new_not_null(ctx);
|
|
|
|
new_exc = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = prev_exc;
|
|
|
|
stack_pointer[0] = new_exc;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GUARD_KEYS_VERSION: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_ATTR_METHOD_WITH_VALUES: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *owner;
|
|
|
|
_Py_UopsSymbol *attr;
|
|
|
|
_Py_UopsSymbol *self = NULL;
|
2024-02-23 03:42:03 -04:00
|
|
|
owner = stack_pointer[-1];
|
|
|
|
PyObject *descr = (PyObject *)this_instr->operand;
|
2024-02-23 11:41:10 -04:00
|
|
|
(void)descr;
|
2024-05-10 13:43:23 -03:00
|
|
|
attr = sym_new_not_null(ctx);
|
2024-02-23 11:41:10 -04:00
|
|
|
self = owner;
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = attr;
|
2024-02-20 06:50:59 -04:00
|
|
|
stack_pointer[0] = self;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_ATTR_METHOD_NO_DICT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *owner;
|
|
|
|
_Py_UopsSymbol *attr;
|
|
|
|
_Py_UopsSymbol *self = NULL;
|
2024-02-23 03:42:03 -04:00
|
|
|
owner = stack_pointer[-1];
|
|
|
|
PyObject *descr = (PyObject *)this_instr->operand;
|
2024-02-23 11:41:10 -04:00
|
|
|
(void)descr;
|
2024-05-10 13:43:23 -03:00
|
|
|
attr = sym_new_not_null(ctx);
|
2024-02-23 11:41:10 -04:00
|
|
|
self = owner;
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = attr;
|
2024-02-20 06:50:59 -04:00
|
|
|
stack_pointer[0] = self;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *attr;
|
2024-03-13 09:57:48 -03:00
|
|
|
attr = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = attr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_ATTR_NONDESCRIPTOR_NO_DICT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *attr;
|
2024-03-13 09:57:48 -03:00
|
|
|
attr = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = attr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_ATTR_METHOD_LAZY_DICT: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_ATTR_METHOD_LAZY_DICT: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *owner;
|
|
|
|
_Py_UopsSymbol *attr;
|
|
|
|
_Py_UopsSymbol *self = NULL;
|
2024-02-23 03:42:03 -04:00
|
|
|
owner = stack_pointer[-1];
|
|
|
|
PyObject *descr = (PyObject *)this_instr->operand;
|
2024-02-23 11:41:10 -04:00
|
|
|
(void)descr;
|
2024-05-10 13:43:23 -03:00
|
|
|
attr = sym_new_not_null(ctx);
|
2024-02-23 11:41:10 -04:00
|
|
|
self = owner;
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = attr;
|
2024-02-20 06:50:59 -04:00
|
|
|
stack_pointer[0] = self;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-07-26 10:35:57 -03:00
|
|
|
case _MAYBE_EXPAND_METHOD: {
|
2024-07-26 14:38:52 -03:00
|
|
|
_Py_UopsSymbol **args;
|
|
|
|
_Py_UopsSymbol *self_or_null;
|
|
|
|
_Py_UopsSymbol *callable;
|
2024-07-26 10:35:57 -03:00
|
|
|
_Py_UopsSymbol *func;
|
|
|
|
_Py_UopsSymbol *maybe_self;
|
2024-07-26 14:38:52 -03:00
|
|
|
args = &stack_pointer[-oparg];
|
|
|
|
self_or_null = stack_pointer[-1 - oparg];
|
|
|
|
callable = stack_pointer[-2 - oparg];
|
2024-08-01 05:27:26 -03:00
|
|
|
args = &stack_pointer[-oparg];
|
2024-07-26 14:38:52 -03:00
|
|
|
(void)callable;
|
|
|
|
(void)self_or_null;
|
|
|
|
(void)args;
|
2024-07-26 10:35:57 -03:00
|
|
|
func = sym_new_not_null(ctx);
|
|
|
|
maybe_self = sym_new_not_null(ctx);
|
|
|
|
stack_pointer[-2 - oparg] = func;
|
|
|
|
stack_pointer[-1 - oparg] = maybe_self;
|
|
|
|
break;
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
|
2024-07-26 10:35:57 -03:00
|
|
|
/* _DO_CALL is not a viable micro-op for tier 2 */
|
2024-02-13 09:24:48 -04:00
|
|
|
|
2024-07-26 10:35:57 -03:00
|
|
|
/* _MONITOR_CALL is not a viable micro-op for tier 2 */
|
|
|
|
|
2024-05-04 08:11:11 -03:00
|
|
|
case _PY_FRAME_GENERAL: {
|
|
|
|
_Py_UopsSymbol **args;
|
|
|
|
_Py_UopsSymbol *self_or_null;
|
|
|
|
_Py_UopsSymbol *callable;
|
|
|
|
_Py_UOpsAbstractFrame *new_frame;
|
|
|
|
args = &stack_pointer[-oparg];
|
|
|
|
self_or_null = stack_pointer[-1 - oparg];
|
|
|
|
callable = stack_pointer[-2 - oparg];
|
|
|
|
/* The _Py_UOpsAbstractFrame design assumes that we can copy arguments across directly */
|
|
|
|
(void)callable;
|
|
|
|
(void)self_or_null;
|
|
|
|
(void)args;
|
2024-05-10 13:43:23 -03:00
|
|
|
new_frame = NULL;
|
|
|
|
ctx->done = true;
|
2024-05-04 08:11:11 -03:00
|
|
|
stack_pointer[-2 - oparg] = (_Py_UopsSymbol *)new_frame;
|
|
|
|
stack_pointer += -1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-05-04 08:11:11 -03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_FUNCTION_VERSION: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_METHOD_VERSION: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _EXPAND_METHOD: {
|
|
|
|
_Py_UopsSymbol *method;
|
2024-09-12 11:32:45 -03:00
|
|
|
_Py_UopsSymbol **self;
|
|
|
|
self = &stack_pointer[-1 - oparg];
|
2024-05-04 08:11:11 -03:00
|
|
|
method = sym_new_not_null(ctx);
|
2024-09-12 11:32:45 -03:00
|
|
|
for (int _i = 1; --_i >= 0;) {
|
|
|
|
self[_i] = sym_new_not_null(ctx);
|
|
|
|
}
|
2024-05-04 08:11:11 -03:00
|
|
|
stack_pointer[-2 - oparg] = method;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_IS_NOT_PY_CALLABLE: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_NON_PY_GENERAL: {
|
|
|
|
_Py_UopsSymbol *res;
|
|
|
|
res = sym_new_not_null(ctx);
|
|
|
|
stack_pointer[-2 - oparg] = res;
|
|
|
|
stack_pointer += -1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-05-04 08:11:11 -03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-13 09:24:48 -04:00
|
|
|
case _CHECK_CALL_BOUND_METHOD_EXACT_ARGS: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *null;
|
|
|
|
_Py_UopsSymbol *callable;
|
2024-02-13 09:24:48 -04:00
|
|
|
null = stack_pointer[-1 - oparg];
|
|
|
|
callable = stack_pointer[-2 - oparg];
|
2024-05-10 13:43:23 -03:00
|
|
|
sym_set_null(null);
|
|
|
|
sym_set_type(callable, &PyMethod_Type);
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _INIT_CALL_BOUND_METHOD_EXACT_ARGS: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *callable;
|
|
|
|
_Py_UopsSymbol *func;
|
|
|
|
_Py_UopsSymbol *self;
|
2024-02-23 03:42:03 -04:00
|
|
|
callable = stack_pointer[-2 - oparg];
|
2024-02-23 11:41:10 -04:00
|
|
|
(void)callable;
|
2024-05-10 13:43:23 -03:00
|
|
|
func = sym_new_not_null(ctx);
|
|
|
|
self = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2 - oparg] = func;
|
|
|
|
stack_pointer[-1 - oparg] = self;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_PEP_523: {
|
2024-04-18 07:09:30 -03:00
|
|
|
/* Setting the eval frame function invalidates
|
|
|
|
* all executors, so no need to check dynamically */
|
|
|
|
if (_PyInterpreterState_GET()->eval_frame == NULL) {
|
|
|
|
REPLACE_OP(this_instr, _NOP, 0 ,0);
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_FUNCTION_EXACT_ARGS: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *self_or_null;
|
|
|
|
_Py_UopsSymbol *callable;
|
2024-02-13 09:24:48 -04:00
|
|
|
self_or_null = stack_pointer[-1 - oparg];
|
|
|
|
callable = stack_pointer[-2 - oparg];
|
2024-05-10 13:43:23 -03:00
|
|
|
sym_set_type(callable, &PyFunction_Type);
|
2024-02-13 09:24:48 -04:00
|
|
|
(void)self_or_null;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_STACK_SPACE: {
|
2024-04-18 07:09:30 -03:00
|
|
|
assert(corresponding_check_stack == NULL);
|
|
|
|
corresponding_check_stack = this_instr;
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _INIT_CALL_PY_EXACT_ARGS: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol **args;
|
|
|
|
_Py_UopsSymbol *self_or_null;
|
|
|
|
_Py_UopsSymbol *callable;
|
2024-02-13 09:24:48 -04:00
|
|
|
_Py_UOpsAbstractFrame *new_frame;
|
|
|
|
args = &stack_pointer[-oparg];
|
|
|
|
self_or_null = stack_pointer[-1 - oparg];
|
|
|
|
callable = stack_pointer[-2 - oparg];
|
|
|
|
int argcount = oparg;
|
|
|
|
(void)callable;
|
gh-117045: Add code object to function version cache (#117028)
Changes to the function version cache:
- In addition to the function object, also store the code object,
and allow the latter to be retrieved even if the function has been evicted.
- Stop assigning new function versions after a critical attribute (e.g. `__code__`)
has been modified; the version is permanently reset to zero in this case.
- Changes to `__annotations__` are no longer considered critical. (This fixes gh-109998.)
Changes to the Tier 2 optimization machinery:
- If we cannot map a function version to a function, but it is still mapped to a code object,
we continue projecting the trace.
The operand of the `_PUSH_FRAME` and `_POP_FRAME` opcodes can be either NULL,
a function object, or a code object with the lowest bit set.
This allows us to trace through code that calls an ephemeral function,
i.e., a function that may not be alive when we are constructing the executor,
e.g. a generator expression or certain nested functions.
We will lose globals removal inside such functions,
but we can still do other peephole operations
(and even possibly [call inlining](https://github.com/python/cpython/pull/116290),
if we decide to do it), which only need the code object.
As before, if we cannot retrieve the code object from the cache, we stop projecting.
2024-03-21 16:37:41 -03:00
|
|
|
PyCodeObject *co = NULL;
|
|
|
|
assert((this_instr + 2)->opcode == _PUSH_FRAME);
|
2024-03-24 15:34:55 -03:00
|
|
|
uint64_t push_operand = (this_instr + 2)->operand;
|
gh-117045: Add code object to function version cache (#117028)
Changes to the function version cache:
- In addition to the function object, also store the code object,
and allow the latter to be retrieved even if the function has been evicted.
- Stop assigning new function versions after a critical attribute (e.g. `__code__`)
has been modified; the version is permanently reset to zero in this case.
- Changes to `__annotations__` are no longer considered critical. (This fixes gh-109998.)
Changes to the Tier 2 optimization machinery:
- If we cannot map a function version to a function, but it is still mapped to a code object,
we continue projecting the trace.
The operand of the `_PUSH_FRAME` and `_POP_FRAME` opcodes can be either NULL,
a function object, or a code object with the lowest bit set.
This allows us to trace through code that calls an ephemeral function,
i.e., a function that may not be alive when we are constructing the executor,
e.g. a generator expression or certain nested functions.
We will lose globals removal inside such functions,
but we can still do other peephole operations
(and even possibly [call inlining](https://github.com/python/cpython/pull/116290),
if we decide to do it), which only need the code object.
As before, if we cannot retrieve the code object from the cache, we stop projecting.
2024-03-21 16:37:41 -03:00
|
|
|
if (push_operand & 1) {
|
|
|
|
co = (PyCodeObject *)(push_operand & ~1);
|
|
|
|
DPRINTF(3, "code=%p ", co);
|
|
|
|
assert(PyCode_Check(co));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PyFunctionObject *func = (PyFunctionObject *)push_operand;
|
|
|
|
DPRINTF(3, "func=%p ", func);
|
|
|
|
if (func == NULL) {
|
|
|
|
DPRINTF(3, "\n");
|
|
|
|
DPRINTF(1, "Missing function\n");
|
2024-05-10 13:43:23 -03:00
|
|
|
ctx->done = true;
|
|
|
|
break;
|
gh-117045: Add code object to function version cache (#117028)
Changes to the function version cache:
- In addition to the function object, also store the code object,
and allow the latter to be retrieved even if the function has been evicted.
- Stop assigning new function versions after a critical attribute (e.g. `__code__`)
has been modified; the version is permanently reset to zero in this case.
- Changes to `__annotations__` are no longer considered critical. (This fixes gh-109998.)
Changes to the Tier 2 optimization machinery:
- If we cannot map a function version to a function, but it is still mapped to a code object,
we continue projecting the trace.
The operand of the `_PUSH_FRAME` and `_POP_FRAME` opcodes can be either NULL,
a function object, or a code object with the lowest bit set.
This allows us to trace through code that calls an ephemeral function,
i.e., a function that may not be alive when we are constructing the executor,
e.g. a generator expression or certain nested functions.
We will lose globals removal inside such functions,
but we can still do other peephole operations
(and even possibly [call inlining](https://github.com/python/cpython/pull/116290),
if we decide to do it), which only need the code object.
As before, if we cannot retrieve the code object from the cache, we stop projecting.
2024-03-21 16:37:41 -03:00
|
|
|
}
|
|
|
|
co = (PyCodeObject *)func->func_code;
|
|
|
|
DPRINTF(3, "code=%p ", co);
|
2024-02-13 09:24:48 -04:00
|
|
|
}
|
|
|
|
assert(self_or_null != NULL);
|
|
|
|
assert(args != NULL);
|
2024-02-27 09:25:02 -04:00
|
|
|
if (sym_is_not_null(self_or_null)) {
|
2024-02-13 09:24:48 -04:00
|
|
|
// Bound method fiddling, same as _INIT_CALL_PY_EXACT_ARGS in VM
|
|
|
|
args--;
|
|
|
|
argcount++;
|
|
|
|
}
|
2024-02-27 09:25:02 -04:00
|
|
|
if (sym_is_null(self_or_null) || sym_is_not_null(self_or_null)) {
|
2024-06-08 06:41:45 -03:00
|
|
|
new_frame = frame_new(ctx, co, 0, args, argcount);
|
|
|
|
} else {
|
|
|
|
new_frame = frame_new(ctx, co, 0, NULL, 0);
|
2024-02-13 09:24:48 -04:00
|
|
|
}
|
2024-02-27 09:25:02 -04:00
|
|
|
stack_pointer[-2 - oparg] = (_Py_UopsSymbol *)new_frame;
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer += -1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _PUSH_FRAME: {
|
|
|
|
_Py_UOpsAbstractFrame *new_frame;
|
|
|
|
new_frame = (_Py_UOpsAbstractFrame *)stack_pointer[-1];
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
ctx->frame->stack_pointer = stack_pointer;
|
|
|
|
ctx->frame = new_frame;
|
|
|
|
ctx->curr_frame_depth++;
|
|
|
|
stack_pointer = new_frame->stack_pointer;
|
2024-04-18 07:09:30 -03:00
|
|
|
co = get_code(this_instr);
|
|
|
|
if (co == NULL) {
|
|
|
|
// should be about to _EXIT_TRACE anyway
|
2024-05-10 13:43:23 -03:00
|
|
|
ctx->done = true;
|
|
|
|
break;
|
2024-04-18 07:09:30 -03:00
|
|
|
}
|
|
|
|
/* Stack space handling */
|
|
|
|
int framesize = co->co_framesize;
|
|
|
|
assert(framesize > 0);
|
|
|
|
curr_space += framesize;
|
|
|
|
if (curr_space < 0 || curr_space > INT32_MAX) {
|
|
|
|
// won't fit in signed 32-bit int
|
2024-05-10 13:43:23 -03:00
|
|
|
ctx->done = true;
|
|
|
|
break;
|
2024-04-18 07:09:30 -03:00
|
|
|
}
|
|
|
|
max_space = curr_space > max_space ? curr_space : max_space;
|
|
|
|
if (first_valid_check_stack == NULL) {
|
|
|
|
first_valid_check_stack = corresponding_check_stack;
|
|
|
|
}
|
2024-05-04 08:11:11 -03:00
|
|
|
else if (corresponding_check_stack) {
|
2024-04-18 07:09:30 -03:00
|
|
|
// delete all but the first valid _CHECK_STACK_SPACE
|
|
|
|
corresponding_check_stack->opcode = _NOP;
|
|
|
|
}
|
|
|
|
corresponding_check_stack = NULL;
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_TYPE_1: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-03-11 06:30:15 -03:00
|
|
|
stack_pointer[-3] = res;
|
|
|
|
stack_pointer += -2;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_STR_1: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-03-11 06:30:15 -03:00
|
|
|
stack_pointer[-3] = res;
|
|
|
|
stack_pointer += -2;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_TUPLE_1: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-03-11 06:30:15 -03:00
|
|
|
stack_pointer[-3] = res;
|
|
|
|
stack_pointer += -2;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-08-20 12:52:58 -03:00
|
|
|
case _CHECK_AND_ALLOCATE_OBJECT: {
|
|
|
|
_Py_UopsSymbol **args;
|
|
|
|
_Py_UopsSymbol *null;
|
|
|
|
_Py_UopsSymbol *callable;
|
|
|
|
_Py_UopsSymbol *self;
|
|
|
|
_Py_UopsSymbol *init;
|
|
|
|
args = &stack_pointer[-oparg];
|
|
|
|
null = stack_pointer[-1 - oparg];
|
|
|
|
callable = stack_pointer[-2 - oparg];
|
|
|
|
args = &stack_pointer[-oparg];
|
|
|
|
uint32_t type_version = (uint32_t)this_instr->operand;
|
|
|
|
(void)type_version;
|
|
|
|
(void)callable;
|
|
|
|
(void)null;
|
|
|
|
(void)args;
|
|
|
|
self = sym_new_not_null(ctx);
|
|
|
|
init = sym_new_not_null(ctx);
|
|
|
|
stack_pointer[-2 - oparg] = self;
|
|
|
|
stack_pointer[-1 - oparg] = init;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CREATE_INIT_FRAME: {
|
|
|
|
_Py_UopsSymbol **args;
|
|
|
|
_Py_UopsSymbol *init;
|
|
|
|
_Py_UopsSymbol *self;
|
|
|
|
_Py_UOpsAbstractFrame *init_frame;
|
|
|
|
args = &stack_pointer[-oparg];
|
|
|
|
init = stack_pointer[-1 - oparg];
|
|
|
|
self = stack_pointer[-2 - oparg];
|
|
|
|
(void)self;
|
|
|
|
(void)init;
|
|
|
|
(void)args;
|
|
|
|
init_frame = NULL;
|
|
|
|
ctx->done = true;
|
|
|
|
stack_pointer[-2 - oparg] = (_Py_UopsSymbol *)init_frame;
|
|
|
|
stack_pointer += -1 - oparg;
|
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
|
|
|
break;
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
|
|
|
|
case _EXIT_INIT_CHECK: {
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_BUILTIN_CLASS: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2 - oparg] = res;
|
|
|
|
stack_pointer += -1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_BUILTIN_O: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2 - oparg] = res;
|
|
|
|
stack_pointer += -1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_BUILTIN_FAST: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2 - oparg] = res;
|
|
|
|
stack_pointer += -1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_BUILTIN_FAST_WITH_KEYWORDS: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2 - oparg] = res;
|
|
|
|
stack_pointer += -1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_LEN: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2 - oparg] = res;
|
|
|
|
stack_pointer += -1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_ISINSTANCE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2 - oparg] = res;
|
|
|
|
stack_pointer += -1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
2024-07-18 18:24:58 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_LIST_APPEND: {
|
|
|
|
stack_pointer += -3;
|
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
|
|
|
break;
|
2024-02-13 09:24:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_METHOD_DESCRIPTOR_O: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2 - oparg] = res;
|
|
|
|
stack_pointer += -1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2 - oparg] = res;
|
|
|
|
stack_pointer += -1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_METHOD_DESCRIPTOR_NOARGS: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2 - oparg] = res;
|
|
|
|
stack_pointer += -1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_METHOD_DESCRIPTOR_FAST: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2 - oparg] = res;
|
|
|
|
stack_pointer += -1 - oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* _INSTRUMENTED_CALL_KW is not a viable micro-op for tier 2 */
|
|
|
|
|
2024-08-14 08:04:05 -03:00
|
|
|
/* _DO_CALL_KW is not a viable micro-op for tier 2 */
|
2024-02-13 09:24:48 -04:00
|
|
|
|
2024-08-16 13:11:24 -03:00
|
|
|
case _PY_FRAME_KW: {
|
|
|
|
_Py_UopsSymbol *kwnames;
|
|
|
|
_Py_UopsSymbol **args;
|
|
|
|
_Py_UopsSymbol *self_or_null;
|
|
|
|
_Py_UopsSymbol *callable;
|
|
|
|
_Py_UOpsAbstractFrame *new_frame;
|
|
|
|
kwnames = stack_pointer[-1];
|
|
|
|
args = &stack_pointer[-1 - oparg];
|
|
|
|
self_or_null = stack_pointer[-2 - oparg];
|
|
|
|
callable = stack_pointer[-3 - oparg];
|
|
|
|
(void)callable;
|
|
|
|
(void)self_or_null;
|
|
|
|
(void)args;
|
|
|
|
(void)kwnames;
|
|
|
|
new_frame = NULL;
|
|
|
|
ctx->done = true;
|
|
|
|
stack_pointer[-3 - oparg] = (_Py_UopsSymbol *)new_frame;
|
|
|
|
stack_pointer += -2 - oparg;
|
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_FUNCTION_VERSION_KW: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_METHOD_VERSION_KW: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _EXPAND_METHOD_KW: {
|
|
|
|
_Py_UopsSymbol *method;
|
2024-09-12 11:32:45 -03:00
|
|
|
_Py_UopsSymbol **self;
|
2024-08-16 13:11:24 -03:00
|
|
|
_Py_UopsSymbol *kwnames;
|
2024-09-12 11:32:45 -03:00
|
|
|
self = &stack_pointer[-2 - oparg];
|
2024-08-16 13:11:24 -03:00
|
|
|
method = sym_new_not_null(ctx);
|
2024-09-12 11:32:45 -03:00
|
|
|
for (int _i = 1; --_i >= 0;) {
|
|
|
|
self[_i] = sym_new_not_null(ctx);
|
|
|
|
}
|
2024-08-16 13:11:24 -03:00
|
|
|
kwnames = sym_new_not_null(ctx);
|
|
|
|
stack_pointer[-3 - oparg] = method;
|
|
|
|
stack_pointer[-1] = kwnames;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_IS_NOT_PY_CALLABLE_KW: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CALL_KW_NON_PY: {
|
|
|
|
_Py_UopsSymbol *res;
|
|
|
|
res = sym_new_not_null(ctx);
|
|
|
|
stack_pointer[-3 - oparg] = res;
|
|
|
|
stack_pointer += -2 - oparg;
|
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-13 09:24:48 -04:00
|
|
|
/* _INSTRUMENTED_CALL_FUNCTION_EX is not a viable micro-op for tier 2 */
|
|
|
|
|
2024-08-14 08:04:05 -03:00
|
|
|
/* __DO_CALL_FUNCTION_EX is not a viable micro-op for tier 2 */
|
2024-02-13 09:24:48 -04:00
|
|
|
|
|
|
|
case _MAKE_FUNCTION: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *func;
|
2024-03-13 09:57:48 -03:00
|
|
|
func = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = func;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _SET_FUNCTION_ATTRIBUTE: {
|
2024-06-26 16:10:43 -03:00
|
|
|
_Py_UopsSymbol *func_st;
|
|
|
|
func_st = sym_new_not_null(ctx);
|
|
|
|
stack_pointer[-2] = func_st;
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-04-25 07:32:47 -03:00
|
|
|
case _RETURN_GENERATOR: {
|
|
|
|
_Py_UopsSymbol *res;
|
|
|
|
ctx->frame->stack_pointer = stack_pointer;
|
|
|
|
frame_pop(ctx);
|
|
|
|
stack_pointer = ctx->frame->stack_pointer;
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_unknown(ctx);
|
2024-04-25 07:32:47 -03:00
|
|
|
/* Stack space handling */
|
|
|
|
assert(corresponding_check_stack == NULL);
|
|
|
|
assert(co != NULL);
|
|
|
|
int framesize = co->co_framesize;
|
|
|
|
assert(framesize > 0);
|
|
|
|
assert(framesize <= curr_space);
|
|
|
|
curr_space -= framesize;
|
|
|
|
co = get_code(this_instr);
|
|
|
|
if (co == NULL) {
|
|
|
|
// might be impossible, but bailing is still safe
|
2024-05-10 13:43:23 -03:00
|
|
|
ctx->done = true;
|
2024-04-25 07:32:47 -03:00
|
|
|
}
|
|
|
|
stack_pointer[0] = res;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-04-25 07:32:47 -03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-13 09:24:48 -04:00
|
|
|
case _BUILD_SLICE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *slice;
|
2024-03-13 09:57:48 -03:00
|
|
|
slice = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2 - ((oparg == 3) ? 1 : 0)] = slice;
|
|
|
|
stack_pointer += -1 - ((oparg == 3) ? 1 : 0);
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CONVERT_VALUE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *result;
|
2024-03-13 09:57:48 -03:00
|
|
|
result = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = result;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _FORMAT_SIMPLE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-1] = res;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _FORMAT_WITH_SPEC: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-03-13 09:57:48 -03:00
|
|
|
res = sym_new_not_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _COPY: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *bottom;
|
|
|
|
_Py_UopsSymbol *top;
|
2024-02-13 09:24:48 -04:00
|
|
|
bottom = stack_pointer[-1 - (oparg-1)];
|
|
|
|
assert(oparg > 0);
|
|
|
|
top = bottom;
|
|
|
|
stack_pointer[0] = top;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _BINARY_OP: {
|
2024-04-22 09:34:06 -03:00
|
|
|
_Py_UopsSymbol *right;
|
|
|
|
_Py_UopsSymbol *left;
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *res;
|
2024-04-22 09:34:06 -03:00
|
|
|
right = stack_pointer[-1];
|
|
|
|
left = stack_pointer[-2];
|
|
|
|
PyTypeObject *ltype = sym_get_type(left);
|
|
|
|
PyTypeObject *rtype = sym_get_type(right);
|
|
|
|
if (ltype != NULL && (ltype == &PyLong_Type || ltype == &PyFloat_Type) &&
|
|
|
|
rtype != NULL && (rtype == &PyLong_Type || rtype == &PyFloat_Type))
|
|
|
|
{
|
|
|
|
if (oparg != NB_TRUE_DIVIDE && oparg != NB_INPLACE_TRUE_DIVIDE &&
|
|
|
|
ltype == &PyLong_Type && rtype == &PyLong_Type) {
|
|
|
|
/* If both inputs are ints and the op is not division the result is an int */
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_type(ctx, &PyLong_Type);
|
2024-04-22 09:34:06 -03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* For any other op combining ints/floats the result is a float */
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_type(ctx, &PyFloat_Type);
|
2024-04-22 09:34:06 -03:00
|
|
|
}
|
|
|
|
}
|
2024-05-10 13:43:23 -03:00
|
|
|
res = sym_new_unknown(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[-2] = res;
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _SWAP: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *top;
|
|
|
|
_Py_UopsSymbol *bottom;
|
2024-02-13 09:24:48 -04:00
|
|
|
top = stack_pointer[-1];
|
|
|
|
bottom = stack_pointer[-2 - (oparg-2)];
|
|
|
|
stack_pointer[-2 - (oparg-2)] = top;
|
|
|
|
stack_pointer[-1] = bottom;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-07-26 08:24:12 -03:00
|
|
|
/* _INSTRUMENTED_LINE is not a viable micro-op for tier 2 */
|
|
|
|
|
2024-02-13 09:24:48 -04:00
|
|
|
/* _INSTRUMENTED_INSTRUCTION is not a viable micro-op for tier 2 */
|
|
|
|
|
|
|
|
/* _INSTRUMENTED_JUMP_FORWARD is not a viable micro-op for tier 2 */
|
|
|
|
|
2024-08-14 08:04:05 -03:00
|
|
|
/* _MONITOR_JUMP_BACKWARD is not a viable micro-op for tier 2 */
|
2024-02-13 09:24:48 -04:00
|
|
|
|
|
|
|
/* _INSTRUMENTED_POP_JUMP_IF_TRUE is not a viable micro-op for tier 2 */
|
|
|
|
|
|
|
|
/* _INSTRUMENTED_POP_JUMP_IF_FALSE is not a viable micro-op for tier 2 */
|
|
|
|
|
|
|
|
/* _INSTRUMENTED_POP_JUMP_IF_NONE is not a viable micro-op for tier 2 */
|
|
|
|
|
|
|
|
/* _INSTRUMENTED_POP_JUMP_IF_NOT_NONE is not a viable micro-op for tier 2 */
|
|
|
|
|
|
|
|
case _GUARD_IS_TRUE_POP: {
|
2024-03-05 11:06:00 -04:00
|
|
|
_Py_UopsSymbol *flag;
|
|
|
|
flag = stack_pointer[-1];
|
|
|
|
if (sym_is_const(flag)) {
|
|
|
|
PyObject *value = sym_get_const(flag);
|
|
|
|
assert(value != NULL);
|
|
|
|
eliminate_pop_guard(this_instr, value != Py_True);
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GUARD_IS_FALSE_POP: {
|
2024-03-05 11:06:00 -04:00
|
|
|
_Py_UopsSymbol *flag;
|
|
|
|
flag = stack_pointer[-1];
|
|
|
|
if (sym_is_const(flag)) {
|
|
|
|
PyObject *value = sym_get_const(flag);
|
|
|
|
assert(value != NULL);
|
|
|
|
eliminate_pop_guard(this_instr, value != Py_False);
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GUARD_IS_NONE_POP: {
|
2024-03-05 11:06:00 -04:00
|
|
|
_Py_UopsSymbol *flag;
|
|
|
|
flag = stack_pointer[-1];
|
|
|
|
if (sym_is_const(flag)) {
|
|
|
|
PyObject *value = sym_get_const(flag);
|
|
|
|
assert(value != NULL);
|
|
|
|
eliminate_pop_guard(this_instr, !Py_IsNone(value));
|
|
|
|
}
|
|
|
|
else if (sym_has_type(flag)) {
|
|
|
|
assert(!sym_matches_type(flag, &_PyNone_Type));
|
|
|
|
eliminate_pop_guard(this_instr, true);
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _GUARD_IS_NOT_NONE_POP: {
|
2024-03-05 11:06:00 -04:00
|
|
|
_Py_UopsSymbol *flag;
|
|
|
|
flag = stack_pointer[-1];
|
|
|
|
if (sym_is_const(flag)) {
|
|
|
|
PyObject *value = sym_get_const(flag);
|
|
|
|
assert(value != NULL);
|
|
|
|
eliminate_pop_guard(this_instr, Py_IsNone(value));
|
|
|
|
}
|
|
|
|
else if (sym_has_type(flag)) {
|
|
|
|
assert(!sym_matches_type(flag, &_PyNone_Type));
|
|
|
|
eliminate_pop_guard(this_instr, false);
|
|
|
|
}
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _JUMP_TO_TOP: {
|
2024-05-10 13:43:23 -03:00
|
|
|
ctx->done = true;
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _SET_IP: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-04-03 14:14:18 -03:00
|
|
|
case _CHECK_STACK_SPACE_OPERAND: {
|
2024-04-18 07:09:30 -03:00
|
|
|
uint32_t framesize = (uint32_t)this_instr->operand;
|
|
|
|
(void)framesize;
|
|
|
|
/* We should never see _CHECK_STACK_SPACE_OPERANDs.
|
|
|
|
* They are only created at the end of this pass. */
|
|
|
|
Py_UNREACHABLE();
|
2024-04-03 14:14:18 -03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-13 09:24:48 -04:00
|
|
|
case _SAVE_RETURN_OFFSET: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _EXIT_TRACE: {
|
2024-07-26 13:40:15 -03:00
|
|
|
PyObject *exit_p = (PyObject *)this_instr->operand;
|
|
|
|
(void)exit_p;
|
2024-05-10 13:43:23 -03:00
|
|
|
ctx->done = true;
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _CHECK_VALIDITY: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_CONST_INLINE: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-02-13 09:24:48 -04:00
|
|
|
PyObject *ptr = (PyObject *)this_instr->operand;
|
2024-05-10 13:43:23 -03:00
|
|
|
value = sym_new_const(ctx, ptr);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = value;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_CONST_INLINE_BORROW: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *value;
|
2024-02-13 09:24:48 -04:00
|
|
|
PyObject *ptr = (PyObject *)this_instr->operand;
|
2024-05-10 13:43:23 -03:00
|
|
|
value = sym_new_const(ctx, ptr);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = value;
|
|
|
|
stack_pointer += 1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-29 18:13:38 -04:00
|
|
|
case _POP_TOP_LOAD_CONST_INLINE_BORROW: {
|
|
|
|
_Py_UopsSymbol *value;
|
2024-03-13 09:57:48 -03:00
|
|
|
value = sym_new_not_null(ctx);
|
2024-02-29 18:13:38 -04:00
|
|
|
stack_pointer[-1] = value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-13 09:24:48 -04:00
|
|
|
case _LOAD_CONST_INLINE_WITH_NULL: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *value;
|
|
|
|
_Py_UopsSymbol *null;
|
2024-02-13 09:24:48 -04:00
|
|
|
PyObject *ptr = (PyObject *)this_instr->operand;
|
2024-05-10 13:43:23 -03:00
|
|
|
value = sym_new_const(ctx, ptr);
|
|
|
|
null = sym_new_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = value;
|
|
|
|
stack_pointer[1] = null;
|
|
|
|
stack_pointer += 2;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _LOAD_CONST_INLINE_BORROW_WITH_NULL: {
|
2024-02-27 09:25:02 -04:00
|
|
|
_Py_UopsSymbol *value;
|
|
|
|
_Py_UopsSymbol *null;
|
2024-02-13 09:24:48 -04:00
|
|
|
PyObject *ptr = (PyObject *)this_instr->operand;
|
2024-05-10 13:43:23 -03:00
|
|
|
value = sym_new_const(ctx, ptr);
|
|
|
|
null = sym_new_null(ctx);
|
2024-02-13 09:24:48 -04:00
|
|
|
stack_pointer[0] = value;
|
|
|
|
stack_pointer[1] = null;
|
|
|
|
stack_pointer += 2;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-03-06 09:12:23 -04:00
|
|
|
case _CHECK_FUNCTION: {
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _INTERNAL_INCREMENT_OPT_COUNTER: {
|
|
|
|
stack_pointer += -1;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-02-13 09:24:48 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-04-26 14:08:50 -03:00
|
|
|
case _DYNAMIC_EXIT: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-20 05:39:55 -04:00
|
|
|
case _START_EXECUTOR: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-09-26 21:35:42 -03:00
|
|
|
case _MAKE_WARM: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-20 05:39:55 -04:00
|
|
|
case _FATAL_ERROR: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-02-13 12:28:19 -04:00
|
|
|
case _CHECK_VALIDITY_AND_SET_IP: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-03-26 06:35:11 -03:00
|
|
|
case _DEOPT: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case _ERROR_POP_N: {
|
|
|
|
stack_pointer += -oparg;
|
2024-06-25 12:42:29 -03:00
|
|
|
assert(WITHIN_STACK_BOUNDS());
|
2024-03-26 06:35:11 -03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-04-29 03:54:05 -03:00
|
|
|
case _TIER2_RESUME_CHECK: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|