[pypy-svn] r75316 - in pypy/branch/multijit-4/pypy/jit/backend: . llgraph test

arigo at codespeak.net arigo at codespeak.net
Sat Jun 12 11:52:54 CEST 2010


Author: arigo
Date: Sat Jun 12 11:52:52 2010
New Revision: 75316

Modified:
   pypy/branch/multijit-4/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/multijit-4/pypy/jit/backend/model.py
   pypy/branch/multijit-4/pypy/jit/backend/test/runner_test.py
Log:
Change the interface: now CALL_ASSEMBLER's descr, which is a LoopToken,
must also contain an 'outermost_jitdriver_sd' with the few attributes
needed by the backend to do the call.  This replaces sticking the
attributes on the cpu, which no longer works in this branch.


Modified: pypy/branch/multijit-4/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/multijit-4/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/multijit-4/pypy/jit/backend/llgraph/llimpl.py	Sat Jun 12 11:52:52 2010
@@ -833,13 +833,16 @@
                     raise Exception("Nonsense type %s" % TYPE)
 
             failindex = self.cpu._execute_token(loop_token)
+            jd = loop_token.outermost_jitdriver_sd
+            assert jd is not None, ("call_assembler(): the loop_token needs "
+                                    "to have 'outermost_jitdriver_sd'")
+            if jd.index_of_virtualizable != -1:
+                vable = args[jd.index_of_virtualizable]
+            else:
+                vable = lltype.nullptr(llmemory.GCREF.TO)
+            assembler_helper_ptr = jd.assembler_helper_adr.ptr  # fish
             try:
-                if self.cpu.index_of_virtualizable != -1:
-                    return self.cpu.assembler_helper_ptr(failindex,
-                        args[self.cpu.index_of_virtualizable])
-                else:
-                    return self.cpu.assembler_helper_ptr(failindex,
-                        lltype.nullptr(llmemory.GCREF.TO))
+                return assembler_helper_ptr(failindex, vable)
             except LLException, lle:
                 assert _last_exception is None, "exception left behind"
                 _last_exception = lle

Modified: pypy/branch/multijit-4/pypy/jit/backend/model.py
==============================================================================
--- pypy/branch/multijit-4/pypy/jit/backend/model.py	(original)
+++ pypy/branch/multijit-4/pypy/jit/backend/model.py	Sat Jun 12 11:52:52 2010
@@ -3,10 +3,6 @@
 
 class AbstractCPU(object):
     supports_floats = False
-    _got_exception = None
-    # assembler_helper_ptr - a pointer to helper to call after a direct
-    #                        assembler call
-    portal_calldescr = None
     done_with_this_frame_void_v = -1
     done_with_this_frame_int_v = -1
     done_with_this_frame_ref_v = -1

Modified: pypy/branch/multijit-4/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/multijit-4/pypy/jit/backend/test/runner_test.py	(original)
+++ pypy/branch/multijit-4/pypy/jit/backend/test/runner_test.py	Sat Jun 12 11:52:52 2010
@@ -1698,16 +1698,23 @@
             assert self.cpu.get_latest_value_int(0) == 10
             called.append(failindex)
             return 4 + 9
-        self.cpu.index_of_virtualizable = -1
-        self.cpu.assembler_helper_ptr = llhelper(lltype.Ptr(lltype.FuncType
-            ([lltype.Signed, llmemory.GCREF], lltype.Signed)), assembler_helper)
-        
+
+        FUNCPTR = lltype.Ptr(lltype.FuncType([lltype.Signed, llmemory.GCREF],
+                                             lltype.Signed))
+        class FakeJitDriverSD:
+            index_of_virtualizable = -1
+            vable_token_descr = None
+            _assembler_helper_ptr = llhelper(FUNCPTR, assembler_helper)
+            assembler_helper_adr = llmemory.cast_ptr_to_adr(
+                _assembler_helper_ptr)
+
         ops = '''
         [i0, i1]
         i2 = int_add(i0, i1)
         finish(i2)'''
         loop = parse(ops)
         looptoken = LoopToken()
+        looptoken.outermost_jitdriver_sd = FakeJitDriverSD()
         self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)
         ARGS = [lltype.Signed, lltype.Signed]
         RES = lltype.Signed
@@ -1739,9 +1746,16 @@
             assert self.cpu.get_latest_value_float(0) == 1.2 + 3.2
             called.append(failindex)
             return 13.5
-        self.cpu.index_of_virtualizable = -1
-        self.cpu.assembler_helper_ptr = llhelper(lltype.Ptr(lltype.FuncType
-            ([lltype.Signed, llmemory.GCREF], lltype.Float)), assembler_helper)
+
+        FUNCPTR = lltype.Ptr(lltype.FuncType([lltype.Signed, llmemory.GCREF],
+                                             lltype.Float))
+        class FakeJitDriverSD:
+            index_of_virtualizable = -1
+            vable_token_descr = None
+            _assembler_helper_ptr = llhelper(FUNCPTR, assembler_helper)
+            assembler_helper_adr = llmemory.cast_ptr_to_adr(
+                _assembler_helper_ptr)
+
         ARGS = [lltype.Float, lltype.Float]
         RES = lltype.Float
         self.cpu.portal_calldescr = self.cpu.calldescrof(
@@ -1753,6 +1767,7 @@
         finish(f2)'''
         loop = parse(ops)
         looptoken = LoopToken()
+        looptoken.outermost_jitdriver_sd = FakeJitDriverSD()
         self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)
         self.cpu.set_future_value_float(0, 1.2)
         self.cpu.set_future_value_float(1, 2.3)



More information about the Pypy-commit mailing list