diff options
author | Guido van Rossum <guido@python.org> | 2023-09-11 22:39:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-11 22:39:19 (GMT) |
commit | fbaf77eb9bd1e6812ebf984d32b29b025cc037d6 (patch) | |
tree | dbe770374dcdb9d414bc9ff4bc9937b194039032 /Python | |
parent | 1ee50e2a78f644d81d341a08562073ad169d8cc7 (diff) | |
download | cpython-fbaf77eb9bd1e6812ebf984d32b29b025cc037d6.zip cpython-fbaf77eb9bd1e6812ebf984d32b29b025cc037d6.tar.gz cpython-fbaf77eb9bd1e6812ebf984d32b29b025cc037d6.tar.bz2 |
gh-109214: Rename SAVE_IP to _SET_IP, and similar (#109285)
* 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
Diffstat (limited to 'Python')
-rw-r--r-- | Python/abstract_interp_cases.c.h | 12 | ||||
-rw-r--r-- | Python/bytecodes.c | 34 | ||||
-rw-r--r-- | Python/executor_cases.c.h | 14 | ||||
-rw-r--r-- | Python/generated_cases.c.h | 20 | ||||
-rw-r--r-- | Python/optimizer.c | 60 |
5 files changed, 70 insertions, 70 deletions
diff --git a/Python/abstract_interp_cases.c.h b/Python/abstract_interp_cases.c.h index 398c046..1b96ca1 100644 --- a/Python/abstract_interp_cases.c.h +++ b/Python/abstract_interp_cases.c.h @@ -521,7 +521,7 @@ break; } - case IS_NONE: { + case _IS_NONE: { PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)PARTITIONNODE_NULLROOT, PEEK(-(-1)), true); break; } @@ -792,23 +792,23 @@ break; } - case JUMP_TO_TOP: { + case _JUMP_TO_TOP: { break; } - case SAVE_IP: { + case _SET_IP: { break; } - case SAVE_CURRENT_IP: { + case _SAVE_CURRENT_IP: { break; } - case EXIT_TRACE: { + case _EXIT_TRACE: { break; } - case INSERT: { + case _INSERT: { PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)PARTITIONNODE_NULLROOT, PEEK(-(-1 - oparg)), true); break; } diff --git a/Python/bytecodes.c b/Python/bytecodes.c index c9dea5c..7c49f9a 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -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 --)) { @@ -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, (--)) { @@ -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; } @@ -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. @@ -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) = @@ -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)) { @@ -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])); } diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 918991d..a4d8130 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -1902,7 +1902,7 @@ break; } - case IS_NONE: { + case _IS_NONE: { PyObject *value; PyObject *b; value = stack_pointer[-1]; @@ -2887,29 +2887,29 @@ break; } - case JUMP_TO_TOP: { + case _JUMP_TO_TOP: { pc = 0; CHECK_EVAL_BREAKER(); break; } - case SAVE_IP: { + case _SET_IP: { frame->prev_instr = ip_offset + oparg; break; } - case SAVE_CURRENT_IP: { + case _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 break; } - case EXIT_TRACE: { + case _EXIT_TRACE: { frame->prev_instr--; // Back up to just before destination _PyFrame_SetStackPointer(frame, stack_pointer); Py_DECREF(self); @@ -2917,7 +2917,7 @@ break; } - case INSERT: { + case _INSERT: { PyObject *top; top = stack_pointer[-1]; // Inserts TOS at position specified by oparg; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index a4944c7..27cda1f 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -987,13 +987,13 @@ TARGET(RETURN_VALUE) { PyObject *retval; - // SAVE_CURRENT_IP + // _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 } @@ -1055,13 +1055,13 @@ value = GETITEM(FRAME_CO_CONSTS, oparg); Py_INCREF(value); } - // SAVE_CURRENT_IP + // _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 } @@ -3024,7 +3024,7 @@ PyObject *value; PyObject *b; PyObject *cond; - // IS_NONE + // _IS_NONE value = stack_pointer[-1]; { if (Py_IsNone(value)) { @@ -3054,7 +3054,7 @@ PyObject *value; PyObject *b; PyObject *cond; - // IS_NONE + // _IS_NONE value = stack_pointer[-1]; { if (Py_IsNone(value)) { @@ -3879,14 +3879,14 @@ new_frame->localsplus[i] = args[i]; } } - // SAVE_CURRENT_IP + // _SAVE_CURRENT_IP next_instr += 3; { #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 } @@ -3958,14 +3958,14 @@ new_frame->localsplus[i] = args[i]; } } - // SAVE_CURRENT_IP + // _SAVE_CURRENT_IP next_instr += 3; { #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 } diff --git a/Python/optimizer.c b/Python/optimizer.c index 8eca37a..453e3e8 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -474,14 +474,14 @@ translate_bytecode_to_trace( } \ reserved = (n); // Keep ADD_TO_TRACE / ADD_TO_STUB honest -// Reserve space for main+stub uops, plus 2 for SAVE_IP and EXIT_TRACE +// Reserve space for main+stub uops, plus 2 for _SET_IP and _EXIT_TRACE #define RESERVE(main, stub) RESERVE_RAW((main) + (stub) + 2, uop_name(opcode)) // Trace stack operations (used by _PUSH_FRAME, _POP_FRAME) #define TRACE_STACK_PUSH() \ if (trace_stack_depth >= TRACE_STACK_SIZE) { \ DPRINTF(2, "Trace stack overflow\n"); \ - ADD_TO_TRACE(SAVE_IP, 0, 0); \ + ADD_TO_TRACE(_SET_IP, 0, 0); \ goto done; \ } \ trace_stack[trace_stack_depth].code = code; \ @@ -504,8 +504,8 @@ translate_bytecode_to_trace( top: // Jump here after _PUSH_FRAME or likely branches for (;;) { - RESERVE_RAW(2, "epilogue"); // Always need space for SAVE_IP and EXIT_TRACE - ADD_TO_TRACE(SAVE_IP, INSTR_IP(instr, code), 0); + RESERVE_RAW(2, "epilogue"); // Always need space for _SET_IP and _EXIT_TRACE + ADD_TO_TRACE(_SET_IP, INSTR_IP(instr, code), 0); uint32_t opcode = instr->op.code; uint32_t oparg = instr->op.arg; @@ -531,7 +531,7 @@ top: // Jump here after _PUSH_FRAME or likely branches case POP_JUMP_IF_NONE: { RESERVE(2, 2); - ADD_TO_TRACE(IS_NONE, 0, 0); + ADD_TO_TRACE(_IS_NONE, 0, 0); opcode = POP_JUMP_IF_TRUE; goto pop_jump_if_bool; } @@ -539,7 +539,7 @@ top: // Jump here after _PUSH_FRAME or likely branches case POP_JUMP_IF_NOT_NONE: { RESERVE(2, 2); - ADD_TO_TRACE(IS_NONE, 0, 0); + ADD_TO_TRACE(_IS_NONE, 0, 0); opcode = POP_JUMP_IF_FALSE; goto pop_jump_if_bool; } @@ -563,8 +563,8 @@ pop_jump_if_bool: uop_name(opcode), oparg, counter, bitcount, jump_likely, jump_sense, uop_name(uopcode)); ADD_TO_TRACE(uopcode, max_length, 0); - ADD_TO_STUB(max_length, SAVE_IP, INSTR_IP(stub_target, code), 0); - ADD_TO_STUB(max_length + 1, EXIT_TRACE, 0, 0); + ADD_TO_STUB(max_length, _SET_IP, INSTR_IP(stub_target, code), 0); + ADD_TO_STUB(max_length + 1, _EXIT_TRACE, 0, 0); if (jump_likely) { DPRINTF(2, "Jump likely (%x = %d bits), continue at byte offset %d\n", instr[1].cache, bitcount, 2 * INSTR_IP(target_instr, code)); @@ -578,7 +578,7 @@ pop_jump_if_bool: { if (instr + 2 - oparg == initial_instr && code == initial_code) { RESERVE(1, 0); - ADD_TO_TRACE(JUMP_TO_TOP, 0, 0); + ADD_TO_TRACE(_JUMP_TO_TOP, 0, 0); } else { DPRINTF(2, "JUMP_BACKWARD not to top ends trace\n"); @@ -589,7 +589,7 @@ pop_jump_if_bool: case JUMP_FORWARD: { RESERVE(0, 0); - // This will emit two SAVE_IP instructions; leave it to the optimizer + // This will emit two _SET_IP instructions; leave it to the optimizer instr += oparg; break; } @@ -629,8 +629,8 @@ pop_jump_if_bool: ADD_TO_TRACE(next_op, 0, 0); ADD_TO_STUB(max_length + 0, POP_TOP, 0, 0); - ADD_TO_STUB(max_length + 1, SAVE_IP, INSTR_IP(target_instr, code), 0); - ADD_TO_STUB(max_length + 2, EXIT_TRACE, 0, 0); + ADD_TO_STUB(max_length + 1, _SET_IP, INSTR_IP(target_instr, code), 0); + ADD_TO_STUB(max_length + 2, _EXIT_TRACE, 0, 0); break; } @@ -638,7 +638,7 @@ pop_jump_if_bool: { const struct opcode_macro_expansion *expansion = &_PyOpcode_macro_expansion[opcode]; if (expansion->nuops > 0) { - // Reserve space for nuops (+ SAVE_IP + EXIT_TRACE) + // Reserve space for nuops (+ _SET_IP + _EXIT_TRACE) int nuops = expansion->nuops; RESERVE(nuops, 0); if (expansion->uops[nuops-1].uop == _POP_FRAME) { @@ -682,7 +682,7 @@ pop_jump_if_bool: case OPARG_BOTTOM: // Second half of super-instr oparg = orig_oparg & 0xF; break; - case OPARG_SAVE_IP: // op==SAVE_IP; oparg=next instr + case OPARG_SET_IP: // op==_SET_IP; oparg=next instr oparg = INSTR_IP(instr + offset, code); break; @@ -722,7 +722,7 @@ pop_jump_if_bool: PyUnicode_AsUTF8(new_code->co_qualname), PyUnicode_AsUTF8(new_code->co_filename), new_code->co_firstlineno); - ADD_TO_TRACE(SAVE_IP, 0, 0); + ADD_TO_TRACE(_SET_IP, 0, 0); goto done; } if (new_code->co_version != func_version) { @@ -730,7 +730,7 @@ pop_jump_if_bool: // Perhaps it may happen again, so don't bother tracing. // TODO: Reason about this -- is it better to bail or not? DPRINTF(2, "Bailing because co_version != func_version\n"); - ADD_TO_TRACE(SAVE_IP, 0, 0); + ADD_TO_TRACE(_SET_IP, 0, 0); goto done; } // Increment IP to the return address @@ -746,7 +746,7 @@ pop_jump_if_bool: 2 * INSTR_IP(instr, code)); goto top; } - ADD_TO_TRACE(SAVE_IP, 0, 0); + ADD_TO_TRACE(_SET_IP, 0, 0); goto done; } } @@ -768,9 +768,9 @@ done: TRACE_STACK_POP(); } assert(code == initial_code); - // Skip short traces like SAVE_IP, LOAD_FAST, SAVE_IP, EXIT_TRACE + // Skip short traces like _SET_IP, LOAD_FAST, _SET_IP, _EXIT_TRACE if (trace_length > 3) { - ADD_TO_TRACE(EXIT_TRACE, 0, 0); + ADD_TO_TRACE(_EXIT_TRACE, 0, 0); DPRINTF(1, "Created a trace for %s (%s:%d) at byte offset %d -- length %d+%d\n", PyUnicode_AsUTF8(code->co_qualname), @@ -819,25 +819,25 @@ done: static int remove_unneeded_uops(_PyUOpInstruction *trace, int trace_length) { - // Stage 1: Replace unneeded SAVE_IP uops with NOP. - // Note that we don't enter stubs, those SAVE_IPs are needed. - int last_save_ip = -1; + // Stage 1: Replace unneeded _SET_IP uops with NOP. + // Note that we don't enter stubs, those SET_IPs are needed. + int last_set_ip = -1; int last_instr = 0; bool need_ip = true; for (int pc = 0; pc < trace_length; pc++) { int opcode = trace[pc].opcode; - if (opcode == SAVE_CURRENT_IP) { - // Special case: never remove preceding SAVE_IP - last_save_ip = -1; + if (opcode == _SAVE_CURRENT_IP) { + // Special case: never remove preceding _SET_IP + last_set_ip = -1; } - else if (opcode == SAVE_IP) { - if (!need_ip && last_save_ip >= 0) { - trace[last_save_ip].opcode = NOP; + else if (opcode == _SET_IP) { + if (!need_ip && last_set_ip >= 0) { + trace[last_set_ip].opcode = NOP; } need_ip = false; - last_save_ip = pc; + last_set_ip = pc; } - else if (opcode == JUMP_TO_TOP || opcode == EXIT_TRACE) { + else if (opcode == _JUMP_TO_TOP || opcode == _EXIT_TRACE) { last_instr = pc + 1; break; } |