Author: Alex Gaynor <alex.gay...@gmail.com> Branch: dynamic-specialized-tuple Changeset: r53620:aa5fbb622e01 Date: 2012-03-14 15:53 -0700 http://bitbucket.org/pypy/pypy/changeset/aa5fbb622e01/
Log: small bit of progress in making optimizeopt happy diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5067,6 +5067,20 @@ """ self.optimize_strunicode_loop(ops, expected) + def test_gcstruct_as_array(self): + ops = """ + [i0] + p0 = new_array(3, descr=gcstructarraydescr) + setfield_gc(p0, i0, descr=gcstructarray_fielddescr) + i1 = getfield_gc(p0, descr=gcstructarray_fielddescr) + finish(i1) + """ + expected = """ + [i0] + finish(i0) + """ + self.optimize_loop(ops, expected) + class TestLLtype(BaseTestOptimizeBasic, LLtypeMixin): pass diff --git a/pypy/jit/metainterp/optimizeopt/test/test_util.py b/pypy/jit/metainterp/optimizeopt/test/test_util.py --- a/pypy/jit/metainterp/optimizeopt/test/test_util.py +++ b/pypy/jit/metainterp/optimizeopt/test/test_util.py @@ -207,6 +207,13 @@ complexrealdescr = cpu.interiorfielddescrof(complexarray, "real") compleximagdescr = cpu.interiorfielddescrof(complexarray, "imag") + gcstructarray = lltype.GcStruct("StructArray", + ("x", lltype.Signed), + ("y", lltype.Array(lltype.Signed)), + ) + gcstructarraydescr = cpu.arraydescrof(gcstructarray) + gcstructarray_fielddescr = cpu.fielddescrof(gcstructarray, "x") + for _name, _os in [ ('strconcatdescr', 'OS_STR_CONCAT'), ('strslicedescr', 'OS_STR_SLICE'), @@ -432,7 +439,7 @@ preamble.inputargs = inputargs preamble.resume_at_jump_descr = FakeDescrWithSnapshot() - token = JitCellToken() + token = JitCellToken() preamble.operations = [ResOperation(rop.LABEL, inputargs, None, descr=TargetToken(token))] + \ operations + \ [ResOperation(rop.LABEL, jump_args, None, descr=token)] @@ -445,7 +452,7 @@ loop.operations = [preamble.operations[-1]] + \ [inliner.inline_op(op, clone=False) for op in cloned_operations] + \ [ResOperation(rop.JUMP, [inliner.inline_arg(a) for a in jump_args], - None, descr=token)] + None, descr=token)] #[inliner.inline_op(jumpop)] assert loop.operations[-1].getopnum() == rop.JUMP assert loop.operations[0].getopnum() == rop.LABEL @@ -464,7 +471,7 @@ preamble.operations.insert(-1, op) return preamble - + class FakeDescr(compile.ResumeGuardDescr): def clone_if_mutable(self): diff --git a/pypy/jit/metainterp/optimizeopt/virtualize.py b/pypy/jit/metainterp/optimizeopt/virtualize.py --- a/pypy/jit/metainterp/optimizeopt/virtualize.py +++ b/pypy/jit/metainterp/optimizeopt/virtualize.py @@ -242,6 +242,7 @@ self.arraydescr = arraydescr self.constvalue = constvalue self._items = [self.constvalue] * size + self._fields = None def getlength(self): return len(self._items) @@ -254,6 +255,15 @@ assert isinstance(itemvalue, optimizer.OptValue) self._items[index] = itemvalue + def getfield(self, ofs, default): + return self._fields.get(ofs, default) + + def setfield(self, ofs, fieldvalue): + assert isinstance(fieldvalue, optimizer.OptValue) + if self._fields is None: + self._fields = {} + self._fields[ofs] = fieldvalue + def force_at_end_of_preamble(self, already_forced, optforce): if self in already_forced: return self _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit