8000 BUILD_SLICE · python/cpython@98c053b · GitHub
[go: up one dir, main page]

Skip to content

Commit 98c053b

Browse files
committed
BUILD_SLICE
1 parent 6a05302 commit 98c053b

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed

Python/bytecodes.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3030,22 +3030,12 @@ dummy_func(
30303030
goto resume_frame;
30313031
}
30323032

3033-
// error: BUILD_SLICE has irregular stack effect
3034-
inst(BUILD_SLICE) {
3035-
PyObject *start, *stop, *step, *slice;
3036-
if (oparg == 3)
3037-
step = POP();
3038-
else
3039-
step = NULL;
3040-
stop = POP();
3041-
start = TOP();
3033+
inst(BUILD_SLICE, (start, stop, step if (oparg == 3) -- slice)) {
30423034
slice = PySlice_New(start, stop, step);
30433035
Py_DECREF(start);
30443036
Py_DECREF(stop);
30453037
Py_XDECREF(step);
3046-
SET_TOP(slice);
3047-
if (slice == NULL)
3048-
goto error;
3038+
ERROR_IF(slice == NULL, error);
30493039
}
30503040

30513041
// error: FORMAT_VALUE has irregular stack effect

Python/generated_cases.c.h

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

Python/opcode_metadata.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) {
329329
case RETURN_GENERATOR:
330330
return 0;
331331
case BUILD_SLICE:
332-
return -1;
332+
return ((oparg == 3) ? 1 : 0) + 2;
333333
case FORMAT_VALUE:
334334
return -1;
335335
case COPY:
@@ -675,7 +675,7 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
675675
case RETURN_GENERATOR:
676676
return 0;
677677
case BUILD_SLICE:
678-
return -1;
678+
return 1;
679679
case FORMAT_VALUE:
680680
return -1;
681681
case COPY:

0 commit comments

Comments
 (0)
0