Skip to content

Commit fdeae7d

Browse files
committed
Make the default build work
1 parent de13810 commit fdeae7d

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

Include/internal/pycore_stackref.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ PyStackRef_CLOSE(_PyStackRef ref)
146146
Py_DECREF(obj);
147147
}
148148

149+
static inline _PyStackRef
150+
_PyStackRef_NewIfBorrowedOrSteal(_PyStackRef ref)
151+
{
152+
return ref;
153+
}
154+
149155
static inline _PyStackRef
150156
_PyStackRef_DUP(_PyStackRef ref, const char *filename, int linenumber)
151157
{
@@ -274,9 +280,6 @@ PyStackRef_DUP(_PyStackRef stackref)
274280
{
275281
assert(!PyStackRef_IsNull(stackref));
276282
if (PyStackRef_IsDeferred(stackref)) {
277-
/* assert(_Py_IsImmortal(PyStackRef_AsPyObjectBorrow(stackref)) || */
278-
/* _PyObject_HasDeferredRefcount(PyStackRef_AsPyObjectBorrow(stackref)) */
279-
/* ); */
280283
return stackref;
281284
}
282285
Py_INCREF(PyStackRef_AsPyObjectBorrow(stackref));
@@ -322,6 +325,8 @@ static const _PyStackRef PyStackRef_NULL = { .bits = 0 };
322325

323326
#define PyStackRef_DUP(stackref) PyStackRef_FromPyObjectSteal(Py_NewRef(PyStackRef_AsPyObjectBorrow(stackref)))
324327

328+
#define _PyStackRef_NewIfBorrowedOrSteal(stackref) stackref
329+
325330
#define PyStackRef_CLOSE_SPECIALIZED(stackref, dealloc) _Py_DECREF_SPECIALIZED(PyStackRef_AsPyObjectBorrow(stackref), dealloc)
326331

327332
#endif // Py_GIL_DISABLED

Lib/test/test_dis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ def load_test(x, y=0):
877877
%3d LOAD_FAST_LOAD_FAST 1 (x, y)
878878
STORE_FAST_STORE_FAST 50 (b, a)
879879
880-
%3d LOAD_FAST_LOAD_FAST 35 (a, b)
880+
%3d LOAD_FAST_BORROW_LOAD_FAST_BORROW 35 (a, b)
881881
BUILD_TUPLE 2
882882
RETURN_VALUE
883883
""" % (load_test.__code__.co_firstlineno,

Python/bytecodes.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,12 @@ dummy_func(
271271
}
272272

273273
inst (LOAD_FAST_BORROW, (-- value)) {
274+
assert(!PyStackRef_IsNull(GETLOCAL(oparg)));
275+
#ifdef Py_GIL_DISABLED
274276
value = PyStackRef_AsDeferred(GETLOCAL(oparg));
277+
#else
278+
value = PyStackRef_DUP(GETLOCAL(oparg));
279+
#endif
275280
}
276281

277282
inst(LOAD_FAST_AND_CLEAR, (-- value)) {
@@ -289,8 +294,13 @@ dummy_func(
289294
inst(LOAD_FAST_BORROW_LOAD_FAST_BORROW, ( -- value1, value2)) {
290295
uint32_t oparg1 = oparg >> 4;
291296
uint32_t oparg2 = oparg & 15;
297+
#ifdef Py_GIL_DISABLED
292298
value1 = PyStackRef_AsDeferred(GETLOCAL(oparg1));
293299
value2 = PyStackRef_AsDeferred(GETLOCAL(oparg2));
300+
#else
301+
value1 = PyStackRef_DUP(GETLOCAL(oparg1));
302+
value2 = PyStackRef_DUP(GETLOCAL(oparg2));
303+
#endif
294304
}
295305

296306
family(LOAD_CONST, 0) = {

Python/executor_cases.c.h

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

Python/generated_cases.c.h

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

0 commit comments

Comments
 (0)