Author: Antonio Cuni <[email protected]>
Branch: virtual-raw-mallocs
Changeset: r59690:b128c43355bf
Date: 2013-01-03 20:47 +0100
http://bitbucket.org/pypy/pypy/changeset/b128c43355bf/
Log: bah, we need to play this dance to fix the annotator in a couple of
tests in which VRawBuffer would never be instantiated, thus leading
to blocked blocks
diff --git a/pypy/jit/backend/x86/test/test_ztranslation.py
b/pypy/jit/backend/x86/test/test_ztranslation.py
--- a/pypy/jit/backend/x86/test/test_ztranslation.py
+++ b/pypy/jit/backend/x86/test/test_ztranslation.py
@@ -13,6 +13,18 @@
from pypy.config.translationoption import DEFL_GC
from pypy.rlib import rgc
+def fix_annotator_for_vrawbuffer(monkeypatch):
+ from pypy.rlib.nonconst import NonConstant
+ from pypy.jit.metainterp.optimizeopt.virtualize import VRawBufferValue
+ from pypy.jit.metainterp import warmspot
+
+ def my_hook_for_tests(cpu):
+ # this is needed so that the annotator can see it
+ if NonConstant(False):
+ v = VRawBufferValue(cpu, None, -1, None, None)
+ monkeypatch.setattr(warmspot, 'hook_for_tests', my_hook_for_tests)
+
+
class TestTranslationX86(CCompiledMixin):
CPUClass = getcpuclass()
@@ -22,7 +34,8 @@
assert '-msse2' in cbuilder.eci.compile_extra
assert '-mfpmath=sse' in cbuilder.eci.compile_extra
- def test_stuff_translates(self):
+ def test_stuff_translates(self, monkeypatch):
+ fix_annotator_for_vrawbuffer(monkeypatch)
# this is a basic test that tries to hit a number of features and their
# translation:
# - jitting of loops and bridges
@@ -95,9 +108,10 @@
res = self.meta_interp(main, [40, -49])
assert res == expected
- def test_direct_assembler_call_translates(self):
+ def test_direct_assembler_call_translates(self, monkeypatch):
"""Test CALL_ASSEMBLER and the recursion limit"""
from pypy.rlib.rstackovf import StackOverflow
+ fix_annotator_for_vrawbuffer(monkeypatch)
class Thing(object):
def __init__(self, val):
@@ -171,7 +185,8 @@
assert 1024 <= bound <= 131072
assert bound & (bound-1) == 0 # a power of two
- def test_jit_get_stats(self):
+ def test_jit_get_stats(self, monkeypatch):
+ fix_annotator_for_vrawbuffer(monkeypatch)
driver = JitDriver(greens = [], reds = ['i'])
def f():
@@ -201,7 +216,8 @@
t.config.translation.gcremovetypeptr = True
return t
- def test_external_exception_handling_translates(self):
+ def test_external_exception_handling_translates(self, monkeypatch):
+ fix_annotator_for_vrawbuffer(monkeypatch)
jitdriver = JitDriver(greens = [], reds = ['n', 'total'])
class ImDone(Exception):
diff --git a/pypy/jit/metainterp/warmspot.py b/pypy/jit/metainterp/warmspot.py
--- a/pypy/jit/metainterp/warmspot.py
+++ b/pypy/jit/metainterp/warmspot.py
@@ -861,8 +861,11 @@
ts = self.cpu.ts
state = jd.warmstate
maybe_compile_and_run = jd._maybe_compile_and_run_fn
+ cpu = jd.warmstate.cpu
def ll_portal_runner(*args):
+ hook_for_tests(cpu) # usually it's empty, but tests can monkeypatch
+ # it to fix the annotator
start = True
while 1:
try:
@@ -1096,3 +1099,10 @@
graphs = self.translator.graphs
for graph, block, i in find_force_quasi_immutable(graphs):
self.replace_force_quasiimmut_with_direct_call(block.operations[i])
+
+def hook_for_tests():
+ """
+ This function is empty and does nothing. Its only role is to be
+ monkey-patched by tests to "fix" the annotator if needed (see
+ e.g.
x86/test/test_ztranslation::test_external_exception_handling_translates
+ """
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit