Skip to content

Commit e0d8c95

Browse files
committed
Remove conditional stack effects -- We no longer need them
1 parent 39b37b0 commit e0d8c95

File tree

14 files changed

+95
-174
lines changed

14 files changed

+95
-174
lines changed

Python/bytecodes.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
#define guard
6060
#define override
6161
#define specializing
62-
#define split
6362
#define replicate(TIMES)
6463
#define tier1
6564
#define no_save_ip
@@ -1686,8 +1685,10 @@ dummy_func(
16861685
ERROR_IF(PyStackRef_IsNull(*res), error);
16871686
}
16881687

1689-
op(_PUSH_NULL_CONDITIONAL, ( -- null if (oparg & 1))) {
1690-
null = PyStackRef_NULL;
1688+
op(_PUSH_NULL_CONDITIONAL, ( -- null[oparg & 1])) {
1689+
if (oparg & 1) {
1690+
null[0] = PyStackRef_NULL;
1691+
}
16911692
}
16921693

16931694
macro(LOAD_GLOBAL) =

Python/executor_cases.c.h

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

Python/generated_cases.c.h

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

Python/optimizer.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,11 +1226,7 @@ uop_optimize(
12261226
for (int pc = 0; pc < length; pc++) {
12271227
int opcode = buffer[pc].opcode;
12281228
int oparg = buffer[pc].oparg;
1229-
if (_PyUop_Flags[opcode] & HAS_OPARG_AND_1_FLAG) {
1230-
buffer[pc].opcode = opcode + 1 + (oparg & 1);
1231-
assert(strncmp(_PyOpcode_uop_name[buffer[pc].opcode], _PyOpcode_uop_name[opcode], strlen(_PyOpcode_uop_name[opcode])) == 0);
1232-
}
1233-
else if (oparg < _PyUop_Replication[opcode]) {
1229+
if (oparg < _PyUop_Replication[opcode]) {
12341230
buffer[pc].opcode = opcode + oparg + 1;
12351231
assert(strncmp(_PyOpcode_uop_name[buffer[pc].opcode], _PyOpcode_uop_name[opcode], strlen(_PyOpcode_uop_name[opcode])) == 0);
12361232
}

Python/optimizer_bytecodes.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,14 @@ dummy_func(void) {
546546
}
547547
}
548548

549-
op (_PUSH_NULL_CONDITIONAL, ( -- null if (oparg & 1))) {
550-
int opcode = (oparg & 1) ? _PUSH_NULL : _NOP;
551-
REPLACE_OP(this_instr, opcode, 0, 0);
552-
null = sym_new_null(ctx);
549+
op (_PUSH_NULL_CONDITIONAL, ( -- null[oparg & 1])) {
550+
if (oparg & 1) {
551+
REPLACE_OP(this_instr, _PUSH_NULL, 0, 0);
552+
null[0] = sym_new_null(ctx);
553+
}
554+
else {
555+
REPLACE_OP(this_instr, _NOP);
556+
}
553557
}
554558

555559
op(_LOAD_ATTR, (owner -- attr, self_or_null[oparg&1])) {
@@ -765,7 +769,7 @@ dummy_func(void) {
765769
Py_UNREACHABLE();
766770
}
767771

768-
op(_PUSH_FRAME, (new_frame: _Py_UOpsAbstractFrame * -- unused if (0))) {
772+
op(_PUSH_FRAME, (new_frame: _Py_UOpsAbstractFrame * -- )) {
769773
SYNC_SP();
770774
ctx->frame->stack_pointer = stack_pointer;
771775
ctx->frame = new_frame;

Python/optimizer_cases.c.h

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

0 commit comments

Comments
 (0)