diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-06-27 19:24:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-27 19:24:58 (GMT) |
commit | 529088100952b31797a29ef7e0f5716613b32d66 (patch) | |
tree | ad6c08c0f5d4a3435b4be33eb44dd132a4f832cc /Python/compile.c | |
parent | eaa1eae55ea66d74c5303924320185dac74d4eb1 (diff) | |
download | cpython-529088100952b31797a29ef7e0f5716613b32d66.zip cpython-529088100952b31797a29ef7e0f5716613b32d66.tar.gz cpython-529088100952b31797a29ef7e0f5716613b32d66.tar.bz2 |
gh-106149: move jump target resolution from optimizer to assembler (#106150)
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/Python/compile.c b/Python/compile.c index 5a05605..d080144 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -131,16 +131,6 @@ enum { }; -int -_PyCompile_InstrSize(int opcode, int oparg) -{ - assert(!IS_PSEUDO_INSTR(opcode)); - assert(OPCODE_HAS_ARG(opcode) || oparg == 0); - int extended_args = (0xFFFFFF < oparg) + (0xFFFF < oparg) + (0xFF < oparg); - int caches = _PyOpcode_Caches[opcode]; - return extended_args + 1 + caches; -} - typedef _PyCompile_Instruction instruction; typedef _PyCompile_InstructionSequence instr_sequence; @@ -7717,17 +7707,20 @@ cfg_to_instr_sequence(cfg_builder *g, instr_sequence *seq) RETURN_IF_ERROR(instr_sequence_use_label(seq, b->b_label.id)); for (int i = 0; i < b->b_iused; i++) { cfg_instr *instr = &b->b_instr[i]; + if (OPCODE_HAS_JUMP(instr->i_opcode)) { + instr->i_oparg = instr->i_target->b_label.id; + } RETURN_IF_ERROR( instr_sequence_addop(seq, instr->i_opcode, instr->i_oparg, instr->i_loc)); _PyCompile_ExceptHandlerInfo *hi = &seq->s_instrs[seq->s_used-1].i_except_handler_info; if (instr->i_except != NULL) { - hi->h_offset = instr->i_except->b_offset; + hi->h_label = instr->i_except->b_label.id; hi->h_startdepth = instr->i_except->b_startdepth; hi->h_preserve_lasti = instr->i_except->b_preserve_lasti; } else { - hi->h_offset = -1; + hi->h_label = -1; } } } |