mirror of
https://github.com/python/cpython.git
synced 2025-08-14 22:01:08 +00:00
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
3 changed files with 13 additions and 15 deletions
10
Include/internal/pycore_opcode_metadata.h
generated
10
Include/internal/pycore_opcode_metadata.h
generated
|
@ -842,15 +842,15 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
|
||||||
case PUSH_EXC_INFO:
|
case PUSH_EXC_INFO:
|
||||||
return 2;
|
return 2;
|
||||||
case LOAD_ATTR_METHOD_WITH_VALUES:
|
case LOAD_ATTR_METHOD_WITH_VALUES:
|
||||||
return 1 + 1;
|
return 2;
|
||||||
case LOAD_ATTR_METHOD_NO_DICT:
|
case LOAD_ATTR_METHOD_NO_DICT:
|
||||||
return 1 + 1;
|
return 2;
|
||||||
case LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES:
|
case LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES:
|
||||||
return 0 + 1;
|
return 1;
|
||||||
case LOAD_ATTR_NONDESCRIPTOR_NO_DICT:
|
case LOAD_ATTR_NONDESCRIPTOR_NO_DICT:
|
||||||
return 0 + 1;
|
return 1;
|
||||||
case LOAD_ATTR_METHOD_LAZY_DICT:
|
case LOAD_ATTR_METHOD_LAZY_DICT:
|
||||||
return 1 + 1;
|
return 2;
|
||||||
case KW_NAMES:
|
case KW_NAMES:
|
||||||
return 0;
|
return 0;
|
||||||
case INSTRUMENTED_CALL:
|
case INSTRUMENTED_CALL:
|
||||||
|
|
8
Python/generated_cases.c.h
generated
8
Python/generated_cases.c.h
generated
|
@ -3356,7 +3356,7 @@
|
||||||
res = self;
|
res = self;
|
||||||
STACK_GROW(1);
|
STACK_GROW(1);
|
||||||
stack_pointer[-1] = res;
|
stack_pointer[-1] = res;
|
||||||
stack_pointer[-(1 + 1)] = res2;
|
stack_pointer[-2] = res2;
|
||||||
next_instr += 9;
|
next_instr += 9;
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
}
|
}
|
||||||
|
@ -3378,7 +3378,7 @@
|
||||||
res = self;
|
res = self;
|
||||||
STACK_GROW(1);
|
STACK_GROW(1);
|
||||||
stack_pointer[-1] = res;
|
stack_pointer[-1] = res;
|
||||||
stack_pointer[-(1 + 1)] = res2;
|
stack_pointer[-2] = res2;
|
||||||
next_instr += 9;
|
next_instr += 9;
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
}
|
}
|
||||||
|
@ -3403,7 +3403,6 @@
|
||||||
assert(descr != NULL);
|
assert(descr != NULL);
|
||||||
Py_DECREF(self);
|
Py_DECREF(self);
|
||||||
res = Py_NewRef(descr);
|
res = Py_NewRef(descr);
|
||||||
STACK_GROW(0);
|
|
||||||
stack_pointer[-1] = res;
|
stack_pointer[-1] = res;
|
||||||
next_instr += 9;
|
next_instr += 9;
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
|
@ -3423,7 +3422,6 @@
|
||||||
assert(descr != NULL);
|
assert(descr != NULL);
|
||||||
Py_DECREF(self);
|
Py_DECREF(self);
|
||||||
res = Py_NewRef(descr);
|
res = Py_NewRef(descr);
|
||||||
STACK_GROW(0);
|
|
||||||
stack_pointer[-1] = res;
|
stack_pointer[-1] = res;
|
||||||
next_instr += 9;
|
next_instr += 9;
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
|
@ -3450,7 +3448,7 @@
|
||||||
res = self;
|
res = self;
|
||||||
STACK_GROW(1);
|
STACK_GROW(1);
|
||||||
stack_pointer[-1] = res;
|
stack_pointer[-1] = res;
|
||||||
stack_pointer[-(1 + 1)] = res2;
|
stack_pointer[-2] = res2;
|
||||||
next_instr += 9;
|
next_instr += 9;
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ def effect_size(effect: StackEffect) -> tuple[int, str]:
|
||||||
return 0, effect.size
|
return 0, effect.size
|
||||||
elif effect.cond:
|
elif effect.cond:
|
||||||
if effect.cond in ("0", "1"):
|
if effect.cond in ("0", "1"):
|
||||||
return 0, effect.cond
|
return int(effect.cond), ""
|
||||||
return 0, f"{maybe_parenthesize(effect.cond)} ? 1 : 0"
|
return 0, f"{maybe_parenthesize(effect.cond)} ? 1 : 0"
|
||||||
else:
|
else:
|
||||||
return 1, ""
|
return 1, ""
|
||||||
|
@ -841,9 +841,9 @@ class Analyzer:
|
||||||
def check_families(self) -> None:
|
def check_families(self) -> None:
|
||||||
"""Check each family:
|
"""Check each family:
|
||||||
|
|
||||||
- Must have at least 2 members
|
- Must have at least 2 members (including head)
|
||||||
- All members must be known instructions
|
- Head and all members must be known instructions
|
||||||
- All members must have the same cache, input and output effects
|
- Head and all members must have the same cache, input and output effects
|
||||||
"""
|
"""
|
||||||
for family in self.families.values():
|
for family in self.families.values():
|
||||||
if family.name not in self.macro_instrs and family.name not in self.instrs:
|
if family.name not in self.macro_instrs and family.name not in self.instrs:
|
||||||
|
@ -868,7 +868,7 @@ class Analyzer:
|
||||||
self.error(
|
self.error(
|
||||||
f"Family {family.name!r} has inconsistent "
|
f"Family {family.name!r} has inconsistent "
|
||||||
f"(cache, input, output) effects:\n"
|
f"(cache, input, output) effects:\n"
|
||||||
f" {family.members[0]} = {expected_effects}; "
|
f" {family.name} = {expected_effects}; "
|
||||||
f"{member} = {member_effects}",
|
f"{member} = {member_effects}",
|
||||||
family,
|
family,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue