8000 GH-98831: Move assorted macros from ceval.h to a new header by gvanrossum · Pull Request #101116 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-98831: Move assorted macros from ceval.h to a new header #101116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -1466,8 +1466,12 @@ regen-cases:
-o $(srcdir)/Python/opcode_metadata.h.new
$(UPDATE_FILE) $(srcdir)/Python/opcode_metadata.h $(srcdir)/Python/opcode_metadata.h.new

Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/condvar.h $(srcdir)/Python/generated_cases.c.h

Python/ceval.o: \
$(srcdir)/Python/ceval_macros.h \
$(srcdir)/Python/condvar.h \
$(srcdir)/Python/generated_cases.c.h \
$(srcdir)/Python/opcode_metadata.h \
$(srcdir)/Python/opcode_targets.h

Python/frozen.o: $(FROZEN_FILES_OUT)

Expand Down
43 changes: 8 additions & 35 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,58 +34,29 @@
#include "setobject.h"
#include "structmember.h" // struct PyMemberDef, T_OFFSET_EX

void _PyFloat_ExactDealloc(PyObject *);
void _PyUnicode_ExactDealloc(PyObject *);

/* Stack effect macros
* These will be mostly replaced by stack effect descriptions,
* but the tooling need to recognize them.
*/
#define SET_TOP(v) (stack_pointer[-1] = (v))
#define SET_SECOND(v) (stack_pointer[-2] = (v))
#define PEEK(n) (stack_pointer[-(n)])
#define POKE(n, v) (stack_pointer[-(n)] = (v))
#define PUSH(val) (*(stack_pointer++) = (val))
#define POP() (*(--stack_pointer))
#define TOP() PEEK(1)
#define SECOND() PEEK(2)
#define STACK_GROW(n) (stack_pointer += (n))
#define STACK_SHRINK(n) (stack_pointer -= (n))
#define EMPTY() 1
#define STACK_LEVEL() 2

/* Local variable macros */
#define GETLOCAL(i) (frame->localsplus[i])
#define SETLOCAL(i, val) \
do { \
PyObject *_tmp = frame->localsplus[i]; \
frame->localsplus[i] = (val); \
Py_XDECREF(_tmp); \
} while (0)
#define USE_COMPUTED_GOTOS 0
#include "ceval_macros.h"

/* Flow control macros */
#define DEOPT_IF(cond, instname) ((void)0)
#define ERROR_IF(cond, labelname) ((void)0)
#define JUMPBY(offset) ((void)0)
#define GO_TO_INSTRUCTION(instname) ((void)0)
#define DISPATCH_SAME_OPARG() ((void)0)
#define PREDICT(opname) ((void)0)

#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 NAME_ERROR_MSG \
"name '%.200s' is not defined"

// Dummy variables for stack effects.
static PyObject *value, *value1, *value2, *left, *right, *res, *sum, *prod, *sub;
static PyObject *container, *start, *stop, *v, *lhs, *rhs;
static PyObject *list, *tuple, *dict, *owner;
static PyObject *list, *tuple, *dict, *owner, *set, *str, *tup, *map, *keys;
static PyObject *exit_func, *lasti, *val, *retval, *obj, *iter;
static PyObject *aiter, *awaitable, *iterable, *w, *exc_value, *bc;
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;
Expand Down Expand Up @@ -456,7 +427,7 @@ dummy_func(
PREDICT(JUMP_BACKWARD);
}

inst(SET_ADD, (set, unused[oparg-1], v -- set, unused[oparg-1])) {
inst(SET_ADD, (set, unused[oparg-1], v -- set, unused[oparg-1])) {
int err = PySet_Add(set, v);
Py_DECREF(v);
ERROR_IF(err, error);
Expand Down Expand Up @@ -3336,8 +3307,10 @@ dummy_func(
// END BYTECODES //

}
dispatch_opcode:
error:
exception_unwind:
exit_unwind:
handle_eval_breaker:
resume_frame:
resume_with_error:
Expand Down
Loading
0