[pypy-svn] r51221 - in pypy/branch/jit-refactoring/pypy/jit/rainbow: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Sat Feb 2 20:13:42 CET 2008


Author: cfbolz
Date: Sat Feb  2 20:13:40 2008
New Revision: 51221

Modified:
   pypy/branch/jit-refactoring/pypy/jit/rainbow/bytecode.py
   pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py
Log:
support hint(variable=True). if only supporting hint(promote=True) were as easy


Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/bytecode.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/bytecode.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/bytecode.py	Sat Feb  2 20:13:40 2008
@@ -418,7 +418,7 @@
         block = self.current_block
         if (arg, block) in self.redvar_positions:
             # already converted
-            return self.redvar_positions[arg]
+            return self.redvar_positions[arg, block]
         self.emit("make_redbox")
         resultindex = self.register_redvar((arg, block))
         argindex = self.green_position(arg)
@@ -441,11 +441,13 @@
             color = "red"
         return color
         
-    def register_redvar(self, arg):
+    def register_redvar(self, arg, where=-1):
         assert arg not in self.redvar_positions
-        self.redvar_positions[arg] = result = self.free_red[self.current_block]
-        self.free_red[self.current_block] += 1
-        return result
+        if where == -1:
+            where = self.free_red[self.current_block]
+            self.free_red[self.current_block] += 1
+        self.redvar_positions[arg] = where
+        return where
 
     def redvar_position(self, arg):
         return self.redvar_positions[arg]
@@ -510,6 +512,14 @@
             assert self.hannotator.binding(result).is_green()
             self.register_greenvar(result, self.green_position(arg))
             return
+        if "variable" in hints:
+            assert not self.hannotator.binding(result).is_green()
+            if self.hannotator.binding(arg).is_green():
+                resultindex = self.convert_to_red(arg)
+                self.register_redvar(result, resultindex)
+            else:
+                self.register_redvar(result, self.redvar_position(arg))
+            return
         XXX
 
 

Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py	Sat Feb  2 20:13:40 2008
@@ -176,7 +176,7 @@
 
 class SimpleTests(AbstractInterpretationTest):
     def test_simple_fixed(self):
-        py.test.skip("green return not working")
+        py.test.skip("green return")
         def ll_function(x, y):
             return hint(x + y, concrete=True)
         res = self.interpret(ll_function, [5, 7])
@@ -359,7 +359,6 @@
         self.check_insns({'int_gt': 1, 'int_add': 2, 'int_sub': 2})
 
     def test_merge_3_redconsts_before_return(self):
-        py.test.skip("XXX hint(variable=True) not implemented yet")
         def ll_function(x):
             if x > 2:
                 y = hint(54, variable=True)



More information about the Pypy-commit mailing list