[pypy-svn] r22792 - in pypy/dist/pypy/jit: . test
pedronis at codespeak.net
pedronis at codespeak.net
Sat Jan 28 15:19:29 CET 2006
Author: pedronis
Date: Sat Jan 28 15:19:27 2006
New Revision: 22792
Modified:
pypy/dist/pypy/jit/hintmodel.py
pypy/dist/pypy/jit/test/test_hint_annotation.py
Log:
(arre, arigo, pedronis)
getfield for immutable structures in the hint annotator.
Modified: pypy/dist/pypy/jit/hintmodel.py
==============================================================================
--- pypy/dist/pypy/jit/hintmodel.py (original)
+++ pypy/dist/pypy/jit/hintmodel.py Sat Jan 28 15:19:27 2006
@@ -3,9 +3,9 @@
from pypy.jit.hintbookkeeper import getbookkeeper
from pypy.rpython.lltypesystem import lltype
-UNARY_OPERATIONS = "same_as hint".split()
+UNARY_OPERATIONS = "same_as hint getfield".split()
-BINARY_OPERATIONS = "int_add int_sub int_gt int_eq".split()
+BINARY_OPERATIONS = "int_add int_sub int_mul int_gt int_eq".split()
class OriginTreeNode(object):
@@ -65,6 +65,15 @@
o1.fixed = True
return SomeLLConcreteValue(hs_c1.concretetype)
+ def getfield(hs_c1, hs_fieldname):
+ S = hs_c1.concretetype.TO
+ FIELD_TYPE = getattr(S, hs_fieldname.const)
+ if S._hints.get('immutable', False):
+ origin = getbookkeeper().myorigin()
+ origin.merge(hs_c1.origins)
+ return SomeLLAbstractConstant(FIELD_TYPE, {origin: True})
+ else:
+ return SomeLLAbstractVariable(FIELD_TYPE)
class __extend__(pairtype(SomeLLAbstractValue, SomeLLAbstractValue)):
@@ -89,7 +98,7 @@
origin.merge(hs_c2.origins)
return SomeLLAbstractConstant(lltype.Signed, {origin: True})
- int_sub = int_add
+ int_mul = int_sub = int_add
def int_gt((hs_c1, hs_c2)):
origin = getbookkeeper().myorigin()
Modified: pypy/dist/pypy/jit/test/test_hint_annotation.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_hint_annotation.py (original)
+++ pypy/dist/pypy/jit/test/test_hint_annotation.py Sat Jan 28 15:19:27 2006
@@ -157,6 +157,17 @@
assert hs.concretetype == lltype.Signed
assert len(hs.origins) == 2
+def test_simple_struct():
+ S = lltype.GcStruct('helloworld', ('hello', lltype.Signed),
+ ('world', lltype.Signed),
+ hints={'immutable': True})
+ def ll_function(s):
+ return s.hello * s.world
+ hs = hannotate(ll_function, [annmodel.SomePtr(lltype.Ptr(S))])
+ assert isinstance(hs, SomeLLAbstractConstant)
+ assert hs.concretetype == lltype.Signed
+ assert len(hs.origins) == 1
+ assert len(hs.origins.keys()[0].origins) == 2
More information about the Pypy-commit
mailing list