[pypy-commit] pypy jit-multilabel: allow the metainterpreter to request an label by placing it in the unoptimized trace

hakanardo noreply at buildbot.pypy.org
Sat Dec 17 20:32:24 CET 2011


Author: Hakan Ardo <hakan at debian.org>
Branch: jit-multilabel
Changeset: r50632:7f2f31e8e4bd
Date: 2011-12-17 18:38 +0100
http://bitbucket.org/pypy/pypy/changeset/7f2f31e8e4bd/

Log:	allow the metainterpreter to request an label by placing it in the
	unoptimized trace

diff --git a/pypy/jit/metainterp/compile.py b/pypy/jit/metainterp/compile.py
--- a/pypy/jit/metainterp/compile.py
+++ b/pypy/jit/metainterp/compile.py
@@ -129,7 +129,8 @@
         part.resume_at_jump_descr = resume_at_jump_descr
         part.operations = [ResOperation(rop.LABEL, inputargs, None, descr=TargetToken(jitcell_token))] + \
                           [h_ops[i].clone() for i in range(start, len(h_ops))] + \
-                          [ResOperation(rop.JUMP, jumpargs, None, descr=jitcell_token)]
+                          [ResOperation(rop.LABEL, jumpargs, None, descr=jitcell_token)]
+
         try:
             optimize_trace(metainterp_sd, part, jitdriver_sd.warmstate.enable_opts)
         except InvalidLoop:
diff --git a/pypy/jit/metainterp/optimizeopt/simplify.py b/pypy/jit/metainterp/optimizeopt/simplify.py
--- a/pypy/jit/metainterp/optimizeopt/simplify.py
+++ b/pypy/jit/metainterp/optimizeopt/simplify.py
@@ -35,6 +35,9 @@
         pass
 
     def optimize_LABEL(self, op):
+        descr = op.getdescr()
+        if isinstance(descr, JitCellToken):
+            return self.optimize_JUMP(op.copy_and_change(rop.JUMP))
         self.last_label_descr = op.getdescr()
         self.emit_operation(op)
         
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_util.py b/pypy/jit/metainterp/optimizeopt/test/test_util.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_util.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_util.py
@@ -435,7 +435,7 @@
         token = JitCellToken() 
         preamble.operations = [ResOperation(rop.LABEL, inputargs, None, descr=TargetToken(token))] + \
                               operations +  \
-                              [ResOperation(rop.JUMP, jump_args, None, descr=token)]
+                              [ResOperation(rop.LABEL, jump_args, None, descr=token)]
         self._do_optimize_loop(preamble, call_pure_results)
 
         assert preamble.operations[-1].getopnum() == rop.LABEL
diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -71,7 +71,6 @@
         loop = self.optimizer.loop
         self.optimizer.clear_newoperations()
 
-
         start_label = loop.operations[0]
         if start_label.getopnum() == rop.LABEL:
             loop.operations = loop.operations[1:]
@@ -82,7 +81,7 @@
             start_label = None            
 
         jumpop = loop.operations[-1]
-        if jumpop.getopnum() == rop.JUMP:
+        if jumpop.getopnum() == rop.JUMP or jumpop.getopnum() == rop.LABEL:
             loop.operations = loop.operations[:-1]
         else:
             jumpop = None
@@ -92,28 +91,30 @@
 
         if not jumpop:
             return
-        
-        if self.jump_to_already_compiled_trace(jumpop):
-            # Found a compiled trace to jump to
-            if self.short:
-                # Construct our short preamble
-                self.close_bridge(start_label)
-            return
 
         cell_token = jumpop.getdescr()
         assert isinstance(cell_token, JitCellToken)
         stop_label = ResOperation(rop.LABEL, jumpop.getarglist(), None, TargetToken(cell_token))
 
-        if self.did_import and self.jump_to_start_label(start_label, stop_label):
-            # Initial label matches, jump to it
-            jumpop = ResOperation(rop.JUMP, stop_label.getarglist(), None,
-                                  descr=start_label.getdescr())
-            if self.short:
-                # Construct our short preamble
-                self.close_loop(start_label, jumpop)
-            else:
-                self.optimizer.send_extra_operation(jumpop)
-            return
+        
+        if jumpop.getopnum() == rop.JUMP:
+            if self.jump_to_already_compiled_trace(jumpop):
+                # Found a compiled trace to jump to
+                if self.short:
+                    # Construct our short preamble
+                    self.close_bridge(start_label)
+                return
+
+            if self.jump_to_start_label(start_label, stop_label):
+                # Initial label matches, jump to it
+                jumpop = ResOperation(rop.JUMP, stop_label.getarglist(), None,
+                                      descr=start_label.getdescr())
+                if self.short:
+                    # Construct our short preamble
+                    self.close_loop(start_label, jumpop)
+                else:
+                    self.optimizer.send_extra_operation(jumpop)
+                return
 
         # Found nothing to jump to, emit a label instead
         self.optimizer.flush()


More information about the pypy-commit mailing list