[pypy-svn] r46478 - in pypy/branch/cleanup-weakref/pypy: annotation rlib rlib/test rpython rpython/lltypesystem rpython/lltypesystem/test translator translator/c translator/c/src translator/c/test translator/cli translator/jvm translator/llvm/test translator/oosupport/test_template translator/stackless

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Sep 11 19:09:46 CEST 2007


Author: cfbolz
Date: Tue Sep 11 19:09:45 2007
New Revision: 46478

Modified:
   pypy/branch/cleanup-weakref/pypy/annotation/binaryop.py
   pypy/branch/cleanup-weakref/pypy/annotation/bookkeeper.py
   pypy/branch/cleanup-weakref/pypy/annotation/builtin.py
   pypy/branch/cleanup-weakref/pypy/annotation/model.py
   pypy/branch/cleanup-weakref/pypy/rlib/objectmodel.py
   pypy/branch/cleanup-weakref/pypy/rlib/test/test_objectmodel.py
   pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/llmemory.py
   pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/lloperation.py
   pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/opimpl.py
   pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/test/test_llmemory.py
   pypy/branch/cleanup-weakref/pypy/rpython/raddress.py
   pypy/branch/cleanup-weakref/pypy/rpython/rbuiltin.py
   pypy/branch/cleanup-weakref/pypy/rpython/rmodel.py
   pypy/branch/cleanup-weakref/pypy/translator/c/funcgen.py
   pypy/branch/cleanup-weakref/pypy/translator/c/node.py
   pypy/branch/cleanup-weakref/pypy/translator/c/primitive.py
   pypy/branch/cleanup-weakref/pypy/translator/c/src/address.h
   pypy/branch/cleanup-weakref/pypy/translator/c/test/test_lladdresses.py
   pypy/branch/cleanup-weakref/pypy/translator/c/test/test_newgc.py
   pypy/branch/cleanup-weakref/pypy/translator/cli/metavm.py
   pypy/branch/cleanup-weakref/pypy/translator/cli/opcodes.py
   pypy/branch/cleanup-weakref/pypy/translator/exceptiontransform.py
   pypy/branch/cleanup-weakref/pypy/translator/jvm/metavm.py
   pypy/branch/cleanup-weakref/pypy/translator/jvm/opcodes.py
   pypy/branch/cleanup-weakref/pypy/translator/llvm/test/test_lladdresses.py
   pypy/branch/cleanup-weakref/pypy/translator/oosupport/test_template/objectmodel.py
   pypy/branch/cleanup-weakref/pypy/translator/stackless/code.py
   pypy/branch/cleanup-weakref/pypy/translator/stackless/frame.py
   pypy/branch/cleanup-weakref/pypy/translator/stackless/transform.py
Log:
yay! kill the ugly and unsafe casts from and to weak addresses


Modified: pypy/branch/cleanup-weakref/pypy/annotation/binaryop.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/annotation/binaryop.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/annotation/binaryop.py	Tue Sep 11 19:09:45 2007
@@ -14,7 +14,6 @@
 from pypy.annotation.model import SomeExternalObject
 from pypy.annotation.model import SomeWeakRef, SomeDeadWeakRef
 from pypy.annotation.model import SomeAddress, SomeTypedAddressAccess
-from pypy.annotation.model import SomeWeakGcAddress
 from pypy.annotation.model import SomeCTypesObject
 from pypy.annotation.model import unionof, UnionError, set, missing_operation, TLS
 from pypy.annotation.model import read_can_only_throw
@@ -949,10 +948,6 @@
         raise UnionError, "union of address and anything else makes no sense"
 
 
-class __extend__(pairtype(SomeWeakGcAddress, SomeWeakGcAddress)):
-    def union((s_addr1, s_addr2)):
-        return SomeWeakGcAddress()
-    
 
 class __extend__(pairtype(SomeCTypesObject, SomeInteger)):
     def setitem((s_cto, s_index), s_value):

Modified: pypy/branch/cleanup-weakref/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/annotation/bookkeeper.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/annotation/bookkeeper.py	Tue Sep 11 19:09:45 2007
@@ -11,8 +11,7 @@
      SomeInteger, SomeExternalObject, SomeOOInstance, TLS, SomeAddress, \
      SomeUnicodeCodePoint, SomeOOStaticMeth, s_None, s_ImpossibleValue, \
      SomeLLADTMeth, SomeBool, SomeTuple, SomeOOClass, SomeImpossibleValue, \
-     SomeList, SomeObject, SomeWeakGcAddress, HarmlesslyBlocked, \
-     SomeWeakRef, SomeDeadWeakRef
+     SomeList, SomeObject, HarmlesslyBlocked, SomeWeakRef, SomeDeadWeakRef
 from pypy.annotation.classdef import ClassDef, InstanceSource
 from pypy.annotation.listdef import ListDef, MOST_GENERAL_LISTDEF
 from pypy.annotation.dictdef import DictDef, MOST_GENERAL_DICTDEF
@@ -409,8 +408,6 @@
             result = SomePtr(lltype.typeOf(x))
         elif isinstance(x, llmemory.fakeaddress):
             result = SomeAddress(is_null=not x)
-        elif isinstance(x, llmemory.fakeweakaddress):
-            result = SomeWeakGcAddress()
         elif isinstance(x, ootype._static_meth):
             result = SomeOOStaticMeth(ootype.typeOf(x))
         elif isinstance(x, ootype._class):

Modified: pypy/branch/cleanup-weakref/pypy/annotation/builtin.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/annotation/builtin.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/annotation/builtin.py	Tue Sep 11 19:09:45 2007
@@ -6,7 +6,7 @@
 from pypy.annotation.model import SomeInteger, SomeObject, SomeChar, SomeBool
 from pypy.annotation.model import SomeString, SomeTuple, SomeSlice, s_Bool
 from pypy.annotation.model import SomeUnicodeCodePoint, SomeAddress
-from pypy.annotation.model import SomeFloat, SomeWeakGcAddress, unionof
+from pypy.annotation.model import SomeFloat, unionof
 from pypy.annotation.model import SomePBC, SomeInstance, SomeDict
 from pypy.annotation.model import SomeExternalObject
 from pypy.annotation.model import SomeWeakRef, SomeLLWeakRef
@@ -331,13 +331,6 @@
     assert s_type.is_constant()
     return SomePtr(s_type.const)
 
-def llmemory_cast_ptr_to_weakadr(s):
-    return SomeWeakGcAddress()
-
-def llmemory_cast_weakadr_to_ptr(s, s_type):
-    assert s_type.is_constant()
-    return SomePtr(s_type.const)
-
 def llmemory_cast_adr_to_int(s):
     return SomeInteger() # xxx
 
@@ -389,8 +382,6 @@
 BUILTIN_ANALYZERS[pypy.rpython.lltypesystem.llmemory.cast_adr_to_ptr] = llmemory_cast_adr_to_ptr
 BUILTIN_ANALYZERS[pypy.rpython.lltypesystem.llmemory.cast_adr_to_int] = llmemory_cast_adr_to_int
 BUILTIN_ANALYZERS[pypy.rpython.lltypesystem.llmemory.cast_int_to_adr] = llmemory_cast_int_to_adr
-BUILTIN_ANALYZERS[pypy.rpython.lltypesystem.llmemory.cast_ptr_to_weakadr] = llmemory_cast_ptr_to_weakadr
-BUILTIN_ANALYZERS[pypy.rpython.lltypesystem.llmemory.cast_weakadr_to_ptr] = llmemory_cast_weakadr_to_ptr
 BUILTIN_ANALYZERS[pypy.rlib.rstack.yield_current_frame_to_caller] = (
     rstack_yield_current_frame_to_caller)
 

Modified: pypy/branch/cleanup-weakref/pypy/annotation/model.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/annotation/model.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/annotation/model.py	Tue Sep 11 19:09:45 2007
@@ -529,9 +529,6 @@
     def can_be_none(self):
         return False
 
-class SomeWeakGcAddress(SomeObject):
-    immutable = True
-
 # The following class is used to annotate the intermediate value that
 # appears in expressions of the form:
 # addr.signed[offset] and addr.signed[offset] = value
@@ -596,7 +593,6 @@
     (SomeChar(), lltype.Char),
     (SomeUnicodeCodePoint(), lltype.UniChar),
     (SomeAddress(), llmemory.Address),
-    (SomeWeakGcAddress(), llmemory.WeakGcAddress),
     (SomeLLWeakRef(), llmemory.WeakRef),
 ]
 

Modified: pypy/branch/cleanup-weakref/pypy/rlib/objectmodel.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/rlib/objectmodel.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/rlib/objectmodel.py	Tue Sep 11 19:09:45 2007
@@ -123,70 +123,8 @@
     obj.__dict__ = {}
     obj.__class__ = FREED_OBJECT
 
-def cast_object_to_weakgcaddress(obj):
-    from pypy.rpython.lltypesystem.llmemory import fakeweakaddress
-    return fakeweakaddress(obj)
-
-def cast_weakgcaddress_to_object(address, expected_result):
-    if address.ref is None:  # NULL address
-        return None
-    obj = address.get()
-    assert obj is not None
-    assert isinstance(obj, expected_result)
-    return obj
-
 from pypy.rpython.extregistry import ExtRegistryEntry
 
-class Entry(ExtRegistryEntry):
-    _about_ = cast_object_to_weakgcaddress
-
-    def compute_result_annotation(self, s_obj):
-        from pypy.annotation import model as annmodel
-        return annmodel.SomeWeakGcAddress()
-
-    def specialize_call(self, hop):
-        vlist = hop.inputargs(hop.args_r[0])
-        return hop.genop('cast_ptr_to_weakadr', vlist,
-                         resulttype=hop.r_result.lowleveltype)
-
-class Entry(ExtRegistryEntry):
-    _about_ = cast_weakgcaddress_to_object
-
-    def compute_result_annotation(self, s_int, s_clspbc):
-        from pypy.annotation import model as annmodel
-        assert len(s_clspbc.descriptions) == 1
-        desc = s_clspbc.descriptions.keys()[0]
-        cdef = desc.getuniqueclassdef()
-        return annmodel.SomeInstance(cdef, can_be_None=True)
-
-    def specialize_call(self, hop):
-        from pypy.rpython import raddress
-        assert isinstance(hop.args_r[0], raddress.WeakGcAddressRepr)
-        vlist = [hop.inputarg(hop.args_r[0], arg=0)]
-        return hop.genop('cast_weakadr_to_ptr', vlist,
-                         resulttype = hop.r_result.lowleveltype)
-
-
-def cast_weakgcaddress_to_int(address):
-    if address.ref is None:  # NULL address
-        return 0
-    return address.cast_to_int()
-
-
-class Entry(ExtRegistryEntry):
-    _about_ = cast_weakgcaddress_to_int
-
-    def compute_result_annotation(self, s_int):
-        return annmodel.SomeInteger()
-    
-
-    def specialize_call(self, hop):
-        from pypy.rpython import raddress
-        assert isinstance(hop.args_r[0], raddress.WeakGcAddressRepr)
-        vlist = [hop.inputarg(hop.args_r[0], arg=0)]
-        return hop.genop('cast_weakadr_to_int', vlist,
-                         resulttype = hop.r_result.lowleveltype)
-
 # ____________________________________________________________
 
 def debug_assert(x, msg):

Modified: pypy/branch/cleanup-weakref/pypy/rlib/test/test_objectmodel.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/rlib/test/test_objectmodel.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/rlib/test/test_objectmodel.py	Tue Sep 11 19:09:45 2007
@@ -271,28 +271,6 @@
 
 class TestLLtype(BaseTestObjectModel, LLRtypeMixin):
 
-    def test_cast_to_and_from_weakaddress(self):
-        class A(object):
-            pass
-        class B(object):
-            pass
-        def f():
-            a = A()
-            addr = cast_object_to_weakgcaddress(a)
-            return a is cast_weakgcaddress_to_object(addr, A)
-        assert f()
-        res = self.interpret(f, [])
-        assert res
-        a = A()
-        addr = cast_object_to_weakgcaddress(A)
-        py.test.raises(AssertionError, "cast_weakgcaddress_to_object(addr, B)")
-        assert isinstance(cast_weakgcaddress_to_int(addr), int)
-        def g():
-            a = A()
-            addr = cast_object_to_weakgcaddress(a)
-            return cast_weakgcaddress_to_int(addr)
-        assert isinstance(self.interpret(f, []), int)
-
     def test_rtype_keepalive(self):
         from pypy.rlib import objectmodel
         def f():

Modified: pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/llmemory.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/llmemory.py	Tue Sep 11 19:09:45 2007
@@ -494,11 +494,10 @@
 #                 target malloc'ed structure alive.  When the target dies
 #                 all WeakRefs to it are cleared.
 #
-# WeakGcAddress - like WeakRef but not automatically cleared.  There is
-#                 no direct way to know if the target is still alive.
-#                 We should more or less deprecate them in favor of WeakRef.
 
-class fakeweakaddress(object):
+# ____________________________________________________________
+
+class fakeweakref(object):
     # XXX convoluted code to support both lltype._ptr and simulatorptr
     def __init__(self, ob):
         if ob is not None:
@@ -531,32 +530,11 @@
         else:
             s = str(self.obref)
         return '<%s %s>' % (self.__class__.__name__, s)
-    def cast_to_int(self):
-        # this is not always the behaviour that is really happening
-        # but make sure that nobody depends on it
-        return self.id ^ ~3
-
-WeakGcAddress = lltype.Primitive("WeakGcAddress",
-                                 fakeweakaddress(None))
-
-def cast_ptr_to_weakadr(obj):
-    assert isinstance(lltype.typeOf(obj), lltype.Ptr)
-    return fakeweakaddress(obj)
-
-def cast_weakadr_to_ptr(adr, EXPECTED_TYPE):
-    result = adr.get()
-    if result is None:
-        return lltype.nullptr(EXPECTED_TYPE.TO)
-    else:
-        return lltype.cast_pointer(EXPECTED_TYPE, result)
-
-fakeweakaddress._TYPE = WeakGcAddress
-WEAKNULL = fakeweakaddress(None)
-
-# ____________________________________________________________
+    #def cast_to_int(self):
+    #    # this is not always the behaviour that is really happening
+    #    # but make sure that nobody depends on it
+    #    return self.id ^ ~3
 
-class fakeweakref(fakeweakaddress):
-    pass        # inheriting only to copy all methods
 
 WeakRef = lltype.Primitive("WeakRef", fakeweakref(None))
 

Modified: pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/lloperation.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/lloperation.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/lloperation.py	Tue Sep 11 19:09:45 2007
@@ -362,9 +362,6 @@
     'adr_call':             LLOp(canraise=(Exception,)),
     'cast_ptr_to_adr':      LLOp(canfold=True),
     'cast_adr_to_ptr':      LLOp(canfold=True),
-    'cast_ptr_to_weakadr':  LLOp(canfold=True),
-    'cast_weakadr_to_ptr':  LLOp(canfold=True),
-    'cast_weakadr_to_int':  LLOp(canfold=True),
     'cast_adr_to_int':      LLOp(canfold=True),
     'cast_int_to_adr':      LLOp(canfold=True),   # not implemented in llinterp
 

Modified: pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/opimpl.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/opimpl.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/opimpl.py	Tue Sep 11 19:09:45 2007
@@ -276,19 +276,6 @@
     return lltype.cast_pointer(RESTYPE, obj)
 op_cast_pointer.need_result_type = True
 
-def op_cast_ptr_to_weakadr(ptr):
-    checkptr(ptr)
-    return llmemory.cast_ptr_to_weakadr(ptr)
-
-def op_cast_weakadr_to_ptr(TYPE, wadr):
-    assert lltype.typeOf(wadr) == llmemory.WeakGcAddress
-    return llmemory.cast_weakadr_to_ptr(wadr, TYPE)
-op_cast_weakadr_to_ptr.need_result_type = True
-
-def op_cast_weakadr_to_int(wadr):
-    assert lltype.typeOf(wadr) == llmemory.WeakGcAddress
-    return wadr.cast_to_int()
-
 def op_cast_ptr_to_adr(ptr):
     checkptr(ptr)
     return llmemory.cast_ptr_to_adr(ptr)

Modified: pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/test/test_llmemory.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/test/test_llmemory.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/rpython/lltypesystem/test/test_llmemory.py	Tue Sep 11 19:09:45 2007
@@ -157,35 +157,6 @@
     res = interpret(f, [])
     assert res
 
-def test_weak_casts():
-    from pypy.rpython.memory.test.test_llinterpsim import interpret
-    S = lltype.GcStruct("S", ("x", lltype.Signed))
-    Sptr = lltype.Ptr(S)
-    def f():
-        s1 = lltype.malloc(S)
-        adr = cast_ptr_to_weakadr(s1)
-        s2 = cast_weakadr_to_ptr(adr, Sptr)
-        return s1 == s2
-    res = interpret(f, [])
-    assert res
-
-def test_weak_casts_lifetime():
-    T = lltype.GcStruct("T", ("x", lltype.Signed))
-    S = lltype.GcStruct("S", ("t", T))
-    Sptr = lltype.Ptr(S)
-    def g():
-        s1 = lltype.malloc(S)
-        adr = cast_ptr_to_weakadr(s1)
-        s2 = cast_weakadr_to_ptr(adr, Sptr)
-        assert s1 == s2
-        return adr, lltype.cast_pointer(lltype.Ptr(T), s2)   # s1, s2 go away
-    def f():
-        adr, t = g()
-        t2 = cast_weakadr_to_ptr(adr, lltype.Ptr(T))
-        return t2 == t
-    res = interpret(f, [])
-    assert res
-
 def test_fakeaccessor():
     S = lltype.GcStruct("S", ("x", lltype.Signed), ("y", lltype.Signed))
     s = lltype.malloc(S)
@@ -609,31 +580,3 @@
     assert weakref_deref(lltype.Ptr(S), w) == lltype.nullptr(S)
     assert weakref_deref(lltype.Ptr(S1), w) == lltype.nullptr(S1)
 
-class TestWeakAddressLLinterp(object):
-    def test_null(self):
-        from pypy.rlib.objectmodel import cast_weakgcaddress_to_object
-        from pypy.rlib.objectmodel import cast_object_to_weakgcaddress
-        class A:
-            pass
-        def f():
-            return cast_weakgcaddress_to_object(WEAKNULL, A) is None
-        assert interpret(f, [])
-    
-    def test_attribute(object):
-        from pypy.rlib.objectmodel import cast_weakgcaddress_to_object
-        from pypy.rlib.objectmodel import cast_object_to_weakgcaddress
-        class A:
-            pass
-        class B:
-            pass
-        def f(x):
-            a = A()
-            b = B()
-            if x:
-                a.addr = WEAKNULL
-            else:
-                a.addr = cast_object_to_weakgcaddress(b)
-            return cast_weakgcaddress_to_object(a.addr, B) is b
-        assert not interpret(f, [1])
-        assert interpret(f, [0])
- 

Modified: pypy/branch/cleanup-weakref/pypy/rpython/raddress.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/rpython/raddress.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/rpython/raddress.py	Tue Sep 11 19:09:45 2007
@@ -3,7 +3,7 @@
 from pypy.annotation import model as annmodel
 from pypy.rpython.memory.lladdress import _address
 from pypy.rpython.lltypesystem.llmemory import NULL, Address, \
-     cast_adr_to_int, WeakGcAddress
+     cast_adr_to_int
 from pypy.rpython.rmodel import Repr, IntegerRepr
 from pypy.rpython.rptr import PtrRepr
 from pypy.rpython.lltypesystem import lltype
@@ -16,13 +16,6 @@
     def rtyper_makekey(self):
         return self.__class__,
 
-class __extend__(annmodel.SomeWeakGcAddress):
-    def rtyper_makerepr(self, rtyper):
-        return WeakGcAddressRepr(rtyper)
-    
-    def rtyper_makekey(self):
-        return self.__class__,
-
 class __extend__(annmodel.SomeTypedAddressAccess):
     def rtyper_makerepr(self, rtyper):
         return TypedAddressAccessRepr(self.type)
@@ -143,27 +136,4 @@
     def convert_from_to((r_ptr, r_addr), v, llops):
         return llops.genop('cast_ptr_to_adr', [v], resulttype=Address)
 
-class WeakGcAddressRepr(Repr):
-    lowleveltype = WeakGcAddress
-
-    def __init__(self, rtyper):
-        self.rtyper = rtyper
 
-    def convert_const(self, value):
-        from pypy.rpython.lltypesystem import llmemory
-        from pypy.rlib.objectmodel import cast_object_to_weakgcaddress
-        from pypy.objspace.flow.model import Constant
-        assert isinstance(value, llmemory.fakeweakaddress)
-        if value.ref is None:
-            return value
-        ob = value.ref()
-        assert ob is not None
-        bk = self.rtyper.annotator.bookkeeper
-        # obscure!  if the annotator hasn't seen this object before,
-        # we don't want to look at it now (confusion tends to result).
-        if bk.have_seen(ob):
-            repr = self.rtyper.bindingrepr(Constant(ob))
-            newob = repr.convert_const(ob)
-            return cast_object_to_weakgcaddress(newob)
-        else:
-            return llmemory.fakeweakaddress(None)

Modified: pypy/branch/cleanup-weakref/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/rpython/rbuiltin.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/rpython/rbuiltin.py	Tue Sep 11 19:09:45 2007
@@ -661,24 +661,9 @@
     return hop.genop('cast_int_to_adr', [v_input],
                      resulttype = llmemory.Address)
 
-def rtype_cast_ptr_to_weakadr(hop):
-    vlist = hop.inputargs(hop.args_r[0])
-    assert isinstance(vlist[0].concretetype, lltype.Ptr)
-    hop.exception_cannot_occur()
-    return hop.genop('cast_ptr_to_weakadr', vlist,
-                     resulttype = llmemory.WeakGcAddress)
-
-def rtype_cast_weakadr_to_ptr(hop):
-    assert isinstance(hop.args_r[0], raddress.WeakGcAddressRepr)
-    adr, TYPE = hop.inputargs(hop.args_r[0], lltype.Void)
-    hop.exception_cannot_occur()
-    return hop.genop('cast_weakadr_to_ptr', [adr],
-                     resulttype = TYPE.value)
 
 BUILTIN_TYPER[llmemory.cast_ptr_to_adr] = rtype_cast_ptr_to_adr
 BUILTIN_TYPER[llmemory.cast_adr_to_ptr] = rtype_cast_adr_to_ptr
 BUILTIN_TYPER[llmemory.cast_adr_to_int] = rtype_cast_adr_to_int
 BUILTIN_TYPER[llmemory.cast_int_to_adr] = rtype_cast_int_to_adr
-BUILTIN_TYPER[llmemory.cast_ptr_to_weakadr] = rtype_cast_ptr_to_weakadr
-BUILTIN_TYPER[llmemory.cast_weakadr_to_ptr] = rtype_cast_weakadr_to_ptr
 

Modified: pypy/branch/cleanup-weakref/pypy/rpython/rmodel.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/rpython/rmodel.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/rpython/rmodel.py	Tue Sep 11 19:09:45 2007
@@ -220,11 +220,8 @@
             raise TyperError('id() of an instance of the non-pointer %r' % (
                 self,))
         vobj, = hop.inputargs(self)
-        # XXX why did this go through weakadr??
-        #v_waddr = hop.genop('cast_ptr_to_weakadr', [vobj],
-        #                    resulttype=llmemory.WeakGcAddress)
-        #return hop.genop('cast_weakadr_to_int', [v_waddr], resulttype=Signed)
-
+        # XXX I am still not sure whether this is the right thing to do,
+        # since the int might keep things alive with boehm
         return hop.genop('cast_ptr_to_int', [vobj], resulttype=Signed)
 
     def rtype_hash(self, hop):

Modified: pypy/branch/cleanup-weakref/pypy/translator/c/funcgen.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/c/funcgen.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/c/funcgen.py	Tue Sep 11 19:09:45 2007
@@ -11,7 +11,7 @@
 from pypy.rpython.lltypesystem.lltype import pyobjectptr, ContainerType
 from pypy.rpython.lltypesystem.lltype import Struct, Array, FixedSizeArray
 from pypy.rpython.lltypesystem.lltype import ForwardReference, FuncType
-from pypy.rpython.lltypesystem.llmemory import Address, WeakGcAddress
+from pypy.rpython.lltypesystem.llmemory import Address
 from pypy.translator.backendopt.ssa import SSI_to_SSA
 
 PyObjPtr = Ptr(PyObject)
@@ -568,18 +568,6 @@
     OP_CAST_ADR_TO_PTR = OP_CAST_POINTER
     OP_CAST_OPAQUE_PTR = OP_CAST_POINTER
 
-    def OP_CAST_PTR_TO_WEAKADR(self, op):
-        return '%s = HIDE_POINTER(%s);' % (self.expr(op.result),
-                                             self.expr(op.args[0]))
-
-    def OP_CAST_WEAKADR_TO_PTR(self, op):
-        TYPE = self.lltypemap(op.result)
-        assert TYPE != PyObjPtr
-        typename = self.db.gettype(TYPE)
-        return '%s = (%s)REVEAL_POINTER(%s);' % (self.expr(op.result),
-                                                   cdecl(typename, ''),
-                                                   self.expr(op.args[0]))
-
     def OP_CAST_INT_TO_PTR(self, op):
         TYPE = self.lltypemap(op.result)
         typename = self.db.gettype(TYPE)
@@ -652,7 +640,7 @@
                 format.append('%d')
             elif T == Float:
                 format.append('%f')
-            elif isinstance(T, Ptr) or T in (Address, WeakGcAddress):
+            elif isinstance(T, Ptr) or T == Address:
                 format.append('%p')
             elif T == Char:
                 if isinstance(arg, Constant):

Modified: pypy/branch/cleanup-weakref/pypy/translator/c/node.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/c/node.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/c/node.py	Tue Sep 11 19:09:45 2007
@@ -4,7 +4,6 @@
      GcStruct, GcArray, RttiStruct, PyStruct, ContainerType, \
      parentlink, Ptr, PyObject, Void, OpaqueType, Float, \
      RuntimeTypeInfo, getRuntimeTypeInfo, Char, _subarray, _pyobjheader
-from pypy.rpython.lltypesystem.llmemory import WeakGcAddress
 from pypy.translator.c.funcgen import FunctionCodeGenerator
 from pypy.translator.c.external import CExternalFunctionCodeGenerator
 from pypy.translator.c.support import USESLOTS # set to False if necessary while refactoring
@@ -593,9 +592,6 @@
             db.late_initializations.append(('%s' % access_expr, db.get(value)))
             expr = '0.0 /* patched later by %sinfinity */' % (
                 '-+'[value > 0])
-        elif typeOf(value) == WeakGcAddress and value.ref is not None:
-            db.late_initializations.append(('%s' % access_expr, db.get(value)))
-            expr = 'HIDE_POINTER(NULL) /* patched later */'
         else:
             expr = db.get(value)
             if typeOf(value) is Void:

Modified: pypy/branch/cleanup-weakref/pypy/translator/c/primitive.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/c/primitive.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/c/primitive.py	Tue Sep 11 19:09:45 2007
@@ -5,7 +5,7 @@
 from pypy.rpython.lltypesystem import rffi
 from pypy.rpython.lltypesystem.llmemory import Address, \
      AddressOffset, ItemOffset, ArrayItemsOffset, FieldOffset, \
-     CompositeOffset, ArrayLengthOffset, WeakGcAddress, fakeweakaddress, \
+     CompositeOffset, ArrayLengthOffset, \
      GCHeaderOffset, WeakRef, fakeweakref
 from pypy.translator.c.support import cdecl
 
@@ -112,15 +112,6 @@
     else:
         return 'NULL'
 
-def name_weakgcaddress(value, db):
-    assert isinstance(value, fakeweakaddress)
-    if value.ref is None: 
-        return 'HIDE_POINTER(NULL)'
-    else:
-        ob = value.ref()
-        assert ob is not None
-        return 'HIDE_POINTER(%s)'%db.get(ob)
-
 def name_weakref(value, db):
     assert isinstance(value, fakeweakref)
     target = value.get()
@@ -142,7 +133,6 @@
     Bool:     name_bool,
     Void:     name_void,
     Address:  name_address,
-    WeakGcAddress:  name_weakgcaddress,
     WeakRef:  name_weakref,
     }
 
@@ -157,7 +147,6 @@
     Bool:     'bool_t @',
     Void:     'void @',
     Address:  'void* @',
-    WeakGcAddress:  'GC_hidden_pointer @',
     WeakRef:  'GCWeakRef @',
     }
 
@@ -172,7 +161,6 @@
     Bool:     '0 /* error */',
     Void:     '/* error */',
     Address:  'NULL',
-    WeakGcAddress:  'HIDE_POINTER(NULL)',
     WeakRef:  'NULL',
     }
 

Modified: pypy/branch/cleanup-weakref/pypy/translator/c/src/address.h
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/c/src/address.h	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/c/src/address.h	Tue Sep 11 19:09:45 2007
@@ -18,7 +18,6 @@
 
 #define OP_CAST_ADR_TO_INT(x, r)     r = ((long)x)
 #define OP_CAST_INT_TO_ADR(x, r)     r = ((void *)(x))
-#define OP_CAST_WEAKADR_TO_INT(x, r) r = ((long)x)
 
 #ifndef HIDE_POINTER
 #define HIDE_POINTER(p) (p)

Modified: pypy/branch/cleanup-weakref/pypy/translator/c/test/test_lladdresses.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/c/test/test_lladdresses.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/c/test/test_lladdresses.py	Tue Sep 11 19:09:45 2007
@@ -120,44 +120,3 @@
         return result
     fn = compile(f, [int])
     assert fn(1) == 2
-
-def test_weakaddress():
-    from pypy.rlib.objectmodel import cast_object_to_weakgcaddress
-    from pypy.rlib.objectmodel import cast_weakgcaddress_to_object
-    from pypy.rpython.lltypesystem.lloperation import llop
-    class A(object):
-        pass
-    def func(i):
-        l1 = []
-        l2 = []
-        for i in range(i):
-            a = A()
-            l1.append(a)
-            l2.append(cast_object_to_weakgcaddress(a))
-        return len(l1) == len(l2)
-    fn = compile(func, [int])
-    assert fn(10)
-
-def test_constant_weakaddress():
-    from pypy.rlib.objectmodel import cast_object_to_weakgcaddress
-    from pypy.rlib.objectmodel import cast_weakgcaddress_to_object
-    from pypy.rpython.lltypesystem.lloperation import llop
-    class A(object):
-        pass
-    constant_a = A()
-    constant_weak_a = cast_object_to_weakgcaddress(constant_a)
-    l = [constant_weak_a]
-    def func(i):
-        l1 = []
-        l2 = []
-        l3 = []
-        l4 = []
-        for i in range(i):
-            a = A()
-            l1.append(a)
-            l2.append(cast_object_to_weakgcaddress(a))
-            l3.append(constant_a)
-            l4.extend(l)
-        return len(l1) == len(l2) == len(l3) == len(l4)
-    fn = compile(func, [int])
-    assert fn(10)

Modified: pypy/branch/cleanup-weakref/pypy/translator/c/test/test_newgc.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/c/test/test_newgc.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/c/test/test_newgc.py	Tue Sep 11 19:09:45 2007
@@ -8,7 +8,6 @@
 from pypy.translator.c import genc, gc
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.lltypesystem.lloperation import llop
-from pypy.rlib.objectmodel import cast_weakgcaddress_to_object, cast_object_to_weakgcaddress
 from pypy import conftest
 
 def compile_func(fn, inputtypes, t=None, gcpolicy="ref"):
@@ -255,125 +254,6 @@
     res = fn(112)
     assert res == -8
 
-class Weakrefable(object):
-    __lifeline__ = None
-
-class Weakref(object):
-    def __init__(self, lifeline, index, obj, callback):
-        self.address = cast_object_to_weakgcaddress(obj)
-        self.callback = callback
-        self.lifeline_addr = cast_object_to_weakgcaddress(lifeline)
-        self.index = index
-    
-    def ref(self):
-        return cast_weakgcaddress_to_object(self.address, Weakrefable)
-
-    def invalidate(self):
-        self.address = llmemory.WEAKNULL
-        self.lifeline_addr = llmemory.WEAKNULL
-        if self.callback is not None:
-            self.callback(self)
-
-    def __del__(self):
-        lifeline = cast_weakgcaddress_to_object(self.lifeline_addr,
-                                                WeakrefLifeline)
-        if lifeline is not None:
-            lifeline.ref_is_dead(self.index)
-
-class WeakrefLifeline(object):
-    def __init__(self, obj):
-        self.refs = []
-        
-    def __del__(self):
-        i = 0
-        while i < len(self.refs):
-            addr_ref = self.refs[i]
-            if cast_weakgcaddress_to_object(addr_ref, Weakref) is not None:
-                ref = cast_weakgcaddress_to_object(addr_ref, Weakref)
-                ref.invalidate()
-            i += 1
-
-    def get_weakref(self, obj, callback):
-        ref = Weakref(self, len(self.refs), obj, callback)
-        addr_ref = cast_object_to_weakgcaddress(ref)
-        self.refs.append(addr_ref)
-        return ref
-
-    def ref_is_dead(self, index):
-        self.refs[index] = llmemory.WEAKNULL
-
-def get_weakref(obj, callback=None):
-    assert isinstance(obj, Weakrefable)
-    if obj.__lifeline__ is None:
-        obj.__lifeline__ = WeakrefLifeline(obj)
-    return obj.__lifeline__.get_weakref(obj, callback)
-
-def test_weakref_alive():
-    def func():
-        f = Weakrefable()
-        f.x = 32
-        ref1 = get_weakref(f)
-        ref2 = get_weakref(f)
-        return f.x + ref2.ref().x
-    assert func() == 64
-    f = compile_func(func, [])
-    assert f() == 64
-
-def test_weakref_dying():
-    def g():
-        f = Weakrefable()
-        f.x = 32
-        return get_weakref(f)
-    def func():
-        ref = g()
-        return ref.ref() is None
-    assert func()
-    f = compile_func(func, [])
-    assert f()
-
-def test_weakref_callback():
-    global_w = Weakrefable()
-    global_w.x = 31
-    def g(ref):
-        global_w.x = 32
-    def h():
-        f = Weakrefable()
-        f.x = 32
-        ref = get_weakref(f, g)
-        return ref
-    def func():
-        ref = h()
-        return (ref.ref() is None and ref.callback is not None and
-                global_w.x == 32)
-    assert func()
-    f = compile_func(func, [])
-    assert f()
-
-def test_weakref_dont_always_callback():
-    global_w1 = Weakrefable()
-    global_w1.x = 30
-    global_w2 = Weakrefable()
-    global_w2.x = 30
-    def g1(ref):
-        global_w1.x = 32
-    def g2(ref):
-        global_w2.x = 32
-    def h():
-        f = Weakrefable()
-        f.x = 32
-        ref1 = get_weakref(f, g1)
-        ref2 = get_weakref(f, g2)
-        if f.x % 2 == 0: # start a new block to make sure ref2 dies before f
-            ref2 = None
-        f.x = 12
-        return ref1
-    def func():
-        ref = h()
-        return global_w1.x == 32 and global_w2.x == 30
-    assert func()
-    f = compile_func(func, [])
-    assert f()
-
 def test_gc_x_operations():
     t = TranslationContext()
     from pypy.rlib.rgc import gc_clone, gc_swap_pool

Modified: pypy/branch/cleanup-weakref/pypy/translator/cli/metavm.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/cli/metavm.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/cli/metavm.py	Tue Sep 11 19:09:45 2007
@@ -120,13 +120,14 @@
                             '[mscorlib]System.Collections.Generic.IEqualityComparer`1<!0>)'
                             % dict_type)
 
-class _CastWeakAdrToPtr(MicroInstruction):
-    def render(self, generator, op):
-        RESULTTYPE = op.result.concretetype
-        resulttype = generator.cts.lltype_to_cts(RESULTTYPE)
-        generator.load(op.args[0])
-        generator.ilasm.call_method('object class %s::get_Target()' % WEAKREF, True)
-        generator.ilasm.opcode('castclass', resulttype)
+#XXX adapt to new way of things
+#class _CastWeakAdrToPtr(MicroInstruction):
+#    def render(self, generator, op):
+#        RESULTTYPE = op.result.concretetype
+#        resulttype = generator.cts.lltype_to_cts(RESULTTYPE)
+#        generator.load(op.args[0])
+#        generator.ilasm.call_method('object class %s::get_Target()' % WEAKREF, True)
+#        generator.ilasm.opcode('castclass', resulttype)
 
 class MapException(MicroInstruction):
     COUNT = 0
@@ -226,7 +227,7 @@
 RuntimeNew = _RuntimeNew()
 OOString = _OOString()
 NewCustomDict = _NewCustomDict()
-CastWeakAdrToPtr = _CastWeakAdrToPtr()
+#CastWeakAdrToPtr = _CastWeakAdrToPtr()
 Box = _Box()
 Unbox = _Unbox()
 NewArray = _NewArray()

Modified: pypy/branch/cleanup-weakref/pypy/translator/cli/opcodes.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/cli/opcodes.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/cli/opcodes.py	Tue Sep 11 19:09:45 2007
@@ -1,6 +1,6 @@
 from pypy.translator.cli.metavm import  Call, CallMethod, \
      IndirectCall, GetField, SetField, OOString, DownCast, NewCustomDict,\
-     CastWeakAdrToPtr, MapException, Box, Unbox, NewArray, GetArrayElem, SetArrayElem,\
+     MapException, Box, Unbox, NewArray, GetArrayElem, SetArrayElem,\
      TypeOf, CastPrimitive
 from pypy.translator.oosupport.metavm import PushArg, PushAllArgs, StoreResult, InstructionList,\
     New, RuntimeNew, CastTo, PushPrimitive
@@ -60,7 +60,6 @@
     'indirect_call':            [IndirectCall],
 
     'cast_ptr_to_weakadr':      [PushAllArgs, 'newobj instance void class %s::.ctor(object)' % WEAKREF],
-    'cast_weakadr_to_ptr':      [CastWeakAdrToPtr],
     'gc__collect':              'call void class [mscorlib]System.GC::Collect()',
     'gc_set_max_heap_size':     Ignore,
     'resume_point':             Ignore,

Modified: pypy/branch/cleanup-weakref/pypy/translator/exceptiontransform.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/exceptiontransform.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/exceptiontransform.py	Tue Sep 11 19:09:45 2007
@@ -24,7 +24,6 @@
                        lltype.UniChar: unichr(0xFFFF), # XXX is this always right?
                        lltype.Bool: True,
                        llmemory.Address: NULL,
-                       llmemory.WeakGcAddress: llmemory.fakeweakaddress(None),
                        llmemory.WeakRef: llmemory.fakeweakref(None),
                        lltype.Void: None}
 

Modified: pypy/branch/cleanup-weakref/pypy/translator/jvm/metavm.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/jvm/metavm.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/jvm/metavm.py	Tue Sep 11 19:09:45 2007
@@ -126,20 +126,21 @@
         generator.emit(jvmgen.CUSTOMDICTMAKE)
 NewCustomDict = _NewCustomDict()
 
-class _CastPtrToWeakAddress(MicroInstruction):
-    def render(self, generator, op):
-        arg = op.args[0]
-        generator.prepare_cast_ptr_to_weak_address()
-        generator.load(arg)
-        generator.finalize_cast_ptr_to_weak_address(arg.concretetype)
-        generator.store(op.result)
-CastPtrToWeakAddress = _CastPtrToWeakAddress()
+#XXX adapt to new way of things
+#class _CastPtrToWeakAddress(MicroInstruction):
+#    def render(self, generator, op):
+#        arg = op.args[0]
+#        generator.prepare_cast_ptr_to_weak_address()
+#        generator.load(arg)
+#        generator.finalize_cast_ptr_to_weak_address(arg.concretetype)
+#        generator.store(op.result)
+#CastPtrToWeakAddress = _CastPtrToWeakAddress()
         
-class _CastWeakAddressToPtr(MicroInstruction):
-    def render(self, generator, op):
-        RESULTTYPE = op.result.concretetype
-        generator.cast_weak_address_to_ptr(RESULTTYPE)
-CastWeakAddressToPtr = _CastWeakAddressToPtr()
+#class _CastWeakAddressToPtr(MicroInstruction):
+#    def render(self, generator, op):
+#        RESULTTYPE = op.result.concretetype
+#        generator.cast_weak_address_to_ptr(RESULTTYPE)
+#CastWeakAddressToPtr = _CastWeakAddressToPtr()
 
 
 CASTS = {

Modified: pypy/branch/cleanup-weakref/pypy/translator/jvm/opcodes.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/jvm/opcodes.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/jvm/opcodes.py	Tue Sep 11 19:09:45 2007
@@ -10,7 +10,7 @@
      SetField, GetField, DownCast, RuntimeNew, OOString, CastTo, PushPrimitive
 from pypy.translator.jvm.metavm import \
      IndirectCall, JvmCallMethod, TranslateException, NewCustomDict, \
-     CastPtrToWeakAddress, CastWeakAddressToPtr, CastPrimitive
+     CastPrimitive
 from pypy.rpython.ootypesystem import ootype
 
 import pypy.translator.jvm.generator as jvmgen
@@ -65,8 +65,6 @@
     'direct_call':              [Call, StoreResult],
     'indirect_call':            [PushAllArgs, IndirectCall, StoreResult],
 
-    'cast_ptr_to_weakadr':      [CastPtrToWeakAddress],
-    'cast_weakadr_to_ptr':      CastWeakAddressToPtr,
     'gc__collect':              jvmgen.SYSTEMGC,
     'gc_set_max_heap_size':     Ignore,
     'resume_point':             Ignore,

Modified: pypy/branch/cleanup-weakref/pypy/translator/llvm/test/test_lladdresses.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/llvm/test/test_lladdresses.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/llvm/test/test_lladdresses.py	Tue Sep 11 19:09:45 2007
@@ -170,20 +170,3 @@
     fn = compile_function(f, [])
     assert f() == 579
     
-def test_weakaddress():
-    from pypy.rlib.objectmodel import cast_object_to_weakgcaddress
-    from pypy.rlib.objectmodel import cast_weakgcaddress_to_object
-    from pypy.rpython.lltypesystem.lloperation import llop
-    class A(object):
-        pass
-    def func(i):
-        l1 = []
-        l2 = []
-        for i in range(i):
-            a = A()
-            l1.append(a)
-            l2.append(cast_object_to_weakgcaddress(a))
-        return len(l1) == len(l2)
-    fn = compile_function(func, [int])
-    assert fn(10)
-    

Modified: pypy/branch/cleanup-weakref/pypy/translator/oosupport/test_template/objectmodel.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/oosupport/test_template/objectmodel.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/oosupport/test_template/objectmodel.py	Tue Sep 11 19:09:45 2007
@@ -1,8 +1,6 @@
 import py
 from pypy.rlib.test.test_objectmodel import BaseTestObjectModel as RLibBase
 
-from pypy.rlib.objectmodel import cast_object_to_weakgcaddress,\
-     cast_weakgcaddress_to_object
 
 class BaseTestObjectModel(RLibBase):
     def test_rdict_of_void_copy(self):
@@ -15,43 +13,3 @@
             return len(d1)
         assert self.interpret(fn, []) == 2
 
-    # this test is copied from TestLLtype in
-    # rlib/test_objectmodel.py. It is not in TestOOtype because at
-    # the moment llinterpret can't handle cast_*weakadr*
-    def test_cast_to_and_from_weakaddress(self):
-        class A(object):
-            pass
-        class B(object):
-            pass
-        def f():
-            a = A()
-            addr = cast_object_to_weakgcaddress(a)
-            return a is cast_weakgcaddress_to_object(addr, A)
-        res = self.interpret(f, [])
-        assert res
-##        def g():
-##            a = A()
-##            addr = cast_object_to_weakgcaddress(a)
-##            return cast_weakgcaddress_to_int(addr)
-##        assert isinstance(self.interpret(f, []), int)
-
-    def test_weakref_const(self):
-        class A(object):
-            def __init__(self):
-                self.x = 42
-        a = A()
-        weak = cast_object_to_weakgcaddress(a)
-        def f():
-            a.x = 10
-            b = cast_weakgcaddress_to_object(weak, A)
-            return b.x
-        assert self.interpret(f, []) == 10
-
-    def test_weakref_const_null(self):
-        class A(object):
-            pass
-        weak = cast_object_to_weakgcaddress(None)
-        def f():
-            b = cast_weakgcaddress_to_object(weak, A)
-            return b
-        assert self.interpret(f, []) is None

Modified: pypy/branch/cleanup-weakref/pypy/translator/stackless/code.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/stackless/code.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/stackless/code.py	Tue Sep 11 19:09:45 2007
@@ -296,7 +296,7 @@
         self.retval_float = 0.0
         self.retval_addr = llmemory.NULL
         self.retval_ref = frame.null_saved_ref
-        self.retval_weak = llmemory.WEAKNULL
+        self.retval_weak = llmemory.WEAKREFNULL
         self.exception = None
         self.masterarray = lltype.malloc(frame.FRAME_INFO_ARRAY, 0,
                                          immortal=True)

Modified: pypy/branch/cleanup-weakref/pypy/translator/stackless/frame.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/stackless/frame.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/stackless/frame.py	Tue Sep 11 19:09:45 2007
@@ -20,7 +20,7 @@
     (lltype.SignedLongLong, 'longlong'),
     (lltype.Signed, 'long'),
     (lltype.Float, 'float'),
-    (llmemory.WeakGcAddress, 'weak'),
+    (llmemory.WeakRef, 'weak'),
      ]
 
 STORAGE_TYPES = []
@@ -55,8 +55,8 @@
         return lltype.SignedLongLong
     elif T is llmemory.Address:
         return llmemory.Address
-    elif T is llmemory.WeakGcAddress:
-        return llmemory.WeakGcAddress
+    elif T is llmemory.WeakRef:
+        return llmemory.WeakRef
     elif isinstance(T, lltype.Primitive):
         return lltype.Signed
     else:

Modified: pypy/branch/cleanup-weakref/pypy/translator/stackless/transform.py
==============================================================================
--- pypy/branch/cleanup-weakref/pypy/translator/stackless/transform.py	(original)
+++ pypy/branch/cleanup-weakref/pypy/translator/stackless/transform.py	Tue Sep 11 19:09:45 2007
@@ -370,8 +370,8 @@
                 code.fetch_retval_addr, [], annmodel.SomeAddress()),
             SAVED_REFERENCE: mixlevelannotator.constfunc(
                 code.fetch_retval_ref, [], annmodel.SomePtr(SAVED_REFERENCE)),
-            llmemory.WeakGcAddress: mixlevelannotator.constfunc(
-                code.fetch_retval_weak, [], annmodel.SomeWeakGcAddress()),
+            llmemory.WeakRef: mixlevelannotator.constfunc(
+                code.fetch_retval_weak, [], annmodel.SomeLLWeakRef()),
             }
 
         s_StatePtr = annmodel.SomePtr(frame.OPAQUE_STATE_HEADER_PTR)
@@ -422,9 +422,9 @@
                 code.resume_after_ref,
                 [s_StatePtr, annmodel.SomePtr(SAVED_REFERENCE)],
                 annmodel.s_None),
-            llmemory.WeakGcAddress: mixlevelannotator.constfunc(
+            llmemory.WeakRef: mixlevelannotator.constfunc(
                 code.resume_after_weak,
-                [s_StatePtr, annmodel.SomeWeakGcAddress()],
+                [s_StatePtr, annmodel.SomeLLWeakRef()],
                 annmodel.s_None),
             }
         exception_def = bk.getuniqueclassdef(Exception)



More information about the Pypy-commit mailing list