[pypy-commit] pypy arm-backend-2: enable tests that check and require gcremovetypeptr
bivab
noreply at buildbot.pypy.org
Wed Feb 15 18:35:32 CET 2012
Author: David Schneider <david.schneider at picle.org>
Branch: arm-backend-2
Changeset: r52518:70dd96853661
Date: 2012-02-15 11:22 +0100
http://bitbucket.org/pypy/pypy/changeset/70dd96853661/
Log: enable tests that check and require gcremovetypeptr
diff --git a/pypy/jit/backend/arm/test/test_zrpy_gc.py b/pypy/jit/backend/arm/test/test_zrpy_gc.py
--- a/pypy/jit/backend/arm/test/test_zrpy_gc.py
+++ b/pypy/jit/backend/arm/test/test_zrpy_gc.py
@@ -94,9 +94,8 @@
#
t = TranslationContext()
t.config.translation.gc = gc
- # The ARM backend does not support this option
- #if gc != 'boehm':
- # t.config.translation.gcremovetypeptr = True
+ if gc != 'boehm':
+ t.config.translation.gcremovetypeptr = True
for name, value in kwds.items():
setattr(t.config.translation, name, value)
ann = t.buildannotator(policy=annpolicy.StrictAnnotatorPolicy())
diff --git a/pypy/jit/backend/arm/test/test_ztranslation.py b/pypy/jit/backend/arm/test/test_ztranslation.py
--- a/pypy/jit/backend/arm/test/test_ztranslation.py
+++ b/pypy/jit/backend/arm/test/test_ztranslation.py
@@ -173,3 +173,87 @@
bound = res & ~255
assert 1024 <= bound <= 131072
assert bound & (bound-1) == 0 # a power of two
+
+class TestTranslationRemoveTypePtrARM(CCompiledMixin):
+ CPUClass = getcpuclass()
+
+ def _get_TranslationContext(self):
+ t = TranslationContext()
+ t.config.translation.gc = DEFL_GC # 'hybrid' or 'minimark'
+ t.config.translation.gcrootfinder = 'shadowstack'
+ t.config.translation.list_comprehension_operations = True
+ t.config.translation.gcremovetypeptr = True
+ return t
+
+ def test_external_exception_handling_translates(self):
+ jitdriver = JitDriver(greens = [], reds = ['n', 'total'])
+
+ class ImDone(Exception):
+ def __init__(self, resvalue):
+ self.resvalue = resvalue
+
+ @dont_look_inside
+ def f(x, total):
+ if x <= 30:
+ raise ImDone(total * 10)
+ if x > 200:
+ return 2
+ raise ValueError
+ @dont_look_inside
+ def g(x):
+ if x > 150:
+ raise ValueError
+ return 2
+ class Base:
+ def meth(self):
+ return 2
+ class Sub(Base):
+ def meth(self):
+ return 1
+ @dont_look_inside
+ def h(x):
+ if x < 20000:
+ return Sub()
+ else:
+ return Base()
+ def myportal(i):
+ set_param(jitdriver, "threshold", 3)
+ set_param(jitdriver, "trace_eagerness", 2)
+ total = 0
+ n = i
+ while True:
+ jitdriver.can_enter_jit(n=n, total=total)
+ jitdriver.jit_merge_point(n=n, total=total)
+ try:
+ total += f(n, total)
+ except ValueError:
+ total += 1
+ try:
+ total += g(n)
+ except ValueError:
+ total -= 1
+ n -= h(n).meth() # this is to force a GUARD_CLASS
+ def main(i):
+ try:
+ myportal(i)
+ except ImDone, e:
+ return e.resvalue
+
+ # XXX custom fishing, depends on the exact env var and format
+ logfile = udir.join('test_ztranslation.log')
+ os.environ['PYPYLOG'] = 'jit-log-opt:%s' % (logfile,)
+ try:
+ res = self.meta_interp(main, [400])
+ assert res == main(400)
+ finally:
+ del os.environ['PYPYLOG']
+
+ guard_class = 0
+ for line in open(str(logfile)):
+ if 'guard_class' in line:
+ guard_class += 1
+ # if we get many more guard_classes, it means that we generate
+ # guards that always fail (the following assert's original purpose
+ # is to catch the following case: each GUARD_CLASS is misgenerated
+ # and always fails with "gcremovetypeptr")
+ assert 0 < guard_class < 10
More information about the pypy-commit
mailing list