mirror of
https://github.com/python/cpython.git
synced 2025-09-03 15:31:08 +00:00
gh-98831: rewrite COPY and SWAP in the instruction definition DSL (#101620)
This commit is contained in:
parent
949c58f945
commit
38752760c9
3 changed files with 21 additions and 22 deletions
18
Python/generated_cases.c.h
generated
18
Python/generated_cases.c.h
generated
|
@ -3723,9 +3723,12 @@
|
|||
}
|
||||
|
||||
TARGET(COPY) {
|
||||
assert(oparg != 0);
|
||||
PyObject *peek = PEEK(oparg);
|
||||
PUSH(Py_NewRef(peek));
|
||||
PyObject *bottom = PEEK(1 + (oparg-1));
|
||||
PyObject *top;
|
||||
assert(oparg > 0);
|
||||
top = Py_NewRef(bottom);
|
||||
STACK_GROW(1);
|
||||
POKE(1, top);
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
|
@ -3760,10 +3763,11 @@
|
|||
}
|
||||
|
||||
TARGET(SWAP) {
|
||||
assert(oparg != 0);
|
||||
PyObject *top = TOP();
|
||||
SET_TOP(PEEK(oparg));
|
||||
PEEK(oparg) = top;
|
||||
PyObject *top = PEEK(1);
|
||||
PyObject *bottom = PEEK(2 + (oparg-2));
|
||||
assert(oparg >= 2);
|
||||
POKE(1, bottom);
|
||||
POKE(2 + (oparg-2), top);
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue