GH-130296: Avoid stack transients in four instructions. (GH-130310)

* Combine _GUARD_GLOBALS_VERSION_PUSH_KEYS and _LOAD_GLOBAL_MODULE_FROM_KEYS into _LOAD_GLOBAL_MODULE

* Combine _GUARD_BUILTINS_VERSION_PUSH_KEYS and _LOAD_GLOBAL_BUILTINS_FROM_KEYS into _LOAD_GLOBAL_BUILTINS

* Combine _CHECK_ATTR_MODULE_PUSH_KEYS and _LOAD_ATTR_MODULE_FROM_KEYS into _LOAD_ATTR_MODULE

* Remove stack transient in LOAD_ATTR_WITH_HINT
This commit is contained in:
Mark Shannon 2025-02-28 18:00:38 +00:00 committed by GitHub
parent ab11c09705
commit 54965f3fb2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 615 additions and 1005 deletions

View file

@ -230,16 +230,18 @@ _PyUOpPrint(const _PyUOpInstruction *uop)
}
switch(uop->format) {
case UOP_FORMAT_TARGET:
printf(" (%d, target=%d, operand=%#" PRIx64,
printf(" (%d, target=%d, operand0=%#" PRIx64 ", operand1=%#" PRIx64,
uop->oparg,
uop->target,
(uint64_t)uop->operand0);
(uint64_t)uop->operand0,
(uint64_t)uop->operand1);
break;
case UOP_FORMAT_JUMP:
printf(" (%d, jump_target=%d, operand=%#" PRIx64,
printf(" (%d, jump_target=%d, operand0=%#" PRIx64 ", operand1=%#" PRIx64,
uop->oparg,
uop->jump_target,
(uint64_t)uop->operand0);
(uint64_t)uop->operand0,
(uint64_t)uop->operand1);
break;
default:
printf(" (%d, Unknown format)", uop->oparg);
@ -682,7 +684,7 @@ translate_bytecode_to_trace(
// Add one to account for the actual opcode/oparg pair:
int offset = expansion->uops[i].offset + 1;
switch (expansion->uops[i].size) {
case OPARG_FULL:
case OPARG_SIMPLE:
assert(opcode != JUMP_BACKWARD_NO_INTERRUPT && opcode != JUMP_BACKWARD);
break;
case OPARG_CACHE_1:
@ -716,6 +718,21 @@ translate_bytecode_to_trace(
}
#endif
break;
case OPERAND1_1:
assert(trace[trace_length-1].opcode == uop);
operand = read_u16(&instr[offset].cache);
trace[trace_length-1].operand1 = operand;
continue;
case OPERAND1_2:
assert(trace[trace_length-1].opcode == uop);
operand = read_u32(&instr[offset].cache);
trace[trace_length-1].operand1 = operand;
continue;
case OPERAND1_4:
assert(trace[trace_length-1].opcode == uop);
operand = read_u64(&instr[offset].cache);
trace[trace_length-1].operand1 = operand;
continue;
default:
fprintf(stderr,
"opcode=%d, oparg=%d; nuops=%d, i=%d; size=%d, offset=%d\n",