Skip to content

Commit bb1d303

Browse files
authored
GH-118093: Make CALL_ALLOC_AND_ENTER_INIT suitable for tier 2. (GH-123140)
* Convert CALL_ALLOC_AND_ENTER_INIT to micro-ops such that tier 2 supports it * Allow inexact arguments for CALL_ALLOC_AND_ENTER_INIT.
1 parent bffed80 commit bb1d303

17 files changed

+464
-299
lines changed

Include/internal/pycore_code.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,10 @@ extern _Py_CODEUNIT _Py_GetBaseCodeUnit(PyCodeObject *code, int offset);
593593

594594
extern int _PyInstruction_GetLength(PyCodeObject *code, int offset);
595595

596+
struct _PyCode8 _PyCode_DEF(8);
597+
598+
PyAPI_DATA(const struct _PyCode8) _Py_InitCleanup;
599+
596600
#ifdef __cplusplus
597601
}
598602
#endif

Include/internal/pycore_frame.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ static inline void _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *
144144
static inline void
145145
_PyFrame_Initialize(
146146
_PyInterpreterFrame *frame, PyFunctionObject *func,
147-
PyObject *locals, PyCodeObject *code, int null_locals_from)
147+
PyObject *locals, PyCodeObject *code, int null_locals_from, _PyInterpreterFrame *previous)
148148
{
149+
frame->previous = previous;
149150
frame->f_funcobj = (PyObject *)func;
150151
frame->f_executable = Py_NewRef(code);
151152
frame->f_builtins = func->func_builtins;
@@ -298,26 +299,27 @@ PyAPI_FUNC(void) _PyThreadState_PopFrame(PyThreadState *tstate, _PyInterpreterFr
298299
* Must be guarded by _PyThreadState_HasStackSpace()
299300
* Consumes reference to func. */
300301
static inline _PyInterpreterFrame *
301-
_PyFrame_PushUnchecked(PyThreadState *tstate, PyFunctionObject *func, int null_locals_from)
302+
_PyFrame_PushUnchecked(PyThreadState *tstate, PyFunctionObject *func, int null_locals_from, _PyInterpreterFrame * previous)
302303
{
303304
CALL_STAT_INC(frames_pushed);
304305
PyCodeObject *code = (PyCodeObject *)func->func_code;
305306
_PyInterpreterFrame *new_frame = (_PyInterpreterFrame *)tstate->datastack_top;
306307
tstate->datastack_top += code->co_framesize;
307308
assert(tstate->datastack_top < tstate->datastack_limit);
308-
_PyFrame_Initialize(new_frame, func, NULL, code, null_locals_from);
309+
_PyFrame_Initialize(new_frame, func, NULL, code, null_locals_from, previous);
309310
return new_frame;
310311
}
311312

312313
/* Pushes a trampoline frame without checking for space.
313314
* Must be guarded by _PyThreadState_HasStackSpace() */
314315
static inline _PyInterpreterFrame *
315-
_PyFrame_PushTrampolineUnchecked(PyThreadState *tstate, PyCodeObject *code, int stackdepth)
316+
_PyFrame_PushTrampolineUnchecked(PyThreadState *tstate, PyCodeObject *code, int stackdepth, _PyInterpreterFrame * previous)
316317
{
317318
CALL_STAT_INC(frames_pushed);
318319
_PyInterpreterFrame *frame = (_PyInterpreterFrame *)tstate->datastack_top;
319320
tstate->datastack_top += code->co_framesize;
320321
assert(tstate->datastack_top < tstate->datastack_limit);
322+
frame->previous = previous;
321323
frame->f_funcobj = Py_None;
322324
frame->f_executable = Py_NewRef(code);
323325
#ifdef Py_DEBUG
@@ -344,7 +346,8 @@ _PyFrame_PushTrampolineUnchecked(PyThreadState *tstate, PyCodeObject *code, int
344346
PyAPI_FUNC(_PyInterpreterFrame *)
345347
_PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func,
346348
PyObject *locals, _PyStackRef const* args,
347-
size_t argcount, PyObject *kwnames);
349+
size_t argcount, PyObject *kwnames,
350+
_PyInterpreterFrame *previous);
348351

349352
#ifdef __cplusplus
350353
}

Include/internal/pycore_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ static inline int _PyType_SUPPORTS_WEAKREFS(PyTypeObject *type) {
761761
}
762762

763763
extern PyObject* _PyType_AllocNoTrack(PyTypeObject *type, Py_ssize_t nitems);
764-
extern PyObject *_PyType_NewManagedObject(PyTypeObject *type);
764+
PyAPI_FUNC(PyObject *) _PyType_NewManagedObject(PyTypeObject *type);
765765

766766
extern PyTypeObject* _PyType_CalculateMetaclass(PyTypeObject *, PyObject *);
767767
extern PyObject* _PyType_GetDocFromInternalDoc(const char *, const char *);

Include/internal/pycore_opcode_metadata.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)