[pypy-svn] r4261 - in pypy/branch/typeinference/pypy: annotation translator
arigo at codespeak.net
arigo at codespeak.net
Mon May 3 19:30:08 CEST 2004
Author: arigo
Date: Mon May 3 19:30:05 2004
New Revision: 4261
Modified:
pypy/branch/typeinference/pypy/annotation/binaryop.py
pypy/branch/typeinference/pypy/annotation/model.py
pypy/branch/typeinference/pypy/translator/annrpython.py
Log:
Fixed the block scheduling algorithm, which contained an endless loop: blocks
far from the creation point of an object could trigger a reflow from the
creation point continuously, not giving the reflow a change to reach the point
where the object is used.
Modified: pypy/branch/typeinference/pypy/annotation/binaryop.py
==============================================================================
--- pypy/branch/typeinference/pypy/annotation/binaryop.py (original)
+++ pypy/branch/typeinference/pypy/annotation/binaryop.py Mon May 3 19:30:05 2004
@@ -3,7 +3,8 @@
"""
from pypy.annotation.pairtype import pair, pairtype
-from pypy.annotation.model import SomeObject, SomeInteger, SomeString, SomeList
+from pypy.annotation.model import SomeObject, SomeInteger, SomeBool
+from pypy.annotation.model import SomeString, SomeList
from pypy.annotation.model import SomeTuple, SomeImpossibleValue
from pypy.annotation.factory import NeedGeneralization
@@ -44,6 +45,12 @@
return SomeInteger()
+class __extend__(pairtype(SomeBool, SomeBool)):
+
+ def union((boo1, boo2)):
+ return SomeBool()
+
+
class __extend__(pairtype(SomeString, SomeString)):
def union((str1, str2)):
Modified: pypy/branch/typeinference/pypy/annotation/model.py
==============================================================================
--- pypy/branch/typeinference/pypy/annotation/model.py (original)
+++ pypy/branch/typeinference/pypy/annotation/model.py Mon May 3 19:30:05 2004
@@ -39,6 +39,9 @@
return (self.__class__, self.__dict__) == (other.__class__, other.__dict__)
def __ne__(self, other):
return not (self == other)
+ def __repr__(self):
+ kwds = ', '.join(['%s=%r' % item for item in self.__dict__.items()])
+ return '%s(%s)' % (self.__class__.__name__, kwds)
def contains(self, other):
return pair(self, other).union() == self
@@ -51,8 +54,9 @@
class SomeBool(SomeInteger):
"Stands for true or false."
knowntype = bool
+ nonneg = True
def __init__(self):
- SomeInteger.__init__(self, nonneg=True)
+ pass
class SomeString(SomeObject):
"Stands for an object which is known to be a string."
Modified: pypy/branch/typeinference/pypy/translator/annrpython.py
==============================================================================
--- pypy/branch/typeinference/pypy/translator/annrpython.py (original)
+++ pypy/branch/typeinference/pypy/translator/annrpython.py Mon May 3 19:30:05 2004
@@ -68,7 +68,13 @@
# XXX don't know if it is better to pop from the head or the tail.
# but suspect from the tail is better in the new Factory model.
block, cells = self.pendingblocks.pop()
- self.processblock(block, cells)
+ if self.processblock(block, cells):
+ # When flowin succeeds, i.e. when the analysis progress,
+ # we can tentatively re-schedule the delayed blocks.
+ delay = [(block, None) for block in self.delayedblocks]
+ delay.reverse()
+ self.pendingblocks[:0] = delay
+ del self.delayedblocks[:]
if self.delayedblocks:
raise AnnotatorError('%d block(s) are still blocked' %
len(delayedblocks))
@@ -150,11 +156,8 @@
for factory in e.invalidatefactories:
self.reflowpendingblock(factory.block)
else:
- # When flowin succeeds, i.e. when the analysis progress,
- # we can tentatively re-schedlue the delayed blocks.
- for block in self.delayedblocks:
- self.addpendingblock(block, None)
- del self.delayedblocks[:]
+ return True # progressed
+ return False
def reflowpendingblock(self, block):
self.pendingblocks.append((block, None))
@@ -177,6 +180,7 @@
self.bindinputargs(block, unions)
def flowin(self, block):
+ #print 'Flowing', block, [self.binding(a) for a in block.inputargs]
if block.operations:
for i in range(len(block.operations)):
self.curblockpos = block, i
More information about the Pypy-commit
mailing list