Skip to content

Commit 76e5f9a

Browse files
committed
Replace uses of array[1]s with scalars in bytecode definitions
1 parent 62ff86f commit 76e5f9a

File tree

7 files changed

+911
-826
lines changed

7 files changed

+911
-826
lines changed

Include/internal/pycore_uop_metadata.h

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

+133-139
Large diffs are not rendered by default.

Python/executor_cases.c.h

+338-306
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

+404-344
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer_bytecodes.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,10 @@ dummy_func(void) {
534534
top = bottom;
535535
}
536536

537-
op(_SWAP, (bottom[1], unused[oparg-2], top[1] -- bottom[1], unused[oparg-2], top[1])) {
538-
JitOptSymbol *temp = bottom[0];
539-
bottom[0] = top[0];
540-
top[0] = temp;
537+
op(_SWAP, (bottom, unused[oparg-2], top -- bottom, unused[oparg-2], top)) {
538+
JitOptSymbol *temp = bottom;
539+
bottom = top;
540+
top = temp;
541541
assert(oparg >= 2);
542542
}
543543

@@ -546,7 +546,7 @@ dummy_func(void) {
546546
(void)offset;
547547
}
548548

549-
op(_LOAD_ATTR_MODULE, (dict_version/2, owner, index/1 -- attr)) {
549+
op(_LOAD_ATTR_MODULE, (dict_version/2, index/1, owner -- attr)) {
550550
(void)dict_version;
551551
(void)index;
552552
attr = NULL;
@@ -626,9 +626,9 @@ dummy_func(void) {
626626
ctx->done = true;
627627
}
628628

629-
op(_INIT_CALL_BOUND_METHOD_EXACT_ARGS, (callable[1], self_or_null[1], unused[oparg] -- callable[1], self_or_null[1], unused[oparg])) {
630-
callable[0] = sym_new_not_null(ctx);
631-
self_or_null[0] = sym_new_not_null(ctx);
629+
op(_INIT_CALL_BOUND_METHOD_EXACT_ARGS, (callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) {
630+
callable = sym_new_not_null(ctx);
631+
self_or_null = sym_new_not_null(ctx);
632632
}
633633

634634
op(_CHECK_FUNCTION_VERSION, (func_version/2, callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) {

Python/optimizer_cases.c.h

+17-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tools/cases_generator/stack.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -572,23 +572,21 @@ def copy(self) -> "Storage":
572572
self.check_liveness, self.spilled
573573
)
574574

575-
def sanity_check(self) -> None:
575+
@staticmethod
576+
def check_names(locals: list[Local]) -> None:
576577
names: set[str] = set()
577-
for var in self.inputs:
578-
if var.name in names:
579-
raise StackError(f"Duplicate name {var.name}")
580-
names.add(var.name)
581-
names = set()
582-
for var in self.outputs:
583-
if var.name in names:
584-
raise StackError(f"Duplicate name {var.name}")
585-
names.add(var.name)
586-
names = set()
587-
for var in self.stack.variables:
578+
for var in locals:
579+
if var.name == "unused":
580+
continue
588581
if var.name in names:
589582
raise StackError(f"Duplicate name {var.name}")
590583
names.add(var.name)
591584

585+
def sanity_check(self) -> None:
586+
self.check_names(self.inputs)
587+
self.check_names(self.outputs)
588+
self.check_names(self.stack.variables)
589+
592590
def is_flushed(self) -> bool:
593591
for var in self.outputs:
594592
if var.in_local and not var.memory_offset:

0 commit comments

Comments
 (0)