Skip to content

Commit b33c297

Browse files
committed
Simplify LOAD_CONST: Always borrow the reference
1 parent 27bd082 commit b33c297

13 files changed

+106
-314
lines changed

Include/internal/pycore_magic_number.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ Known values:
278278
Python 3.14a7 3623 (Add BUILD_INTERPOLATION & BUILD_TEMPLATE opcodes)
279279
Python 3.14b1 3624 (Don't optimize LOAD_FAST when local is killed by DELETE_FAST)
280280
Python 3.15a0 3650 (Initial version)
281+
Python 3.15a1 3651 (Simplify LOAD_CONST)
281282
282283
Python 3.16 will start with 3700
283284
@@ -290,7 +291,7 @@ PC/launcher.c must also be updated.
290291
291292
*/
292293

293-
#define PYC_MAGIC_NUMBER 3650
294+
#define PYC_MAGIC_NUMBER 3651
294295
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
295296
(little-endian) and then appending b'\r\n'. */
296297
#define PYC_MAGIC_NUMBER_TOKEN \

Include/internal/pycore_opcode_metadata.h

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

Include/internal/pycore_stackref.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,11 @@ _PyStackRef_FromPyObjectSteal(PyObject *obj, const char *filename, int linenumbe
134134
#define PyStackRef_FromPyObjectSteal(obj) _PyStackRef_FromPyObjectSteal(_PyObject_CAST(obj), __FILE__, __LINE__)
135135

136136
static inline _PyStackRef
137-
_PyStackRef_FromPyObjectImmortal(PyObject *obj, const char *filename, int linenumber)
137+
_PyStackRef_FromPyObjectBorrow(PyObject *obj, const char *filename, int linenumber)
138138
{
139-
assert(_Py_IsImmortal(obj));
140139
return _Py_stackref_create(obj, filename, linenumber);
141140
}
142-
#define PyStackRef_FromPyObjectImmortal(obj) _PyStackRef_FromPyObjectImmortal(_PyObject_CAST(obj), __FILE__, __LINE__)
141+
#define PyStackRef_FromPyObjectBorrow(obj) _PyStackRef_FromPyObjectBorrow(_PyObject_CAST(obj), __FILE__, __LINE__)
143142

144143
static inline void
145144
_PyStackRef_CLOSE(_PyStackRef ref, const char *filename, int linenumber)
@@ -366,15 +365,14 @@ PyStackRef_FromPyObjectNew(PyObject *obj)
366365
#define PyStackRef_FromPyObjectNew(obj) PyStackRef_FromPyObjectNew(_PyObject_CAST(obj))
367366

368367
static inline _PyStackRef
369-
PyStackRef_FromPyObjectImmortal(PyObject *obj)
368+
PyStackRef_FromPyObjectBorrow(PyObject *obj)
370369
{
371370
// Make sure we don't take an already tagged value.
372371
assert(((uintptr_t)obj & Py_TAG_BITS) == 0);
373372
assert(obj != NULL);
374-
assert(_Py_IsImmortal(obj));
375373
return (_PyStackRef){ .bits = (uintptr_t)obj | Py_TAG_DEFERRED };
376374
}
377-
#define PyStackRef_FromPyObjectImmortal(obj) PyStackRef_FromPyObjectImmortal(_PyObject_CAST(obj))
375+
#define PyStackRef_FromPyObjectBorrow(obj) PyStackRef_FromPyObjectBorrow(_PyObject_CAST(obj))
378376

379377
#define PyStackRef_CLOSE(REF) \
380378
do { \
@@ -582,9 +580,8 @@ _PyStackRef_FromPyObjectNewMortal(PyObject *obj)
582580

583581
/* Create a new reference from an object with an embedded reference count */
584582
static inline _PyStackRef
585-
PyStackRef_FromPyObjectImmortal(PyObject *obj)
583+
PyStackRef_FromPyObjectBorrow(PyObject *obj)
586584
{
587-
assert(_Py_IsImmortal(obj));
588585
return (_PyStackRef){ .bits = (uintptr_t)obj | Py_TAG_REFCNT};
589586
}
590587

Include/internal/pycore_uop_ids.h

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

Include/internal/pycore_uop_metadata.h

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

Include/opcode_ids.h

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

Lib/_opcode_metadata.py

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

0 commit comments

Comments
 (0)