Skip to content

Commit b083450

Browse files
GH-93429: Merge LOAD_METHOD back into LOAD_ATTR (GH-93430)
1 parent cd543d0 commit b083450

File tree

13 files changed

+321
-380
lines changed

13 files changed

+321
-380
lines changed

Include/internal/pycore_code.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@ typedef struct {
5858
_Py_CODEUNIT index;
5959
} _PyAttrCache;
6060

61-
#define INLINE_CACHE_ENTRIES_LOAD_ATTR CACHE_ENTRIES(_PyAttrCache)
62-
63-
#define INLINE_CACHE_ENTRIES_STORE_ATTR CACHE_ENTRIES(_PyAttrCache)
64-
6561
typedef struct {
6662
_Py_CODEUNIT counter;
6763
_Py_CODEUNIT type_version[2];
6864
_Py_CODEUNIT keys_version[2];
6965
_Py_CODEUNIT descr[4];
7066
} _PyLoadMethodCache;
7167

72-
#define INLINE_CACHE_ENTRIES_LOAD_METHOD CACHE_ENTRIES(_PyLoadMethodCache)
68+
69+
// MUST be the max(_PyAttrCache, _PyLoadMethodCache)
70+
#define INLINE_CACHE_ENTRIES_LOAD_ATTR CACHE_ENTRIES(_PyLoadMethodCache)
71+
72+
#define INLINE_CACHE_ENTRIES_STORE_ATTR CACHE_ENTRIES(_PyAttrCache)
7373

7474
typedef struct {
7575
_Py_CODEUNIT counter;
@@ -233,8 +233,6 @@ extern int _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr,
233233
extern int _Py_Specialize_StoreAttr(PyObject *owner, _Py_CODEUNIT *instr,
234234
PyObject *name);
235235
extern int _Py_Specialize_LoadGlobal(PyObject *globals, PyObject *builtins, _Py_CODEUNIT *instr, PyObject *name);
236-
extern int _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr,
237-
PyObject *name);
238236
extern int _Py_Specialize_BinarySubscr(PyObject *sub, PyObject *container, _Py_CODEUNIT *instr);
239237
extern int _Py_Specialize_StoreSubscr(PyObject *container, PyObject *sub, _Py_CODEUNIT *instr);
240238
extern int _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr,

Include/internal/pycore_opcode.h

Lines changed: 38 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/opcode.h

Lines changed: 29 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/dis.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
LOAD_GLOBAL = opmap['LOAD_GLOBAL']
3838
BINARY_OP = opmap['BINARY_OP']
3939
JUMP_BACKWARD = opmap['JUMP_BACKWARD']
40+
LOAD_ATTR = opmap['LOAD_ATTR']
4041

4142
CACHE = opmap["CACHE"]
4243

@@ -463,6 +464,10 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
463464
argval, argrepr = _get_name_info(arg//2, get_name)
464465
if (arg & 1) and argrepr:
465466
argrepr = "NULL + " + argrepr
467+
elif deop == LOAD_ATTR:
468+
argval, argrepr = _get_name_info(arg//2, get_name)
469+
if (arg & 1) and argrepr:
470+
argrepr = "NULL|self + " + argrepr
466471
else:
467472
argval, argrepr = _get_name_info(arg, get_name)
468473
elif deop in hasjabs:

Lib/importlib/_bootstrap_external.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ def _write_atomic(path, data, mode=0o666):
408408
# Python 3.12a1 3501 (YIELD_VALUE oparg == stack_depth)
409409
# Python 3.12a1 3502 (LOAD_FAST_CHECK, no NULL-check in LOAD_FAST)
410410
# Python 3.12a1 3503 (Shrink LOAD_METHOD cache)
411+
# Python 3.12a1 3504 (Merge LOAD_METHOD back into LOAD_ATTR)
411412

412413
# Python 3.13 will start with 3550
413414

@@ -421,7 +422,7 @@ def _write_atomic(path, data, mode=0o666):
421422
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
422423
# in PC/launcher.c must also be updated.
423424

424-
MAGIC_NUMBER = (3503).to_bytes(2, 'little') + b'\r\n'
425+
MAGIC_NUMBER = (3504).to_bytes(2, 'little') + b'\r\n'
425426

426427
_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c
427428

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy