[pypy-svn] r34009 - pypy/dist/pypy/jit/timeshifter/test
ac at codespeak.net
ac at codespeak.net
Wed Nov 1 13:13:24 CET 2006
Author: ac
Date: Wed Nov 1 13:13:23 2006
New Revision: 34009
Modified:
pypy/dist/pypy/jit/timeshifter/test/test_portal.py
pypy/dist/pypy/jit/timeshifter/test/test_promotion.py
pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py
Log:
Move a test using the _dont_cache_ hack to use a portal and remove the hack.
Modified: pypy/dist/pypy/jit/timeshifter/test/test_portal.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_portal.py (original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_portal.py Wed Nov 1 13:13:23 2006
@@ -130,3 +130,42 @@
res = self.timeshift_from_portal(main, recognizetable, [0], policy=P_NOVIRTUAL)
assert res >= 0
+
+ def test_method_call_promote(self):
+ class Base(object):
+ pass
+ class Int(Base):
+ def __init__(self, n):
+ self.n = n
+ def double(self):
+ return Int(self.n * 2)
+ def get(self):
+ return self.n
+ class Str(Base):
+ def __init__(self, s):
+ self.s = s
+ def double(self):
+ return Str(self.s + self.s)
+ def get(self):
+ return ord(self.s[4])
+
+ def ll_make(n):
+ if n > 0:
+ return Int(n)
+ else:
+ return Str('123')
+
+ def ll_function(n):
+ hint(None, global_merge_point=True)
+ o = ll_make(n)
+ hint(o.__class__, promote=True)
+ return o.double().get()
+
+ res = self.timeshift_from_portal(ll_function, ll_function, [5], policy=P_NOVIRTUAL)
+ assert res == 10
+ self.check_insns(indirect_call=0)
+
+ res = self.timeshift_from_portal(ll_function, ll_function, [0], policy=P_NOVIRTUAL)
+ assert res == ord('2')
+ self.check_insns(indirect_call=0)
+
Modified: pypy/dist/pypy/jit/timeshifter/test/test_promotion.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_promotion.py (original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_promotion.py Wed Nov 1 13:13:23 2006
@@ -223,45 +223,6 @@
self.check_insns(indirect_call=2)
- def test_method_call_promote(self):
- class Base(object):
- pass
- class Int(Base):
- def __init__(self, n):
- self.n = n
- def double(self):
- return Int(self.n * 2)
- def get(self):
- return self.n
- class Str(Base):
- def __init__(self, s):
- self.s = s
- def double(self):
- return Str(self.s + self.s)
- def get(self):
- return ord(self.s[4])
-
- def ll_make(n):
- if n > 0:
- return Int(n)
- else:
- return Str('123')
-
- def ll_function(n):
- hint(None, global_merge_point=True)
- o = ll_make(n)
- hint(o.__class__, promote=True)
- return o.double().get()
- ll_function._dont_cache_ = True
-
- res = self.timeshift(ll_function, [5], [], policy=P_NOVIRTUAL)
- assert res == 10
- self.check_insns(indirect_call=0)
-
- res = self.timeshift(ll_function, [0], [], policy=P_NOVIRTUAL)
- assert res == ord('2')
- self.check_insns(indirect_call=0)
-
def test_mixed_merges(self):
def ll_function(x, y, z, k):
if x:
Modified: pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py (original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py Wed Nov 1 13:13:23 2006
@@ -222,14 +222,9 @@
from pypy.translator.tool.graphpage import FlowGraphPage
FlowGraphPage(t, ha.translator.graphs).display()
- if getattr(ll_function, '_dont_cache_', False):
- # XXX TEMPORARY: for now, caching doesn't work in the presence
- # of global caches
- pass
- else:
- cache = self.__dict__.copy()
- self._cache[key] = cache, getargtypes(rtyper.annotator, values)
- self._cache_order.append(key)
+ cache = self.__dict__.copy()
+ self._cache[key] = cache, getargtypes(rtyper.annotator, values)
+ self._cache_order.append(key)
return values
def annotate_interface_functions(self):
More information about the Pypy-commit
mailing list