Commits

Armin Rigo committed 517570d

Compress the numerous lists 'rd_locs' into 2 bytes instead of WORD bytes
per entry.

Comments (0)

Files changed (3)

rpython/jit/backend/llsupport/assembler.py

         else:
             coeff = 2
         for pos in descr.rd_locs:
-            if pos == -1:
+            pos = rffi.cast(lltype.Signed, pos)
+            if pos == 0xFFFF:
                 continue
-            elif pos < GPR_REGS * WORD:
-                locs.append(self.cpu.gen_regs[pos // WORD])
-            elif pos < (GPR_REGS + XMM_REGS * coeff) * WORD:
-                pos = (pos // WORD - GPR_REGS) // coeff
+            elif pos < GPR_REGS:
+                locs.append(self.cpu.gen_regs[pos])
+            elif pos < GPR_REGS + XMM_REGS * coeff:
+                pos = (pos - GPR_REGS) // coeff
                 locs.append(self.cpu.float_regs[pos])
             else:
-                i = pos // WORD - self.cpu.JITFRAME_FIXED_SIZE
+                i = pos - self.cpu.JITFRAME_FIXED_SIZE
                 assert i >= 0
                 tp = inputargs[input_i].type
                 locs.append(self.new_stack_loc(i, pos, tp))
         fail_descr = cast_instance_to_gcref(guardtok.faildescr)
         fail_descr = rffi.cast(lltype.Signed, fail_descr)
         base_ofs = self.cpu.get_baseofs_of_frame_field()
-        positions = [0] * len(guardtok.fail_locs)
+        positions = [rffi.cast(rffi.USHORT, 0)] * len(guardtok.fail_locs)
         for i, loc in enumerate(guardtok.fail_locs):
             if loc is None:
-                positions[i] = -1
+                position = 0xFFFF
             elif loc.is_stack():
-                positions[i] = loc.value - base_ofs
+                assert (loc.value & (WORD - 1)) == 0, \
+                    "store_info_on_descr: misaligned"
+                position = (loc.value - base_ofs) // WORD
+                assert 0 < position < 0xFFFF, "store_info_on_descr: overflow!"
             else:
                 assert loc is not self.cpu.frame_reg # for now
                 if self.cpu.IS_64_BIT:
                 else:
                     coeff = 2
                 if loc.is_float():
-                    v = len(self.cpu.gen_regs) + loc.value * coeff
+                    position = len(self.cpu.gen_regs) + loc.value * coeff
                 else:
-                    v = self.cpu.all_reg_indexes[loc.value]
-                positions[i] = v * WORD
+                    position = self.cpu.all_reg_indexes[loc.value]
+            positions[i] = rffi.cast(rffi.USHORT, position)
         # write down the positions of locs
         guardtok.faildescr.rd_locs = positions
         # we want the descr to keep alive

rpython/jit/backend/llsupport/llmodel.py

 from rpython.rtyper.annlowlevel import llhelper, MixLevelHelperAnnotator
 from rpython.rtyper.llannotation import lltype_to_annotation
 from rpython.rlib.objectmodel import we_are_translated, specialize
-from rpython.jit.metainterp import history
+from rpython.jit.metainterp import history, compile
 from rpython.jit.codewriter import heaptracker, longlong
 from rpython.jit.backend.model import AbstractCPU
 from rpython.jit.backend.llsupport import symbolic, jitframe
 
     def _decode_pos(self, deadframe, index):
         descr = self.get_latest_descr(deadframe)
-        if descr.final_descr:
-            assert index == 0
-            return 0
-        return descr.rd_locs[index]
+        return rffi.cast(lltype.Signed, descr.rd_locs[index]) * WORD
 
     def get_int_value(self, deadframe, index):
         pos = self._decode_pos(deadframe, index)
             calldescr.verify_types(args_i, args_r, args_f, history.VOID)
         # the 'i' return value is ignored (and nonsense anyway)
         calldescr.call_stub_i(func, args_i, args_r, args_f)
+
+
+final_descr_rd_locs = [rffi.cast(rffi.USHORT, 0)]
+history.BasicFinalDescr.rd_locs = final_descr_rd_locs
+compile._DoneWithThisFrameDescr.rd_locs = final_descr_rd_locs

rpython/jit/backend/test/runner_test.py

             assert res == 2 + i
 
     def test_finish(self):
+        from rpython.jit.backend.llsupport.llmodel import final_descr_rd_locs
+
         i0 = BoxInt()
         class UntouchableFailDescr(AbstractFailDescr):
             final_descr = True
+            rd_locs = final_descr_rd_locs
 
             def __setattr__(self, name, value):
                 if (name == 'index' or name == '_carry_around_for_tests'