mirror of https://github.com/python/cpython
Small fixes to code generator (#106845)
These repair nits I found in PR gh-106798 (issue gh-106797) and in PR gh-106716 (issue gh-106706).
This commit is contained in:
parent
00e52acebd
commit
1e36ca63f9
|
@ -842,15 +842,15 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
|
|||
case PUSH_EXC_INFO:
|
||||
return 2;
|
||||
case LOAD_ATTR_METHOD_WITH_VALUES:
|
||||
return 1 + 1;
|
||||
return 2;
|
||||
case LOAD_ATTR_METHOD_NO_DICT:
|
||||
return 1 + 1;
|
||||
return 2;
|
||||
case LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES:
|
||||
return 0 + 1;
|
||||
return 1;
|
||||
case LOAD_ATTR_NONDESCRIPTOR_NO_DICT:
|
||||
return 0 + 1;
|
||||
return 1;
|
||||
case LOAD_ATTR_METHOD_LAZY_DICT:
|
||||
return 1 + 1;
|
||||
return 2;
|
||||
case KW_NAMES:
|
||||
return 0;
|
||||
case INSTRUMENTED_CALL:
|
||||
|
|
|
@ -3356,7 +3356,7 @@
|
|||
res = self;
|
||||
STACK_GROW(1);
|
||||
stack_pointer[-1] = res;
|
||||
stack_pointer[-(1 + 1)] = res2;
|
||||
stack_pointer[-2] = res2;
|
||||
next_instr += 9;
|
||||
DISPATCH();
|
||||
}
|
||||
|
@ -3378,7 +3378,7 @@
|
|||
res = self;
|
||||
STACK_GROW(1);
|
||||
stack_pointer[-1] = res;
|
||||
stack_pointer[-(1 + 1)] = res2;
|
||||
stack_pointer[-2] = res2;
|
||||
next_instr += 9;
|
||||
DISPATCH();
|
||||
}
|
||||
|
@ -3403,7 +3403,6 @@
|
|||
assert(descr != NULL);
|
||||
Py_DECREF(self);
|
||||
res = Py_NewRef(descr);
|
||||
STACK_GROW(0);
|
||||
stack_pointer[-1] = res;
|
||||
next_instr += 9;
|
||||
DISPATCH();
|
||||
|
@ -3423,7 +3422,6 @@
|
|||
assert(descr != NULL);
|
||||
Py_DECREF(self);
|
||||
res = Py_NewRef(descr);
|
||||
STACK_GROW(0);
|
||||
stack_pointer[-1] = res;
|
||||
next_instr += 9;
|
||||
DISPATCH();
|
||||
|
@ -3450,7 +3448,7 @@
|
|||
res = self;
|
||||
STACK_GROW(1);
|
||||
stack_pointer[-1] = res;
|
||||
stack_pointer[-(1 + 1)] = res2;
|
||||
stack_pointer[-2] = res2;
|
||||
next_instr += 9;
|
||||
DISPATCH();
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ def effect_size(effect: StackEffect) -> tuple[int, str]:
|
|||
return 0, effect.size
|
||||
elif effect.cond:
|
||||
if effect.cond in ("0", "1"):
|
||||
return 0, effect.cond
|
||||
return int(effect.cond), ""
|
||||
return 0, f"{maybe_parenthesize(effect.cond)} ? 1 : 0"
|
||||
else:
|
||||
return 1, ""
|
||||
|
@ -841,9 +841,9 @@ class Analyzer:
|
|||
def check_families(self) -> None:
|
||||
"""Check each family:
|
||||
|
||||
- Must have at least 2 members
|
||||
- All members must be known instructions
|
||||
- All members must have the same cache, input and output effects
|
||||
- Must have at least 2 members (including head)
|
||||
- Head and all members must be known instructions
|
||||
- Head and all members must have the same cache, input and output effects
|
||||
"""
|
||||
for family in self.families.values():
|
||||
if family.name not in self.macro_instrs and family.name not in self.instrs:
|
||||
|
@ -868,7 +868,7 @@ class Analyzer:
|
|||
self.error(
|
||||
f"Family {family.name!r} has inconsistent "
|
||||
f"(cache, input, output) effects:\n"
|
||||
f" {family.members[0]} = {expected_effects}; "
|
||||
f" {family.name} = {expected_effects}; "
|
||||
f"{member} = {member_effects}",
|
||||
family,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue