Author: David Schneider <[email protected]>
Branch: arm-backend-2
Changeset: r52281:85839a0e54fe
Date: 2012-02-03 16:42 +0100
http://bitbucket.org/pypy/pypy/changeset/85839a0e54fe/
Log: remove an obsolete translation test, import another translation test
from the x86 backend and add a conftest option to explicitly run
translation tests
diff --git a/pypy/jit/backend/arm/test/conftest.py
b/pypy/jit/backend/arm/test/conftest.py
new file mode 100644
--- /dev/null
+++ b/pypy/jit/backend/arm/test/conftest.py
@@ -0,0 +1,12 @@
+"""
+This conftest adds an option to run the translation tests which by default will
+be disabled.
+"""
+
+def pytest_addoption(parser):
+ group = parser.getgroup('translation test options')
+ group.addoption('--run-translation-tests',
+ action="store_true",
+ default=False,
+ dest="run_translation_tests",
+ help="run tests that translate code")
diff --git a/pypy/jit/backend/arm/test/support.py
b/pypy/jit/backend/arm/test/support.py
--- a/pypy/jit/backend/arm/test/support.py
+++ b/pypy/jit/backend/arm/test/support.py
@@ -1,5 +1,6 @@
import os
import py
+import pytest
from pypy.rpython.lltypesystem import lltype, rffi
from pypy.jit.backend.detect_cpu import getcpuclass
@@ -29,6 +30,11 @@
def skip_unless_arm():
check_skip(os.uname()[4])
+def skip_unless_run_translation():
+ if not pytest.config.option.run_translation_tests:
+ py.test.skip("Test skipped beause --run-translation-tests option is
not set")
+
+
def requires_arm_as():
import commands
i = commands.getoutput("%s -version </dev/null -o /dev/null 2>&1" % AS)
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
@@ -15,7 +15,10 @@
from pypy.tool.udir import udir
from pypy.config.translationoption import DEFL_GC
from pypy.jit.backend.arm.test.support import skip_unless_arm
+from pypy.jit.backend.arm.test.support import skip_unless_run_translation
skip_unless_arm()
+skip_unless_run_translation()
+
class X(object):
def __init__(self, x=0):
diff --git a/pypy/jit/backend/arm/test/test_ztranslate_backend.py
b/pypy/jit/backend/arm/test/test_ztranslate_backend.py
deleted file mode 100644
--- a/pypy/jit/backend/arm/test/test_ztranslate_backend.py
+++ /dev/null
@@ -1,62 +0,0 @@
-import py
-import os
-from pypy.jit.metainterp.history import (AbstractFailDescr,
- AbstractDescr,
- BasicFailDescr,
- BoxInt, Box, BoxPtr,
- ConstInt, ConstPtr,
- BoxObj, Const,
- ConstObj, BoxFloat, ConstFloat)
-from pypy.jit.metainterp.history import JitCellToken
-from pypy.jit.metainterp.resoperation import ResOperation, rop
-from pypy.rpython.test.test_llinterp import interpret
-from pypy.jit.backend.detect_cpu import getcpuclass
-from pypy.jit.backend.arm.runner import ArmCPU
-from pypy.tool.udir import udir
-from pypy.jit.backend.arm.test.support import skip_unless_arm
-skip_unless_arm()
-
-class FakeStats(object):
- pass
-cpu = getcpuclass()(rtyper=None, stats=FakeStats(),
translate_support_code=True)
-class TestBackendTranslation(object):
- def test_compile_bridge(self):
- def loop():
- i0 = BoxInt()
- i1 = BoxInt()
- i2 = BoxInt()
- faildescr1 = BasicFailDescr(1)
- faildescr2 = BasicFailDescr(2)
- looptoken = JitCellToken()
- operations = [
- ResOperation(rop.INT_ADD, [i0, ConstInt(1)], i1),
- ResOperation(rop.INT_LE, [i1, ConstInt(9)], i2),
- ResOperation(rop.GUARD_TRUE, [i2], None, descr=faildescr1),
- ResOperation(rop.JUMP, [i1], None, descr=looptoken),
- ]
- inputargs = [i0]
- operations[2].setfailargs([i1])
- cpu.setup_once()
- cpu.compile_loop(inputargs, operations, looptoken)
-
- i1b = BoxInt()
- i3 = BoxInt()
- bridge = [
- ResOperation(rop.INT_LE, [i1b, ConstInt(19)], i3),
- ResOperation(rop.GUARD_TRUE, [i3], None, descr=faildescr2),
- ResOperation(rop.JUMP, [i1b], None, descr=looptoken),
- ]
- bridge[1].setfailargs([i1b])
- assert looptoken._arm_func_addr != 0
- assert looptoken._arm_loop_code != 0
- cpu.compile_bridge(faildescr1, [i1b], bridge, looptoken, True)
-
- fail = cpu.execute_token(looptoken, 2)
- res = cpu.get_latest_value_int(0)
- return fail.identifier * 1000 + res
-
- logfile = udir.join('test_ztranslation.log')
- os.environ['PYPYLOG'] = 'jit-log-opt:%s' % (logfile,)
- res = interpret(loop, [], insist=True)
- assert res == 2020
-
diff --git a/pypy/jit/backend/x86/test/test_ztranslation.py
b/pypy/jit/backend/arm/test/test_ztranslation.py
copy from pypy/jit/backend/x86/test/test_ztranslation.py
copy to pypy/jit/backend/arm/test/test_ztranslation.py
--- a/pypy/jit/backend/x86/test/test_ztranslation.py
+++ b/pypy/jit/backend/arm/test/test_ztranslation.py
@@ -8,18 +8,23 @@
from pypy.jit.backend.test.support import CCompiledMixin
from pypy.jit.codewriter.policy import StopAtXPolicy
from pypy.translator.translator import TranslationContext
-from pypy.jit.backend.x86.arch import IS_X86_32, IS_X86_64
from pypy.config.translationoption import DEFL_GC
-from pypy.rlib import rgc
+from pypy.jit.backend.arm.test.support import skip_unless_arm
+from pypy.jit.backend.arm.test.support import skip_unless_run_translation
+skip_unless_arm()
+skip_unless_run_translation()
-class TestTranslationX86(CCompiledMixin):
+class TestTranslationARM(CCompiledMixin):
CPUClass = getcpuclass()
+ def _get_TranslationContext(self):
+ t = TranslationContext()
+ t.config.translation.gc = DEFL_GC # 'hybrid' or 'minimark'
+ t.config.translation.gcrootfinder = 'shadowstack'
+ return t
+
def _check_cbuilder(self, cbuilder):
- # We assume here that we have sse2. If not, the CPUClass
- # needs to be changed to CPU386_NO_SSE2, but well.
- assert '-msse2' in cbuilder.eci.compile_extra
- assert '-mfpmath=sse' in cbuilder.eci.compile_extra
+ import pdb; pdb.set_trace()
def test_stuff_translates(self):
# this is a basic test that tries to hit a number of features and their
@@ -168,88 +173,3 @@
bound = res & ~255
assert 1024 <= bound <= 131072
assert bound & (bound-1) == 0 # a power of two
-
-
-class TestTranslationRemoveTypePtrX86(CCompiledMixin):
- CPUClass = getcpuclass()
-
- def _get_TranslationContext(self):
- t = TranslationContext()
- t.config.translation.gc = DEFL_GC # 'hybrid' or 'minimark'
- t.config.translation.gcrootfinder = 'asmgcc'
- 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
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit