Skip to content

Commit

Permalink
Arrange things so DECREF(temp) happens even if sym_new_const() runs o…
Browse files Browse the repository at this point in the history
…ut of space
  • Loading branch information
gvanrossum committed Feb 28, 2024
1 parent d2078db commit bbe8cd9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
30 changes: 18 additions & 12 deletions Python/optimizer_bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ dummy_func(void) {
if (temp == NULL) {
goto error;
}
OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp));
res = sym_new_const(ctx, temp);
Py_DECREF(temp);
OUT_OF_SPACE_IF_NULL(res);
// TODO gh-115506:
// replace opcode with constant propagated one and add tests!
Py_DECREF(temp);
}
else {
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyLong_Type));
Expand All @@ -139,10 +140,11 @@ dummy_func(void) {
if (temp == NULL) {
goto error;
}
OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp));
res = sym_new_const(ctx, temp);
Py_DECREF(temp);
OUT_OF_SPACE_IF_NULL(res);
// TODO gh-115506:
// replace opcode with constant propagated one and add tests!
Py_DECREF(temp);
}
else {
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyLong_Type));
Expand All @@ -160,10 +162,11 @@ dummy_func(void) {
if (temp == NULL) {
goto error;
}
OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp));
res = sym_new_const(ctx, temp);
Py_DECREF(temp);
OUT_OF_SPACE_IF_NULL(res);
// TODO gh-115506:
// replace opcode with constant propagated one and add tests!
Py_DECREF(temp);
}
else {
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyLong_Type));
Expand All @@ -182,10 +185,11 @@ dummy_func(void) {
if (temp == NULL) {
goto error;
}
OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp));
res = sym_new_const(ctx, temp);
Py_DECREF(temp);
OUT_OF_SPACE_IF_NULL(res);
// TODO gh-115506:
// replace opcode with constant propagated one and update tests!
Py_DECREF(temp);
}
else {
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyFloat_Type));
Expand All @@ -204,10 +208,11 @@ dummy_func(void) {
if (temp == NULL) {
goto error;
}
OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp));
res = sym_new_const(ctx, temp);
Py_DECREF(temp);
OUT_OF_SPACE_IF_NULL(res);
// TODO gh-115506:
// replace opcode with constant propagated one and update tests!
Py_DECREF(temp);
}
else {
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyFloat_Type));
Expand All @@ -226,10 +231,11 @@ dummy_func(void) {
if (temp == NULL) {
goto error;
}
OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp));
res = sym_new_const(ctx, temp);
Py_DECREF(temp);
OUT_OF_SPACE_IF_NULL(res);
// TODO gh-115506:
// replace opcode with constant propagated one and update tests!
Py_DECREF(temp);
}
else {
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyFloat_Type));
Expand Down
30 changes: 18 additions & 12 deletions Python/optimizer_cases.c.h

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

0 comments on commit bbe8cd9

Please sign in to comment.