Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2,028 changes: 1,010 additions & 1,018 deletions Include/internal/pycore_uop_ids.h

Large diffs are not rendered by default.

60 changes: 0 additions & 60 deletions Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,6 @@ def testfunc(n):
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertNotIn("_BINARY_OP_ADD_INT", uops)
self.assertNotIn("_POP_TWO", uops)
self.assertNotIn("_GUARD_NOS_INT", uops)
self.assertNotIn("_GUARD_TOS_INT", uops)

Expand Down Expand Up @@ -1862,7 +1861,6 @@ def testfunc(n):
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertNotIn("_COMPARE_OP", uops)
self.assertNotIn("_POP_TWO", uops)

def test_compare_op_int_insert_two_load_const_inline_borrow(self):
def testfunc(n):
Expand Down Expand Up @@ -1930,7 +1928,6 @@ def testfunc(n):
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertNotIn("_CONTAINS_OP", uops)
self.assertNotIn("_POP_TWO", uops)

def test_to_bool_bool_contains_op_set(self):
"""
Expand Down
26 changes: 0 additions & 26 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,6 @@ dummy_func(
PyStackRef_CLOSE_SPECIALIZED(value, _PyUnicode_ExactDealloc);
}

tier2 op(_POP_TWO, (nos, tos --)) {
PyStackRef_CLOSE(tos);
PyStackRef_CLOSE(nos);
}

op(_POP_TOP_OPARG, (args[oparg] -- )) {
_PyStackRef_CloseStack(args, oparg);
DEAD(args);
Expand Down Expand Up @@ -5922,27 +5917,6 @@ dummy_func(
value = PyStackRef_FromPyObjectBorrow(ptr);
}

tier2 op(_POP_CALL, (callable, null --)) {
(void)null; // Silence compiler warnings about unused variables
DEAD(null);
PyStackRef_CLOSE(callable);
}

tier2 op(_POP_CALL_ONE, (callable, null, pop --)) {
PyStackRef_CLOSE(pop);
(void)null; // Silence compiler warnings about unused variables
DEAD(null);
PyStackRef_CLOSE(callable);
}

tier2 op(_POP_CALL_TWO, (callable, null, pop1, pop2 --)) {
PyStackRef_CLOSE(pop2);
PyStackRef_CLOSE(pop1);
(void)null; // Silence compiler warnings about unused variables
DEAD(null);
PyStackRef_CLOSE(callable);
}

tier2 op(_SHUFFLE_3_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, arg -- res, a, c)) {
res = PyStackRef_FromPyObjectBorrow(ptr);
a = arg;
Expand Down
122 changes: 0 additions & 122 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 4 additions & 18 deletions Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand All @@ -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,
};


Expand Down Expand Up @@ -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--;
Expand All @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion Python/optimizer_bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,10 @@ dummy_func(void) {
out = Py_True;
}
sym_set_const(res, out);
ADD_OP(_POP_CALL_TWO, 0, 0);
ADD_OP(_POP_TOP, 0, 0);
ADD_OP(_POP_TOP, 0, 0);
ADD_OP(_POP_TOP_NOP, 0, 0);
ADD_OP(_POP_TOP, 0, 0);
ADD_OP(_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)out);
}
}
Expand Down
Loading
Loading