[pypy-svn] r64921 - pypy/branch/pyjitpl5/pypy/rpython
antocuni at codespeak.net
antocuni at codespeak.net
Fri May 1 10:07:25 CEST 2009
Author: antocuni
Date: Fri May 1 10:07:17 2009
New Revision: 64921
Modified:
pypy/branch/pyjitpl5/pypy/rpython/annlowlevel.py
Log:
merge r54317 from oo-jit/
svn merge svn+ssh://codespeak.net/svn/pypy/branch/oo-jit/pypy/ -r54316:54317
------------------------------------------------------------------------
r54317 | antocuni | 2008-05-02 14:01:57 +0200 (Fri, 02 May 2008) | 4 lines
Changed paths:
M /pypy/branch/oo-jit/pypy/rpython/annlowlevel.py
forgot to checkin this in in r54301; make cast_object_to_ptr and
cast_base_ptr_to_instance ootype-friendly
------------------------------------------------------------------------
Modified: pypy/branch/pyjitpl5/pypy/rpython/annlowlevel.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/rpython/annlowlevel.py (original)
+++ pypy/branch/pyjitpl5/pypy/rpython/annlowlevel.py Fri May 1 10:07:17 2009
@@ -462,28 +462,51 @@
return cast_object_to_ptr(base_ptr_lltype(), instance)
cast_instance_to_base_ptr._annspecialcase_ = 'specialize:argtype(0)'
+def cast_instance_to_base_obj(instance):
+ return cast_object_to_ptr(base_obj_ootype(), instance)
+cast_instance_to_base_obj._annspecialcase_ = 'specialize:argtype(0)'
+
def base_ptr_lltype():
from pypy.rpython.lltypesystem.rclass import OBJECTPTR
return OBJECTPTR
+def base_obj_ootype():
+ from pypy.rpython.ootypesystem.rclass import OBJECT
+ return OBJECT
+
class CastObjectToPtrEntry(extregistry.ExtRegistryEntry):
_about_ = cast_object_to_ptr
def compute_result_annotation(self, s_PTR, s_object):
assert s_PTR.is_constant()
- assert isinstance(s_PTR.const, lltype.Ptr)
- return annmodel.SomePtr(s_PTR.const)
+ if isinstance(s_PTR.const, lltype.Ptr):
+ return annmodel.SomePtr(s_PTR.const)
+ elif isinstance(s_PTR.const, ootype.Instance):
+ return annmodel.SomeOOInstance(s_PTR.const)
+ else:
+ assert False
def specialize_call(self, hop):
from pypy.rpython import rpbc
PTR = hop.r_result.lowleveltype
+ if isinstance(PTR, lltype.Ptr):
+ T = lltype.Ptr
+ opname = 'cast_pointer'
+ null = lltype.nullptr(PTR.TO)
+ elif isinstance(PTR, ootype.Instance):
+ T = ootype.Instance
+ opname = 'ooupcast'
+ null = ootype.null(PTR)
+ else:
+ assert False
+
if isinstance(hop.args_r[1], rpbc.NoneFrozenPBCRepr):
- return hop.inputconst(PTR, lltype.nullptr(PTR.TO))
+ return hop.inputconst(PTR, null)
v_arg = hop.inputarg(hop.args_r[1], arg=1)
- assert isinstance(v_arg.concretetype, lltype.Ptr)
+ assert isinstance(v_arg.concretetype, T)
hop.exception_cannot_occur()
- return hop.genop('cast_pointer', [v_arg],
- resulttype = PTR)
+ return hop.genop(opname, [v_arg], resulttype = PTR)
+
# ____________________________________________________________
@@ -513,6 +536,7 @@
# ____________________________________________________________
+
def placeholder_sigarg(s):
if s == "self":
def expand(s_self, *args_s):
More information about the Pypy-commit
mailing list