mirror of
https://github.com/python/cpython.git
synced 2026-03-06 13:00:50 +00:00
gh-130704: Strength reduce LOAD_FAST{_LOAD_FAST} (#130708)
Optimize `LOAD_FAST` opcodes into faster versions that load borrowed references onto the operand stack when we can prove that the lifetime of the local outlives the lifetime of the temporary that is loaded onto the stack.
This commit is contained in:
parent
e9556e1004
commit
053c285f6b
35 changed files with 1282 additions and 345 deletions
10
Python/opcode_targets.h
generated
10
Python/opcode_targets.h
generated
|
|
@ -84,6 +84,8 @@ static void *opcode_targets[256] = {
|
|||
&&TARGET_LOAD_DEREF,
|
||||
&&TARGET_LOAD_FAST,
|
||||
&&TARGET_LOAD_FAST_AND_CLEAR,
|
||||
&&TARGET_LOAD_FAST_BORROW,
|
||||
&&TARGET_LOAD_FAST_BORROW_LOAD_FAST_BORROW,
|
||||
&&TARGET_LOAD_FAST_CHECK,
|
||||
&&TARGET_LOAD_FAST_LOAD_FAST,
|
||||
&&TARGET_LOAD_FROM_DICT_OR_DEREF,
|
||||
|
|
@ -126,8 +128,6 @@ static void *opcode_targets[256] = {
|
|||
&&_unknown_opcode,
|
||||
&&_unknown_opcode,
|
||||
&&_unknown_opcode,
|
||||
&&_unknown_opcode,
|
||||
&&_unknown_opcode,
|
||||
&&TARGET_RESUME,
|
||||
&&TARGET_BINARY_OP_ADD_FLOAT,
|
||||
&&TARGET_BINARY_OP_ADD_INT,
|
||||
|
|
@ -414,6 +414,8 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_LOAD_CONST_MORTAL(TAIL_CALL_PARA
|
|||
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_LOAD_DEREF(TAIL_CALL_PARAMS);
|
||||
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_LOAD_FAST(TAIL_CALL_PARAMS);
|
||||
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_LOAD_FAST_AND_CLEAR(TAIL_CALL_PARAMS);
|
||||
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_LOAD_FAST_BORROW(TAIL_CALL_PARAMS);
|
||||
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_LOAD_FAST_BORROW_LOAD_FAST_BORROW(TAIL_CALL_PARAMS);
|
||||
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_LOAD_FAST_CHECK(TAIL_CALL_PARAMS);
|
||||
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_LOAD_FAST_LOAD_FAST(TAIL_CALL_PARAMS);
|
||||
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_LOAD_FROM_DICT_OR_DEREF(TAIL_CALL_PARAMS);
|
||||
|
|
@ -648,6 +650,8 @@ static py_tail_call_funcptr INSTRUCTION_TABLE[256] = {
|
|||
[LOAD_DEREF] = _TAIL_CALL_LOAD_DEREF,
|
||||
[LOAD_FAST] = _TAIL_CALL_LOAD_FAST,
|
||||
[LOAD_FAST_AND_CLEAR] = _TAIL_CALL_LOAD_FAST_AND_CLEAR,
|
||||
[LOAD_FAST_BORROW] = _TAIL_CALL_LOAD_FAST_BORROW,
|
||||
[LOAD_FAST_BORROW_LOAD_FAST_BORROW] = _TAIL_CALL_LOAD_FAST_BORROW_LOAD_FAST_BORROW,
|
||||
[LOAD_FAST_CHECK] = _TAIL_CALL_LOAD_FAST_CHECK,
|
||||
[LOAD_FAST_LOAD_FAST] = _TAIL_CALL_LOAD_FAST_LOAD_FAST,
|
||||
[LOAD_FROM_DICT_OR_DEREF] = _TAIL_CALL_LOAD_FROM_DICT_OR_DEREF,
|
||||
|
|
@ -725,8 +729,6 @@ static py_tail_call_funcptr INSTRUCTION_TABLE[256] = {
|
|||
[UNPACK_SEQUENCE_TWO_TUPLE] = _TAIL_CALL_UNPACK_SEQUENCE_TWO_TUPLE,
|
||||
[WITH_EXCEPT_START] = _TAIL_CALL_WITH_EXCEPT_START,
|
||||
[YIELD_VALUE] = _TAIL_CALL_YIELD_VALUE,
|
||||
[117] = _TAIL_CALL_UNKNOWN_OPCODE,
|
||||
[118] = _TAIL_CALL_UNKNOWN_OPCODE,
|
||||
[119] = _TAIL_CALL_UNKNOWN_OPCODE,
|
||||
[120] = _TAIL_CALL_UNKNOWN_OPCODE,
|
||||
[121] = _TAIL_CALL_UNKNOWN_OPCODE,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue