mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +00:00
bpo-46841: Move the cache for LOAD_GLOBAL
inline. (GH-31575)
This commit is contained in:
parent
da7d99a4de
commit
4558af5a8f
10 changed files with 284 additions and 232 deletions
|
@ -36,7 +36,7 @@ def write_int_array_from_ops(name, ops, out):
|
|||
bits = 0
|
||||
for op in ops:
|
||||
bits |= 1<<op
|
||||
out.write(f"static uint32_t {name}[8] = {{\n")
|
||||
out.write(f"static const uint32_t {name}[8] = {{\n")
|
||||
for i in range(8):
|
||||
out.write(f" {bits & UINT32_MASK}U,\n")
|
||||
bits >>= 32
|
||||
|
@ -75,9 +75,16 @@ def main(opcode_py, outfile='Include/opcode.h'):
|
|||
fobj.write(DEFINE.format(name, next_op))
|
||||
used[next_op] = True
|
||||
fobj.write(DEFINE.format('DO_TRACING', 255))
|
||||
fobj.write("#ifdef NEED_OPCODE_JUMP_TABLES\n")
|
||||
fobj.write("\nextern const uint8_t _PyOpcode_InlineCacheEntries[256];\n")
|
||||
fobj.write("\n#ifdef NEED_OPCODE_TABLES\n")
|
||||
write_int_array_from_ops("_PyOpcode_RelativeJump", opcode['hasjrel'], fobj)
|
||||
write_int_array_from_ops("_PyOpcode_Jump", opcode['hasjrel'] + opcode['hasjabs'], fobj)
|
||||
|
||||
fobj.write("\nconst uint8_t _PyOpcode_InlineCacheEntries[256] = {\n")
|
||||
for i, entries in enumerate(opcode["_inline_cache_entries"]):
|
||||
if entries:
|
||||
fobj.write(f" [{opname[i]}] = {entries},\n")
|
||||
fobj.write("};\n")
|
||||
fobj.write("#endif /* OPCODE_TABLES */\n")
|
||||
|
||||
fobj.write("\n")
|
||||
|
@ -90,12 +97,6 @@ def main(opcode_py, outfile='Include/opcode.h'):
|
|||
for i, (op, _) in enumerate(opcode["_nb_ops"]):
|
||||
fobj.write(DEFINE.format(op, i))
|
||||
|
||||
fobj.write("\nstatic const uint8_t _PyOpcode_InlineCacheEntries[256] = {\n")
|
||||
for i, entries in enumerate(opcode["_inline_cache_entries"]):
|
||||
if entries:
|
||||
fobj.write(f" [{opname[i]}] = {entries},\n")
|
||||
fobj.write("};\n")
|
||||
|
||||
fobj.write(footer)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue