Skip to content

Commit 1872715

Browse files
Cleanup
1 parent 608772f commit 1872715

File tree

13 files changed

+92
-78
lines changed

13 files changed

+92
-78
lines changed

Include/internal/pycore_opcode_metadata.h

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

Include/internal/pycore_uop_metadata.h

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

Objects/frameobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "frameobject.h" // PyFrameLocalsProxyObject
1919
#include "opcode.h" // EXTENDED_ARG
2020
#include "../Include/pytypedefs.h"
21-
#include "../Include/internal/pycore_optimizer.h"
21+
#include "pycore_optimizer.h"
2222

2323
#include "clinic/frameobject.c.h"
2424

Python/bytecodes.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,10 +1251,12 @@ dummy_func(
12511251
frame = tstate->current_frame = dying->previous;
12521252
_PyEval_FrameClearAndPop(tstate, dying);
12531253
RELOAD_STACK();
1254+
#if TIER_ONE
12541255
LOAD_IP(frame->return_offset);
1255-
#if TIER_TWO
1256-
frame->instr_ptr += frame->return_offset;
1257-
#endif
1256+
#endif
1257+
#if TIER_TWO
1258+
TIER2_STORE_IP(frame->return_offset);
1259+
#endif
12581260
res = temp;
12591261
LLTRACE_RESUME_FRAME();
12601262
}
@@ -1441,10 +1443,12 @@ dummy_func(
14411443
_PyOpcode_Deopt[frame->instr_ptr->op.code] == ENTER_EXECUTOR);
14421444
#endif
14431445
RELOAD_STACK();
1446+
#if TIER_ONE
14441447
LOAD_IP(1 + INLINE_CACHE_ENTRIES_SEND);
1445-
#if TIER_TWO
1446-
frame->instr_ptr += (1 + INLINE_CACHE_ENTRIES_SEND);
1447-
#endif
1448+
#endif
1449+
#if TIER_TWO
1450+
TIER2_STORE_IP(1 + INLINE_CACHE_ENTRIES_SEND);
1451+
#endif
14481452
value = PyStackRef_MakeHeapSafe(temp);
14491453
LLTRACE_RESUME_FRAME();
14501454
}
@@ -3084,15 +3088,13 @@ dummy_func(
30843088

30853089
macro(POP_JUMP_IF_NOT_NONE) = unused/1 + _IS_NONE + _POP_JUMP_IF_FALSE;
30863090

3087-
inst(JUMP_BACKWARD_NO_INTERRUPT, (--)) {
3091+
replaced inst(JUMP_BACKWARD_NO_INTERRUPT, (--)) {
30883092
/* This bytecode is used in the `yield from` or `await` loop.
30893093
* If there is an interrupt, we want it handled in the innermost
30903094
* generator or coroutine, so we deliberately do not check it here.
30913095
* (see bpo-30039).
30923096
*/
3093-
#if TIER_ONE
30943097
assert(oparg <= INSTR_OFFSET());
3095-
#endif
30963098
JUMPBY(-oparg);
30973099
}
30983100

@@ -3233,15 +3235,15 @@ dummy_func(
32333235
}
32343236

32353237
op(_FOR_ITER_TIER_TWO, (iter, null_or_index -- iter, null_or_index, next)) {
3236-
TIER2_JUMPBY(1 + INLINE_CACHE_ENTRIES_FOR_ITER);
3238+
TIER2_STORE_IP(1 + INLINE_CACHE_ENTRIES_FOR_ITER);
32373239
_PyStackRef item = _PyForIter_VirtualIteratorNext(tstate, frame, iter, &null_or_index);
32383240
if (!PyStackRef_IsValid(item)) {
32393241
if (PyStackRef_IsError(item)) {
32403242
ERROR_NO_POP();
32413243
}
32423244
/* iterator ended normally */
3243-
// Jump forward by oparg and skip the following END_FOR
3244-
TIER2_JUMPBY(oparg + 1);
3245+
/* This just sets the IP to what it expects */
3246+
TIER2_STORE_IP(oparg + 1);
32453247
EXIT_IF(true);
32463248
}
32473249
next = item;
@@ -4992,10 +4994,12 @@ dummy_func(
49924994
_PyInterpreterFrame *prev = frame->previous;
49934995
_PyThreadState_PopFrame(tstate, frame);
49944996
frame = tstate->current_frame = prev;
4997+
#if TIER_ONE
49954998
LOAD_IP(frame->return_offset);
4996-
#if TIER_TWO
4999+
#endif
5000+
#if TIER_TWO
49975001
frame->instr_ptr += (frame->return_offset);
4998-
#endif
5002+
#endif
49995003
RELOAD_STACK();
50005004
res = PyStackRef_FromPyObjectStealMortal((PyObject *)gen);
50015005
LLTRACE_RESUME_FRAME();

Python/ceval.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,26 +1194,26 @@ _PyTier2Interpreter(
11941194
for (;;) {
11951195
uopcode = next_uop->opcode;
11961196
#ifdef Py_DEBUG
1197-
if (frame->lltrace >= 2) {
1197+
if (frame->lltrace >= 4) {
11981198
if (next_uop->opcode != _YIELD_VALUE &&
11991199
next_uop->opcode != _FOR_ITER_GEN_FRAME &&
12001200
next_uop->opcode != _PUSH_FRAME &&
12011201
next_uop->opcode != _PY_FRAME_KW &&
12021202
next_uop->opcode != _SAVE_RETURN_OFFSET &&
12031203
next_uop->opcode != _SAVE_RETURN_OFFSET) {
1204-
// if (next_uop->opcode != _START_EXECUTOR) {
1205-
// if (next_uop->format == UOP_FORMAT_TARGET) {
1206-
// _Py_CODEUNIT *aim = _PyFrame_GetBytecode(frame) + next_uop->target;
1207-
// printf(" aim=[%s]\n", _PyOpcode_OpName[aim->op.code]);
1208-
// }
1209-
// else if (next_uop->format == UOP_FORMAT_JUMP) {
1210-
// _PyUOpInstruction *aim_uop = current_executor->trace + next_uop->jump_target;
1211-
// if (aim_uop->format == UOP_FORMAT_TARGET) {
1212-
// _Py_CODEUNIT *aim = _PyFrame_GetBytecode(frame) + aim_uop->target;
1213-
// printf(" aim=[%s]\n", _PyOpcode_OpName[aim->op.code]);
1214-
// }
1215-
// }
1216-
// }
1204+
if (next_uop->opcode != _START_EXECUTOR) {
1205+
if (next_uop->format == UOP_FORMAT_TARGET) {
1206+
_Py_CODEUNIT *aim = _PyFrame_GetBytecode(frame) + next_uop->target;
1207+
printf(" aim=[%s]\n", _PyOpcode_OpName[aim->op.code]);
1208+
}
1209+
else if (next_uop->format == UOP_FORMAT_JUMP) {
1210+
_PyUOpInstruction *aim_uop = current_executor->trace + next_uop->jump_target;
1211+
if (aim_uop->format == UOP_FORMAT_TARGET) {
1212+
_Py_CODEUNIT *aim = _PyFrame_GetBytecode(frame) + aim_uop->target;
1213+
printf(" aim=[%s]\n", _PyOpcode_OpName[aim->op.code]);
1214+
}
1215+
}
1216+
}
12171217
dump_stack(frame, stack_pointer);
12181218
}
12191219
if (next_uop->opcode == _START_EXECUTOR) {

Python/ceval_macros.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
# define TAIL_CALL_ARGS frame, stack_pointer, tstate, next_instr, instruction_funcptr_table, oparg
7979
#endif
8080

81-
8281
#if _Py_TAIL_CALL_INTERP
8382
// Note: [[clang::musttail]] works for GCC 15, but not __attribute__((musttail)) at the moment.
8483
# define Py_MUSTTAIL [[clang::musttail]]
@@ -267,7 +266,7 @@ GETITEM(PyObject *v, Py_ssize_t i) {
267266
* and skipped instructions.
268267
*/
269268
#define JUMPBY(x) (next_instr += (x))
270-
#define TIER2_JUMPBY(x) (frame->instr_ptr += (x))
269+
#define TIER2_STORE_IP(x) (frame->instr_ptr += (x))
271270
#define SKIP_OVER(x) (next_instr += (x))
272271

273272
#define STACK_LEVEL() ((int)(stack_pointer - _PyFrame_Stackbase(frame)))

Python/executor_cases.c.h

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

Python/generated_cases.c.h

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

0 commit comments

Comments
 (0)