Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2904d99

Browse files
authored
GH-111485: Remove some special cases from the code generator and bytecodes.c (GH-111540)
1 parent d27acd4 commit 2904d99

File tree

8 files changed

+119
-55
lines changed

8 files changed

+119
-55
lines changed

Include/internal/pycore_opcode_metadata.h

Lines changed: 19 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/abstract_interp_cases.c.h

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@ dummy_func(
742742
}
743743

744744
inst(RAISE_VARARGS, (args[oparg] -- )) {
745+
TIER_ONE_ONLY
745746
PyObject *cause = NULL, *exc = NULL;
746747
switch (oparg) {
747748
case 2:
@@ -1073,6 +1074,7 @@ dummy_func(
10731074
}
10741075

10751076
inst(RERAISE, (values[oparg], exc -- values[oparg])) {
1077+
TIER_ONE_ONLY
10761078
assert(oparg >= 0 && oparg <= 2);
10771079
if (oparg) {
10781080
PyObject *lasti = values[0];
@@ -1094,6 +1096,7 @@ dummy_func(
10941096
}
10951097

10961098
inst(END_ASYNC_FOR, (awaitable, exc -- )) {
1099+
TIER_ONE_ONLY
10971100
assert(exc && PyExceptionInstance_Check(exc));
10981101
if (PyErr_GivenExceptionMatches(exc, PyExc_StopAsyncIteration)) {
10991102
DECREF_INPUTS();
@@ -1107,6 +1110,7 @@ dummy_func(
11071110
}
11081111

11091112
inst(CLEANUP_THROW, (sub_iter, last_sent_val, exc_value -- none, value)) {
1113+
TIER_ONE_ONLY
11101114
assert(throwflag);
11111115
assert(exc_value && PyExceptionInstance_Check(exc_value));
11121116
if (PyErr_GivenExceptionMatches(exc_value, PyExc_StopIteration)) {
@@ -1467,7 +1471,7 @@ dummy_func(
14671471
PyObject *initial = GETLOCAL(oparg);
14681472
PyObject *cell = PyCell_New(initial);
14691473
if (cell == NULL) {
1470-
goto resume_with_error;
1474+
goto error;
14711475
}
14721476
SETLOCAL(oparg, cell);
14731477
}
@@ -2247,13 +2251,15 @@ dummy_func(
22472251
}
22482252

22492253
inst(IMPORT_NAME, (level, fromlist -- res)) {
2254+
TIER_ONE_ONLY
22502255
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
22512256
res = import_name(tstate, frame, name, fromlist, level);
22522257
DECREF_INPUTS();
22532258
ERROR_IF(res == NULL, error);
22542259
}
22552260

22562261
inst(IMPORT_FROM, (from -- from, res)) {
2262+
TIER_ONE_ONLY
22572263
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
22582264
res = import_from(tstate, from, name);
22592265
ERROR_IF(res == NULL, error);
@@ -2263,10 +2269,10 @@ dummy_func(
22632269
JUMPBY(oparg);
22642270
}
22652271

2266-
inst(JUMP_BACKWARD, (--)) {
2272+
inst(JUMP_BACKWARD, (unused/1 --)) {
22672273
CHECK_EVAL_BREAKER();
22682274
assert(oparg <= INSTR_OFFSET());
2269-
JUMPBY(1-oparg);
2275+
JUMPBY(-oparg);
22702276
#if ENABLE_SPECIALIZATION
22712277
this_instr[1].cache += (1 << OPTIMIZER_BITS_IN_COUNTER);
22722278
if (this_instr[1].cache > tstate->interp->optimizer_backedge_threshold &&
@@ -2297,6 +2303,7 @@ dummy_func(
22972303
};
22982304

22992305
inst(ENTER_EXECUTOR, (--)) {
2306+
TIER_ONE_ONLY
23002307
CHECK_EVAL_BREAKER();
23012308

23022309
PyCodeObject *code = _PyFrame_GetCode(frame);
@@ -2703,6 +2710,7 @@ dummy_func(
27032710
}
27042711

27052712
inst(BEFORE_WITH, (mgr -- exit, res)) {
2713+
TIER_ONE_ONLY
27062714
/* pop the context manager, push its __exit__ and the
27072715
* value returned from calling its __enter__
27082716
*/
@@ -3831,9 +3839,9 @@ dummy_func(
38313839
INSTRUMENTED_JUMP(this_instr, next_instr + oparg, PY_MONITORING_EVENT_JUMP);
38323840
}
38333841

3834-
inst(INSTRUMENTED_JUMP_BACKWARD, ( -- )) {
3842+
inst(INSTRUMENTED_JUMP_BACKWARD, (unused/1 -- )) {
38353843
CHECK_EVAL_BREAKER();
3836-
INSTRUMENTED_JUMP(this_instr, next_instr + 1 - oparg, PY_MONITORING_EVENT_JUMP);
3844+
INSTRUMENTED_JUMP(this_instr, next_instr - oparg, PY_MONITORING_EVENT_JUMP);
38373845
}
38383846

38393847
inst(INSTRUMENTED_POP_JUMP_IF_TRUE, (unused/1 -- )) {

Python/executor_cases.c.h

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)