Skip to content

Commit ba214fc

Browse files
committed
Clean things up
1 parent 59ad3ed commit ba214fc

File tree

9 files changed

+337
-349
lines changed

9 files changed

+337
-349
lines changed

Include/internal/pycore_code.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ extern "C" {
99
*/
1010

1111

12-
/* Inline caches */
12+
// Inline caches. If you change the number of cache entries for an instruction,
13+
// you must *also* bump the magic number in Lib/importlib/_bootstap_external.py!
1314

1415
#define CACHE_ENTRIES(cache) (sizeof(cache)/sizeof(_Py_CODEUNIT))
1516

@@ -70,20 +71,16 @@ typedef struct {
7071

7172
#define INLINE_CACHE_ENTRIES_LOAD_METHOD CACHE_ENTRIES(_PyLoadMethodCache)
7273

73-
// XXX: These members can definitely shrink:
7474
typedef struct {
7575
_Py_CODEUNIT counter;
7676
_Py_CODEUNIT func_version[2];
7777
_Py_CODEUNIT min_args;
78-
_Py_CODEUNIT defaults_len;
7978
} _PyCallCache;
8079

8180
#define INLINE_CACHE_ENTRIES_CALL CACHE_ENTRIES(_PyCallCache)
8281

83-
// XXX: Combine with _PyCallCache?
8482
typedef struct {
8583
_Py_CODEUNIT counter;
86-
_Py_CODEUNIT callable[4];
8784
} _PyPrecallCache;
8885

8986
#define INLINE_CACHE_ENTRIES_PRECALL CACHE_ENTRIES(_PyPrecallCache)
@@ -116,6 +113,10 @@ _Py_IncrementCountAndMaybeQuicken(PyCodeObject *code)
116113

117114
extern Py_ssize_t _Py_QuickenedCount;
118115

116+
extern PyObject *builtin_isinstance;
117+
extern PyObject *builtin_len;
118+
extern PyObject *builtin_list_append;
119+
119120
/* "Locals plus" for a code object is the set of locals + cell vars +
120121
* free vars. This relates to variable names as well as offsets into
121122
* the "fast locals" storage array of execution frames. The compiler

Include/opcode.h

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

Lib/importlib/_bootstrap_external.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ def _write_atomic(path, data, mode=0o666):
393393
# Python 3.11a5 3484 (Use inline caching for LOAD_ATTR, LOAD_METHOD, and
394394
# STORE_ATTR)
395395
# Python 3.11a5 3485 (Add an oparg to GET_AWAITABLE)
396+
# Python 3.11a6 3486 (Use inline caching for PRECALL and CALL)
396397

397398
# Python 3.12 will start with magic number 3500
398399

@@ -407,7 +408,7 @@ def _write_atomic(path, data, mode=0o666):
407408
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
408409
# in PC/launcher.c must also be updated.
409410

410-
MAGIC_NUMBER = (3485).to_bytes(2, 'little') + b'\r\n'
411+
MAGIC_NUMBER = (3486).to_bytes(2, 'little') + b'\r\n'
411412
_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c
412413

413414
_PYCACHE = '__pycache__'

Lib/opcode.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ def jabs_op(name, op, entries=0):
5757
# Instruction opcodes for compiled code
5858
# Blank lines correspond to available opcodes
5959

60+
def_op('CACHE', 0)
6061
def_op('POP_TOP', 1)
6162
def_op('PUSH_NULL', 2)
62-
def_op('CACHE', 3)
6363

6464
def_op('NOP', 9)
6565
def_op('UNARY_POSITIVE', 10)
@@ -191,9 +191,9 @@ def jabs_op(name, op, entries=0):
191191
def_op('SET_UPDATE', 163)
192192
def_op('DICT_MERGE', 164)
193193
def_op('DICT_UPDATE', 165)
194-
def_op('PRECALL', 166, 5)
194+
def_op('PRECALL', 166, 1)
195195

196-
def_op('CALL', 171, 5)
196+
def_op('CALL', 171, 4)
197197
def_op('KW_NAMES', 172)
198198
hasconst.append(172)
199199

0 commit comments

Comments
 (0)