Skip to content

Commit ce66f3b

Browse files
Remove TIER2_STORE_IP
1 parent a53ca1d commit ce66f3b

File tree

7 files changed

+25
-80
lines changed

7 files changed

+25
-80
lines changed

Objects/frameobject.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "frameobject.h" // PyFrameLocalsProxyObject
1919
#include "opcode.h" // EXTENDED_ARG
20-
#include "../Include/pytypedefs.h"
2120
#include "pycore_optimizer.h"
2221

2322
#include "clinic/frameobject.c.h"

Python/bytecodes.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,12 +1249,7 @@ dummy_func(
12491249
frame = tstate->current_frame = dying->previous;
12501250
_PyEval_FrameClearAndPop(tstate, dying);
12511251
RELOAD_STACK();
1252-
#if TIER_ONE
12531252
LOAD_IP(frame->return_offset);
1254-
#endif
1255-
#if TIER_TWO
1256-
TIER2_STORE_IP(frame->return_offset);
1257-
#endif
12581253
res = temp;
12591254
LLTRACE_RESUME_FRAME();
12601255
}
@@ -1441,12 +1436,7 @@ dummy_func(
14411436
_PyOpcode_Deopt[frame->instr_ptr->op.code] == ENTER_EXECUTOR);
14421437
#endif
14431438
RELOAD_STACK();
1444-
#if TIER_ONE
14451439
LOAD_IP(1 + INLINE_CACHE_ENTRIES_SEND);
1446-
#endif
1447-
#if TIER_TWO
1448-
TIER2_STORE_IP(1 + INLINE_CACHE_ENTRIES_SEND);
1449-
#endif
14501440
value = PyStackRef_MakeHeapSafe(temp);
14511441
LLTRACE_RESUME_FRAME();
14521442
}
@@ -3236,15 +3226,14 @@ dummy_func(
32363226
}
32373227

32383228
op(_FOR_ITER_TIER_TWO, (iter, null_or_index -- iter, null_or_index, next)) {
3239-
TIER2_STORE_IP(1 + INLINE_CACHE_ENTRIES_FOR_ITER);
32403229
_PyStackRef item = _PyForIter_VirtualIteratorNext(tstate, frame, iter, &null_or_index);
32413230
if (!PyStackRef_IsValid(item)) {
32423231
if (PyStackRef_IsError(item)) {
32433232
ERROR_NO_POP();
32443233
}
32453234
/* iterator ended normally */
3246-
/* This just sets the IP to what it expects */
3247-
TIER2_STORE_IP(oparg + 1);
3235+
/* This just sets the IP to what it expects (see normal _FOR_ITER */
3236+
frame->instr_ptr += (oparg + 2 + INLINE_CACHE_ENTRIES_FOR_ITER);
32483237
EXIT_IF(true);
32493238
}
32503239
next = item;
@@ -4992,12 +4981,7 @@ dummy_func(
49924981
_PyInterpreterFrame *prev = frame->previous;
49934982
_PyThreadState_PopFrame(tstate, frame);
49944983
frame = tstate->current_frame = prev;
4995-
#if TIER_ONE
49964984
LOAD_IP(frame->return_offset);
4997-
#endif
4998-
#if TIER_TWO
4999-
TIER2_STORE_IP(frame->return_offset);
5000-
#endif
50014985
RELOAD_STACK();
50024986
res = PyStackRef_FromPyObjectStealMortal((PyObject *)gen);
50034987
LLTRACE_RESUME_FRAME();

Python/ceval.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,20 +1213,7 @@ _PyTier2Interpreter(
12131213
for (;;) {
12141214
uopcode = next_uop->opcode;
12151215
#ifdef Py_DEBUG
1216-
if (frame->lltrace >= 4) {
1217-
if (next_uop->opcode != _START_EXECUTOR) {
1218-
if (next_uop->format == UOP_FORMAT_TARGET) {
1219-
_Py_CODEUNIT *aim = _PyFrame_GetBytecode(frame) + next_uop->target;
1220-
printf(" aim=[%s]\n", _PyOpcode_OpName[aim->op.code]);
1221-
}
1222-
else if (next_uop->format == UOP_FORMAT_JUMP) {
1223-
_PyUOpInstruction *aim_uop = current_executor->trace + next_uop->jump_target;
1224-
if (aim_uop->format == UOP_FORMAT_TARGET) {
1225-
_Py_CODEUNIT *aim = _PyFrame_GetBytecode(frame) + aim_uop->target;
1226-
printf(" aim=[%s]\n", _PyOpcode_OpName[aim->op.code]);
1227-
}
1228-
}
1229-
}
1216+
if (frame->lltrace >= 3) {
12301217
dump_stack(frame, stack_pointer);
12311218
if (next_uop->opcode == _START_EXECUTOR) {
12321219
printf("%4d uop: ", 0);

Python/ceval_macros.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,14 @@ do { \
210210
JUMP_TO_LABEL(start_frame); \
211211
} while (0)
212212
#else
213+
213214
#define DISPATCH_SAME_OPARG() \
214215
{ \
215216
opcode = next_instr->op.code; \
216217
PRE_DISPATCH_GOTO(); \
217218
DISPATCH_GOTO(); \
218219
}
220+
219221
#define DISPATCH_INLINED(NEW_FRAME) \
220222
do { \
221223
assert(tstate->interp->eval_frame == NULL); \
@@ -257,7 +259,6 @@ GETITEM(PyObject *v, Py_ssize_t i) {
257259
* and skipped instructions.
258260
*/
259261
#define JUMPBY(x) (next_instr += (x))
260-
#define TIER2_STORE_IP(x) (frame->instr_ptr += (x))
261262
#define SKIP_OVER(x) (next_instr += (x))
262263

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

Python/executor_cases.c.h

Lines changed: 5 additions & 21 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: 0 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tools/cases_generator/tier2_generator.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def __init__(self, out: CWriter, labels: dict[str, Label]):
6565
self._replacers["oparg"] = self.oparg
6666
self._replacers["JUMPBY"] = self.jumpby
6767
self._replacers["DISPATCH"] = self.dispatch
68+
self._replacers["LOAD_IP"] = self.load_ip
6869

6970
def goto_error(self, offset: int, storage: Storage) -> str:
7071
# To do: Add jump targets for popping values.
@@ -169,6 +170,20 @@ def dispatch(
169170
next(tkn_iter)
170171
return False
171172

173+
def load_ip(
174+
self,
175+
tkn: Token,
176+
tkn_iter: TokenIterator,
177+
uop: CodeSection,
178+
storage: Storage,
179+
inst: Instruction | None,
180+
) -> bool:
181+
self.out.start_line()
182+
self.emit("frame->instr_ptr += ")
183+
emit_to(self.out, tkn_iter, "SEMI")
184+
self.emit(";\n")
185+
return True
186+
172187
def write_uop(uop: Uop, emitter: Emitter, stack: Stack) -> Stack:
173188
locals: dict[str, Local] = {}
174189
try:

0 commit comments

Comments
 (0)