Skip to content

Commit 5bfa810

Browse files
authored
Merge branch 'main' into fix-issue-134209
2 parents 59b49b4 + 6dcb0fd commit 5bfa810

17 files changed

+87
-327
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: 5 additions & 16 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: 3 additions & 7 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.

Lib/test/test_capi/test_object.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def test_is_uniquely_referenced(self):
180180
self.assertTrue(_testcapi.is_uniquely_referenced(object()))
181181
self.assertTrue(_testcapi.is_uniquely_referenced([]))
182182
# Immortals
183-
self.assertFalse(_testcapi.is_uniquely_referenced("spanish inquisition"))
183+
self.assertFalse(_testcapi.is_uniquely_referenced(()))
184184
self.assertFalse(_testcapi.is_uniquely_referenced(42))
185185
# CRASHES is_uniquely_referenced(NULL)
186186

Lib/test/test_dis.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ def loop_test():
902902
%3d RESUME_CHECK 0
903903
904904
%3d BUILD_LIST 0
905-
LOAD_CONST_MORTAL 2 ((1, 2, 3))
905+
LOAD_CONST 2 ((1, 2, 3))
906906
LIST_EXTEND 1
907907
LOAD_SMALL_INT 3
908908
BINARY_OP 5 (*)
@@ -918,7 +918,7 @@ def loop_test():
918918
919919
%3d L2: END_FOR
920920
POP_ITER
921-
LOAD_CONST_IMMORTAL 1 (None)
921+
LOAD_CONST 1 (None)
922922
RETURN_VALUE
923923
""" % (loop_test.__code__.co_firstlineno,
924924
loop_test.__code__.co_firstlineno + 1,
@@ -1304,7 +1304,7 @@ def test_load_attr_specialize(self):
13041304
load_attr_quicken = """\
13051305
0 RESUME_CHECK 0
13061306
1307-
1 LOAD_CONST_IMMORTAL 0 ('a')
1307+
1 LOAD_CONST 0 ('a')
13081308
LOAD_ATTR_SLOT 0 (__class__)
13091309
RETURN_VALUE
13101310
"""

Lib/test/test_opcache.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,20 +1810,6 @@ def compare_op_str():
18101810
self.assert_specialized(compare_op_str, "COMPARE_OP_STR")
18111811
self.assert_no_opcode(compare_op_str, "COMPARE_OP")
18121812

1813-
@cpython_only
1814-
@requires_specialization_ft
1815-
def test_load_const(self):
1816-
def load_const():
1817-
def unused(): pass
1818-
# Currently, the empty tuple is immortal, and the otherwise
1819-
# unused nested function's code object is mortal. This test will
1820-
# have to use different values if either of that changes.
1821-
return ()
1822-
1823-
load_const()
1824-
self.assert_specialized(load_const, "LOAD_CONST_IMMORTAL")
1825-
self.assert_specialized(load_const, "LOAD_CONST_MORTAL")
1826-
self.assert_no_opcode(load_const, "LOAD_CONST")
18271813

18281814
@cpython_only
18291815
@requires_specialization_ft

0 commit comments

Comments
 (0)