Skip to content

Commit 6ae3e03

Browse files
fix instrumented instructions partially
1 parent ac80cdd commit 6ae3e03

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

Python/generated_tail_call_handlers.c.h

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4269,7 +4269,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_END_SEND(TAIL_CALL_PARAMS){
42694269
}
42704270

42714271
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_ENTER_EXECUTOR(TAIL_CALL_PARAMS){
4272-
int opcode = next_instr->op.code;
4272+
int opcode = ENTER_EXECUTOR;
42734273
(void)(opcode);
42744274
{
42754275
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -4918,7 +4918,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_IMPORT_NAME(TAIL_CALL_PARAMS){
49184918
}
49194919

49204920
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_CALL(TAIL_CALL_PARAMS){
4921-
int opcode = next_instr->op.code;
4921+
int opcode = INSTRUMENTED_CALL;
49224922
(void)(opcode);
49234923
{
49244924
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5088,7 +5088,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_CALL(TAIL_CALL_PARA
50885088
}
50895089

50905090
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_CALL_FUNCTION_EX(TAIL_CALL_PARAMS){
5091-
int opcode = next_instr->op.code;
5091+
int opcode = INSTRUMENTED_CALL_FUNCTION_EX;
50925092
(void)(opcode);
50935093
{
50945094
frame->instr_ptr = next_instr;
@@ -5099,7 +5099,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_CALL_FUNCTION_EX(TA
50995099
}
51005100

51015101
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_CALL_KW(TAIL_CALL_PARAMS){
5102-
int opcode = next_instr->op.code;
5102+
int opcode = INSTRUMENTED_CALL_KW;
51035103
(void)(opcode);
51045104
{
51055105
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5127,7 +5127,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_CALL_KW(TAIL_CALL_P
51275127
}
51285128

51295129
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_END_FOR(TAIL_CALL_PARAMS){
5130-
int opcode = next_instr->op.code;
5130+
int opcode = INSTRUMENTED_END_FOR;
51315131
(void)(opcode);
51325132
{
51335133
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5156,7 +5156,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_END_FOR(TAIL_CALL_P
51565156
}
51575157

51585158
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_END_SEND(TAIL_CALL_PARAMS){
5159-
int opcode = next_instr->op.code;
5159+
int opcode = INSTRUMENTED_END_SEND;
51605160
(void)(opcode);
51615161
{
51625162
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5187,7 +5187,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_END_SEND(TAIL_CALL_
51875187
}
51885188

51895189
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_FOR_ITER(TAIL_CALL_PARAMS){
5190-
int opcode = next_instr->op.code;
5190+
int opcode = INSTRUMENTED_FOR_ITER;
51915191
(void)(opcode);
51925192
{
51935193
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5230,7 +5230,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_FOR_ITER(TAIL_CALL_
52305230
}
52315231

52325232
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_INSTRUCTION(TAIL_CALL_PARAMS){
5233-
int opcode = next_instr->op.code;
5233+
int opcode = INSTRUMENTED_INSTRUCTION;
52345234
(void)(opcode);
52355235
{
52365236
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5253,7 +5253,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_INSTRUCTION(TAIL_CA
52535253
}
52545254

52555255
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_JUMP_BACKWARD(TAIL_CALL_PARAMS){
5256-
int opcode = next_instr->op.code;
5256+
int opcode = INSTRUMENTED_JUMP_BACKWARD;
52575257
(void)(opcode);
52585258
{
52595259
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5281,7 +5281,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_JUMP_BACKWARD(TAIL_
52815281
}
52825282

52835283
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_JUMP_FORWARD(TAIL_CALL_PARAMS){
5284-
int opcode = next_instr->op.code;
5284+
int opcode = INSTRUMENTED_JUMP_FORWARD;
52855285
(void)(opcode);
52865286
{
52875287
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5294,7 +5294,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_JUMP_FORWARD(TAIL_C
52945294
}
52955295

52965296
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_LINE(TAIL_CALL_PARAMS){
5297-
int opcode = next_instr->op.code;
5297+
int opcode = INSTRUMENTED_LINE;
52985298
(void)(opcode);
52995299
{
53005300
_Py_CODEUNIT* const prev_instr = frame->instr_ptr;
@@ -5335,7 +5335,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_LINE(TAIL_CALL_PARA
53355335
}
53365336

53375337
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_LOAD_SUPER_ATTR(TAIL_CALL_PARAMS){
5338-
int opcode = next_instr->op.code;
5338+
int opcode = INSTRUMENTED_LOAD_SUPER_ATTR;
53395339
(void)(opcode);
53405340
{
53415341
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5351,7 +5351,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_LOAD_SUPER_ATTR(TAI
53515351
}
53525352

53535353
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_NOT_TAKEN(TAIL_CALL_PARAMS){
5354-
int opcode = next_instr->op.code;
5354+
int opcode = INSTRUMENTED_NOT_TAKEN;
53555355
(void)(opcode);
53565356
{
53575357
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5364,7 +5364,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_NOT_TAKEN(TAIL_CALL
53645364
}
53655365

53665366
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_POP_JUMP_IF_FALSE(TAIL_CALL_PARAMS){
5367-
int opcode = next_instr->op.code;
5367+
int opcode = INSTRUMENTED_POP_JUMP_IF_FALSE;
53685368
(void)(opcode);
53695369
{
53705370
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5384,7 +5384,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_POP_JUMP_IF_FALSE(T
53845384
}
53855385

53865386
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_POP_JUMP_IF_NONE(TAIL_CALL_PARAMS){
5387-
int opcode = next_instr->op.code;
5387+
int opcode = INSTRUMENTED_POP_JUMP_IF_NONE;
53885388
(void)(opcode);
53895389
{
53905390
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5406,7 +5406,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_POP_JUMP_IF_NONE(TA
54065406
}
54075407

54085408
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_POP_JUMP_IF_NOT_NONE(TAIL_CALL_PARAMS){
5409-
int opcode = next_instr->op.code;
5409+
int opcode = INSTRUMENTED_POP_JUMP_IF_NOT_NONE;
54105410
(void)(opcode);
54115411
{
54125412
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5426,7 +5426,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_POP_JUMP_IF_NOT_NON
54265426
}
54275427

54285428
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_POP_JUMP_IF_TRUE(TAIL_CALL_PARAMS){
5429-
int opcode = next_instr->op.code;
5429+
int opcode = INSTRUMENTED_POP_JUMP_IF_TRUE;
54305430
(void)(opcode);
54315431
{
54325432
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5446,7 +5446,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_POP_JUMP_IF_TRUE(TA
54465446
}
54475447

54485448
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_RESUME(TAIL_CALL_PARAMS){
5449-
int opcode = next_instr->op.code;
5449+
int opcode = INSTRUMENTED_RESUME;
54505450
(void)(opcode);
54515451
{
54525452
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5522,7 +5522,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_RESUME(TAIL_CALL_PA
55225522
}
55235523

55245524
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_RETURN_VALUE(TAIL_CALL_PARAMS){
5525-
int opcode = next_instr->op.code;
5525+
int opcode = INSTRUMENTED_RETURN_VALUE;
55265526
(void)(opcode);
55275527
{
55285528
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -5571,7 +5571,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_RETURN_VALUE(TAIL_C
55715571
}
55725572

55735573
Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_INSTRUMENTED_YIELD_VALUE(TAIL_CALL_PARAMS){
5574-
int opcode = next_instr->op.code;
5574+
int opcode = INSTRUMENTED_YIELD_VALUE;
55755575
(void)(opcode);
55765576
{
55775577
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
@@ -7795,7 +7795,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_RESUME(TAIL_CALL_PARAMS){
77957795
next_instr += 1;
77967796
INSTRUCTION_STATS(RESUME);
77977797
PREDICTED(RESUME);
7798-
_Py_CODEUNIT* const this_instr = next_instr - 1;
7798+
_Py_CODEUNIT* this_instr = next_instr - 1;
77997799
(void)this_instr;
78007800
// _LOAD_BYTECODE
78017801
{
@@ -7832,6 +7832,7 @@ Py_PRESERVE_NONE_CC static PyObject *_TAIL_CALL_RESUME(TAIL_CALL_PARAMS){
78327832
CEVAL_GOTO(error);
78337833
}
78347834
next_instr = this_instr;
7835+
78357836
DISPATCH();
78367837
}
78377838
}

Tools/cases_generator/tier1_tail_call_generator.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ def generate_tier1(
9393
out.emit("\n")
9494
out.emit(function_proto(name))
9595
out.emit("{\n")
96-
out.emit("int opcode = next_instr->op.code;\n")
96+
if analysis.opmap[name] >= analysis.min_instrumented:
97+
out.emit(f"int opcode = {name};\n")
98+
else:
99+
out.emit("int opcode = next_instr->op.code;\n")
97100
# Some instructions don't use opcode.
98101
out.emit(f"(void)(opcode);\n")
99102
out.emit("{\n")

0 commit comments

Comments
 (0)