Commits

Maciej Fijalkowski committed d1e8b34

Make sure we allocate floats at even places (and the comments are true)

Comments (0)

Files changed (2)

rpython/jit/backend/llsupport/regalloc.py

 import os
-from rpython.jit.metainterp.history import Const, Box, REF, INT
+from rpython.jit.metainterp.history import Const, Box, REF
 from rpython.rlib.objectmodel import we_are_translated, specialize
 from rpython.jit.metainterp.resoperation import rop
 
         return self.fm.frame_pos(node.val, tp)
 
     def _candidate(self, node):
-        return node.val + 1 == node.next.val
+        return (node.val & 1 == 0) and (node.val + 1 == node.next.val)
         
     def _pop_two(self, tp):
         node = self.master_node
         if newloc is None:
             #
             index = self.get_frame_depth()
-            newloc = self.frame_pos(index, box.type)
-            self.current_frame_depth += size
+            if index & 1 and size == 2:
+                # we can't allocate it at odd position
+                self.freelist._append(index)
+                newloc = self.frame_pos(index + 1, box.type)
+                self.current_frame_depth += 3
+                index += 1 # for test
+            else:
+                newloc = self.frame_pos(index, box.type)
+                self.current_frame_depth += size
             #
             if not we_are_translated():    # extra testing
                 testindex = self.get_loc_index(newloc)

rpython/jit/backend/llsupport/test/test_regalloc.py

         assert l.pop(1, 0).pos == 2
         assert l.pop(1, 0) is None
         l.append(2, Loc(1, 2, 0))
+        # this will not work because the result will be odd
+        assert l.pop(2, 13) is None
+        l.append(1, Loc(3, 1, 0))
         item = l.pop(2, 13)
-        assert item.pos == 1
+        assert item.pos == 2
         assert item.tp == 13
         assert item.size == 2
 
         #
         f0 = BoxFloat()
         locf0 = fm.loc(f0)
-        assert fm.get_loc_index(locf0) == 3
-        assert fm.get_frame_depth() == 5
+        # can't be odd
+        assert fm.get_loc_index(locf0) == 4
+        assert fm.get_frame_depth() == 6
         #
         f1 = BoxFloat()
         locf1 = fm.loc(f1)
-        assert fm.get_loc_index(locf1) == 5
-        assert fm.get_frame_depth() == 7
+        assert fm.get_loc_index(locf1) == 6
+        assert fm.get_frame_depth() == 8
         fm.mark_as_free(b1)
         assert fm.freelist
         b2 = BoxInt()
         p0 = BoxPtr()
         ploc = fm.loc(p0)
         assert fm.get_loc_index(ploc) == 0
-        assert fm.get_frame_depth() == 7
+        assert fm.get_frame_depth() == 8
         assert ploc != loc1
         p1 = BoxPtr()
         p1loc = fm.loc(p1)
-        assert fm.get_loc_index(p1loc) == 7
+        assert fm.get_loc_index(p1loc) == 3
         assert fm.get_frame_depth() == 8
         fm.mark_as_free(p0)
         p2 = BoxPtr()