mirror of
https://github.com/python/cpython.git
synced 2026-01-22 07:08:40 +00:00
177 lines
5.2 KiB
C
177 lines
5.2 KiB
C
// This file contains instruction definitions.
|
|
// It is read by generators stored in Tools/cases_generator/
|
|
// to generate Python/generated_cases.c.h and others.
|
|
// Note that there is some dummy C code at the top and bottom of the file
|
|
// to fool text editors like VS Code into believing this is valid C code.
|
|
// The actual instruction definitions start at // BEGIN BYTECODES //.
|
|
// See Tools/cases_generator/README.md for more information.
|
|
|
|
#include "Python.h"
|
|
#include "pycore_abstract.h" // _PyIndex_Check()
|
|
#include "pycore_audit.h" // _PySys_Audit()
|
|
#include "pycore_backoff.h"
|
|
#include "pycore_cell.h" // PyCell_GetRef()
|
|
#include "pycore_code.h"
|
|
#include "pycore_emscripten_signal.h" // _Py_CHECK_EMSCRIPTEN_SIGNALS
|
|
#include "pycore_function.h"
|
|
#include "pycore_instruments.h"
|
|
#include "pycore_interpolation.h" // _PyInterpolation_Build()
|
|
#include "pycore_intrinsics.h"
|
|
#include "pycore_long.h" // _PyLong_ExactDealloc(), _PyLong_GetZero()
|
|
#include "pycore_moduleobject.h" // PyModuleObject
|
|
#include "pycore_object.h" // _PyObject_GC_TRACK()
|
|
#include "pycore_opcode_metadata.h" // uop names
|
|
#include "pycore_opcode_utils.h" // MAKE_FUNCTION_*
|
|
#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_*
|
|
#include "pycore_pyerrors.h" // _PyErr_GetRaisedException()
|
|
#include "pycore_pystate.h" // _PyInterpreterState_GET()
|
|
#include "pycore_range.h" // _PyRangeIterObject
|
|
#include "pycore_setobject.h" // _PySet_NextEntry()
|
|
#include "pycore_sliceobject.h" // _PyBuildSlice_ConsumeRefs
|
|
#include "pycore_stackref.h"
|
|
#include "pycore_template.h" // _PyTemplate_Build()
|
|
#include "pycore_tuple.h" // _PyTuple_ITEMS()
|
|
#include "pycore_typeobject.h" // _PySuper_Lookup()
|
|
|
|
#include "pycore_dict.h"
|
|
#include "dictobject.h"
|
|
#include "pycore_frame.h"
|
|
#include "opcode.h"
|
|
#include "optimizer.h"
|
|
#include "pydtrace.h"
|
|
#include "setobject.h"
|
|
|
|
|
|
#define USE_COMPUTED_GOTOS 0
|
|
#include "ceval_macros.h"
|
|
|
|
/* Flow control macros */
|
|
|
|
#define inst(name, ...) case name:
|
|
#define op(name, ...) /* NAME is ignored */
|
|
#define macro(name) static int MACRO_##name
|
|
#define super(name) static int SUPER_##name
|
|
#define family(name, ...) static int family_##name
|
|
#define pseudo(name) static int pseudo_##name
|
|
#define label(name) name:
|
|
|
|
/* Annotations */
|
|
#define guard
|
|
#define override
|
|
#define specializing
|
|
#define replicate(TIMES)
|
|
#define tier1
|
|
#define no_save_ip
|
|
|
|
// Dummy variables for stack effects.
|
|
static PyObject *value, *value1, *value2, *left, *right, *res, *sum, *prod, *sub;
|
|
static PyObject *container, *start, *stop, *v, *lhs, *rhs, *res2;
|
|
static PyObject *list, *tuple, *dict, *owner, *set, *str, *tup, *map, *keys;
|
|
static PyObject *exit_func, *lasti, *val, *retval, *obj, *iter, *exhausted;
|
|
static PyObject *aiter, *awaitable, *iterable, *w, *exc_value, *bc, *locals;
|
|
static PyObject *orig, *excs, *update, *b, *fromlist, *level, *from;
|
|
static PyObject **pieces, **values;
|
|
static size_t jump;
|
|
// Dummy variables for cache effects
|
|
static uint16_t invert, counter, index, hint;
|
|
#define unused 0 // Used in a macro def, can't be static
|
|
static uint32_t type_version;
|
|
static _PyExecutorObject *current_executor;
|
|
|
|
static PyObject *
|
|
dummy_func(
|
|
PyThreadState *tstate,
|
|
_PyInterpreterFrame *frame,
|
|
unsigned char opcode,
|
|
unsigned int oparg,
|
|
_Py_CODEUNIT *next_instr,
|
|
PyObject **stack_pointer,
|
|
int throwflag,
|
|
PyObject *args[]
|
|
)
|
|
{
|
|
// Dummy labels.
|
|
pop_1_error:
|
|
// Dummy locals.
|
|
PyObject *dummy;
|
|
_Py_CODEUNIT *this_instr;
|
|
PyObject *attr;
|
|
PyObject *attrs;
|
|
PyObject *bottom;
|
|
PyObject *callable;
|
|
PyObject *callargs;
|
|
PyObject *codeobj;
|
|
PyObject *cond;
|
|
PyObject *descr;
|
|
PyObject *exc;
|
|
PyObject *exit;
|
|
PyObject *fget;
|
|
PyObject *fmt_spec;
|
|
PyObject *func;
|
|
uint32_t func_version;
|
|
PyObject *getattribute;
|
|
PyObject *kwargs;
|
|
PyObject *kwdefaults;
|
|
PyObject *len_o;
|
|
PyObject *match;
|
|
PyObject *match_type;
|
|
PyObject *method;
|
|
PyObject *mgr;
|
|
Py_ssize_t min_args;
|
|
PyObject *names;
|
|
PyObject *new_exc;
|
|
PyObject *next;
|
|
PyObject *none;
|
|
PyObject *null;
|
|
PyObject *prev_exc;
|
|
PyObject *receiver;
|
|
PyObject *rest;
|
|
int result;
|
|
PyObject *self;
|
|
PyObject *seq;
|
|
PyObject *slice;
|
|
PyObject *step;
|
|
PyObject *subject;
|
|
PyObject *top;
|
|
PyObject *type;
|
|
PyObject *typevars;
|
|
PyObject *val0;
|
|
PyObject *val1;
|
|
int values_or_none;
|
|
|
|
switch (opcode) {
|
|
|
|
// BEGIN BYTECODES //
|
|
|
|
// Override an op
|
|
override op(_CHECK_PERIODIC_IF_NOT_YIELD_FROM, (--)) {
|
|
Test_EvalFrame_Resumes++;
|
|
if ((oparg & RESUME_OPARG_LOCATION_MASK) < RESUME_AFTER_YIELD_FROM) {
|
|
int err = check_periodics(tstate);
|
|
ERROR_IF(err != 0);
|
|
}
|
|
}
|
|
|
|
// Override an inst
|
|
override inst(LOAD_CONST, (-- value)) {
|
|
Test_EvalFrame_Loads++;
|
|
PyObject *obj = GETITEM(FRAME_CO_CONSTS, oparg);
|
|
value = PyStackRef_FromPyObjectBorrow(obj);
|
|
}
|
|
|
|
|
|
// END BYTECODES //
|
|
|
|
}
|
|
dispatch_opcode:
|
|
error:
|
|
exception_unwind:
|
|
exit_unwind:
|
|
handle_eval_breaker:
|
|
resume_frame:
|
|
start_frame:
|
|
unbound_local_error:
|
|
;
|
|
}
|
|
|
|
// Future families go below this point //
|