Skip to content

GH-128682: Mark two more macros as escaping. #129645

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 1 commit into from
Feb 4, 2025
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
25 changes: 18 additions & 7 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ dummy_func(

inst(LOAD_FAST_AND_CLEAR, (-- value)) {
value = GETLOCAL(oparg);
// do not use SETLOCAL here, it decrefs the old value
GETLOCAL(oparg) = PyStackRef_NULL;
}

Expand Down Expand Up @@ -328,8 +327,10 @@ dummy_func(
}

replicate(8) inst(STORE_FAST, (value --)) {
SETLOCAL(oparg, value);
_PyStackRef tmp = GETLOCAL(oparg);
GETLOCAL(oparg) = value;
DEAD(value);
PyStackRef_XCLOSE(tmp);
}

pseudo(STORE_FAST_MAYBE_NULL, (unused --)) = {
Expand All @@ -339,18 +340,24 @@ dummy_func(
inst(STORE_FAST_LOAD_FAST, (value1 -- value2)) {
uint32_t oparg1 = oparg >> 4;
uint32_t oparg2 = oparg & 15;
SETLOCAL(oparg1, value1);
_PyStackRef tmp = GETLOCAL(oparg1);
GETLOCAL(oparg1) = value1;
DEAD(value1);
value2 = PyStackRef_DUP(GETLOCAL(oparg2));
PyStackRef_XCLOSE(tmp);
}

inst(STORE_FAST_STORE_FAST, (value2, value1 --)) {
uint32_t oparg1 = oparg >> 4;
uint32_t oparg2 = oparg & 15;
SETLOCAL(oparg1, value1);
_PyStackRef tmp = GETLOCAL(oparg1);
GETLOCAL(oparg1) = value1;
DEAD(value1);
SETLOCAL(oparg2, value2);
PyStackRef_XCLOSE(tmp);
tmp = GETLOCAL(oparg2);
GETLOCAL(oparg2) = value2;
DEAD(value2);
PyStackRef_XCLOSE(tmp);
}

pure inst(POP_TOP, (value --)) {
Expand Down Expand Up @@ -1775,7 +1782,9 @@ dummy_func(
);
ERROR_IF(1, error);
}
SETLOCAL(oparg, PyStackRef_NULL);
_PyStackRef tmp = GETLOCAL(oparg);
GETLOCAL(oparg) = PyStackRef_NULL;
PyStackRef_XCLOSE(tmp);
}

inst(MAKE_CELL, (--)) {
Expand All @@ -1786,7 +1795,9 @@ dummy_func(
if (cell == NULL) {
ERROR_NO_POP();
}
SETLOCAL(oparg, PyStackRef_FromPyObjectSteal(cell));
_PyStackRef tmp = GETLOCAL(oparg);
GETLOCAL(oparg) = PyStackRef_FromPyObjectSteal(cell);
PyStackRef_XCLOSE(tmp);
}

inst(DELETE_DEREF, (--)) {
Expand Down
1 change: 1 addition & 0 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ lltrace_instruction(_PyInterpreterFrame *frame,
}
fflush(stdout);
}

static void
lltrace_resume_frame(_PyInterpreterFrame *frame)
{
Expand Down
9 changes: 0 additions & 9 deletions Python/ceval_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,6 @@ GETITEM(PyObject *v, Py_ssize_t i) {
#define LOCALS_ARRAY (frame->localsplus)
#define GETLOCAL(i) (frame->localsplus[i])

/* The SETLOCAL() macro must not DECREF the local variable in-place and
then store the new value; it must copy the old value to a temporary
value, then store the new value, and then DECREF the temporary value.
This is because it is possible that during the DECREF the frame is
accessed by other code (e.g. a __del__ method or gc.collect()) and the
variable would be pointing to already-freed memory. */
#define SETLOCAL(i, value) do { _PyStackRef tmp = GETLOCAL(i); \
GETLOCAL(i) = value; \
PyStackRef_XCLOSE(tmp); } while (0)

#ifdef Py_STATS
#define UPDATE_MISS_STATS(INSTNAME) \
Expand Down
69 changes: 57 additions & 12 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading