[pypy-svn] r77620 - in pypy/branch/32ptr-on-64bit/pypy: rpython/lltypesystem rpython/lltypesystem/test rpython/memory/gc rpython/memory/gctransform translator/c translator/c/src

arigo at codespeak.net arigo at codespeak.net
Tue Oct 5 19:02:35 CEST 2010


Author: arigo
Date: Tue Oct  5 19:02:33 2010
New Revision: 77620

Modified:
   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/translator/c/funcgen.py
   pypy/branch/32ptr-on-64bit/pypy/translator/c/genc.py
   pypy/branch/32ptr-on-64bit/pypy/translator/c/node.py
   pypy/branch/32ptr-on-64bit/pypy/translator/c/primitive.py
   pypy/branch/32ptr-on-64bit/pypy/translator/c/src/hiddengcref32.h
Log:
Rename {hide_into,show_from}_adr32 into *_ptr32,
which matches the current implementation better.


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 19:02:33 2010
@@ -426,8 +426,8 @@
     'gc_gettypeptr_group':  LLOp(canfold=True),
     'get_member_index':     LLOp(canfold=True),
 
-    'hide_into_adr32':      LLOp(canrun=True),
-    'show_from_adr32':      LLOp(canrun=True),
+    'hide_into_ptr32':      LLOp(canrun=True),
+    'show_from_ptr32':      LLOp(canrun=True),
 
     # __________ used by the JIT ________
 

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 19:02:33 2010
@@ -526,14 +526,14 @@
 def op_shrink_array(array, smallersize):
     return False
 
-def op_hide_into_adr32(ptr):
+def op_hide_into_ptr32(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, ptr32):
+def op_show_from_ptr32(RESTYPE, ptr32):
     if RESTYPE == llmemory.Address:
         if not ptr32:
             return llmemory.NULL
@@ -541,7 +541,7 @@
         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
+op_show_from_ptr32.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 19:02:33 2010
@@ -50,7 +50,7 @@
         ptr = self.baserepr.convert_const(value)
         T = lltype.typeOf(ptr)
         assert T == self.BASETYPE
-        return llop.hide_into_adr32(self.lowleveltype, ptr)
+        return llop.hide_into_ptr32(self.lowleveltype, ptr)
 
     def get_ll_eq_function(self):
         if self.baserepr.get_ll_eq_function() is not None:
@@ -63,7 +63,7 @@
             BASETYPE = self.BASETYPE
             #
             def ll_hiddengcref32_hash(x):
-                x = llop.show_from_adr32(BASETYPE, x)
+                x = llop.show_from_ptr32(BASETYPE, x)
                 return basefunc(x)
             #
             self.ll_hash_function = ll_hiddengcref32_hash
@@ -77,7 +77,7 @@
             BASETYPE = self.BASETYPE
             #
             def ll_hiddengcref32_fasthash(x):
-                x = llop.show_from_adr32(BASETYPE, x)
+                x = llop.show_from_ptr32(BASETYPE, x)
                 return basefunc(x)
             #
             self.ll_fasthash_function = ll_hiddengcref32_hash
@@ -98,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('hide_into_adr32', [v],
+        return llops.genop('hide_into_ptr32', [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('show_from_adr32', [v],
+        return llops.genop('show_from_ptr32', [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 19:02:33 2010
@@ -654,6 +654,6 @@
     from pypy.rpython.lltypesystem.lloperation import llop
     S = lltype.GcStruct('S')
     p = lltype.malloc(S)
-    q = llop.hide_into_adr32(HiddenGcRef32, p)
-    r = llop.show_from_adr32(lltype.Ptr(S), q)
+    q = llop.hide_into_ptr32(HiddenGcRef32, p)
+    r = llop.show_from_ptr32(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 19:02:33 2010
@@ -215,11 +215,11 @@
             ofs = llmemory.remove_odd_value_marker(ofs)
             item = obj + ofs
             item = llmemory.cast_adr_to_ptr(item, lltype.Ptr(HIDDENGCREFFIELD))
-            address = llop.show_from_adr32(llmemory.Address, item[0])
+            address = llop.show_from_ptr32(llmemory.Address, item[0])
             if self.is_valid_gc_object(address):
                 newaddr = callback(address, arg)
                 if newaddr is not None:
-                    item[0] = llop.hide_into_adr32(llmemory.HiddenGcRef32,
+                    item[0] = llop.hide_into_ptr32(llmemory.HiddenGcRef32,
                                                    newaddr)
         else:
             # common case

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 19:02:33 2010
@@ -1060,16 +1060,16 @@
 
     def _fetch_unpacked_address(self, hop, v_value):
         # optimization for the common case where this setfield is preceded
-        # by v_value = hide_into_adr32(v_normal_pointer)
+        # by v_value = hide_into_ptr32(v_normal_pointer)
         for op in hop.llops[::-1]:
-            if op.opname == 'hide_into_adr32' and op.result == v_value:
+            if op.opname == 'hide_into_ptr32' and op.result == v_value:
                 v_value = op.args[0]
                 if v_value.concretetype != llmemory.Address:
                     v_value = hop.genop("cast_ptr_to_adr", [v_value],
                                         resulttype = llmemory.Address)
                 return v_value
         else:
-            return hop.genop("show_from_adr32", [v_value],
+            return hop.genop("show_from_ptr32", [v_value],
                              resulttype = llmemory.Address)
 
     def transform_getfield_typeptr(self, hop):

Modified: pypy/branch/32ptr-on-64bit/pypy/translator/c/funcgen.py
==============================================================================
--- pypy/branch/32ptr-on-64bit/pypy/translator/c/funcgen.py	(original)
+++ pypy/branch/32ptr-on-64bit/pypy/translator/c/funcgen.py	Tue Oct  5 19:02:33 2010
@@ -647,17 +647,28 @@
                                         self.expr(op.args[0])))
         return '\t'.join(result)
 
-    OP_CAST_PTR_TO_ADR = OP_CAST_POINTER
-    OP_CAST_ADR_TO_PTR = OP_CAST_POINTER
+    def OP_CAST_PTR_TO_ADR(self, op):
+        # detect a case that is not supported and should be handled with
+        # show_from_ptr32.
+        if op.args[0].concretetype == HiddenGcRef32:
+            raise Exception("cast_ptr_to_adr(hiddengcref32): not supported")
+        return self.OP_CAST_POINTER(op)
+
+    def OP_CAST_ADR_TO_PTR(self, op):
+        # detect a case that is not supported and should be handled with
+        # hide_into_ptr32.
+        if op.result.concretetype == HiddenGcRef32:
+            raise Exception("hiddengcref32 = cast_adr_to_ptr(): not supported")
+        return self.OP_CAST_POINTER(op)
 
     def OP_CAST_OPAQUE_PTR(self, op):
+        # detect cases that are not supported and should be handled with
+        # hide_into_ptr32 or show_from_ptr32.
         if op.result.concretetype == HiddenGcRef32:
-            return 'OP_HIDE_INTO_ADR32(%s, %s);' % (self.expr(op.args[0]),
-                                                    self.expr(op.result))
+            raise Exception("hiddengcref32 = cast_opaque_ptr(): not supported")
         if op.args[0].concretetype == HiddenGcRef32:
-            return 'OP_SHOW_FROM_ADR32(%s, %s);' % (self.expr(op.args[0]),
-                                                    self.expr(op.result))
-        return self.OP_CAST_OPAQUE_PTR(op)
+            raise Exception("cast_opaque_ptr(hiddengcref32): not supported")
+        return self.OP_CAST_POINTER(op)
 
     def OP_CAST_INT_TO_PTR(self, op):
         TYPE = self.lltypemap(op.result)

Modified: pypy/branch/32ptr-on-64bit/pypy/translator/c/genc.py
==============================================================================
--- pypy/branch/32ptr-on-64bit/pypy/translator/c/genc.py	(original)
+++ pypy/branch/32ptr-on-64bit/pypy/translator/c/genc.py	Tue Oct  5 19:02:33 2010
@@ -923,7 +923,7 @@
 \tfor (p = pypy_hiddengcref32; p[0] != NULL; p += 2)
 \t{
 \t\thiddengcref32_t h;
-\t\tOP_HIDE_INTO_ADR32_CHECK((p[1]), h);
+\t\tOP_HIDE_INTO_PTR32_CHECK((p[1]), h);
 \t\t*(hiddengcref32_t*)(p[0]) = h;
 \t}
 }

Modified: pypy/branch/32ptr-on-64bit/pypy/translator/c/node.py
==============================================================================
--- pypy/branch/32ptr-on-64bit/pypy/translator/c/node.py	(original)
+++ pypy/branch/32ptr-on-64bit/pypy/translator/c/node.py	Tue Oct  5 19:02:33 2010
@@ -790,14 +790,14 @@
             expr = '0.0 /* patched later by %sinfinity */' % (
                 '-+'[value > 0])
         elif (TYPE == llmemory.HiddenGcRef32
-              and value and not hasattr(value, 'dummy_value')):
+              and value and not hasattr(value._obj, 'dummy_value')):
             realobj = value._obj.container
             realvalue = cast_opaque_ptr(Ptr(typeOf(realobj)), value)
             name = db.get(realvalue)
             db.late_initializations_hiddengcref32.append((access_expr, name))
             if not name.startswith('('):
                 name = '(%s)' % name
-            expr = '0 /*HIDE_INTO_ADR32%s*/' % name
+            expr = '0 /*HIDE_INTO_PTR32%s*/' % name
         else:
             expr = db.get(value)
             if TYPE is Void:

Modified: pypy/branch/32ptr-on-64bit/pypy/translator/c/primitive.py
==============================================================================
--- pypy/branch/32ptr-on-64bit/pypy/translator/c/primitive.py	(original)
+++ pypy/branch/32ptr-on-64bit/pypy/translator/c/primitive.py	Tue Oct  5 19:02:33 2010
@@ -148,17 +148,17 @@
         return 'NULL'
 
 def name_hiddengcref32(value, db):
-    if hasattr(value, 'dummy_value'):
-        return '1 /* dummy value */'
-    elif not value:
+    if not value:
         return '0'   # NULL
+    elif hasattr(value._obj, 'dummy_value'):
+        return '1 /* dummy value */'
     # The only prebuilt HiddenGcRef32 that should occur in a translated C
     # program occur as fields or items of a GcStruct or GcArray.  They are
     # handled by late_initializations_hiddengcref32.
     realobj = value._obj.container
     realvalue = cast_opaque_ptr(Ptr(typeOf(realobj)), value)
     db.get(realvalue)      # force following dependencies
-    return 'HIDE_INTO_ADR32(???) /* see primitive.py, name_hiddengcref32() */'
+    return 'HIDE_INTO_PTR32(???) /* see primitive.py, name_hiddengcref32() */'
 
 def name_small_integer(value, db):
     """Works for integers of size at most INT or UINT."""

Modified: pypy/branch/32ptr-on-64bit/pypy/translator/c/src/hiddengcref32.h
==============================================================================
--- pypy/branch/32ptr-on-64bit/pypy/translator/c/src/hiddengcref32.h	(original)
+++ pypy/branch/32ptr-on-64bit/pypy/translator/c/src/hiddengcref32.h	Tue Oct  5 19:02:33 2010
@@ -17,13 +17,13 @@
 #endif
 
 
-#define OP_SHOW_FROM_ADR32(x, r)  r = (void*)(((unsigned long)(x)) << 3)
+#define OP_SHOW_FROM_PTR32(x, r)  r = (void*)(((unsigned long)(x)) << 3)
 
-#define OP_HIDE_INTO_ADR32_CHECK(x, r)  \
+#define OP_HIDE_INTO_PTR32_CHECK(x, r)  \
    r = (hiddengcref32_t)(((unsigned long)(x)) >> 3); \
    if ((void*)(((unsigned long)(r)) << 3) != (x)) \
      RPyPointerTooBig()
 
-#define OP_HIDE_INTO_ADR32(x, r)  \
+#define OP_HIDE_INTO_PTR32(x, r)  \
    RPyAssert(!(((long)(x)) & 0x7FFFFFFF8), "Pointer too big or misaligned"); \
    r = (hiddengcref32_t)(((unsigned long)(x)) >> 3)



More information about the Pypy-commit mailing list