[pypy-svn] pypy 32ptr-on-64bit: cpu.bh_setarrayitem_gc_r.

arigo commits-noreply at bitbucket.org
Thu Apr 14 22:32:29 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 32ptr-on-64bit
Changeset: r43372:57af0689bf34
Date: 2011-04-14 13:31 -0700
http://bitbucket.org/pypy/pypy/changeset/57af0689bf34/

Log:	cpu.bh_setarrayitem_gc_r.

diff --git a/pypy/jit/backend/llsupport/llmodel.py b/pypy/jit/backend/llsupport/llmodel.py
--- a/pypy/jit/backend/llsupport/llmodel.py
+++ b/pypy/jit/backend/llsupport/llmodel.py
@@ -341,11 +341,16 @@
 
     def bh_setarrayitem_gc_r(self, arraydescr, gcref, itemindex, newvalue):
         ofs, size, _ = self.unpack_arraydescr(arraydescr)
+        icp = self.gcdescr.is_compressed_ptr(size)
         self.gc_ll_descr.do_write_barrier(gcref, newvalue)
         # --- start of GC unsafe code (no GC operation!) ---
         items = rffi.ptradd(rffi.cast(rffi.CCHARP, gcref), ofs)
-        items = rffi.cast(rffi.CArrayPtr(lltype.Signed), items)
-        items[itemindex] = self.cast_gcref_to_int(newvalue)
+        if icp:
+            items = rffi.cast(rffi.CArrayPtr(rffi.UINT), items)
+            items[itemindex] = self.cast_gcref_to_hidden_uint32(newvalue)
+        else:
+            items = rffi.cast(rffi.CArrayPtr(lltype.Signed), items)
+            items[itemindex] = self.cast_gcref_to_int(newvalue)
         # --- end of GC unsafe code ---
 
     @specialize.argtype(2)

diff --git a/pypy/jit/backend/test/runner_test.py b/pypy/jit/backend/test/runner_test.py
--- a/pypy/jit/backend/test/runner_test.py
+++ b/pypy/jit/backend/test/runner_test.py
@@ -2497,6 +2497,12 @@
                                      lltype.cast_opaque_ptr(llmemory.GCREF, a),
                                      4)
         assert lltype.cast_opaque_ptr(lltype.Ptr(S), x) == s
+        #
+        cpu.bh_setarrayitem_gc_r(descrarray,
+                                 lltype.cast_opaque_ptr(llmemory.GCREF, a),
+                                 4,
+                                 lltype.cast_opaque_ptr(llmemory.GCREF, t))
+        assert llop.show_from_ptr32(lltype.Ptr(S), a[4]) == t
 
 
 class OOtypeBackendTest(BaseBackendTest):


More information about the Pypy-commit mailing list