mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
GH-141794: Limit size of generated machine code. (GH-142228)
* Factor out bodies of the largest uops, to reduce jit code size. * Factor out common assert, also reducing jit code size. * Limit size of jitted code for a single executor to 1MB.
This commit is contained in:
parent
aea5531583
commit
62423c9c36
14 changed files with 1406 additions and 1731 deletions
|
|
@ -165,7 +165,7 @@ def test_inst_one_pop(self):
|
|||
value = stack_pointer[-1];
|
||||
SPAM(value);
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -190,7 +190,7 @@ def test_inst_one_push(self):
|
|||
res = SPAM();
|
||||
stack_pointer[0] = res;
|
||||
stack_pointer += 1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -247,7 +247,7 @@ def test_binary_op(self):
|
|||
res = SPAM(left, right);
|
||||
stack_pointer[-2] = res;
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -366,14 +366,14 @@ def test_sync_sp(self):
|
|||
_PyStackRef res;
|
||||
arg = stack_pointer[-1];
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
escaping_call();
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
res = Py_None;
|
||||
stack_pointer[0] = res;
|
||||
stack_pointer += 1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
|
|
@ -489,7 +489,7 @@ def test_error_if_pop(self):
|
|||
res = 0;
|
||||
stack_pointer[-2] = res;
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -523,7 +523,7 @@ def test_error_if_pop_with_result(self):
|
|||
}
|
||||
stack_pointer[-2] = res;
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -553,7 +553,7 @@ def test_cache_effect(self):
|
|||
uint32_t extra = read_u32(&this_instr[2].cache);
|
||||
(void)extra;
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -640,7 +640,7 @@ def test_macro_instruction(self):
|
|||
}
|
||||
stack_pointer[-3] = res;
|
||||
stack_pointer += -2;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
|
|
@ -688,7 +688,7 @@ def test_macro_instruction(self):
|
|||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
stack_pointer[-3] = res;
|
||||
stack_pointer += -2;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -827,7 +827,7 @@ def test_array_input(self):
|
|||
below = stack_pointer[-2 - oparg*2];
|
||||
SPAM(values, oparg);
|
||||
stack_pointer += -2 - oparg*2;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -860,7 +860,7 @@ def test_array_output(self):
|
|||
stack_pointer[-2] = below;
|
||||
stack_pointer[-1 + oparg*3] = above;
|
||||
stack_pointer += oparg*3;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -889,7 +889,7 @@ def test_array_input_output(self):
|
|||
above = 0;
|
||||
stack_pointer[0] = above;
|
||||
stack_pointer += 1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -918,11 +918,11 @@ def test_array_error_if(self):
|
|||
extra = stack_pointer[-1 - oparg];
|
||||
if (oparg == 0) {
|
||||
stack_pointer += -1 - oparg;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
JUMP_TO_LABEL(error);
|
||||
}
|
||||
stack_pointer += -1 - oparg;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -960,7 +960,7 @@ def test_macro_push_push(self):
|
|||
stack_pointer[0] = val1;
|
||||
stack_pointer[1] = val2;
|
||||
stack_pointer += 2;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -1263,13 +1263,13 @@ def test_flush(self):
|
|||
stack_pointer[0] = a;
|
||||
stack_pointer[1] = b;
|
||||
stack_pointer += 2;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
// SECOND
|
||||
{
|
||||
USE(a, b);
|
||||
}
|
||||
stack_pointer += -2;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -1325,7 +1325,7 @@ def test_pop_on_error_peeks(self):
|
|||
}
|
||||
}
|
||||
stack_pointer += -2;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -1368,14 +1368,14 @@ def test_push_then_error(self):
|
|||
stack_pointer[0] = a;
|
||||
stack_pointer[1] = b;
|
||||
stack_pointer += 2;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
JUMP_TO_LABEL(error);
|
||||
}
|
||||
}
|
||||
stack_pointer[0] = a;
|
||||
stack_pointer[1] = b;
|
||||
stack_pointer += 2;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -1661,7 +1661,7 @@ def test_pystackref_frompyobject_new_next_to_cmacro(self):
|
|||
stack_pointer[0] = out1;
|
||||
stack_pointer[1] = out2;
|
||||
stack_pointer += 2;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
"""
|
||||
|
|
@ -1881,7 +1881,7 @@ def test_reassigning_dead_inputs(self):
|
|||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
in = temp;
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_CLOSE(in);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
|
|
@ -2116,7 +2116,7 @@ def test_validate_uop_unused_input(self):
|
|||
output = """
|
||||
case OP: {
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
"""
|
||||
|
|
@ -2133,7 +2133,7 @@ def test_validate_uop_unused_input(self):
|
|||
output = """
|
||||
case OP: {
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
"""
|
||||
|
|
@ -2155,7 +2155,7 @@ def test_validate_uop_unused_output(self):
|
|||
foo = NULL;
|
||||
stack_pointer[0] = foo;
|
||||
stack_pointer += 1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
"""
|
||||
|
|
@ -2173,7 +2173,7 @@ def test_validate_uop_unused_output(self):
|
|||
output = """
|
||||
case OP: {
|
||||
stack_pointer += 1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue