Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8efce0a

Browse filesBrowse files
committed
Make PyStackRef_BoxInt inline for JIT
1 parent e5f666d commit 8efce0a
Copy full SHA for 8efce0a

File tree

Expand file treeCollapse file tree

2 files changed

+14
-18
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-18
lines changed

‎Include/internal/pycore_stackref.h

Copy file name to clipboardExpand all lines: Include/internal/pycore_stackref.h
+14-2Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,6 @@ PyStackRef_TaggedIntLessThan(_PyStackRef a, _PyStackRef b)
292292

293293
#define PyStackRef_IsDeferredOrTaggedInt(ref) (((ref).bits & Py_TAG_REFCNT) != 0)
294294

295-
extern _PyStackRef PyStackRef_BoxInt(_PyStackRef i);
296-
297295
#ifdef Py_GIL_DISABLED
298296

299297
#define Py_TAG_DEFERRED Py_TAG_REFCNT
@@ -807,6 +805,20 @@ _Py_TryXGetStackRef(PyObject **src, _PyStackRef *out)
807805
} \
808806
} while (0)
809807

808+
809+
static inline _PyStackRef
810+
PyStackRef_BoxInt(_PyStackRef i)
811+
{
812+
assert(PyStackRef_IsTaggedInt(i));
813+
intptr_t val = PyStackRef_UntagInt(i);
814+
PyObject *boxed = PyLong_FromSsize_t(val);
815+
if (boxed == NULL) {
816+
return PyStackRef_NULL;
817+
}
818+
return PyStackRef_FromPyObjectSteal(boxed);
819+
}
820+
821+
810822
#ifdef __cplusplus
811823
}
812824
#endif

‎Objects/longobject.c

Copy file name to clipboardExpand all lines: Objects/longobject.c
-16Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6873,19 +6873,3 @@ PyLongWriter_Finish(PyLongWriter *writer)
68736873

68746874
return (PyObject*)obj;
68756875
}
6876-
6877-
// Tagged int support
6878-
6879-
_PyStackRef
6880-
PyStackRef_BoxInt(_PyStackRef i)
6881-
{
6882-
assert((i.bits & Py_INT_TAG) == Py_INT_TAG);
6883-
intptr_t val = (intptr_t)i.bits;
6884-
val = Py_ARITHMETIC_RIGHT_SHIFT(intptr_t, val, 2);
6885-
PyObject *boxed = PyLong_FromSsize_t(val);
6886-
if (boxed == NULL) {
6887-
return PyStackRef_NULL;
6888-
}
6889-
return PyStackRef_FromPyObjectSteal(boxed);
6890-
}
6891-

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.