GH-135379: Remove types from stack items in code generator. by markshannon · Pull Request #135384 · python/cpython · GitHub
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
26 changes: 26 additions & 0 deletions Include/internal/pycore_stackref.h
38 changes: 6 additions & 32 deletions Lib/test/test_generated_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ class TestEffects(unittest.TestCase):
def test_effect_sizes(self):
stack = Stack()
inputs = [
x := StackItem("x", None, "1"),
y := StackItem("y", None, "oparg"),
z := StackItem("z", None, "oparg*2"),
x := StackItem("x", "1"),
y := StackItem("y", "oparg"),
z := StackItem("z", "oparg*2"),
]
outputs = [
StackItem("x", None, "1"),
StackItem("b", None, "oparg*4"),
StackItem("c", None, "1"),
StackItem("x", "1"),
StackItem("b", "oparg*4"),
StackItem("c", "1"),
]
null = CWriter.null()
stack.pop(z, null)
Expand Down Expand Up @@ -1103,32 +1103,6 @@ def test_array_of_one(self):
"""
self.run_cases_test(input, output)

def test_pointer_to_stackref(self):
input = """
inst(OP, (arg: _PyStackRef * -- out)) {
out = *arg;
DEAD(arg);
}
"""
output = """
TARGET(OP) {
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
frame->instr_ptr = next_instr;
next_instr += 1;
INSTRUCTION_STATS(OP);
_PyStackRef *arg;
_PyStackRef out;
arg = (_PyStackRef *)stack_pointer[-1].bits;
out = *arg;
stack_pointer[-1] = out;
DISPATCH();
}
"""
self.run_cases_test(input, output)

def test_unused_cached_value(self):
input = """
op(FIRST, (arg1 -- out)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The cases generator no longer accepts type annotations on stack items.
Conversions to non-default types are now done explictly in bytecodes.c and
optimizer_bytecodes.c. This will simplify code generation for top-of-stack
caching and other future features.
63 changes: 33 additions & 30 deletions Python/bytecodes.c
Loading
Loading