Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r81402:b697480a86fb
Date: 2015-12-20 09:27 +0100
http://bitbucket.org/pypy/pypy/changeset/b697480a86fb/

Log:    Kill the last bits of ZERO_PTR_FIELD that are still there but never
        used (this used to be an operation generated by rewrite.py: it is
        never produced in the front-end, so rewrite.py doesn't need to
        handle it as input)

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
@@ -296,13 +296,6 @@
                                                  
self.cpu.translate_support_code)
             self.emit_gc_store_or_indexed(op, op.getarg(0), op.getarg(1), 
op.getarg(2),
                                          itemsize, itemsize, basesize)
-        elif op.getopnum() == rop.ZERO_PTR_FIELD:
-            ofs = op.getarg(1).getint()
-            size = WORD
-            index_box = ConstInt(0)
-            value_box = ConstInt(0)
-            self.emit_gc_store_or_indexed(op, op.getarg(0), index_box, 
value_box,
-                                          size, 1, ofs)
         return False
 
 
@@ -678,7 +671,7 @@
         del self.last_zero_arrays[:]
         self._setarrayitems_occurred.clear()
         #
-        # Then write the ZERO_PTR_FIELDs that are still pending
+        # Then write the NULL-pointer-writing ops that are still pending
         for v, d in self._delayed_zero_setfields.iteritems():
             v = self.get_box_replacement(v)
             for ofs in d.iterkeys():
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
@@ -4964,52 +4964,6 @@
                                    [boxfloat(12.5)], 'int')
         assert res == struct.unpack("I", struct.pack("f", 12.5))[0]
 
-    def test_zero_ptr_field(self):
-        if not isinstance(self.cpu, AbstractLLCPU):
-            py.test.skip("llgraph can't do zero_ptr_field")
-        T = lltype.GcStruct('T')
-        S = lltype.GcStruct('S', ('x', lltype.Ptr(T)))
-        tdescr = self.cpu.sizeof(T)
-        sdescr = self.cpu.sizeof(S)
-        fielddescr = self.cpu.fielddescrof(S, 'x')
-        loop = parse("""
-        []
-        p0 = new(descr=tdescr)
-        p1 = new(descr=sdescr)
-        setfield_gc(p1, p0, descr=fielddescr)
-        zero_ptr_field(p1, %d)
-        finish(p1)
-        """ % fielddescr.offset, namespace=locals())
-        looptoken = JitCellToken()
-        self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)
-        deadframe = self.cpu.execute_token(looptoken)
-        ref = self.cpu.get_ref_value(deadframe, 0)
-        s = lltype.cast_opaque_ptr(lltype.Ptr(S), ref)
-        assert not s.x
-
-    def test_zero_ptr_field_2(self):
-        if not isinstance(self.cpu, AbstractLLCPU):
-            py.test.skip("llgraph does not do zero_ptr_field")
-
-        from rpython.jit.backend.llsupport import symbolic
-        S = lltype.GcStruct('S', ('x', lltype.Signed),
-                                 ('p', llmemory.GCREF),
-                                 ('y', lltype.Signed))
-        s = lltype.malloc(S)
-        s.x = -1296321
-        s.y = -4398176
-        s_ref = lltype.cast_opaque_ptr(llmemory.GCREF, s)
-        s.p = s_ref
-        ofs_p, _ = symbolic.get_field_token(S, 'p', False)
-        #
-        self.execute_operation(rop.ZERO_PTR_FIELD, [
-            InputArgRef(s_ref), ConstInt(ofs_p)],   # OK for now to assume 
that the
-            'void')                            # 2nd argument is a constant
-        #
-        assert s.x == -1296321
-        assert s.p == lltype.nullptr(llmemory.GCREF.TO)
-        assert s.y == -4398176
-
     def test_zero_array(self):
         if not isinstance(self.cpu, AbstractLLCPU):
             py.test.skip("llgraph does not do zero_array")
diff --git a/rpython/jit/backend/test/test_ll_random.py 
b/rpython/jit/backend/test/test_ll_random.py
--- a/rpython/jit/backend/test/test_ll_random.py
+++ b/rpython/jit/backend/test/test_ll_random.py
@@ -745,7 +745,6 @@
     OPERATIONS.append(GetInteriorFieldOperation(rop.GETINTERIORFIELD_GC_I))
     OPERATIONS.append(GetInteriorFieldOperation(rop.GETINTERIORFIELD_GC_I))
     OPERATIONS.append(SetFieldOperation(rop.SETFIELD_GC))
-    OPERATIONS.append(ZeroPtrFieldOperation(rop.ZERO_PTR_FIELD))
     OPERATIONS.append(SetInteriorFieldOperation(rop.SETINTERIORFIELD_GC))
     OPERATIONS.append(NewOperation(rop.NEW))
     OPERATIONS.append(NewOperation(rop.NEW_WITH_VTABLE))
diff --git a/rpython/jit/backend/test/test_random.py 
b/rpython/jit/backend/test/test_random.py
--- a/rpython/jit/backend/test/test_random.py
+++ b/rpython/jit/backend/test/test_random.py
@@ -57,19 +57,11 @@
     def do(self, opnum, argboxes, descr=None):
         self.fakemetainterp._got_exc = None
         op = ResOperation(opnum, argboxes, descr)
-        if opnum != rop.ZERO_PTR_FIELD:
-            result = _execute_arglist(self.cpu, self.fakemetainterp,
-                                      opnum, argboxes, descr)
-            if result is not None:
-                c_result = wrap_constant(result)
-                op.copy_value_from(c_result)
-        else:
-            import ctypes
-            addr = self.cpu.cast_gcref_to_int(argboxes[0].getref_base())
-            offset = argboxes[1].getint()
-            assert (offset % ctypes.sizeof(ctypes.c_long)) == 0
-            ptr = ctypes.cast(addr, ctypes.POINTER(ctypes.c_long))
-            ptr[offset / ctypes.sizeof(ctypes.c_long)] = 0
+        result = _execute_arglist(self.cpu, self.fakemetainterp,
+                                  opnum, argboxes, descr)
+        if result is not None:
+            c_result = wrap_constant(result)
+            op.copy_value_from(c_result)
         self.loop.operations.append(op)
         return op
 
diff --git a/rpython/jit/metainterp/executor.py 
b/rpython/jit/metainterp/executor.py
--- a/rpython/jit/metainterp/executor.py
+++ b/rpython/jit/metainterp/executor.py
@@ -367,7 +367,6 @@
                          rop.INCREMENT_DEBUG_COUNTER,
                          rop.COND_CALL_GC_WB,
                          rop.COND_CALL_GC_WB_ARRAY,
-                         rop.ZERO_PTR_FIELD,
                          rop.ZERO_ARRAY,
                          rop.DEBUG_MERGE_POINT,
                          rop.JIT_DEBUG,
diff --git a/rpython/jit/metainterp/optimizeopt/dependency.py 
b/rpython/jit/metainterp/optimizeopt/dependency.py
--- a/rpython/jit/metainterp/optimizeopt/dependency.py
+++ b/rpython/jit/metainterp/optimizeopt/dependency.py
@@ -18,7 +18,6 @@
                      , (rop.SETINTERIORFIELD_RAW, 0, -1)
                      , (rop.SETFIELD_GC, 0, -1)
                      , (rop.SETFIELD_RAW, 0, -1)
-                     , (rop.ZERO_PTR_FIELD, 0, -1)
                      , (rop.ZERO_ARRAY, 0, -1)
                      , (rop.STRSETITEM, 0, -1)
                      , (rop.UNICODESETITEM, 0, -1)
diff --git a/rpython/jit/metainterp/resoperation.py 
b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -1221,8 +1221,6 @@
     'SETINTERIORFIELD_GC/3d/n',
     'SETINTERIORFIELD_RAW/3d/n',    # right now, only used by tests
     'SETFIELD_GC/2d/n',
-    'ZERO_PTR_FIELD/2/n', # only emitted by the rewrite, clears a pointer field
-                        # at a given constant offset, no descr
     'ZERO_ARRAY/3d/n',  # only emitted by the rewrite, clears (part of) an 
array
                         # [arraygcptr, firstindex, length], descr=ArrayDescr
     'SETFIELD_RAW/2d/n',
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to