Skip to content

Commit 38b45e6

Browse files
committed
Add ability for external executor
1 parent ee4e14a commit 38b45e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1048
-681
lines changed

Include/cpython/pyframe.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,26 @@ PyAPI_FUNC(PyObject*) PyFrame_GetVarString(PyFrameObject *frame, const char *nam
2222
/* The following functions are for use by debuggers and other tools
2323
* implementing custom frame evaluators with PEP 523. */
2424

25+
struct _PyInterpreterFrameCore;
2526
struct _PyInterpreterFrame;
2627

2728
/* Returns the code object of the frame (strong reference).
2829
* Does not raise an exception. */
29-
PyAPI_FUNC(PyObject *) PyUnstable_InterpreterFrame_GetCode(struct _PyInterpreterFrame *frame);
30+
PyAPI_FUNC(PyObject *) PyUnstable_InterpreterFrame_GetCode(struct _PyInterpreterFrameCore *frame);
3031

3132
/* Returns a byte offset into the last executed instruction.
3233
* Does not raise an exception. */
33-
PyAPI_FUNC(int) PyUnstable_InterpreterFrame_GetLasti(struct _PyInterpreterFrame *frame);
34+
PyAPI_FUNC(int) PyUnstable_InterpreterFrame_GetLasti(struct _PyInterpreterFrameCore *frame);
3435

3536
/* Returns the currently executing line number, or -1 if there is no line number.
3637
* Does not raise an exception. */
37-
PyAPI_FUNC(int) PyUnstable_InterpreterFrame_GetLine(struct _PyInterpreterFrame *frame);
38+
PyAPI_FUNC(int) PyUnstable_InterpreterFrame_GetLine(struct _PyInterpreterFrameCore *frame);
3839

3940
#define PyUnstable_EXECUTABLE_KIND_SKIP 0
4041
#define PyUnstable_EXECUTABLE_KIND_PY_FUNCTION 1
4142
#define PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION 3
4243
#define PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR 4
43-
#define PyUnstable_EXECUTABLE_KINDS 5
44+
#define PyUnstable_EXECUTABLE_KIND_JIT 5
45+
#define PyUnstable_EXECUTABLE_KINDS 6
4446

4547
PyAPI_DATA(const PyTypeObject *) const PyUnstable_ExecutableKinds[PyUnstable_EXECUTABLE_KINDS+1];

Include/cpython/pystate.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,16 @@ struct _ts {
133133
int what_event; /* The event currently being monitored, if any. */
134134

135135
/* Pointer to currently executing frame. */
136-
struct _PyInterpreterFrame *current_frame;
136+
struct _PyInterpreterFrameCore *current_frame;
137137

138138
/* Pointer to the base frame (bottommost sentinel frame).
139139
Used by profilers to validate complete stack unwinding.
140140
Points to the embedded base_frame in _PyThreadStateImpl.
141-
The frame is embedded there rather than here because _PyInterpreterFrame
141+
The frame is embedded there rather than here because _PyInterpreterFrameCore
142142
is defined in internal headers that cannot be exposed in the public API. */
143-
struct _PyInterpreterFrame *base_frame;
143+
struct _PyInterpreterFrameCore *base_frame;
144144

145-
struct _PyInterpreterFrame *last_profiled_frame;
145+
struct _PyInterpreterFrameCore *last_profiled_frame;
146146

147147
Py_tracefunc c_profilefunc;
148148
Py_tracefunc c_tracefunc;

Include/internal/pycore_ceval.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#include "pycore_interp.h" // PyInterpreterState.eval_frame
1515
#include "pycore_pystate.h" // _PyThreadState_GET()
1616
#include "pycore_stats.h" // EVAL_CALL_STAT_INC()
17-
#include "pycore_typedefs.h" // _PyInterpreterFrame
17+
#include "pycore_typedefs.h" // _PyInterpreterFrameCore
1818

1919

2020
/* Forward declarations */
@@ -268,7 +268,7 @@ PyAPI_FUNC(int) _Py_ReachedRecursionLimitWithMargin(
268268
static inline void _Py_LeaveRecursiveCall(void) {
269269
}
270270

271-
extern _PyInterpreterFrame* _PyEval_GetFrame(void);
271+
extern _PyInterpreterFrameCore* _PyEval_GetFrame(void);
272272

273273
extern PyObject * _PyEval_GetGlobalsFromRunningMain(PyThreadState *);
274274
extern int _PyEval_EnsureBuiltins(
@@ -310,7 +310,7 @@ PyAPI_FUNC(void) _PyEval_FormatExcCheckArg(PyThreadState *tstate, PyObject *exc,
310310
PyAPI_FUNC(void) _PyEval_FormatExcUnbound(PyThreadState *tstate, PyCodeObject *co, int oparg);
311311
PyAPI_FUNC(void) _PyEval_FormatKwargsError(PyThreadState *tstate, PyObject *func, PyObject *kwargs);
312312
PyAPI_FUNC(PyObject *) _PyEval_ImportFrom(PyThreadState *, PyObject *, PyObject *);
313-
PyAPI_FUNC(PyObject *) _PyEval_ImportName(PyThreadState *, _PyInterpreterFrame *, PyObject *, PyObject *, PyObject *);
313+
PyAPI_FUNC(PyObject *) _PyEval_ImportName(PyThreadState *, _PyInterpreterFrameCore *, PyObject *, PyObject *, PyObject *);
314314
PyAPI_FUNC(PyObject *)_PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type, Py_ssize_t nargs, PyObject *kwargs);
315315
PyAPI_FUNC(PyObject *)_PyEval_MatchKeys(PyThreadState *tstate, PyObject *map, PyObject *keys);
316316
PyAPI_FUNC(void) _PyEval_MonitorRaise(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr);

Include/internal/pycore_debug_offsets.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,11 @@ typedef struct _Py_DebugOffsets {
297297
}, \
298298
.interpreter_frame = { \
299299
.size = sizeof(_PyInterpreterFrame), \
300-
.previous = offsetof(_PyInterpreterFrame, previous), \
301-
.executable = offsetof(_PyInterpreterFrame, f_executable), \
300+
.previous = offsetof(_PyInterpreterFrameCore, previous), \
301+
.executable = offsetof(_PyInterpreterFrameCore, f_executable), \
302302
.instr_ptr = offsetof(_PyInterpreterFrame, instr_ptr), \
303303
.localsplus = offsetof(_PyInterpreterFrame, localsplus), \
304-
.owner = offsetof(_PyInterpreterFrame, owner), \
304+
.owner = offsetof(_PyInterpreterFrameCore, owner), \
305305
.stackpointer = offsetof(_PyInterpreterFrame, stackpointer), \
306306
.tlbc_index = _Py_Debug_interpreter_frame_tlbc_index, \
307307
}, \

Include/internal/pycore_genobject.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11-
#include "pycore_interpframe_structs.h" // _PyGenObject
11+
#include "pycore_interpframe.h" // _PyFrame_Core
12+
#include "pycore_interpframe_structs.h" // _PyInterpreterFrame
1213

1314
#include <stddef.h> // offsetof()
1415

1516

1617
static inline
1718
PyGenObject *_PyGen_GetGeneratorFromFrame(_PyInterpreterFrame *frame)
1819
{
19-
assert(frame->owner == FRAME_OWNED_BY_GENERATOR);
20+
assert(_PyFrame_Core(frame)->owner & FRAME_OWNED_BY_GENERATOR);
2021
size_t offset_in_gen = offsetof(PyGenObject, gi_iframe);
2122
return (PyGenObject *)(((char *)frame) - offset_in_gen);
2223
}

Include/internal/pycore_interp_structs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ struct _gc_runtime_state {
224224
int collecting;
225225
// The frame that started the current collection. It might be NULL even when
226226
// collecting (if no Python frame is running):
227-
_PyInterpreterFrame *frame;
227+
_PyInterpreterFrameCore *frame;
228228
/* list of uncollectable objects */
229229
PyObject *garbage;
230230
/* a list of callbacks to be invoked when collection is performed */
@@ -782,7 +782,7 @@ struct _Py_unique_id_pool {
782782

783783
#endif
784784

785-
typedef _Py_CODEUNIT *(*_PyJitEntryFuncPtr)(struct _PyExecutorObject *exec, _PyInterpreterFrame *frame, _PyStackRef *stack_pointer, PyThreadState *tstate);
785+
typedef _Py_CODEUNIT *(*_PyJitEntryFuncPtr)(struct _PyExecutorObject *exec, _PyInterpreterFrameCore *frame, _PyStackRef *stack_pointer, PyThreadState *tstate);
786786

787787
/* PyInterpreterState holds the global state for one of the runtime's
788788
interpreters. Typically the initial (main) interpreter is the only one.

0 commit comments

Comments
 (0)