Antonio Cuni avatar Antonio Cuni committed b128c43

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

Comments (0)

Files changed (2)

pypy/jit/backend/x86/test/test_ztranslation.py

 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()
 
         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
         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):
         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():
         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):

pypy/jit/metainterp/warmspot.py

         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:
         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
+    """
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.