Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-131798: JIT: Optimize _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW #134369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 22, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify logic
  • Loading branch information
tomasr8 committed May 22, 2025
commit af8864687ac5bf1c8e717d1a8c2d7df88631230a
39 changes: 14 additions & 25 deletions 39 Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,43 +611,32 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
// _LOAD_FAST + _POP_TWO_LOAD_CONST_INLINE_BORROW + _POP_TOP
// ...becomes:
// _NOP + _POP_TOP + _NOP
again:
while (op_without_pop[opcode]) {
while (op_without_pop[opcode] || opcode == _POP_CALL || opcode == _POP_CALL_LOAD_CONST_INLINE_BORROW) {
_PyUOpInstruction *last = &buffer[pc - 1];
while (op_skip[last->opcode]) {
last--;
}
if (!op_without_push[last->opcode]) {
break;
}
last->opcode = op_without_push[last->opcode];
opcode = buffer[pc].opcode = op_without_pop[opcode];
if (op_without_pop[last->opcode]) {
opcode = last->opcode;
pc = last - buffer;
}
}
// Handle _POP_CALL and _POP_CALL_LOAD_CONST_INLINE_BORROW separately.
// This looks for a preceding _PUSH_NULL instruction and simplifies to _POP_TOP.
if (opcode == _POP_CALL || opcode == _POP_CALL_LOAD_CONST_INLINE_BORROW) {
_PyUOpInstruction *last = &buffer[pc - 1];
while (op_skip[last->opcode]) {
last--;
if (op_without_push[last->opcode]) {
last->opcode = op_without_push[last->opcode];
opcode = buffer[pc].opcode = op_without_pop[opcode];
if (op_without_pop[last->opcode]) {
opcode = last->opcode;
pc = last - buffer;
}
}
if (last->opcode == _PUSH_NULL) {
else if (last->opcode == _PUSH_NULL) {
// Handle _POP_CALL and _POP_CALL_LOAD_CONST_INLINE_BORROW separately.
// This looks for a preceding _PUSH_NULL instruction and
// simplifies to _POP_TOP(_LOAD_CONST_INLINE_BORROW).
last->opcode = _NOP;
if (opcode == _POP_CALL) {
opcode = buffer[pc].opcode = _POP_TOP;
}
else {
opcode = buffer[pc].opcode = _POP_TOP_LOAD_CONST_INLINE_BORROW;
}
opcode = buffer[pc].opcode = _POP_TOP;
if (op_without_pop[last->opcode]) {
opcode = last->opcode;
pc = last - buffer;
}
goto again;
} else {
break;
}
}
/* _PUSH_FRAME doesn't escape or error, but it
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.