Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Include/internal/pycore_tstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ typedef struct _PyThreadStateImpl {
#if defined(Py_REF_DEBUG) && defined(Py_GIL_DISABLED)
Py_ssize_t reftotal; // this thread's total refcount operations
#endif
#if _Py_TIER2
#if defined(_Py_TIER2)
struct _PyJitTracerState *jit_tracer_state;
#endif

Expand Down
2 changes: 1 addition & 1 deletion Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ framelocalsproxy_setitem(PyObject *self, PyObject *key, PyObject *value)
return -1;
}

#if _Py_TIER2
#ifdef _Py_TIER2
_Py_Executors_InvalidateDependency(_PyInterpreterState_GET(), co, 1);
#endif

Expand Down
2 changes: 1 addition & 1 deletion Objects/funcobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ handle_func_event(PyFunction_WatchEvent event, PyFunctionObject *func,
case PyFunction_EVENT_MODIFY_DEFAULTS:
case PyFunction_EVENT_MODIFY_KWDEFAULTS:
case PyFunction_EVENT_MODIFY_QUALNAME:
#if _Py_TIER2
#ifdef _Py_TIER2
// Note: we only invalidate JIT code if a function version changes.
// Not when the function is deallocated.
// Function deallocation occurs frequently (think: lambdas),
Expand Down
18 changes: 9 additions & 9 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ dummy_func(
tstate->current_frame = frame->previous;
assert(!_PyErr_Occurred(tstate));
PyObject *result = PyStackRef_AsPyObjectSteal(retval);
#if !_Py_TAIL_CALL_INTERP
#ifndef _Py_TAIL_CALL_INTERP
assert(frame == &entry.frame);
#endif
#ifdef _Py_TIER2
Expand Down Expand Up @@ -1962,7 +1962,7 @@ dummy_func(

tier1 inst(CLEANUP_THROW, (sub_iter, null_in, last_sent_val, exc_value_st -- none, null_out, value)) {
PyObject *exc_value = PyStackRef_AsPyObjectBorrow(exc_value_st);
#if !_Py_TAIL_CALL_INTERP
#ifndef _Py_TAIL_CALL_INTERP
assert(throwflag);
#endif
assert(exc_value && PyExceptionInstance_Check(exc_value));
Expand Down Expand Up @@ -6102,10 +6102,10 @@ dummy_func(
}

op(_SAVE_RETURN_OFFSET, (--)) {
#if TIER_ONE
#ifdef TIER_ONE
frame->return_offset = (uint16_t)(next_instr - this_instr);
#endif
#if TIER_TWO
#ifdef TIER_TWO
frame->return_offset = oparg;
#endif
}
Expand Down Expand Up @@ -6501,7 +6501,7 @@ dummy_func(
}
#endif
RELOAD_STACK();
#if _Py_TAIL_CALL_INTERP
#ifdef _Py_TAIL_CALL_INTERP
int opcode;
#endif
DISPATCH();
Expand All @@ -6525,7 +6525,7 @@ dummy_func(
if (frame->owner == FRAME_OWNED_BY_INTERPRETER) {
/* Restore previous frame and exit */
tstate->current_frame = frame->previous;
#if !_Py_TAIL_CALL_INTERP
#ifndef _Py_TAIL_CALL_INTERP
assert(frame == &entry.frame);
#endif
#ifdef _Py_TIER2
Expand Down Expand Up @@ -6565,14 +6565,14 @@ dummy_func(
assert(!_PyErr_Occurred(tstate));
#endif
RELOAD_STACK();
#if _Py_TAIL_CALL_INTERP
#ifdef _Py_TAIL_CALL_INTERP
int opcode;
#endif
DISPATCH();
}

inst(TRACE_RECORD, (--)) {
#if _Py_TIER2
#ifdef _Py_TIER2
assert(IS_JIT_TRACING());
next_instr = this_instr;
frame->instr_ptr = prev_instr;
Expand Down Expand Up @@ -6629,7 +6629,7 @@ dummy_func(
}

label(stop_tracing) {
#if _Py_TIER2
#ifdef _Py_TIER2
assert(IS_JIT_TRACING());
int opcode = next_instr->op.code;
_PyJit_translate_single_bytecode_to_trace(tstate, frame, NULL, _EXIT_TRACE);
Expand Down
12 changes: 6 additions & 6 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ _PyObjectArray_Free(PyObject **array, PyObject **scratch)
}
}

#if _Py_TIER2
#ifdef _Py_TIER2
// 0 for success, -1 for error.
static int
stop_tracing_and_jit(PyThreadState *tstate, _PyInterpreterFrame *frame)
Expand Down Expand Up @@ -1066,7 +1066,7 @@ stop_tracing_and_jit(PyThreadState *tstate, _PyInterpreterFrame *frame)
/* This setting is reversed below following _PyEval_EvalFrameDefault */
#endif

#if _Py_TAIL_CALL_INTERP
#ifdef _Py_TAIL_CALL_INTERP
#include "opcode_targets.h"
#include "generated_cases.c.h"
#endif
Expand Down Expand Up @@ -1213,7 +1213,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
check_invalid_reentrancy();
CALL_STAT_INC(pyeval_calls);

#if USE_COMPUTED_GOTOS && !_Py_TAIL_CALL_INTERP
#if USE_COMPUTED_GOTOS && !defined(_Py_TAIL_CALL_INTERP)
/* Import the static jump table */
#include "opcode_targets.h"
void **opcode_targets = opcode_targets_table;
Expand All @@ -1222,7 +1222,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
#ifdef Py_STATS
int lastopcode = 0;
#endif
#if !_Py_TAIL_CALL_INTERP
#if !defined(_Py_TAIL_CALL_INTERP)
uint8_t opcode; /* Current opcode */
int oparg; /* Current opcode argument, if any */
assert(tstate->current_frame == NULL || tstate->current_frame->stackpointer != NULL);
Expand Down Expand Up @@ -1301,7 +1301,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
monitor_throw(tstate, frame, next_instr);
stack_pointer = _PyFrame_GetStackPointer(frame);
_PyFrame_StackPointerInvalidate(frame);
#if _Py_TAIL_CALL_INTERP
#ifdef _Py_TAIL_CALL_INTERP
# if Py_STATS
return _TAIL_CALL_error(frame, stack_pointer, tstate, next_instr, instruction_funcptr_handler_table, 0, lastopcode);
# else
Expand All @@ -1312,7 +1312,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
#endif
}

#if _Py_TAIL_CALL_INTERP
#ifdef _Py_TAIL_CALL_INTERP
# if Py_STATS
return _TAIL_CALL_start_frame(frame, NULL, tstate, NULL, instruction_funcptr_handler_table, 0, lastopcode);
# else
Expand Down
6 changes: 3 additions & 3 deletions Python/ceval_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
# define TAIL_CALL_ARGS frame, stack_pointer, tstate, next_instr, instruction_funcptr_table, oparg
#endif

#if _Py_TAIL_CALL_INTERP
#ifdef _Py_TAIL_CALL_INTERP
# if defined(__clang__) || defined(__GNUC__)
# if !_Py__has_attribute(preserve_none) || !_Py__has_attribute(musttail)
# error "This compiler does not have support for efficient tail calling."
Expand Down Expand Up @@ -144,7 +144,7 @@
# define LABEL(name) name:
#endif

#if (_Py_TAIL_CALL_INTERP || USE_COMPUTED_GOTOS) && _Py_TIER2
#if (defined(_Py_TAIL_CALL_INTERP) || USE_COMPUTED_GOTOS) && defined(_Py_TIER2)
# define IS_JIT_TRACING() (DISPATCH_TABLE_VAR == TRACING_DISPATCH_TABLE)
# define ENTER_TRACING() \
DISPATCH_TABLE_VAR = TRACING_DISPATCH_TABLE;
Expand All @@ -156,7 +156,7 @@
# define LEAVE_TRACING() tracing_mode = 0
#endif

#if _Py_TIER2
#ifdef _Py_TIER2
#define STOP_TRACING() \
do { \
if (IS_JIT_TRACING()) { \
Expand Down
2 changes: 1 addition & 1 deletion Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,7 @@ tstate_delete_common(PyThreadState *tstate, int release_gil, int is_unlinked)
assert(tstate_impl->refcounts.values == NULL);
#endif

#if _Py_TIER2
#ifdef _Py_TIER2
_PyJit_TracerFree((_PyThreadStateImpl *)tstate);
#endif

Expand Down
Loading