Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r72039:517570d93b88 Date: 2014-06-13 14:06 +0200 http://bitbucket.org/pypy/pypy/changeset/517570d93b88/
Log: Compress the numerous lists 'rd_locs' into 2 bytes instead of WORD bytes per entry. diff --git a/rpython/jit/backend/llsupport/assembler.py b/rpython/jit/backend/llsupport/assembler.py --- a/rpython/jit/backend/llsupport/assembler.py +++ b/rpython/jit/backend/llsupport/assembler.py @@ -141,15 +141,16 @@ 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)) @@ -167,12 +168,15 @@ 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: @@ -180,10 +184,10 @@ 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 diff --git a/rpython/jit/backend/llsupport/llmodel.py b/rpython/jit/backend/llsupport/llmodel.py --- a/rpython/jit/backend/llsupport/llmodel.py +++ b/rpython/jit/backend/llsupport/llmodel.py @@ -4,7 +4,7 @@ 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 @@ -342,10 +342,7 @@ 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) @@ -659,3 +656,8 @@ 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 diff --git a/rpython/jit/backend/test/runner_test.py b/rpython/jit/backend/test/runner_test.py --- a/rpython/jit/backend/test/runner_test.py +++ b/rpython/jit/backend/test/runner_test.py @@ -344,9 +344,12 @@ 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' _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit