Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
7ca9b11
Tag objects in ceval, type, gen, frame
Fidget-Spinner Mar 23, 2024
09dbeca
partially convert cases
Fidget-Spinner Mar 23, 2024
84142a5
fix the rest
Fidget-Spinner Mar 23, 2024
25bf135
fixups
Fidget-Spinner Mar 23, 2024
d484628
fix all remaining warnings
Fidget-Spinner Mar 26, 2024
744357e
fix tests
Fidget-Spinner Mar 26, 2024
4cc9fb8
fix frames
Fidget-Spinner Mar 26, 2024
8423e75
Merge remote-tracking branch 'upstream/main' into tagged_evaluation_s…
Fidget-Spinner Mar 26, 2024
6b9ad92
📜🤖 Added by blurb_it.
blurb-it[bot] Mar 26, 2024
0bb6def
fix mypy errors
Fidget-Spinner Mar 26, 2024
8fe65c1
Merge branch 'tagged_evaluation_stack' of github.com:Fidget-Spinner/c…
Fidget-Spinner Mar 26, 2024
8412d46
fix mypy for real this time
Fidget-Spinner Mar 26, 2024
973c41c
fix windows builds
Fidget-Spinner Mar 26, 2024
4428279
fix JIT builds
Fidget-Spinner Mar 26, 2024
a4917ae
untag into temp stack for vectorcall
Fidget-Spinner Mar 27, 2024
3f7f25a
address review
Fidget-Spinner Mar 27, 2024
adfbd43
remove .obj field
Fidget-Spinner Mar 27, 2024
868b78e
add ways to test this
Fidget-Spinner Mar 27, 2024
6024a4b
minor fixups
Fidget-Spinner Mar 27, 2024
b1a614b
fix all remaining uses of PyObject **
Fidget-Spinner Mar 29, 2024
e4fa6da
minor fix
Fidget-Spinner Mar 29, 2024
7bead7f
fixed gdb
Fidget-Spinner Mar 29, 2024
eb9e9a5
move tags to internal header
Fidget-Spinner Mar 29, 2024
59b237a
replace incref decrefs with tagged versions
Fidget-Spinner Mar 29, 2024
b566e39
no-op tags on default build
Fidget-Spinner Mar 29, 2024
a036f57
fix operator associativity
Fidget-Spinner Mar 29, 2024
02408cc
Merge remote-tracking branch 'upstream/main' into tagged_evaluation_s…
Fidget-Spinner Mar 29, 2024
6b1bcf3
rename to tag/untag
Fidget-Spinner Mar 29, 2024
340f5e1
rename as requested
Fidget-Spinner Mar 29, 2024
7471fe3
default to tagged pointers in cases generator (part 1)
Fidget-Spinner Mar 29, 2024
8be49a5
(broken) convert default to tagged ptr
Fidget-Spinner Mar 29, 2024
5e2018c
swap order of tags and refcounts
Fidget-Spinner Mar 29, 2024
adff67f
Merge remote-tracking branch 'upstream/main' into tagged_evaluation_s…
Fidget-Spinner Apr 1, 2024
c09ddee
minor fixes (still broken)
Fidget-Spinner Apr 1, 2024
515536e
bunch of fixes
Fidget-Spinner Apr 1, 2024
7d7ef29
fix everything
Fidget-Spinner Apr 1, 2024
4be812f
fix some tests
Fidget-Spinner Apr 1, 2024
2f972c5
Merge remote-tracking branch 'upstream/main' into tagged_evaluation_s…
Fidget-Spinner Apr 7, 2024
72ff61b
fix up warnings
Fidget-Spinner Apr 7, 2024
2e9b411
Rename _PyTaggedPtr -> _PyStackRef
Fidget-Spinner Apr 7, 2024
b5e4c83
make ownership clear in tagging and untagging
Fidget-Spinner Apr 7, 2024
175700c
further cleanup
Fidget-Spinner Apr 7, 2024
b75c171
rename tagged -> stackref
Fidget-Spinner Apr 7, 2024
ed3a3e6
Introduced owned references
Fidget-Spinner Apr 7, 2024
6e7a917
fix syntaxerror on nogil
Fidget-Spinner Apr 7, 2024
4675ce8
Fix mypy errors
Fidget-Spinner Apr 7, 2024
629a303
fix slices
Fidget-Spinner Apr 10, 2024
4170db1
Merge remote-tracking branch 'upstream/main' into tagged_evaluation_s…
Fidget-Spinner Apr 10, 2024
038cb8a
Merge Sam's deferred refcounting in
Fidget-Spinner Apr 10, 2024
65da5a0
Fix STORE_SUBSCR, and friends
Fidget-Spinner Apr 10, 2024
6a9e1bc
traverse the stack in GC
Fidget-Spinner Apr 11, 2024
bc2a6ec
fix bugs in frame pushing and popping
Fidget-Spinner Apr 12, 2024
3bb3de2
fix for shim frames
Fidget-Spinner Apr 12, 2024
8afd8b6
stackref -> tagged
Fidget-Spinner Apr 12, 2024
87fda3e
Merge remote-tracking branch 'upstream/main' into tagged_evaluation_s…
Fidget-Spinner Apr 12, 2024
3269f20
Fix _PyFrame_Copy
Fidget-Spinner Apr 12, 2024
693b64b
fix memleak and address sam's comment
Fidget-Spinner Apr 12, 2024
03af3a4
all tests pass except references
Fidget-Spinner Apr 13, 2024
aef8e3c
Fix some refleaks
Fidget-Spinner Apr 13, 2024
87112bb
fix another references
Fidget-Spinner Apr 13, 2024
a34cec8
clean up a little
Fidget-Spinner Apr 13, 2024
5b4ddb6
undo gc changes
Fidget-Spinner Apr 13, 2024
019bc3d
rename stack to stackref
Fidget-Spinner Apr 16, 2024
b38e507
defer stack for bound methods
Fidget-Spinner Apr 16, 2024
933b5b4
fix a bunch of ownership, and deferred methods
Fidget-Spinner Apr 24, 2024
11af18d
Merge remote-tracking branch 'upstream/main' into tagged_evaluation_s…
Fidget-Spinner Apr 24, 2024
1bbf021
fix upstream merge conflicts
Fidget-Spinner Apr 24, 2024
bd6889b
Merge remote-tracking branch 'upstream/main' into tagged_evaluation_s…
Fidget-Spinner Apr 25, 2024
bafd342
fix merge conflicts
Fidget-Spinner Apr 25, 2024
752a49b
lint
Fidget-Spinner Apr 25, 2024
c6be5aa
use old code, fix decref on traceback
Fidget-Spinner Apr 26, 2024
d59145b
make bound methods work for keyword calls as well
Fidget-Spinner Apr 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixups
  • Loading branch information
Fidget-Spinner committed Mar 23, 2024
commit 25bf135097fea350fe29f630fc1e3634aa1245b1
2 changes: 1 addition & 1 deletion Include/internal/pycore_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ extern void _Py_Specialize_StoreSubscr(PyObject *container, PyObject *sub,
extern void _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr,
int nargs);
extern void _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,
int oparg, PyObject **locals);
int oparg, _Py_TaggedObject *locals);
extern void _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs,
_Py_CODEUNIT *instr, int oparg);
extern void _Py_Specialize_UnpackSequence(PyObject *seq, _Py_CODEUNIT *instr,
Expand Down
16 changes: 1 addition & 15 deletions Include/internal/pycore_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,6 @@ enum _frameowner {
FRAME_OWNED_BY_CSTACK = 3,
};

typedef struct {
PyObject *obj;
uintptr_t bits;
} _Py_TaggedObject;

#define Py_OBJECT_TAG (0b0)

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

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

typedef struct _PyInterpreterFrame {
PyObject *f_executable; /* Strong reference (code object or None) */
Expand All @@ -94,7 +80,7 @@ static inline PyCodeObject *_PyFrame_GetCode(_PyInterpreterFrame *f) {
}

static inline _Py_TaggedObject *_PyFrame_Stackbase(_PyInterpreterFrame *f) {
return (_Py_TaggedObject *)(f->localsplus + _PyFrame_GetCode(f)->co_nlocalsplus);
return (f->localsplus + _PyFrame_GetCode(f)->co_nlocalsplus);
}

static inline _Py_TaggedObject _PyFrame_StackPeek(_PyInterpreterFrame *f) {
Expand Down
1 change: 1 addition & 0 deletions Include/internal/pycore_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ extern "C" {
#endif

#include "pycore_freelist.h" // _PyFreeListState
#include "pycore_frame.h" // _Py_TaggedObject

PyAPI_FUNC(PyObject*) _PyList_Extend(PyListObject *, PyObject *);
extern void _PyList_DebugMallocStats(FILE *out);
Expand Down
15 changes: 15 additions & 0 deletions Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,21 @@ struct _object {
/* Cast argument to PyObject* type. */
#define _PyObject_CAST(op) _Py_CAST(PyObject*, (op))

typedef union {
Comment thread
Fidget-Spinner marked this conversation as resolved.
Outdated
PyObject *obj;
uintptr_t bits;
} _Py_TaggedObject;

#define Py_OBJECT_TAG (0b0)

#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))
#endif

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

typedef struct {
PyObject ob_base;
Py_ssize_t ob_size; /* Number of items in variable part */
Expand Down
4 changes: 3 additions & 1 deletion Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,9 @@ dummy_func(
*/
assert(Py_REFCNT(left) >= 2);
_Py_DECREF_NO_DEALLOC(left);
PyUnicode_Append(target_local, right);
PyObject *temp = Py_CLEAR_TAG(*target_local);
PyUnicode_Append(&temp, right);
*target_local = Py_OBJ_PACK(temp);
_Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc);
ERROR_IF(Py_CLEAR_TAG(*target_local) == NULL, error);
// The STORE_FAST is already done.
Expand Down
8 changes: 4 additions & 4 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ static int check_args_iterable(PyThreadState *, PyObject *func, PyObject *vararg
static int get_exception_handler(PyCodeObject *, int, int*, int*, int*);
static _PyInterpreterFrame *
_PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func,
PyObject *locals, PyObject* const* args,
PyObject *locals, _Py_TaggedObject const* args,
size_t argcount, PyObject *kwnames);
static _PyInterpreterFrame *
_PyEvalFramePushAndInit_Ex(PyThreadState *tstate, PyFunctionObject *func,
Expand Down Expand Up @@ -1724,7 +1724,7 @@ _PyEval_FrameClearAndPop(PyThreadState *tstate, _PyInterpreterFrame * frame)
/* Consumes references to func, locals and all the args */
static _PyInterpreterFrame *
_PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func,
PyObject *locals, PyObject* const* args,
PyObject *locals, _Py_TaggedObject const* args,
size_t argcount, PyObject *kwnames)
{
PyCodeObject * code = (PyCodeObject *)func->func_code;
Expand All @@ -1743,12 +1743,12 @@ _PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func,
fail:
/* Consume the references */
for (size_t i = 0; i < argcount; i++) {
Py_DECREF(args[i]);
Py_DECREF(Py_CLEAR_TAG(args[i]));
}
if (kwnames) {
Py_ssize_t kwcount = PyTuple_GET_SIZE(kwnames);
for (Py_ssize_t i = 0; i < kwcount; i++) {
Py_DECREF(args[i+argcount]);
Py_DECREF(Py_CLEAR_TAG(args[i+argcount]));
}
}
PyErr_NoMemory();
Expand Down
4 changes: 3 additions & 1 deletion Python/generated_cases.c.h

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

4 changes: 2 additions & 2 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,7 @@ binary_op_fail_kind(int oparg, PyObject *lhs, PyObject *rhs)

void
_Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,
int oparg, PyObject **locals)
int oparg, _Py_TaggedObject *locals)
{
assert(ENABLE_SPECIALIZATION);
assert(_PyOpcode_Caches[BINARY_OP] == INLINE_CACHE_ENTRIES_BINARY_OP);
Expand All @@ -2151,7 +2151,7 @@ _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,
if (PyUnicode_CheckExact(lhs)) {
_Py_CODEUNIT next = instr[INLINE_CACHE_ENTRIES_BINARY_OP + 1];
bool to_store = (next.op.code == STORE_FAST);
if (to_store && locals[next.op.arg] == lhs) {
if (to_store && Py_CLEAR_TAG(locals[next.op.arg]) == lhs) {
instr->op.code = BINARY_OP_INPLACE_ADD_UNICODE;
goto success;
}
Expand Down