mirror of
https://github.com/python/cpython.git
synced 2026-05-07 02:51:00 +00:00
gh-148211: decompose _POP_TWO/_POP_CALL(_ONE/_TWO) in JIT (GH-148377)
This commit is contained in:
parent
72006a71b2
commit
9831dea3bf
9 changed files with 1027 additions and 1280 deletions
|
|
@ -677,6 +677,7 @@ const uint16_t op_without_push[MAX_UOP_ID + 1] = {
|
|||
[_LOAD_FAST] = _NOP,
|
||||
[_LOAD_FAST_BORROW] = _NOP,
|
||||
[_LOAD_SMALL_INT] = _NOP,
|
||||
[_PUSH_NULL] = _NOP,
|
||||
};
|
||||
|
||||
const bool op_skip[MAX_UOP_ID + 1] = {
|
||||
|
|
@ -692,13 +693,6 @@ const uint16_t op_without_pop[MAX_UOP_ID + 1] = {
|
|||
[_POP_TOP_INT] = _NOP,
|
||||
[_POP_TOP_FLOAT] = _NOP,
|
||||
[_POP_TOP_UNICODE] = _NOP,
|
||||
[_POP_TWO] = _POP_TOP,
|
||||
[_POP_CALL_TWO] = _POP_CALL_ONE,
|
||||
[_POP_CALL_ONE] = _POP_CALL,
|
||||
};
|
||||
|
||||
const uint16_t op_without_pop_null[MAX_UOP_ID + 1] = {
|
||||
[_POP_CALL] = _POP_TOP,
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -733,10 +727,10 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
|
|||
default:
|
||||
{
|
||||
// Cancel out pushes and pops, repeatedly. So:
|
||||
// _LOAD_FAST + _POP_TWO + _LOAD_CONST_INLINE_BORROW + _POP_TOP
|
||||
// _LOAD_FAST + _POP_TOP + _POP_TOP + _LOAD_CONST_INLINE_BORROW + _POP_TOP
|
||||
// ...becomes:
|
||||
// _NOP + _POP_TOP + _NOP + _NOP
|
||||
while (op_without_pop[opcode] || op_without_pop_null[opcode]) {
|
||||
// _NOP + _NOP + _POP_TOP + _NOP + _NOP
|
||||
while (op_without_pop[opcode]) {
|
||||
_PyUOpInstruction *last = &buffer[pc - 1];
|
||||
while (op_skip[last->opcode]) {
|
||||
last--;
|
||||
|
|
@ -749,14 +743,6 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
|
|||
pc = (int)(last - buffer);
|
||||
}
|
||||
}
|
||||
else if (last->opcode == _PUSH_NULL) {
|
||||
// Handle _POP_CALL separately.
|
||||
// This looks for a preceding _PUSH_NULL instruction and
|
||||
// simplifies to _POP_TOP.
|
||||
last->opcode = _NOP;
|
||||
opcode = buffer[pc].opcode = op_without_pop_null[opcode];
|
||||
assert(opcode);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue