[pypy-svn] pypy out-of-line-guards-2: Fixes.
arigo
commits-noreply at bitbucket.org
Sat Apr 2 20:17:28 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: out-of-line-guards-2
Changeset: r43114:7142ac33e6a5
Date: 2011-04-02 18:20 +0200
http://bitbucket.org/pypy/pypy/changeset/7142ac33e6a5/
Log: Fixes.
diff --git a/pypy/rpython/lltypesystem/lltype.py b/pypy/rpython/lltypesystem/lltype.py
--- a/pypy/rpython/lltypesystem/lltype.py
+++ b/pypy/rpython/lltypesystem/lltype.py
@@ -998,6 +998,8 @@
return None # null pointer
if type(p._obj0) is int:
return p # a pointer obtained by cast_int_to_ptr
+ if getattr(p._obj0, '_carry_around_for_tests', False):
+ return p # a pointer obtained by cast_instance_to_base_ptr
container = obj._normalizedcontainer()
if type(container) is int:
# this must be an opaque ptr originating from an integer
@@ -1850,8 +1852,8 @@
if self.__class__ is not other.__class__:
return NotImplemented
if hasattr(self, 'container') and hasattr(other, 'container'):
- obj1 = self.container._normalizedcontainer()
- obj2 = other.container._normalizedcontainer()
+ obj1 = self._normalizedcontainer()
+ obj2 = other._normalizedcontainer()
return obj1 == obj2
else:
return self is other
@@ -1875,6 +1877,8 @@
# an integer, cast to a ptr, cast to an opaque
if type(self.container) is int:
return self.container
+ if getattr(self.container, '_carry_around_for_tests', False):
+ return self.container
return self.container._normalizedcontainer()
else:
return _parentable._normalizedcontainer(self)
diff --git a/pypy/rpython/annlowlevel.py b/pypy/rpython/annlowlevel.py
--- a/pypy/rpython/annlowlevel.py
+++ b/pypy/rpython/annlowlevel.py
@@ -484,16 +484,19 @@
Limited to casting a given object to a single type.
"""
if isinstance(PTR, lltype.Ptr):
- if not hasattr(object, '_TYPE'):
- object._TYPE = PTR.TO
- else:
- assert object._TYPE == PTR.TO
+ TO = PTR.TO
+ else:
+ TO = PTR
+ if not hasattr(object, '_carry_around_for_tests'):
+ assert not hasattr(object, '_TYPE')
+ object._carry_around_for_tests = True
+ object._TYPE = TO
+ else:
+ assert object._TYPE == TO
+ #
+ if isinstance(PTR, lltype.Ptr):
return lltype._ptr(PTR, object, True)
elif isinstance(PTR, ootype.Instance):
- if not hasattr(object, '_TYPE'):
- object._TYPE = PTR
- else:
- assert object._TYPE == PTR
return object
else:
raise NotImplementedError("cast_object_to_ptr(%r, ...)" % PTR)
More information about the Pypy-commit
mailing list