Author: Richard Plangger <r...@pasra.at>
Branch: vecopt
Changeset: r78584:0d1dc4ba30d3
Date: 2015-07-17 17:19 +0200
http://bitbucket.org/pypy/pypy/changeset/0d1dc4ba30d3/

Log:    trace versioning now compiles each version just once, and attaches
        patches all further guards to the bridge

diff --git a/rpython/jit/backend/llsupport/assembler.py 
b/rpython/jit/backend/llsupport/assembler.py
--- a/rpython/jit/backend/llsupport/assembler.py
+++ b/rpython/jit/backend/llsupport/assembler.py
@@ -69,6 +69,9 @@
         self.rtyper = cpu.rtyper
         self._debug = False
 
+    def attach_bridge(self, failargs, token):
+        raise NotImplementedError
+
     def setup_once(self):
         # the address of the function called by 'new'
         gc_ll_descr = self.cpu.gc_ll_descr
diff --git a/rpython/jit/backend/llsupport/llmodel.py 
b/rpython/jit/backend/llsupport/llmodel.py
--- a/rpython/jit/backend/llsupport/llmodel.py
+++ b/rpython/jit/backend/llsupport/llmodel.py
@@ -97,6 +97,9 @@
                                             inputargs, operations,
                                             looptoken, log=log)
 
+    def attach_bridge(self, faildescr, token):
+        self.assembler.attach_bridge(faildescr, token)
+
     def _setup_frame_realloc(self, translate_support_code):
         FUNC_TP = lltype.Ptr(lltype.FuncType([llmemory.GCREF, lltype.Signed],
                                              llmemory.GCREF))
diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -589,6 +589,10 @@
                                                        rawstart, fullsize)
         return AsmInfo(ops_offset, startpos + rawstart, codeendpos - startpos)
 
+    def attach_bridge(self, failargs, token):
+        rawstart = self.materialize_loop(token)
+        self.patch_jump_for_descr(faildescr, rawstart)
+
     def write_pending_failure_recoveries(self, regalloc):
         # for each pending guard, generate the code of the recovery stub
         # at the end of self.mc.
diff --git a/rpython/jit/metainterp/compile.py 
b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -199,17 +199,19 @@
     if loop.versions is not None:
         token = jitcell_token
         for version in loop.versions:
-            for i, faildescr in enumerate(version.faildescrs):
-                vl = create_empty_loop(metainterp)
-                vl.inputargs = version.inputargs
-                vl.operations = version.operations
-                if i > 0:
-                    vl.operations = vl.copy_operations()
-                vl.original_jitcell_token = jitcell_token
-                send_bridge_to_backend(jitdriver_sd, metainterp_sd,
-                                       faildescr, version.inputargs,
-                                       version.operations, jitcell_token)
-                record_loop_or_bridge(metainterp_sd, vl)
+            if len(version.faildescrs) == 0:
+                continue
+            faildescr = version.faildescrs[0]
+            vl = create_empty_loop(metainterp)
+            vl.inputargs = version.inputargs
+            vl.operations = version.operations
+            vl.original_jitcell_token = jitcell_token
+            send_bridge_to_backend(jitdriver_sd, metainterp_sd,
+                                   faildescr, version.inputargs,
+                                   version.operations, jitcell_token)
+            record_loop_or_bridge(metainterp_sd, vl)
+            for faildescr in version.faildescrs[1:]:
+                cpu.attach_bridge(faildescr, jitcell_token)
     loop.versions = None
 
 def compile_retrace(metainterp, greenkey, start,
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to