Skip to content

Commit

Permalink
gh-109214: Rename SAVE_IP to _SET_IP, and similar (#109285)
Browse files Browse the repository at this point in the history
* Rename SAVE_IP to _SET_IP
* Rename EXIT_TRACE to _EXIT_TRACE
* Rename SAVE_CURRENT_IP to _SAVE_CURRENT_IP
* Rename INSERT to _INSERT (This is for Ken Jin's abstract interpreter)
* Rename IS_NONE to _IS_NONE
* Rename JUMP_TO_TOP to _JUMP_TO_TOP
  • Loading branch information
gvanrossum authored Sep 11, 2023
1 parent 1ee50e2 commit fbaf77e
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 117 deletions.
70 changes: 35 additions & 35 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Lib/test/test_capi/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2390,7 +2390,7 @@ def testfunc(x):
ex = get_first_executor(testfunc)
self.assertIsNotNone(ex)
uops = {opname for opname, _, _ in ex}
self.assertIn("SAVE_IP", uops)
self.assertIn("_SET_IP", uops)
self.assertIn("LOAD_FAST", uops)

def test_extended_arg(self):
Expand Down Expand Up @@ -2536,7 +2536,7 @@ def testfunc(n):
ex = get_first_executor(testfunc)
self.assertIsNotNone(ex)
uops = {opname for opname, _, _ in ex}
self.assertIn("JUMP_TO_TOP", uops)
self.assertIn("_JUMP_TO_TOP", uops)

def test_jump_forward(self):
def testfunc(n):
Expand Down
12 changes: 6 additions & 6 deletions Python/abstract_interp_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,8 @@ dummy_func(
}

macro(RETURN_VALUE) =
SAVE_IP + // Tier 2 only; special-cased oparg
SAVE_CURRENT_IP + // Sets frame->prev_instr
_SET_IP + // Tier 2 only; special-cased oparg
_SAVE_CURRENT_IP + // Sets frame->prev_instr
_POP_FRAME;

inst(INSTRUMENTED_RETURN_VALUE, (retval --)) {
Expand All @@ -828,8 +828,8 @@ dummy_func(

macro(RETURN_CONST) =
LOAD_CONST +
SAVE_IP + // Tier 2 only; special-cased oparg
SAVE_CURRENT_IP + // Sets frame->prev_instr
_SET_IP + // Tier 2 only; special-cased oparg
_SAVE_CURRENT_IP + // Sets frame->prev_instr
_POP_FRAME;

inst(INSTRUMENTED_RETURN_CONST, (--)) {
Expand Down Expand Up @@ -2310,7 +2310,7 @@ dummy_func(
JUMPBY(oparg * flag);
}

op(IS_NONE, (value -- b)) {
op(_IS_NONE, (value -- b)) {
if (Py_IsNone(value)) {
b = Py_True;
}
Expand All @@ -2320,9 +2320,9 @@ dummy_func(
}
}

macro(POP_JUMP_IF_NONE) = IS_NONE + POP_JUMP_IF_TRUE;
macro(POP_JUMP_IF_NONE) = _IS_NONE + POP_JUMP_IF_TRUE;

macro(POP_JUMP_IF_NOT_NONE) = IS_NONE + POP_JUMP_IF_FALSE;
macro(POP_JUMP_IF_NOT_NONE) = _IS_NONE + POP_JUMP_IF_FALSE;

inst(JUMP_BACKWARD_NO_INTERRUPT, (--)) {
/* This bytecode is used in the `yield from` or `await` loop.
Expand Down Expand Up @@ -3069,8 +3069,8 @@ dummy_func(
_CHECK_FUNCTION_EXACT_ARGS +
_CHECK_STACK_SPACE +
_INIT_CALL_PY_EXACT_ARGS +
SAVE_IP + // Tier 2 only; special-cased oparg
SAVE_CURRENT_IP + // Sets frame->prev_instr
_SET_IP + // Tier 2 only; special-cased oparg
_SAVE_CURRENT_IP + // Sets frame->prev_instr
_PUSH_FRAME;

macro(CALL_PY_EXACT_ARGS) =
Expand All @@ -3079,8 +3079,8 @@ dummy_func(
_CHECK_FUNCTION_EXACT_ARGS +
_CHECK_STACK_SPACE +
_INIT_CALL_PY_EXACT_ARGS +
SAVE_IP + // Tier 2 only; special-cased oparg
SAVE_CURRENT_IP + // Sets frame->prev_instr
_SET_IP + // Tier 2 only; special-cased oparg
_SAVE_CURRENT_IP + // Sets frame->prev_instr
_PUSH_FRAME;

inst(CALL_PY_WITH_DEFAULTS, (unused/1, func_version/2, callable, self_or_null, args[oparg] -- unused)) {
Expand Down Expand Up @@ -3851,33 +3851,33 @@ dummy_func(
}
}

op(JUMP_TO_TOP, (--)) {
op(_JUMP_TO_TOP, (--)) {
pc = 0;
CHECK_EVAL_BREAKER();
}

op(SAVE_IP, (--)) {
op(_SET_IP, (--)) {
frame->prev_instr = ip_offset + oparg;
}

op(SAVE_CURRENT_IP, (--)) {
op(_SAVE_CURRENT_IP, (--)) {
#if TIER_ONE
frame->prev_instr = next_instr - 1;
#endif
#if TIER_TWO
// Relies on a preceding SAVE_IP
// Relies on a preceding _SET_IP
frame->prev_instr--;
#endif
}

op(EXIT_TRACE, (--)) {
op(_EXIT_TRACE, (--)) {
frame->prev_instr--; // Back up to just before destination
_PyFrame_SetStackPointer(frame, stack_pointer);
Py_DECREF(self);
return frame;
}

op(INSERT, (unused[oparg], top -- top, unused[oparg])) {
op(_INSERT, (unused[oparg], top -- top, unused[oparg])) {
// Inserts TOS at position specified by oparg;
memmove(&stack_pointer[-1 - oparg], &stack_pointer[-oparg], oparg * sizeof(stack_pointer[0]));
}
Expand Down
14 changes: 7 additions & 7 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fbaf77e

Please sign in to comment.