[pypy-svn] r79255 - pypy/branch/arm-backend/pypy/jit/backend/arm

david at codespeak.net david at codespeak.net
Thu Nov 18 15:30:14 CET 2010


Author: david
Date: Thu Nov 18 15:30:12 2010
New Revision: 79255

Modified:
   pypy/branch/arm-backend/pypy/jit/backend/arm/assembler.py
   pypy/branch/arm-backend/pypy/jit/backend/arm/regalloc.py
Log:
Improve argument decoding when entering a bridge

Modified: pypy/branch/arm-backend/pypy/jit/backend/arm/assembler.py
==============================================================================
--- pypy/branch/arm-backend/pypy/jit/backend/arm/assembler.py	(original)
+++ pypy/branch/arm-backend/pypy/jit/backend/arm/assembler.py	Thu Nov 18 15:30:12 2010
@@ -77,7 +77,7 @@
                 stack_loc = self.decode32(enc, i+1)
                 value = self.decode32(stack, (frame_depth - stack_loc)*WORD)
                 i += 4
-            else: # an int for now
+            else: # an int in a reg location
                 reg = ord(enc[i])
                 value = self.decode32(regs, reg*WORD)
 
@@ -94,6 +94,31 @@
         self.fail_boxes_count = fail_index
         return descr
 
+    def update_bridge_bindings(self, enc, inputargs, regalloc):
+        # first word contains frame depth
+        j = 4
+        for i in range(len(inputargs)):
+            res = enc[j]
+            if res == '\xFF':
+                assert 0, 'reached end of encoded area'
+            # XXX decode imm and and stack locs and REFs
+            while res == '\xFE':
+                j += 1
+                res = enc[j]
+
+            assert res == '\xEF' # only int location for now
+            j += 1
+            res = enc[j]
+            if res == '\xFD': # imm location
+                assert 0, 'fail'
+            elif res == '\xFC': # stack location
+                stack_loc = self.decode32(enc, j+1)
+                loc = regalloc.make_sure_var_in_reg(inputargs[i])
+                self.mc.LDR_ri(loc.value, r.fp.value, -stack_loc)
+                j += 4
+            else: # reg location
+                regalloc.force_allocate_reg(inputargs[i], selected_reg=r.all_regs[ord(res)])
+            j += 1
     def decode32(self, mem, index):
         highval = ord(mem[index+3])
         if highval >= 128:
@@ -271,7 +296,7 @@
         loop_head=self.mc.curraddr()
         looptoken._arm_bootstrap_code = loop_start
         looptoken._arm_loop_code = loop_head
-        print inputargs, operations
+        print 'Loop', inputargs, operations
         self._walk_operations(operations, regalloc)
 
         self._patch_sp_offset(sp_patch_location, regalloc)
@@ -353,11 +378,12 @@
         longevity = compute_vars_longevity(inputargs, operations)
         regalloc = ARMRegisterManager(longevity, assembler=self, frame_manager=ARMFrameManager())
 
-        regalloc.update_bindings(enc, inputargs)
         bridge_head = self.mc.curraddr()
+        self.update_bridge_bindings(enc, inputargs, regalloc)
 
+        print 'Bridge', inputargs, operations
         self._walk_operations(operations, regalloc)
-        self.gen_func_epilog()
+
         print 'Done building bridges'
         self.patch_trace(faildescr, bridge_head)
         print 'Done patching trace'

Modified: pypy/branch/arm-backend/pypy/jit/backend/arm/regalloc.py
==============================================================================
--- pypy/branch/arm-backend/pypy/jit/backend/arm/regalloc.py	(original)
+++ pypy/branch/arm-backend/pypy/jit/backend/arm/regalloc.py	Thu Nov 18 15:30:12 2010
@@ -14,18 +14,6 @@
     def __init__(self, longevity, frame_manager=None, assembler=None):
         RegisterManager.__init__(self, longevity, frame_manager, assembler)
 
-    def update_bindings(self, enc, inputargs):
-        # first word contains frame depth
-        j = 4
-        for i in range(len(inputargs)):
-            # XXX decode imm and and stack locs and REFs
-            while enc[j] == '\xFE':
-                j += 1
-            assert enc[j] == '\xEF'
-            j += 1
-            self.force_allocate_reg(inputargs[i], selected_reg=r.all_regs[ord(enc[j])])
-            j += 1
-
     def convert_to_imm(self, c):
         if isinstance(c, ConstInt):
             return locations.ImmLocation(c.value)



More information about the Pypy-commit mailing list