Skip to content

Commit 09be7db

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
Onboard 3.15 interpreter
Summary: Copies the 3.14 bytecodes into 3.15. The only changes here are that the `_PUSH_FRAME` opcode is changed to use `PyStackRef_Unwrap`. The opcode targets get re-generated and the few things the remaining Cinder differences are brought in too. Updates ceval_macros.h with our call tracing stuff. Reviewed By: jbower-fb Differential Revision: D85901138 fbshipit-source-id: 77e3cdc815ba32297d28761b8cf69b1b22f5d6d3
1 parent d4dc4a4 commit 09be7db

File tree

8 files changed

+3899
-391
lines changed

8 files changed

+3899
-391
lines changed

cinderx/Interpreter/3.15/Includes/ceval_macros.h

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,12 @@ do { \
162162
DISPATCH_GOTO(); \
163163
}
164164

165+
#define IS_PEP523_HOOKED(tstate) \
166+
(tstate->interp->eval_frame != NULL && \
167+
tstate->interp->eval_frame != Ci_EvalFrame)
168+
165169
#define DISPATCH_INLINED(NEW_FRAME) \
166170
do { \
167-
assert(tstate->interp->eval_frame == NULL); \
168171
_PyFrame_SetStackPointer(frame, stack_pointer); \
169172
assert((NEW_FRAME)->previous == frame); \
170173
frame = tstate->current_frame = (NEW_FRAME); \
@@ -416,3 +419,33 @@ check_periodics(PyThreadState *tstate) {
416419
return 0;
417420
}
418421

422+
// CO_NO_MONITORING_EVENTS indicates the code object is read-only and therefore
423+
// cannot have code-extra data added.
424+
#define CI_SET_ADAPTIVE_INTERPRETER_ENABLED_STATE \
425+
do { \
426+
PyObject* executable = PyStackRef_AsPyObjectBorrow(frame->f_executable); \
427+
if (PyCode_Check(executable)) { \
428+
PyCodeObject* code = (PyCodeObject*)executable; \
429+
if (!(code->co_flags & CO_NO_MONITORING_EVENTS)) { \
430+
CodeExtra* extra = codeExtra(code); \
431+
adaptive_enabled = extra != NULL && is_adaptive_enabled(extra); \
432+
} \
433+
} \
434+
} while (0);
435+
436+
#define CI_UPDATE_CALL_COUNT \
437+
do { \
438+
PyObject* executable = PyStackRef_AsPyObjectBorrow(frame->f_executable); \
439+
if (PyCode_Check(executable)) { \
440+
PyCodeObject* code = (PyCodeObject*)executable; \
441+
if (!(code->co_flags & CO_NO_MONITORING_EVENTS)) { \
442+
CodeExtra* extra = codeExtra(code); \
443+
if (extra == NULL) { \
444+
adaptive_enabled = false; \
445+
} else { \
446+
extra->calls += 1; \
447+
adaptive_enabled = is_adaptive_enabled(extra); \
448+
} \
449+
} \
450+
} \
451+
} while (0);

cinderx/Interpreter/3.15/Includes/generated_cases.c.h

Lines changed: 1998 additions & 380 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)