Skip to content

Commit 558c2cf

Browse files
fix tests
1 parent ac6c21a commit 558c2cf

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

Lib/test/test_generated_cases.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,8 +2115,9 @@ def test_validate_uop_unused_input(self):
21152115
"""
21162116
output = """
21172117
case OP: {
2118+
CHECK_STACK_BOUNDS(-1);
21182119
stack_pointer += -1;
2119-
CHECK_STACK_BOUNDS();
2120+
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
21202121
break;
21212122
}
21222123
"""
@@ -2132,8 +2133,9 @@ def test_validate_uop_unused_input(self):
21322133
"""
21332134
output = """
21342135
case OP: {
2136+
CHECK_STACK_BOUNDS(-1);
21352137
stack_pointer += -1;
2136-
CHECK_STACK_BOUNDS();
2138+
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
21372139
break;
21382140
}
21392141
"""
@@ -2153,9 +2155,10 @@ def test_validate_uop_unused_output(self):
21532155
case OP: {
21542156
JitOptRef foo;
21552157
foo = NULL;
2158+
CHECK_STACK_BOUNDS(1);
21562159
stack_pointer[0] = foo;
21572160
stack_pointer += 1;
2158-
CHECK_STACK_BOUNDS();
2161+
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
21592162
break;
21602163
}
21612164
"""
@@ -2172,8 +2175,9 @@ def test_validate_uop_unused_output(self):
21722175
"""
21732176
output = """
21742177
case OP: {
2178+
CHECK_STACK_BOUNDS(1);
21752179
stack_pointer += 1;
2176-
CHECK_STACK_BOUNDS();
2180+
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
21772181
break;
21782182
}
21792183
"""

Python/optimizer_analysis.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ incorrect_keys(PyObject *obj, uint32_t version)
190190
#define CHECK_STACK_BOUNDS(offset) \
191191
do { \
192192
int stack_level = (int)(stack_pointer + (offset) - ctx->frame->stack); \
193-
if (!CURRENT_FRAME_IS_INIT_SHIM() && (stack_level < 0 || stack_level > STACK_SIZE())) { \
193+
if (stack_level < 0 || stack_level > STACK_SIZE()) { \
194194
ctx->contradiction = true; \
195195
ctx->done = true; \
196196
break; \

Python/optimizer_cases.c.h

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tools/cases_generator/stack.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ def stack_bound_check(self, out: CWriter):
321321
if not self.check_stack_bounds:
322322
return
323323
if self.physical_sp != self.logical_sp:
324-
diff = self.logical_sp - self.physical_sp
324+
diff = self.logical_sp - self.physical_sp
325+
out.start_line()
325326
out.emit(f"CHECK_STACK_BOUNDS({diff});\n")
326327

327328
def flush(self, out: CWriter) -> None:

0 commit comments

Comments
 (0)