Skip to content

Commit fba9d2d

Browse files
fix a bug with specializzation
1 parent e63de39 commit fba9d2d

File tree

12 files changed

+581
-314
lines changed

12 files changed

+581
-314
lines changed

Include/internal/pycore_opcode_metadata.h

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

Include/internal/pycore_optimizer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,12 @@ extern void _Py_ClearExecutorDeletionList(PyInterpreterState *interp);
359359
int
360360
_PyJIT_translate_single_bytecode_to_trace(
361361
PyThreadState *tstate,
362+
_PyInterpreterFrame *frame,
362363
_Py_CODEUNIT *this_instr,
363364
_Py_CODEUNIT *next_instr,
364365
PyCodeObject *code,
365366
PyFunctionObject *func,
367+
int opcode,
366368
int oparg);
367369

368370
void

Include/internal/pycore_uop_metadata.h

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3050,18 +3050,20 @@ dummy_func(
30503050
#endif /* _Py_TIER2 */
30513051
}
30523052

3053-
op(_POP_JUMP_IF_FALSE, (cond -- )) {
3053+
replaced op(_POP_JUMP_IF_FALSE, (cond -- )) {
30543054
assert(PyStackRef_BoolCheck(cond));
30553055
int flag = PyStackRef_IsFalse(cond);
30563056
DEAD(cond);
3057-
JUMPBY(flag ? oparg : 0);
3057+
RECORD_BRANCH_TAKEN(this_instr[1].cache, flag);
3058+
JUMPBY(flag ? oparg : next_instr->op.code == NOT_TAKEN);
30583059
}
30593060

3060-
op(_POP_JUMP_IF_TRUE, (cond -- )) {
3061+
replaced op(_POP_JUMP_IF_TRUE, (cond -- )) {
30613062
assert(PyStackRef_BoolCheck(cond));
30623063
int flag = PyStackRef_IsTrue(cond);
30633064
DEAD(cond);
3064-
JUMPBY(flag ? oparg : 0);
3065+
RECORD_BRANCH_TAKEN(this_instr[1].cache, flag);
3066+
JUMPBY(flag ? oparg : next_instr->op.code == NOT_TAKEN);
30653067
}
30663068

30673069
op(_IS_NONE, (value -- b)) {

Python/ceval.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,12 +975,12 @@ _PyObjectArray_Free(PyObject **array, PyObject **scratch)
975975

976976
// 1 for trace full, 0 for successful write.
977977
static int
978-
add_to_code_trace(PyThreadState *tstate, _PyInterpreterFrame *frame, PyCodeObject *old_code, _Py_CODEUNIT *this_instr, _Py_CODEUNIT *next_instr, int oparg)
978+
add_to_code_trace(PyThreadState *tstate, _PyInterpreterFrame *frame, PyCodeObject *old_code, _Py_CODEUNIT *this_instr, _Py_CODEUNIT *next_instr, int opcode, int oparg)
979979
{
980980
assert(frame != NULL);
981981
assert(tstate->interp->jit_tracer_code_curr_size < UOP_MAX_TRACE_LENGTH);
982982
PyFunctionObject *func = (PyFunctionObject *)PyStackRef_AsPyObjectBorrow(frame->f_funcobj);
983-
return !_PyJIT_translate_single_bytecode_to_trace(tstate, this_instr, next_instr, old_code, func, oparg);
983+
return !_PyJIT_translate_single_bytecode_to_trace(tstate, frame, this_instr, next_instr, old_code, func, opcode, oparg);
984984
}
985985

986986
/* _PyEval_EvalFrameDefault is too large to optimize for speed with PGO on MSVC.

Python/ceval_macros.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
DISPATCH();
145145
# define RECORD_TRACE() do { \
146146
frame->instr_ptr = next_instr; \
147-
if (add_to_code_trace(tstate, frame, old_code, this_instr, next_instr, oparg)) { \
147+
if (add_to_code_trace(tstate, frame, old_code, this_instr, next_instr, opcode, oparg)) { \
148148
BAIL_TRACING(); \
149149
} \
150150
} while (0);
@@ -407,6 +407,7 @@ do { \
407407
} \
408408
if (keep_tracing_bit) { \
409409
ENTER_TRACING(); \
410+
_PyJIT_InitializeTracing(tstate, frame, next_instr, STACK_LEVEL(), 0); \
410411
} \
411412
else { \
412413
LEAVE_TRACING(); \

Python/executor_cases.c.h

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

0 commit comments

Comments
 (0)