mirror of
https://github.com/python/cpython.git
synced 2026-01-04 06:22:20 +00:00
gh-134584: Decref elimination for float ops in the JIT (GH-134588)
This PR adds a PyJitRef API to the JIT's optimizer that mimics the _PyStackRef API. This allows it to track references and their stack lifetimes properly. Thus opening up the doorway to refcount elimination in the JIT.
This commit is contained in:
parent
8dd8b5c2f0
commit
fba5dded6d
14 changed files with 1023 additions and 736 deletions
|
|
@ -347,8 +347,8 @@ static int
|
|||
optimize_to_bool(
|
||||
_PyUOpInstruction *this_instr,
|
||||
JitOptContext *ctx,
|
||||
JitOptSymbol *value,
|
||||
JitOptSymbol **result_ptr)
|
||||
JitOptRef value,
|
||||
JitOptRef *result_ptr)
|
||||
{
|
||||
if (sym_matches_type(value, &PyBool_Type)) {
|
||||
REPLACE_OP(this_instr, _NOP, 0, 0);
|
||||
|
|
@ -375,7 +375,7 @@ eliminate_pop_guard(_PyUOpInstruction *this_instr, bool exit)
|
|||
}
|
||||
}
|
||||
|
||||
static JitOptSymbol *
|
||||
static JitOptRef
|
||||
lookup_attr(JitOptContext *ctx, _PyUOpInstruction *this_instr,
|
||||
PyTypeObject *type, PyObject *name, uint16_t immortal,
|
||||
uint16_t mortal)
|
||||
|
|
@ -440,6 +440,13 @@ get_code_with_logging(_PyUOpInstruction *op)
|
|||
return co;
|
||||
}
|
||||
|
||||
// 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,
|
||||
};
|
||||
|
||||
/* 1 for success, 0 for not ready, cannot error at the moment. */
|
||||
static int
|
||||
optimize_uops(
|
||||
|
|
@ -477,7 +484,7 @@ optimize_uops(
|
|||
|
||||
int oparg = this_instr->oparg;
|
||||
opcode = this_instr->opcode;
|
||||
JitOptSymbol **stack_pointer = ctx->frame->stack_pointer;
|
||||
JitOptRef *stack_pointer = ctx->frame->stack_pointer;
|
||||
|
||||
#ifdef Py_DEBUG
|
||||
if (get_lltrace() >= 3) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue