[pypy-svn] r60279 - in pypy/branch/oo-jit/pypy: jit/hintannotator/test rpython/ootypesystem
antocuni at codespeak.net
antocuni at codespeak.net
Tue Dec 2 14:50:09 CET 2008
Author: antocuni
Date: Tue Dec 2 14:50:07 2008
New Revision: 60279
Modified:
pypy/branch/oo-jit/pypy/jit/hintannotator/test/test_annotator.py
pypy/branch/oo-jit/pypy/rpython/ootypesystem/rdict.py
Log:
make sure that getitem on a green dictionary returns a green on ootype. For
now, it's enough to add oopspec to the right function, but in theory when this
skipped test pass it will work also without oopspec.
Modified: pypy/branch/oo-jit/pypy/jit/hintannotator/test/test_annotator.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/hintannotator/test/test_annotator.py (original)
+++ pypy/branch/oo-jit/pypy/jit/hintannotator/test/test_annotator.py Tue Dec 2 14:50:07 2008
@@ -979,6 +979,31 @@
hs = self.hannotate(f, [int], policy=P)
assert hs.is_green()
+ def test_getitem_deepfrozen_dict(self):
+ d = {1: 2, 2: 4, 3: 9}
+ def f(k):
+ d1 = hint(d, deepfreeze=True)
+ k1 = hint(k, concrete=True)
+ return d1[k1]
+ hs = self.hannotate(f, [int], policy=P_OOPSPEC_NOVIRTUAL)
+ assert hs.myorigin
+ assert hs.is_green()
+
+ def test_missing_myorigin(self):
+ py.test.skip('do we want this to pass?')
+ def g(k):
+ if k:
+ return k
+ else:
+ raise KeyError
+ def f(k):
+ k1 = hint(k, concrete=True)
+ return g(k)
+ hs = self.hannotate(f, [int], policy=P_OOPSPEC_NOVIRTUAL)
+ assert hs.myorigin
+ assert hs.is_green()
+
+
class TestLLType(BaseAnnotatorTest):
type_system = 'lltype'
@@ -1105,12 +1130,6 @@
class TestOOType(BaseAnnotatorTest):
type_system = 'ootype'
malloc = property(lambda self: ootype.new)
-
- def fixpolicy(self, policy):
- import copy
- newpolicy = copy.copy(policy)
- newpolicy.oopspec = False
- return newpolicy
def make_struct(self, name, *fields, **kwds):
fields = dict(fields)
Modified: pypy/branch/oo-jit/pypy/rpython/ootypesystem/rdict.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/ootypesystem/rdict.py (original)
+++ pypy/branch/oo-jit/pypy/rpython/ootypesystem/rdict.py Tue Dec 2 14:50:07 2008
@@ -307,12 +307,13 @@
value = it.ll_current_value()
d1.ll_set(key, value)
-
def ll_dict_getitem(d, key):
if d.ll_contains(key):
return d.ll_get(key)
else:
raise KeyError
+ll_dict_getitem.oopspec = 'dict.getitem(d, key)'
+ll_dict_getitem.oopargcheck = lambda d, key: bool(d)
def ll_dict_delitem(d, key):
if not d.ll_remove(key):
More information about the Pypy-commit
mailing list