[pypy-svn] r77614 - in pypy/branch/32ptr-on-64bit/pypy/rpython: . lltypesystem lltypesystem/test memory/gc memory/gctransform

arigo at codespeak.net arigo at codespeak.net
Tue Oct 5 18:23:15 CEST 2010


Author: arigo
Date: Tue Oct  5 18:23:13 2010
New Revision: 77614

Modified:
   pypy/branch/32ptr-on-64bit/pypy/rpython/llinterp.py
   pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/llmemory.py
   pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/lloperation.py
   pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/opimpl.py
   pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/rcompressed.py
   pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/test/test_llmemory.py
   pypy/branch/32ptr-on-64bit/pypy/rpython/memory/gc/base.py
   pypy/branch/32ptr-on-64bit/pypy/rpython/memory/gctransform/framework.py
   pypy/branch/32ptr-on-64bit/pypy/rpython/rtyper.py
Log:
Intermediate check-in.


Modified: pypy/branch/32ptr-on-64bit/pypy/rpython/llinterp.py
==============================================================================
--- pypy/branch/32ptr-on-64bit/pypy/rpython/llinterp.py	(original)
+++ pypy/branch/32ptr-on-64bit/pypy/rpython/llinterp.py	Tue Oct  5 18:23:13 2010
@@ -1025,14 +1025,22 @@
 
     def op_raw_load(self, addr, typ, offset):
         checkadr(addr)
-        value = getattr(addr, str(typ).lower())[offset]
+        if typ == llmemory.HiddenGcRef32:
+            name = 'hiddengcref32'
+        else:
+            name = str(typ).lower()
+        value = getattr(addr, name)[offset]
         assert lltype.typeOf(value) == typ
         return value
 
     def op_raw_store(self, addr, typ, offset, value):
         checkadr(addr)
+        if typ == llmemory.HiddenGcRef32:
+            name = 'hiddengcref32'
+        else:
+            name = str(typ).lower()
         assert lltype.typeOf(value) == typ
-        getattr(addr, str(typ).lower())[offset] = value
+        getattr(addr, name)[offset] = value
 
     def op_stack_malloc(self, size): # mmh
         raise NotImplementedError("backend only")

Modified: pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/llmemory.py	(original)
+++ pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/llmemory.py	Tue Oct  5 18:23:13 2010
@@ -669,22 +669,22 @@
             raise TypeError(TARGETTYPE)
         ptr[0] = value
 
-class _address32_fakeaccessor(_address_fakeaccessor):
-    pass
+class _hiddengcref32_fakeaccessor(_fakeaccessor):
+    TYPE = HiddenGcRef32
 
 supported_access_types = {"signed":    lltype.Signed,
                           "unsigned":  lltype.Unsigned,
                           "char":      lltype.Char,
                           "address":   Address,
                           "float":     lltype.Float,
-                          "address32": Address,
+                          "hiddengcref32": HiddenGcRef32,
                           }
 
 fakeaddress.signed = property(_signed_fakeaccessor)
 fakeaddress.float = property(_float_fakeaccessor)
 fakeaddress.char = property(_char_fakeaccessor)
 fakeaddress.address = property(_address_fakeaccessor)
-fakeaddress.address32 = property(_address32_fakeaccessor)
+fakeaddress.hiddengcref32 = property(_hiddengcref32_fakeaccessor)
 fakeaddress._TYPE = Address
 
 # the obtained address will not keep the object alive. e.g. if the object is

Modified: pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/lloperation.py
==============================================================================
--- pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/lloperation.py	(original)
+++ pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/lloperation.py	Tue Oct  5 18:23:13 2010
@@ -426,6 +426,9 @@
     'gc_gettypeptr_group':  LLOp(canfold=True),
     'get_member_index':     LLOp(canfold=True),
 
+    'hide_into_adr32':      LLOp(canrun=True),
+    'show_from_adr32':      LLOp(canrun=True),
+
     # __________ used by the JIT ________
 
     'jit_marker':           LLOp(),

Modified: pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/opimpl.py
==============================================================================
--- pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/opimpl.py	(original)
+++ pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/opimpl.py	Tue Oct  5 18:23:13 2010
@@ -526,16 +526,21 @@
 def op_shrink_array(array, smallersize):
     return False
 
-def op_hide_into_adr32(adr):
-    if lltype.typeOf(adr) != llmemory.Address:
-        adr = llmemory.cast_ptr_to_adr(adr)
-    return llmemory._hiddengcref32(adr)
+def op_hide_into_adr32(ptr):
+    if lltype.typeOf(ptr) == llmemory.Address:
+        if not ptr:
+            return lltype.nullptr(llmemory.HiddenGcRef32.TO)
+        ptr = ptr.ptr
+    return lltype.cast_opaque_ptr(llmemory.HiddenGcRef32, ptr)
 
-def op_show_from_adr32(RESTYPE, adr32):
+def op_show_from_adr32(RESTYPE, ptr32):
     if RESTYPE == llmemory.Address:
-        return adr32.adr64
-    else:
-        return llmemory.cast_adr_to_ptr(adr32.adr64, RESTYPE)
+        if not ptr32:
+            return llmemory.NULL
+        PTRTYPE = lltype.Ptr(ptr32._obj.container._TYPE)
+        ptr = lltype.cast_opaque_ptr(PTRTYPE, ptr32)
+        return llmemory.cast_ptr_to_adr(ptr)
+    return lltype.cast_opaque_ptr(RESTYPE, ptr32)
 op_show_from_adr32.need_result_type = True
 
 # ____________________________________________________________

Modified: pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/rcompressed.py
==============================================================================
--- pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/rcompressed.py	(original)
+++ pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/rcompressed.py	Tue Oct  5 18:23:13 2010
@@ -3,6 +3,7 @@
 from pypy.config.translationoption import IS_64_BITS
 from pypy.rpython.rmodel import Repr, inputconst
 from pypy.rpython.lltypesystem import lltype, llmemory, rffi
+from pypy.rpython.lltypesystem.lloperation import llop
 from pypy.rpython.error import TyperError
 
 
@@ -49,7 +50,7 @@
         ptr = self.baserepr.convert_const(value)
         T = lltype.typeOf(ptr)
         assert T == self.BASETYPE
-        return lltype.cast_opaque_ptr(self.lowleveltype, ptr)
+        return llop.hide_into_adr32(self.lowleveltype, ptr)
 
     def get_ll_eq_function(self):
         if self.baserepr.get_ll_eq_function() is not None:
@@ -62,7 +63,7 @@
             BASETYPE = self.BASETYPE
             #
             def ll_hiddengcref32_hash(x):
-                x = lltype.cast_opaque_ptr(BASETYPE, x)
+                x = llop.show_from_adr32(BASETYPE, x)
                 return basefunc(x)
             #
             self.ll_hash_function = ll_hiddengcref32_hash
@@ -76,7 +77,7 @@
             BASETYPE = self.BASETYPE
             #
             def ll_hiddengcref32_fasthash(x):
-                x = lltype.cast_opaque_ptr(BASETYPE, x)
+                x = llop.show_from_adr32(BASETYPE, x)
                 return basefunc(x)
             #
             self.ll_fasthash_function = ll_hiddengcref32_hash
@@ -97,12 +98,12 @@
     def convert_from_to((r_from, r_to), v, llops):
         assert r_from.lowleveltype.TO._gckind == 'gc'
         assert not isinstance(r_from.lowleveltype.TO, lltype.GcOpaqueType)
-        return llops.genop('cast_opaque_ptr', [v],
+        return llops.genop('hide_into_adr32', [v],
                            resulttype=llmemory.HiddenGcRef32)
 
 class __extend__(pairtype(CompressedGcRefRepr, Repr)):
     def convert_from_to((r_from, r_to), v, llops):
         assert r_to.lowleveltype.TO._gckind == 'gc'
         assert not isinstance(r_to.lowleveltype.TO, lltype.GcOpaqueType)
-        return llops.genop('cast_opaque_ptr', [v],
+        return llops.genop('show_from_adr32', [v],
                            resulttype=r_to.lowleveltype)

Modified: pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/test/test_llmemory.py
==============================================================================
--- pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/test/test_llmemory.py	(original)
+++ pypy/branch/32ptr-on-64bit/pypy/rpython/lltypesystem/test/test_llmemory.py	Tue Oct  5 18:23:13 2010
@@ -650,8 +650,10 @@
     from pypy.config.translationoption import IS_64_BITS
     if not IS_64_BITS:
         py.test.skip("only on 64-bits")
+    #
+    from pypy.rpython.lltypesystem.lloperation import llop
     S = lltype.GcStruct('S')
     p = lltype.malloc(S)
-    q = lltype.cast_opaque_ptr(HiddenGcRef32, p)
-    r = lltype.cast_opaque_ptr(lltype.Ptr(S), q)
+    q = llop.hide_into_adr32(HiddenGcRef32, p)
+    r = llop.show_from_adr32(lltype.Ptr(S), q)
     assert r == p

Modified: pypy/branch/32ptr-on-64bit/pypy/rpython/memory/gc/base.py
==============================================================================
--- pypy/branch/32ptr-on-64bit/pypy/rpython/memory/gc/base.py	(original)
+++ pypy/branch/32ptr-on-64bit/pypy/rpython/memory/gc/base.py	Tue Oct  5 18:23:13 2010
@@ -1,4 +1,5 @@
 from pypy.rpython.lltypesystem import lltype, llmemory, llarena
+from pypy.rpython.lltypesystem.lloperation import llop
 from pypy.rlib.debug import ll_assert
 from pypy.rpython.memory.gcheader import GCHeaderBuilder
 from pypy.rpython.memory.support import DEFAULT_CHUNK_SIZE
@@ -211,11 +212,13 @@
             # special handling of HiddenGcRef32 on 64-bit platforms
             ofs = llmemory.remove_odd_value_marker(ofs)
             item = obj + ofs
-            address = item.address32[0]
+            address = llop.show_from_adr32(
+                llmemory.Address, item.hiddengcref32[0])
             if self.is_valid_gc_object(address):
                 newaddr = callback(address, arg)
                 if newaddr is not None:
-                    item.address32[0] = newaddr
+                    item.hiddengcref32[0] = llop.hide_into_adr32(
+                        llmemory.HiddenGcRef32, newaddr)
         else:
             # common case
             item = obj + ofs

Modified: pypy/branch/32ptr-on-64bit/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/branch/32ptr-on-64bit/pypy/rpython/memory/gctransform/framework.py	(original)
+++ pypy/branch/32ptr-on-64bit/pypy/rpython/memory/gctransform/framework.py	Tue Oct  5 18:23:13 2010
@@ -1059,12 +1059,12 @@
 
     def _fetch_unpacked_pointer(self, hop, v_value):
         # optimization for the common case where this setfield is preceded
-        # by v_value = cast_opaque_ptr(v_normal_pointer)
+        # by v_value = hide_into_adr32(v_normal_pointer)
         for op in hop.llops[::-1]:
-            if op.opname == 'cast_opaque_ptr' and op.result == v_value:
+            if op.opname == 'hide_into_adr32' and op.result == v_value:
                 return op.args[0]
         else:
-            return hop.genop("cast_opaque_ptr", [v_value],
+            return hop.genop("show_from_adr32", [v_value],
                              resulttype = llmemory.Address)
 
     def transform_getfield_typeptr(self, hop):

Modified: pypy/branch/32ptr-on-64bit/pypy/rpython/rtyper.py
==============================================================================
--- pypy/branch/32ptr-on-64bit/pypy/rpython/rtyper.py	(original)
+++ pypy/branch/32ptr-on-64bit/pypy/rpython/rtyper.py	Tue Oct  5 18:23:13 2010
@@ -100,7 +100,8 @@
             return self.primitive_to_repr[lltype]
         except KeyError:
             pass
-        if isinstance(lltype, Primitive):
+        from pypy.rpython.lltypesystem import llmemory
+        if isinstance(lltype, Primitive) or lltype == llmemory.HiddenGcRef32:
             repr = self.primitive_to_repr[lltype] = self.getrepr(annmodel.lltype_to_annotation(lltype))
             return repr
         raise TyperError('There is no primitive repr for %r'%(lltype,))



More information about the Pypy-commit mailing list