gh-134584: Remove custom float decref ops (GH-142576)

This commit is contained in:
Ken Jin 2025-12-16 03:38:58 +08:00 committed by GitHub
parent b3b644b6b8
commit 0ac4e6c6cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 2606 additions and 3131 deletions

View file

@ -196,7 +196,7 @@ check_stack_bounds(JitOptContext *ctx, JitOptRef *stack_pointer, int offset, int
(opcode == _RETURN_VALUE) ||
(opcode == _RETURN_GENERATOR) ||
(opcode == _YIELD_VALUE);
if (should_check && (stack_level < 0 || stack_level > STACK_SIZE())) {
if (should_check && (stack_level < 0 || stack_level > STACK_SIZE() + MAX_CACHED_REGISTER)) {
ctx->contradiction = true;
ctx->done = true;
return 1;
@ -312,7 +312,7 @@ _Py_opt_assert_within_stack_bounds(
fflush(stdout);
abort();
}
int size = (int)(frame->stack_len);
int size = (int)(frame->stack_len) + MAX_CACHED_REGISTER;
if (level > size) {
printf("Stack overflow (depth = %d) at %s:%d\n", level, filename, lineno);
fflush(stdout);
@ -327,13 +327,6 @@ _Py_opt_assert_within_stack_bounds(
#define ASSERT_WITHIN_STACK_BOUNDS(F, L) (void)0
#endif
// TODO (gh-134584) generate most of this table automatically
const uint16_t op_without_decref_inputs[MAX_UOP_ID + 1] = {
[_BINARY_OP_MULTIPLY_FLOAT] = _BINARY_OP_MULTIPLY_FLOAT__NO_DECREF_INPUTS,
[_BINARY_OP_ADD_FLOAT] = _BINARY_OP_ADD_FLOAT__NO_DECREF_INPUTS,
[_BINARY_OP_SUBTRACT_FLOAT] = _BINARY_OP_SUBTRACT_FLOAT__NO_DECREF_INPUTS,
};
/* >0 (length) for success, 0 for not ready, clears all possible errors. */
static int
optimize_uops(