Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r76886:70a22aaa3a7c Date: 2015-04-22 15:10 +0200 http://bitbucket.org/pypy/pypy/changeset/70a22aaa3a7c/
Log: A test and fix for rewrite.py. diff --git a/rpython/jit/backend/llsupport/rewrite.py b/rpython/jit/backend/llsupport/rewrite.py --- a/rpython/jit/backend/llsupport/rewrite.py +++ b/rpython/jit/backend/llsupport/rewrite.py @@ -62,6 +62,10 @@ op = operations[i] if op.getopnum() == rop.DEBUG_MERGE_POINT: continue + # ---------- GETFIELD_GC ---------- + if op.getopnum() == rop.GETFIELD_GC: + self.handle_getfield_gc(op) + continue # ---------- turn NEWxxx into CALL_MALLOC_xxx ---------- if op.is_malloc(): self.handle_malloc_operation(op) @@ -122,6 +126,18 @@ # ---------- + def handle_getfield_gc(self, op): + """See test_zero_ptr_field_before_getfield(). We hope there is + no getfield_gc in the middle of initialization code, but there + shouldn't be, given that a 'new' is already delayed by previous + optimization steps. In practice it should immediately be + followed by a bunch of 'setfields', and the 'pending_zeros' + optimization we do here is meant for this case.""" + self.emit_pending_zeros() + self.newops.append(op) + + # ---------- + def handle_malloc_operation(self, op): opnum = op.getopnum() if opnum == rop.NEW: diff --git a/rpython/jit/backend/llsupport/test/test_rewrite.py b/rpython/jit/backend/llsupport/test/test_rewrite.py --- a/rpython/jit/backend/llsupport/test/test_rewrite.py +++ b/rpython/jit/backend/llsupport/test/test_rewrite.py @@ -1031,3 +1031,21 @@ guard_false(i1, descr=guarddescr) [] jump() """) + + def test_zero_ptr_field_before_getfield(self): + # This case may need to be fixed in the metainterp/optimizeopt + # already so that it no longer occurs for rewrite.py. But anyway + # it's a good idea to make sure rewrite.py is correct on its own. + self.check_rewrite(""" + [] + p0 = new(descr=tdescr) + p1 = getfield_gc(p0, descr=tdescr) + jump(p1) + """, """ + [] + p0 = call_malloc_nursery(%(tdescr.size)d) + setfield_gc(p0, 5678, descr=tiddescr) + zero_ptr_field(p0, %(tdescr.gc_fielddescrs[0].offset)s) + p1 = getfield_gc(p0, descr=tdescr) + jump(p1) + """) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit