[pypy-svn] r37836 - pypy/branch/jit-virtual-world/pypy/jit/codegen/i386

arigo at codespeak.net arigo at codespeak.net
Sat Feb 3 00:11:54 CET 2007


Author: arigo
Date: Sat Feb  3 00:11:52 2007
New Revision: 37836

Modified:
   pypy/branch/jit-virtual-world/pypy/jit/codegen/i386/rgenop.py
Log:
Avoid an issue whereby all variables forced to be in the stack
would end up being copied during an enter_next_block().


Modified: pypy/branch/jit-virtual-world/pypy/jit/codegen/i386/rgenop.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/codegen/i386/rgenop.py	(original)
+++ pypy/branch/jit-virtual-world/pypy/jit/codegen/i386/rgenop.py	Sat Feb  3 00:11:52 2007
@@ -253,16 +253,24 @@
         return mc
 
     def enter_next_block(self, kinds, args_gv):
-##        mc = self.generate_block_code(args_gv)
-##        assert len(self.inputargs_gv) == len(args_gv)
-##        args_gv[:len(args_gv)] = self.inputargs_gv
-##        self.set_coming_from(mc)
-##        self.rgenop.close_mc(mc)
-##        self.start_writing()
-        for i in range(len(args_gv)):
-            op = OpSameAs(args_gv[i])
-            args_gv[i] = op
-            self.operations.append(op)
+        if self.force_in_stack is not None:
+            # force_in_stack would keep the variables alive until the end
+            # of the whole mc block, i.e. past the OpSameAs that we are
+            # about to introduce => duplication of the value.
+            mc = self.generate_block_code(args_gv)
+            assert len(self.inputargs_gv) == len(args_gv)
+            args_gv[:len(args_gv)] = self.inputargs_gv
+            self.set_coming_from(mc)
+            mc.done()
+            self.rgenop.close_mc(mc)
+            self.start_writing()
+        else:
+            # otherwise, we get better register allocation if we write a
+            # single larger mc block
+            for i in range(len(args_gv)):
+                op = OpSameAs(args_gv[i])
+                args_gv[i] = op
+                self.operations.append(op)
         lbl = Label()
         lblop = OpLabel(lbl, args_gv)
         self.operations.append(lblop)



More information about the Pypy-commit mailing list