mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-117494: extract the Instruction Sequence data structure into a separate file (#117496)
This commit is contained in:
parent
060a96f1a9
commit
04697bcfaf
13 changed files with 283 additions and 224 deletions
|
@ -23,7 +23,7 @@
|
|||
#define DEFAULT_BLOCK_SIZE 16
|
||||
|
||||
typedef _Py_SourceLocation location;
|
||||
typedef _PyCfgJumpTargetLabel jump_target_label;
|
||||
typedef _PyJumpTargetLabel jump_target_label;
|
||||
|
||||
typedef struct _PyCfgInstruction {
|
||||
int i_opcode;
|
||||
|
@ -40,7 +40,7 @@ typedef struct _PyCfgBasicblock {
|
|||
control flow. */
|
||||
struct _PyCfgBasicblock *b_list;
|
||||
/* The label of this block if it is a jump target, -1 otherwise */
|
||||
_PyCfgJumpTargetLabel b_label;
|
||||
_PyJumpTargetLabel b_label;
|
||||
/* Exception stack at start of block, used by assembler to create the exception handling table */
|
||||
struct _PyCfgExceptStack *b_exceptstack;
|
||||
/* pointer to an array of instructions, initially NULL */
|
||||
|
@ -81,7 +81,7 @@ struct _PyCfgBuilder {
|
|||
/* pointer to the block currently being constructed */
|
||||
struct _PyCfgBasicblock *g_curblock;
|
||||
/* label for the next instruction to be placed */
|
||||
_PyCfgJumpTargetLabel g_current_label;
|
||||
_PyJumpTargetLabel g_current_label;
|
||||
};
|
||||
|
||||
typedef struct _PyCfgBuilder cfg_builder;
|
||||
|
@ -2712,7 +2712,7 @@ prepare_localsplus(_PyCompile_CodeUnitMetadata *umd, cfg_builder *g, int code_fl
|
|||
}
|
||||
|
||||
int
|
||||
_PyCfg_ToInstructionSequence(cfg_builder *g, _PyCompile_InstructionSequence *seq)
|
||||
_PyCfg_ToInstructionSequence(cfg_builder *g, _PyInstructionSequence *seq)
|
||||
{
|
||||
int lbl = 0;
|
||||
for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) {
|
||||
|
@ -2720,7 +2720,7 @@ _PyCfg_ToInstructionSequence(cfg_builder *g, _PyCompile_InstructionSequence *seq
|
|||
lbl += 1;
|
||||
}
|
||||
for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) {
|
||||
RETURN_IF_ERROR(_PyCompile_InstructionSequence_UseLabel(seq, b->b_label.id));
|
||||
RETURN_IF_ERROR(_PyInstructionSequence_UseLabel(seq, b->b_label.id));
|
||||
for (int i = 0; i < b->b_iused; i++) {
|
||||
cfg_instr *instr = &b->b_instr[i];
|
||||
if (HAS_TARGET(instr->i_opcode)) {
|
||||
|
@ -2728,10 +2728,10 @@ _PyCfg_ToInstructionSequence(cfg_builder *g, _PyCompile_InstructionSequence *seq
|
|||
instr->i_oparg = instr->i_target->b_label.id;
|
||||
}
|
||||
RETURN_IF_ERROR(
|
||||
_PyCompile_InstructionSequence_Addop(
|
||||
_PyInstructionSequence_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;
|
||||
_PyExceptHandlerInfo *hi = &seq->s_instrs[seq->s_used-1].i_except_handler_info;
|
||||
if (instr->i_except != NULL) {
|
||||
hi->h_label = instr->i_except->b_label.id;
|
||||
hi->h_startdepth = instr->i_except->b_startdepth;
|
||||
|
@ -2750,7 +2750,7 @@ int
|
|||
_PyCfg_OptimizedCfgToInstructionSequence(cfg_builder *g,
|
||||
_PyCompile_CodeUnitMetadata *umd, int code_flags,
|
||||
int *stackdepth, int *nlocalsplus,
|
||||
_PyCompile_InstructionSequence *seq)
|
||||
_PyInstructionSequence *seq)
|
||||
{
|
||||
*stackdepth = calculate_stackdepth(g);
|
||||
if (*stackdepth < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue