Skip to content

Commit

Permalink
add ways to test this
Browse files Browse the repository at this point in the history
  • Loading branch information
Fidget-Spinner committed Mar 27, 2024
1 parent adfbd43 commit 868b78e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
7 changes: 5 additions & 2 deletions Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,17 @@ typedef union {
} _Py_TaggedObject;

#define Py_OBJECT_TAG (0b0)
#define Py_OBJECT_TEST_TAG (0b1)

#ifdef Py_GIL_DISABLED
#define Py_CLEAR_TAG(tagged) ((PyObject *)((tagged).bits & ~(Py_OBJECT_TAG)))
#else
#define Py_CLEAR_TAG(tagged) ((PyObject *)(uintptr_t)((tagged).bits))
#define Py_CLEAR_TAG(tagged) ((PyObject *)(uintptr_t)((tagged).bits & (~Py_OBJECT_TEST_TAG)))
#endif

#define Py_OBJ_PACK(obj) ((_Py_TaggedObject){.bits = (uintptr_t)(obj)})
#define Py_OBJ_PACK(obj) ((_Py_TaggedObject){.bits = ((uintptr_t)(obj) | Py_OBJECT_TEST_TAG)})

#define MAX_UNTAG_SCRATCH 10

static inline void
_Py_untag_stack(PyObject **dst, const _Py_TaggedObject *src, size_t length) {
Expand Down
8 changes: 4 additions & 4 deletions Objects/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ PyObject *
PyObject_Vectorcall_Tagged(PyObject *callable,
const _Py_TaggedObject *tagged, size_t nargsf, PyObject *kwnames)
{
#ifdef Py_GIL_DISABLED
#if defined(Py_GIL_DISABLED) || defined(Py_OBJECT_TEST_TAG)
size_t nargs = nargsf & ~PY_VECTORCALL_ARGUMENTS_OFFSET;
if (kwnames != NULL && PyTuple_CheckExact(kwnames)) {
nargs += PyTuple_GET_SIZE(kwnames);
Expand Down Expand Up @@ -1108,7 +1108,7 @@ PyObject *
PyObject_TypeVectorcall_Tagged(PyTypeObject *callable,
const _Py_TaggedObject *tagged, size_t nargsf, PyObject *kwnames)
{
#ifdef Py_GIL_DISABLED
#if defined(Py_GIL_DISABLED) || defined(Py_OBJECT_TEST_TAG)
size_t nargs = nargsf & ~PY_VECTORCALL_ARGUMENTS_OFFSET;
PyObject *args[MAX_UNTAG_SCRATCH];
if (nargs >= MAX_UNTAG_SCRATCH) {
Expand Down Expand Up @@ -1145,7 +1145,7 @@ PyObject_PyCFunctionFastCall_Tagged(PyCFunctionFast cfunc,
PyObject *self,
const _Py_TaggedObject *tagged, Py_ssize_t nargsf)
{
#ifdef Py_GIL_DISABLED
#if defined(Py_GIL_DISABLED) || defined(Py_OBJECT_TEST_TAG)
size_t nargs = nargsf & ~PY_VECTORCALL_ARGUMENTS_OFFSET;
PyObject *args[MAX_UNTAG_SCRATCH];
if (nargs >= MAX_UNTAG_SCRATCH) {
Expand Down Expand Up @@ -1183,7 +1183,7 @@ PyObject_PyCFunctionFastWithKeywordsCall_Tagged(PyCFunctionFastWithKeywords cfun
const _Py_TaggedObject *tagged, Py_ssize_t nargsf,
PyObject *kwds)
{
#ifdef Py_GIL_DISABLED
#if defined(Py_GIL_DISABLED) || defined(Py_OBJECT_TEST_TAG)
size_t nargs = nargsf & ~PY_VECTORCALL_ARGUMENTS_OFFSET;
PyObject *args[MAX_UNTAG_SCRATCH];
if (nargs >= MAX_UNTAG_SCRATCH) {
Expand Down
2 changes: 1 addition & 1 deletion Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ dummy_func(
inst(BUILD_CONST_KEY_MAP, (values[oparg], keys -- map)) {
assert(PyTuple_CheckExact(keys));
assert(PyTuple_GET_SIZE(keys) == (Py_ssize_t)oparg);
map = _PyDict_FromItems(
map = _PyDict_FromTaggedItems(
&PyTuple_GET_ITEM(keys, 0), 1,
(PyObject **)(values), 1, oparg);
DECREF_INPUTS();
Expand Down
6 changes: 3 additions & 3 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 868b78e

Please sign in to comment.