gh-117494: extract the Instruction Sequence data structure into a separate file (#117496)

This commit is contained in:
Irit Katriel 2024-04-04 16:47:26 +01:00 committed by GitHub
parent 060a96f1a9
commit 04697bcfaf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 283 additions and 224 deletions

View file

@ -3,6 +3,7 @@
#include "Python.h"
#include "pycore_code.h" // write_location_entry_start()
#include "pycore_compile.h"
#include "pycore_instruction_sequence.h"
#include "pycore_opcode_utils.h" // IS_BACKWARDS_JUMP_OPCODE
#include "pycore_opcode_metadata.h" // is_pseudo_target, _PyOpcode_Caches
#include "pycore_symtable.h" // _Py_SourceLocation
@ -23,8 +24,8 @@
}
typedef _Py_SourceLocation location;
typedef _PyCompile_Instruction instruction;
typedef _PyCompile_InstructionSequence instr_sequence;
typedef _PyInstruction instruction;
typedef _PyInstructionSequence instr_sequence;
static inline bool
same_location(location a, location b)
@ -132,7 +133,7 @@ assemble_emit_exception_table_item(struct assembler *a, int value, int msb)
static int
assemble_emit_exception_table_entry(struct assembler *a, int start, int end,
int handler_offset,
_PyCompile_ExceptHandlerInfo *handler)
_PyExceptHandlerInfo *handler)
{
Py_ssize_t len = PyBytes_GET_SIZE(a->a_except_table);
if (a->a_except_table_off + MAX_SIZE_OF_ENTRY >= len) {
@ -158,7 +159,7 @@ static int
assemble_exception_table(struct assembler *a, instr_sequence *instrs)
{
int ioffset = 0;
_PyCompile_ExceptHandlerInfo handler;
_PyExceptHandlerInfo handler;
handler.h_label = -1;
handler.h_startdepth = -1;
handler.h_preserve_lasti = -1;
@ -736,8 +737,7 @@ _PyAssemble_MakeCodeObject(_PyCompile_CodeUnitMetadata *umd, PyObject *const_cac
PyObject *consts, int maxdepth, instr_sequence *instrs,
int nlocalsplus, int code_flags, PyObject *filename)
{
if (_PyCompile_InstructionSequence_ApplyLabelMap(instrs) < 0) {
if (_PyInstructionSequence_ApplyLabelMap(instrs) < 0) {
return NULL;
}
if (resolve_unconditional_jumps(instrs) < 0) {