diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2022-03-21 11:11:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-21 11:11:17 (GMT) |
commit | 2bde6827ea4f136297b2d882480b981ff26262b6 (patch) | |
tree | 8ad0569c15e0f516eaf8547581c6de2ca702b349 /Python/compile.c | |
parent | 08eb754d840696914928355014c2d424131f8835 (diff) | |
download | cpython-2bde6827ea4f136297b2d882480b981ff26262b6.zip cpython-2bde6827ea4f136297b2d882480b981ff26262b6.tar.gz cpython-2bde6827ea4f136297b2d882480b981ff26262b6.tar.bz2 |
bpo-46841: Quicken code in-place (GH-31888)
* Moves the bytecode to the end of the corresponding PyCodeObject, and quickens it in-place.
* Removes the almost-always-unused co_varnames, co_freevars, and co_cellvars member caches
* _PyOpcode_Deopt is a new mapping from all opcodes to their un-quickened forms.
* _PyOpcode_InlineCacheEntries is renamed to _PyOpcode_Caches
* _Py_IncrementCountAndMaybeQuicken is renamed to _PyCode_Warmup
* _Py_Quicken is renamed to _PyCode_Quicken
* _co_quickened is renamed to _co_code_adaptive (and is now a read-only memoryview).
* Do not emit unused nonzero opargs anymore in the compiler.
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/compile.c b/Python/compile.c index 950c44a..e24f425 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -134,9 +134,9 @@ static int instr_size(struct instr *instruction) { int opcode = instruction->i_opcode; - int oparg = instruction->i_oparg; + int oparg = HAS_ARG(opcode) ? instruction->i_oparg : 0; int extended_args = (0xFFFFFF < oparg) + (0xFFFF < oparg) + (0xFF < oparg); - int caches = _PyOpcode_InlineCacheEntries[opcode]; + int caches = _PyOpcode_Caches[opcode]; return extended_args + 1 + caches; } @@ -144,8 +144,8 @@ static void write_instr(_Py_CODEUNIT *codestr, struct instr *instruction, int ilen) { int opcode = instruction->i_opcode; - int oparg = instruction->i_oparg; - int caches = _PyOpcode_InlineCacheEntries[opcode]; + int oparg = HAS_ARG(opcode) ? instruction->i_oparg : 0; + int caches = _PyOpcode_Caches[opcode]; switch (ilen - caches) { case 4: *codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG, (oparg >> 24) & 0xFF); |