GH-120982: Add stack check assertions to generated interpreter code (GH-120992)

This commit is contained in:
Mark Shannon 2024-06-25 16:42:29 +01:00 committed by GitHub
parent 42b2c9d78d
commit 8f5a01707f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 448 additions and 0 deletions

View file

@ -151,6 +151,7 @@ def test_inst_one_pop(self):
value = stack_pointer[-1];
spam();
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
"""
@ -171,6 +172,7 @@ def test_inst_one_push(self):
spam();
stack_pointer[0] = res;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
"""
@ -216,6 +218,7 @@ def test_binary_op(self):
spam();
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
"""
@ -337,6 +340,7 @@ def test_error_if_pop(self):
if (cond) goto pop_2_label;
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
"""
@ -360,6 +364,7 @@ def test_cache_effect(self):
uint32_t extra = read_u32(&this_instr[2].cache);
(void)extra;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
"""
@ -425,6 +430,7 @@ def test_macro_instruction(self):
}
stack_pointer[-3] = res;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -459,6 +465,7 @@ def test_macro_instruction(self):
res = op3(arg2, left, right);
stack_pointer[-3] = res;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
"""
@ -540,6 +547,7 @@ def test_array_input(self):
below = stack_pointer[-2 - oparg*2];
spam();
stack_pointer += -2 - oparg*2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
"""
@ -564,6 +572,7 @@ def test_array_output(self):
stack_pointer[-2] = below;
stack_pointer[-1 + oparg*3] = above;
stack_pointer += oparg*3;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
"""
@ -586,6 +595,7 @@ def test_array_input_output(self):
spam(values, oparg);
stack_pointer[0] = above;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
"""
@ -608,6 +618,7 @@ def test_array_error_if(self):
extra = stack_pointer[-1 - oparg];
if (oparg == 0) { stack_pointer += -1 - oparg; goto somewhere; }
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
"""
@ -638,6 +649,7 @@ def test_cond_effect(self):
if (oparg & 2) stack_pointer[-1 - (((oparg & 1) == 1) ? 1 : 0)] = output;
stack_pointer[-1 - (((oparg & 1) == 1) ? 1 : 0) + ((oparg & 2) ? 1 : 0)] = zz;
stack_pointer += -(((oparg & 1) == 1) ? 1 : 0) + ((oparg & 2) ? 1 : 0);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
"""
@ -679,6 +691,7 @@ def test_macro_cond_effect(self):
if (oparg) stack_pointer[-2] = extra;
stack_pointer[-2 + ((oparg) ? 1 : 0)] = res;
stack_pointer += -1 + ((oparg) ? 1 : 0);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
"""
@ -712,6 +725,7 @@ def test_macro_push_push(self):
stack_pointer[0] = val1;
stack_pointer[1] = val2;
stack_pointer += 2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
"""

View file

@ -246,6 +246,8 @@ GETITEM(PyObject *v, Py_ssize_t i) {
#define STACK_SHRINK(n) BASIC_STACKADJ(-(n))
#endif
#define WITHIN_STACK_BOUNDS() \
(frame == &entry_frame || (STACK_LEVEL() >= 0 && STACK_LEVEL() <= STACK_SIZE()))
/* Data access macros */
#define FRAME_CO_CONSTS (_PyFrame_GetCode(frame)->co_consts)

File diff suppressed because it is too large Load diff

View file

@ -47,6 +47,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -76,6 +77,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -105,6 +107,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -134,6 +137,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -179,6 +183,7 @@
SKIP_OVER(1);
}
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -208,6 +213,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -237,6 +243,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -266,6 +273,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -295,6 +303,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -323,6 +332,7 @@
if (res == NULL) goto pop_3_error;
stack_pointer[-3] = res;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -361,6 +371,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -387,6 +398,7 @@
// not found or error
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -448,6 +460,7 @@
Py_DECREF(list);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -476,6 +489,7 @@
Py_DECREF(str);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -504,6 +518,7 @@
Py_DECREF(tuple);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -528,6 +543,7 @@
if (map == NULL) { stack_pointer += -1 - oparg; goto error; }
stack_pointer[-1 - oparg] = map;
stack_pointer += -oparg;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -542,6 +558,7 @@
if (list == NULL) { stack_pointer += -oparg; goto error; }
stack_pointer[-oparg] = list;
stack_pointer += 1 - oparg;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -562,6 +579,7 @@
if (map == NULL) { stack_pointer += -oparg*2; goto error; }
stack_pointer[-oparg*2] = map;
stack_pointer += 1 - oparg*2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -588,6 +606,7 @@
}
stack_pointer[-oparg] = set;
stack_pointer += 1 - oparg;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -609,6 +628,7 @@
if (slice == NULL) { stack_pointer += -2 - ((oparg == 3) ? 1 : 0); goto error; }
stack_pointer[-2 - ((oparg == 3) ? 1 : 0)] = slice;
stack_pointer += -1 - ((oparg == 3) ? 1 : 0);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -626,6 +646,7 @@
if (str == NULL) { stack_pointer += -oparg; goto error; }
stack_pointer[-oparg] = str;
stack_pointer += 1 - oparg;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -640,6 +661,7 @@
if (tup == NULL) { stack_pointer += -oparg; goto error; }
stack_pointer[-oparg] = tup;
stack_pointer += 1 - oparg;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -754,6 +776,7 @@
}
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
CHECK_EVAL_BREAKER();
DISPATCH();
}
@ -906,6 +929,7 @@
// Eventually this should be the only occurrence of this code.
assert(tstate->interp->eval_frame == NULL);
stack_pointer += -2 - oparg;
assert(WITHIN_STACK_BOUNDS());
_PyFrame_SetStackPointer(frame, stack_pointer);
new_frame->previous = frame;
CALL_STAT_INC(inlined_py_calls);
@ -979,6 +1003,7 @@
// The frame has stolen all the arguments from the stack,
// so there is no need to clean them up.
stack_pointer += -2 - oparg;
assert(WITHIN_STACK_BOUNDS());
if (new_frame == NULL) {
goto error;
}
@ -1047,6 +1072,7 @@
}
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
CHECK_EVAL_BREAKER();
DISPATCH();
}
@ -1095,6 +1121,7 @@
}
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
CHECK_EVAL_BREAKER();
DISPATCH();
}
@ -1142,6 +1169,7 @@
}
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
CHECK_EVAL_BREAKER();
DISPATCH();
}
@ -1189,6 +1217,7 @@
}
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
CHECK_EVAL_BREAKER();
DISPATCH();
}
@ -1275,6 +1304,7 @@
if (result == NULL) { stack_pointer += -3 - (oparg & 1); goto error; }
stack_pointer[-3 - (oparg & 1)] = result;
stack_pointer += -2 - (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
CHECK_EVAL_BREAKER();
DISPATCH();
}
@ -1310,6 +1340,7 @@
if (res == NULL) goto pop_2_error;
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -1353,6 +1384,7 @@
Py_DECREF(callable);
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -1443,6 +1475,7 @@
if (res == NULL) { stack_pointer += -3 - oparg; goto error; }
stack_pointer[-3 - oparg] = res;
stack_pointer += -2 - oparg;
assert(WITHIN_STACK_BOUNDS());
CHECK_EVAL_BREAKER();
DISPATCH();
}
@ -1485,6 +1518,7 @@
Py_DECREF(arg);
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -1565,6 +1599,7 @@
}
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
CHECK_EVAL_BREAKER();
DISPATCH();
}
@ -1615,6 +1650,7 @@
}
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
CHECK_EVAL_BREAKER();
DISPATCH();
}
@ -1665,6 +1701,7 @@
}
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
CHECK_EVAL_BREAKER();
DISPATCH();
}
@ -1716,6 +1753,7 @@
}
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
CHECK_EVAL_BREAKER();
DISPATCH();
}
@ -1766,6 +1804,7 @@
}
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
CHECK_EVAL_BREAKER();
DISPATCH();
}
@ -1836,6 +1875,7 @@
// Eventually this should be the only occurrence of this code.
assert(tstate->interp->eval_frame == NULL);
stack_pointer += -2 - oparg;
assert(WITHIN_STACK_BOUNDS());
_PyFrame_SetStackPointer(frame, stack_pointer);
new_frame->previous = frame;
CALL_STAT_INC(inlined_py_calls);
@ -1890,6 +1930,7 @@
// The frame has stolen all the arguments from the stack,
// so there is no need to clean them up.
stack_pointer += -2 - oparg;
assert(WITHIN_STACK_BOUNDS());
if (new_frame == NULL) {
goto error;
}
@ -1949,6 +1990,7 @@
}
stack_pointer[-3] = res;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
CHECK_EVAL_BREAKER();
DISPATCH();
}
@ -1982,6 +2024,7 @@
}
stack_pointer[-3] = res;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
CHECK_EVAL_BREAKER();
DISPATCH();
}
@ -2008,6 +2051,7 @@
Py_DECREF(arg);
stack_pointer[-3] = res;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2094,6 +2138,7 @@
stack_pointer[-3] = none;
stack_pointer[-2] = value;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2139,6 +2184,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2172,6 +2218,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2209,6 +2256,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2243,6 +2291,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2282,6 +2331,7 @@
}
stack_pointer[-2] = b;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2305,6 +2355,7 @@
b = (res ^ oparg) ? Py_True : Py_False;
stack_pointer[-2] = b;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2329,6 +2380,7 @@
b = (res ^ oparg) ? Py_True : Py_False;
stack_pointer[-2] = b;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2360,6 +2412,7 @@
top = Py_NewRef(bottom);
stack_pointer[0] = top;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2391,6 +2444,7 @@
Py_DECREF(owner);
if (err) goto pop_1_error;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2481,6 +2535,7 @@
Py_DECREF(sub);
if (err) goto pop_2_error;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2501,6 +2556,7 @@
}
Py_DECREF(update);
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2523,6 +2579,7 @@
}
Py_DECREF(update);
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2547,6 +2604,7 @@
goto exception_unwind;
}
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2558,6 +2616,7 @@
value = stack_pointer[-1];
Py_DECREF(value);
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2572,6 +2631,7 @@
Py_DECREF(receiver);
stack_pointer[-2] = value;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2622,6 +2682,7 @@
goto error;
}
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2672,6 +2733,7 @@
if (res == NULL) goto pop_2_error;
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2724,6 +2786,7 @@
}
stack_pointer[0] = next;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2818,6 +2881,7 @@
}
stack_pointer[0] = next;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2861,6 +2925,7 @@
}
stack_pointer[0] = next;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2906,6 +2971,7 @@
}
stack_pointer[0] = next;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -2992,6 +3058,7 @@
}
stack_pointer[0] = awaitable;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -3054,6 +3121,7 @@
if (len_o == NULL) goto error;
stack_pointer[0] = len_o;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -3104,6 +3172,7 @@
if (res == NULL) goto error;
stack_pointer[0] = res;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -3123,6 +3192,7 @@
if (res == NULL) goto pop_2_error;
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -3187,6 +3257,7 @@
}
Py_DECREF(value);
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -3207,6 +3278,7 @@
Py_DECREF(receiver);
stack_pointer[-2] = value;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -3513,6 +3585,7 @@
b = res ? Py_True : Py_False;
stack_pointer[-2] = b;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -3586,6 +3659,7 @@
list = stack_pointer[-2 - (oparg-1)];
if (_PyList_AppendTakeRef((PyListObject *)list, v) < 0) goto pop_1_error;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -3613,6 +3687,7 @@
assert(Py_IsNone(none_val));
Py_DECREF(iterable);
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -3679,6 +3754,7 @@
stack_pointer[-1] = attr;
if (oparg & 1) stack_pointer[0] = self_or_null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -3712,6 +3788,7 @@
stack_pointer[-1] = attr;
if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -3787,6 +3864,7 @@
stack_pointer[-1] = attr;
if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -3829,6 +3907,7 @@
stack_pointer[-1] = attr;
stack_pointer[0] = self;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -3864,6 +3943,7 @@
stack_pointer[-1] = attr;
stack_pointer[0] = self;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -3910,6 +3990,7 @@
stack_pointer[-1] = attr;
stack_pointer[0] = self;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -3949,6 +4030,7 @@
stack_pointer[-1] = attr;
if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4089,6 +4171,7 @@
stack_pointer[-1] = attr;
if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4142,6 +4225,7 @@
stack_pointer[-1] = attr;
if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4158,6 +4242,7 @@
}
stack_pointer[0] = bc;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4179,6 +4264,7 @@
}
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4191,6 +4277,7 @@
Py_INCREF(value);
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4207,6 +4294,7 @@
}
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4220,6 +4308,7 @@
Py_INCREF(value);
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4233,6 +4322,7 @@
GETLOCAL(oparg) = NULL;
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4252,6 +4342,7 @@
Py_INCREF(value);
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4270,6 +4361,7 @@
stack_pointer[0] = value1;
stack_pointer[1] = value2;
stack_pointer += 2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4415,6 +4507,7 @@
stack_pointer[0] = res;
if (oparg & 1) stack_pointer[1] = null;
stack_pointer += 1 + (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4456,6 +4549,7 @@
stack_pointer[0] = res;
if (oparg & 1) stack_pointer[1] = null;
stack_pointer += 1 + (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4490,6 +4584,7 @@
stack_pointer[0] = res;
if (oparg & 1) stack_pointer[1] = null;
stack_pointer += 1 + (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4507,6 +4602,7 @@
Py_INCREF(locals);
stack_pointer[0] = locals;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4543,6 +4639,7 @@
}
stack_pointer[0] = v;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4568,6 +4665,7 @@
stack_pointer[-1] = attr;
stack_pointer[0] = self_or_null;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4643,6 +4741,7 @@
stack_pointer[-3] = attr;
if (oparg & 1) stack_pointer[-2] = null;
stack_pointer += -2 + (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4671,6 +4770,7 @@
if (attr == NULL) goto pop_3_error;
stack_pointer[-3] = attr;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4712,6 +4812,7 @@
stack_pointer[-3] = attr;
stack_pointer[-2] = self_or_null;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4765,6 +4866,7 @@
// Do not DECREF INPUTS because the function steals the references
if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4796,6 +4898,7 @@
}
stack_pointer[-3] = attrs;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4813,6 +4916,7 @@
if (values_or_none == NULL) goto error;
stack_pointer[0] = values_or_none;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4827,6 +4931,7 @@
res = match ? Py_True : Py_False;
stack_pointer[0] = res;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4841,6 +4946,7 @@
res = match ? Py_True : Py_False;
stack_pointer[0] = res;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4860,6 +4966,7 @@
_PyErr_StackItem *exc_info = tstate->exc_info;
Py_XSETREF(exc_info->exc_value, exc_value == Py_None ? NULL : exc_value);
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4878,6 +4985,7 @@
#endif
JUMPBY(oparg * flag);
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4912,6 +5020,7 @@
JUMPBY(oparg * flag);
}
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4946,6 +5055,7 @@
JUMPBY(oparg * flag);
}
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4964,6 +5074,7 @@
#endif
JUMPBY(oparg * flag);
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4975,6 +5086,7 @@
value = stack_pointer[-1];
Py_DECREF(value);
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -4997,6 +5109,7 @@
stack_pointer[-1] = prev_exc;
stack_pointer[0] = new_exc;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5008,6 +5121,7 @@
res = NULL;
stack_pointer[0] = res;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5164,6 +5278,7 @@
}
stack_pointer[0] = res;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5196,6 +5311,7 @@
LLTRACE_RESUME_FRAME();
stack_pointer[0] = res;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5210,6 +5326,7 @@
assert(frame != &entry_frame);
#endif
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
_PyFrame_SetStackPointer(frame, stack_pointer);
assert(EMPTY());
_Py_LeaveRecursiveCallPy(tstate);
@ -5223,6 +5340,7 @@
LLTRACE_RESUME_FRAME();
stack_pointer[0] = res;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5360,6 +5478,7 @@
Py_DECREF(v);
if (err) goto pop_1_error;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5402,6 +5521,7 @@
}
stack_pointer[-2] = func;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5417,6 +5537,7 @@
Py_DECREF(iterable);
if (err < 0) goto pop_1_error;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5456,6 +5577,7 @@
if (err) goto pop_2_error;
}
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5500,6 +5622,7 @@
Py_DECREF(owner);
}
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5531,6 +5654,7 @@
Py_DECREF(owner);
}
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5589,6 +5713,7 @@
Py_DECREF(owner);
}
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5601,6 +5726,7 @@
PyCellObject *cell = (PyCellObject *)GETLOCAL(oparg);
PyCell_SetTakeRef(cell, v);
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5612,6 +5738,7 @@
value = stack_pointer[-1];
SETLOCAL(oparg, value);
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5644,6 +5771,7 @@
SETLOCAL(oparg1, value1);
SETLOCAL(oparg2, value2);
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5658,6 +5786,7 @@
Py_DECREF(v);
if (err) goto pop_1_error;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5683,6 +5812,7 @@
Py_DECREF(v);
if (err) goto pop_1_error;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5711,6 +5841,7 @@
Py_DECREF(container);
if (err) goto pop_4_error;
stack_pointer += -4;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5751,6 +5882,7 @@
if (err) goto pop_3_error;
}
stack_pointer += -3;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5772,6 +5904,7 @@
Py_DECREF(dict);
if (err) goto pop_3_error;
stack_pointer += -3;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -5802,6 +5935,7 @@
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
Py_DECREF(list);
stack_pointer += -3;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -6034,6 +6168,7 @@
Py_DECREF(seq);
if (res == 0) goto pop_1_error;
stack_pointer += (oparg >> 8) + (oparg & 0xFF);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -6070,6 +6205,7 @@
if (res == 0) goto pop_1_error;
}
stack_pointer += -1 + oparg;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -6092,6 +6228,7 @@
}
Py_DECREF(seq);
stack_pointer += -1 + oparg;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -6114,6 +6251,7 @@
}
Py_DECREF(seq);
stack_pointer += -1 + oparg;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -6137,6 +6275,7 @@
stack_pointer[-1] = val1;
stack_pointer[0] = val0;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -6181,6 +6320,7 @@
if (res == NULL) goto error;
stack_pointer[0] = res;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
@ -6203,6 +6343,7 @@
assert(oparg == 0 || oparg == 1);
gen->gi_frame_state = FRAME_SUSPENDED + oparg;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
_PyFrame_SetStackPointer(frame, stack_pointer);
tstate->exc_info = gen->gi_exc_state.previous_item;
gen->gi_exc_state.previous_item = NULL;
@ -6226,6 +6367,7 @@
LLTRACE_RESUME_FRAME();
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
#undef TIER_ONE

View file

@ -301,6 +301,11 @@ remove_globals(_PyInterpreterFrame *frame, _PyUOpInstruction *buffer,
#define STACK_LEVEL() ((int)(stack_pointer - ctx->frame->stack))
#define STACK_SIZE() ((int)(ctx->frame->stack_len))
#define WITHIN_STACK_BOUNDS() \
(STACK_LEVEL() >= 0 && STACK_LEVEL() <= STACK_SIZE())
#define GETLOCAL(idx) ((ctx->frame->locals[idx]))

View file

@ -22,6 +22,7 @@
}
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -30,6 +31,7 @@
value = GETLOCAL(oparg);
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -40,6 +42,7 @@
GETLOCAL(oparg) = temp;
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -51,6 +54,7 @@
value = sym_new_const(ctx, val);
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -59,11 +63,13 @@
value = stack_pointer[-1];
GETLOCAL(oparg) = value;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _POP_TOP: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -72,6 +78,7 @@
res = sym_new_null(ctx);
stack_pointer[0] = res;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -80,6 +87,7 @@
value = sym_new_not_null(ctx);
stack_pointer[-2] = value;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -239,6 +247,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -268,6 +277,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -297,6 +307,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -358,6 +369,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -388,6 +400,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -418,6 +431,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -455,6 +469,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -463,6 +478,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -471,11 +487,13 @@
res = sym_new_not_null(ctx);
stack_pointer[-3] = res;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _STORE_SLICE: {
stack_pointer += -4;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -484,6 +502,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -492,6 +511,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -500,6 +520,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -508,6 +529,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -515,31 +537,37 @@
case _LIST_APPEND: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _SET_ADD: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _STORE_SUBSCR: {
stack_pointer += -3;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _STORE_SUBSCR_LIST_INT: {
stack_pointer += -3;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _STORE_SUBSCR_DICT: {
stack_pointer += -3;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _DELETE_SUBSCR: {
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -555,6 +583,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -563,6 +592,7 @@
_Py_UopsSymbol *res;
retval = stack_pointer[-1];
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
ctx->frame->stack_pointer = stack_pointer;
frame_pop(ctx);
stack_pointer = ctx->frame->stack_pointer;
@ -581,6 +611,7 @@
}
stack_pointer[0] = res;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -600,6 +631,7 @@
awaitable = sym_new_not_null(ctx);
stack_pointer[0] = awaitable;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -625,6 +657,7 @@
case _POP_EXCEPT: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -633,6 +666,7 @@
value = sym_new_not_null(ctx);
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -641,11 +675,13 @@
bc = sym_new_not_null(ctx);
stack_pointer[0] = bc;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _STORE_NAME: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -664,6 +700,7 @@
values[i] = sym_new_unknown(ctx);
}
stack_pointer += -1 + oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -675,6 +712,7 @@
stack_pointer[-1] = val1;
stack_pointer[0] = val0;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -685,6 +723,7 @@
values[_i] = sym_new_not_null(ctx);
}
stack_pointer += -1 + oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -695,6 +734,7 @@
values[_i] = sym_new_not_null(ctx);
}
stack_pointer += -1 + oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -710,21 +750,25 @@
values[i] = sym_new_unknown(ctx);
}
stack_pointer += (oparg >> 8) + (oparg & 0xFF);
assert(WITHIN_STACK_BOUNDS());
break;
}
case _STORE_ATTR: {
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _DELETE_ATTR: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _STORE_GLOBAL: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -737,6 +781,7 @@
locals = sym_new_not_null(ctx);
stack_pointer[0] = locals;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -752,6 +797,7 @@
stack_pointer[0] = res;
if (oparg & 1) stack_pointer[1] = null;
stack_pointer += 1 + (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -771,6 +817,7 @@
stack_pointer[0] = res;
if (oparg & 1) stack_pointer[1] = null;
stack_pointer += 1 + (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -782,6 +829,7 @@
stack_pointer[0] = res;
if (oparg & 1) stack_pointer[1] = null;
stack_pointer += 1 + (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -809,11 +857,13 @@
value = sym_new_not_null(ctx);
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _STORE_DEREF: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -826,6 +876,7 @@
str = sym_new_not_null(ctx);
stack_pointer[-oparg] = str;
stack_pointer += 1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -834,6 +885,7 @@
tup = sym_new_not_null(ctx);
stack_pointer[-oparg] = tup;
stack_pointer += 1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -842,16 +894,19 @@
list = sym_new_not_null(ctx);
stack_pointer[-oparg] = list;
stack_pointer += 1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _LIST_EXTEND: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _SET_UPDATE: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -862,6 +917,7 @@
map = sym_new_not_null(ctx);
stack_pointer[-oparg*2] = map;
stack_pointer += 1 - oparg*2;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -874,21 +930,25 @@
map = sym_new_not_null(ctx);
stack_pointer[-1 - oparg] = map;
stack_pointer += -oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _DICT_UPDATE: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _DICT_MERGE: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _MAP_ADD: {
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -899,6 +959,7 @@
attr = sym_new_not_null(ctx);
stack_pointer[-3] = attr;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -910,6 +971,7 @@
stack_pointer[-3] = attr;
stack_pointer[-2] = self_or_null;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -926,6 +988,7 @@
stack_pointer[-1] = attr;
if (oparg & 1) stack_pointer[0] = self_or_null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -972,6 +1035,7 @@
stack_pointer[-1] = attr;
if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1024,6 +1088,7 @@
stack_pointer[-1] = attr;
if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1044,6 +1109,7 @@
stack_pointer[-1] = attr;
if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1060,6 +1126,7 @@
stack_pointer[-1] = attr;
if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1080,6 +1147,7 @@
stack_pointer[-1] = attr;
if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1093,16 +1161,19 @@
case _STORE_ATTR_INSTANCE_VALUE: {
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _STORE_ATTR_WITH_HINT: {
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _STORE_ATTR_SLOT: {
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1122,6 +1193,7 @@
}
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1136,6 +1208,7 @@
res = sym_new_type(ctx, &PyBool_Type);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1150,6 +1223,7 @@
res = sym_new_type(ctx, &PyBool_Type);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1164,6 +1238,7 @@
res = sym_new_type(ctx, &PyBool_Type);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1178,6 +1253,7 @@
res = sym_new_type(ctx, &PyBool_Type);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1192,6 +1268,7 @@
res = sym_new_type(ctx, &PyBool_Type);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1200,6 +1277,7 @@
b = sym_new_not_null(ctx);
stack_pointer[-2] = b;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1208,6 +1286,7 @@
b = sym_new_not_null(ctx);
stack_pointer[-2] = b;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1244,6 +1323,7 @@
len_o = sym_new_not_null(ctx);
stack_pointer[0] = len_o;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1252,6 +1332,7 @@
attrs = sym_new_not_null(ctx);
stack_pointer[-3] = attrs;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1260,6 +1341,7 @@
res = sym_new_not_null(ctx);
stack_pointer[0] = res;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1268,6 +1350,7 @@
res = sym_new_not_null(ctx);
stack_pointer[0] = res;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1276,6 +1359,7 @@
values_or_none = sym_new_not_null(ctx);
stack_pointer[0] = values_or_none;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1300,6 +1384,7 @@
next = sym_new_not_null(ctx);
stack_pointer[0] = next;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1320,6 +1405,7 @@
next = sym_new_not_null(ctx);
stack_pointer[0] = next;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1338,6 +1424,7 @@
next = sym_new_not_null(ctx);
stack_pointer[0] = next;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1359,6 +1446,7 @@
(void)iter;
stack_pointer[0] = next;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1379,6 +1467,7 @@
stack_pointer[-1] = attr;
stack_pointer[0] = self_or_null;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1387,6 +1476,7 @@
res = sym_new_not_null(ctx);
stack_pointer[0] = res;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1398,6 +1488,7 @@
stack_pointer[-1] = prev_exc;
stack_pointer[0] = new_exc;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1421,6 +1512,7 @@
stack_pointer[-1] = attr;
stack_pointer[0] = self;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1436,6 +1528,7 @@
stack_pointer[-1] = attr;
stack_pointer[0] = self;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1469,6 +1562,7 @@
stack_pointer[-1] = attr;
stack_pointer[0] = self;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1496,6 +1590,7 @@
ctx->done = true;
stack_pointer[-2 - oparg] = (_Py_UopsSymbol *)new_frame;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1526,6 +1621,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1621,6 +1717,7 @@
}
stack_pointer[-2 - oparg] = (_Py_UopsSymbol *)new_frame;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1628,6 +1725,7 @@
_Py_UOpsAbstractFrame *new_frame;
new_frame = (_Py_UOpsAbstractFrame *)stack_pointer[-1];
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
ctx->frame->stack_pointer = stack_pointer;
ctx->frame = new_frame;
ctx->curr_frame_depth++;
@ -1664,6 +1762,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-3] = res;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1672,6 +1771,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-3] = res;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1680,6 +1780,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-3] = res;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1687,6 +1788,7 @@
case _EXIT_INIT_CHECK: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1695,6 +1797,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1703,6 +1806,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1711,6 +1815,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1719,6 +1824,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1727,6 +1833,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1735,6 +1842,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1743,6 +1851,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1751,6 +1860,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1759,6 +1869,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1767,6 +1878,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1790,6 +1902,7 @@
func = sym_new_not_null(ctx);
stack_pointer[-2] = func;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1813,6 +1926,7 @@
}
stack_pointer[0] = res;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1821,6 +1935,7 @@
slice = sym_new_not_null(ctx);
stack_pointer[-2 - ((oparg == 3) ? 1 : 0)] = slice;
stack_pointer += -1 - ((oparg == 3) ? 1 : 0);
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1843,6 +1958,7 @@
res = sym_new_not_null(ctx);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1854,6 +1970,7 @@
top = bottom;
stack_pointer[0] = top;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1881,6 +1998,7 @@
res = sym_new_unknown(ctx);
stack_pointer[-2] = res;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1917,6 +2035,7 @@
eliminate_pop_guard(this_instr, value != Py_True);
}
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1929,6 +2048,7 @@
eliminate_pop_guard(this_instr, value != Py_False);
}
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1945,6 +2065,7 @@
eliminate_pop_guard(this_instr, true);
}
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -1961,6 +2082,7 @@
eliminate_pop_guard(this_instr, false);
}
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -2001,6 +2123,7 @@
value = sym_new_const(ctx, ptr);
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -2010,6 +2133,7 @@
value = sym_new_const(ctx, ptr);
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -2029,6 +2153,7 @@
stack_pointer[0] = value;
stack_pointer[1] = null;
stack_pointer += 2;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -2041,6 +2166,7 @@
stack_pointer[0] = value;
stack_pointer[1] = null;
stack_pointer += 2;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -2050,6 +2176,7 @@
case _INTERNAL_INCREMENT_OPT_COUNTER: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
break;
}
@ -2079,6 +2206,7 @@
case _ERROR_POP_N: {
stack_pointer += -oparg;
assert(WITHIN_STACK_BOUNDS());
break;
}

View file

@ -199,6 +199,7 @@ def flush(self, out: CWriter, cast_type: str = "PyObject *") -> None:
number = self.base_offset.to_c()
if number != "0":
out.emit(f"stack_pointer += {number};\n")
out.emit("assert(WITHIN_STACK_BOUNDS());\n")
self.variables = []
self.base_offset.clear()
self.top_offset.clear()

View file

@ -80,6 +80,9 @@ do { \
#undef JUMP_TO_ERROR
#define JUMP_TO_ERROR() PATCH_JUMP(_JIT_ERROR_TARGET)
#undef WITHIN_STACK_BOUNDS
#define WITHIN_STACK_BOUNDS() 1
_Py_CODEUNIT *
_JIT_ENTRY(_PyInterpreterFrame *frame, PyObject **stack_pointer, PyThreadState *tstate)
{