gh-105481: expose opcode metadata via the _opcode module (#106688)

This commit is contained in:
Irit Katriel 2023-07-14 18:41:52 +01:00 committed by GitHub
parent 243fdcb40e
commit 6a70edf24c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 558 additions and 21 deletions

View file

@ -36,7 +36,9 @@
#include "pycore_pystate.h" // _Py_GetConfig()
#include "pycore_symtable.h" // PySTEntryObject, _PyFuture_FromAST()
#define NEED_OPCODE_METADATA
#include "pycore_opcode_metadata.h" // _PyOpcode_opcode_metadata, _PyOpcode_num_popped/pushed
#undef NEED_OPCODE_METADATA
#define COMP_GENEXP 0
#define COMP_LISTCOMP 1
@ -864,6 +866,36 @@ PyCompile_OpcodeStackEffect(int opcode, int oparg)
return stack_effect(opcode, oparg, -1);
}
int
PyUnstable_OpcodeIsValid(int opcode)
{
return IS_VALID_OPCODE(opcode);
}
int
PyUnstable_OpcodeHasArg(int opcode)
{
return OPCODE_HAS_ARG(opcode);
}
int
PyUnstable_OpcodeHasConst(int opcode)
{
return OPCODE_HAS_CONST(opcode);
}
int
PyUnstable_OpcodeHasName(int opcode)
{
return OPCODE_HAS_NAME(opcode);
}
int
PyUnstable_OpcodeHasJump(int opcode)
{
return OPCODE_HAS_JUMP(opcode);
}
static int
codegen_addop_noarg(instr_sequence *seq, int opcode, location loc)
{