mirror of
https://github.com/python/cpython.git
synced 2025-08-26 11:45:20 +00:00
Revert "GH-128914: Remove conditional stack effects from bytecodes.c
and the code generators (GH-128918)" (GH-129202)
The commit introduced a ~2.5-3% regression in the free threading build.
This reverts commit ab61d3f430
.
This commit is contained in:
parent
d7d066c3ab
commit
a10f99375e
44 changed files with 1679 additions and 1460 deletions
|
@ -77,11 +77,12 @@ class Block(Node):
|
|||
class StackEffect(Node):
|
||||
name: str = field(compare=False) # __eq__ only uses type, cond, size
|
||||
type: str = "" # Optional `:type`
|
||||
cond: str = "" # Optional `if (cond)`
|
||||
size: str = "" # Optional `[size]`
|
||||
# Note: size cannot be combined with type or cond
|
||||
|
||||
def __repr__(self) -> str:
|
||||
items = [self.name, self.type, self.size]
|
||||
items = [self.name, self.type, self.cond, self.size]
|
||||
while items and items[-1] == "":
|
||||
del items[-1]
|
||||
return f"StackEffect({', '.join(repr(item) for item in items)})"
|
||||
|
@ -277,15 +278,22 @@ class Parser(PLexer):
|
|||
type_text = self.require(lx.IDENTIFIER).text.strip()
|
||||
if self.expect(lx.TIMES):
|
||||
type_text += " *"
|
||||
cond_text = ""
|
||||
if self.expect(lx.IF):
|
||||
self.require(lx.LPAREN)
|
||||
if not (cond := self.expression()):
|
||||
raise self.make_syntax_error("Expected condition")
|
||||
self.require(lx.RPAREN)
|
||||
cond_text = cond.text.strip()
|
||||
size_text = ""
|
||||
if self.expect(lx.LBRACKET):
|
||||
if type_text:
|
||||
if type_text or cond_text:
|
||||
raise self.make_syntax_error("Unexpected [")
|
||||
if not (size := self.expression()):
|
||||
raise self.make_syntax_error("Expected expression")
|
||||
self.require(lx.RBRACKET)
|
||||
size_text = size.text.strip()
|
||||
return StackEffect(tkn.text, type_text, size_text)
|
||||
return StackEffect(tkn.text, type_text, cond_text, size_text)
|
||||
return None
|
||||
|
||||
@contextual
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue