[pypy-svn] r67248 - in pypy/branch/pyjitpl5-less-is_oo/pypy/jit: backend/cli backend/llgraph backend/llgraph/test backend/llvm backend/test backend/x86 metainterp metainterp/test
antocuni at codespeak.net
antocuni at codespeak.net
Thu Aug 27 16:21:55 CEST 2009
Author: antocuni
Date: Thu Aug 27 16:21:54 2009
New Revision: 67248
Modified:
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/method.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/runner.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llgraph/runner.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llgraph/test/test_llgraph.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llvm/runner.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/test/runner_test.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/test/test_ll_random.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/x86/runner.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/compile.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/executor.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/history.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/optimizeopt.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/pyjitpl.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/test/test_optimizeopt.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/typesystem.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/virtualizable.py
pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/warmspot.py
Log:
unify {Const,Box}{Obj,Ptr} interfaces:
- rename getptr_base and getobj to getref_base
- rename getptr to getref
- introduce getref for objects, which helps to get rid of a lot of ootype.cast_from_object(...)
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/method.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/method.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/method.py Thu Aug 27 16:21:54 2009
@@ -71,7 +71,7 @@
assert False, 'cannot store() to Constant'
def get_cliobj(self):
- return dotnet.cast_to_native_object(self.getobj())
+ return dotnet.cast_to_native_object(self.getref_base())
class __extend__(ConstInt):
__metaclass__ = extendabletype
@@ -228,7 +228,6 @@
# initialize the array of genconsts
consts = dotnet.new_array(System.Object, len(self.consts))
for av_const, i in self.consts.iteritems():
- #consts[i] = dotnet.cast_to_native_object(av_const.getobj())
consts[i] = av_const.get_cliobj()
# build the delegate
func = self.meth_wrapper.create_delegate(delegatetype, consts)
@@ -459,7 +458,7 @@
il_label = self.newbranch(op)
classbox = op.args[0]
assert isinstance(classbox, ConstObj)
- oocls = ootype.cast_from_object(ootype.Class, classbox.getobj())
+ oocls = classbox.getref(ootype.Class)
clitype = dotnet.class2type(oocls)
self.av_inputargs.load(self)
self.il.Emit(OpCodes.Ldfld, self.exc_value_field)
@@ -507,7 +506,7 @@
def emit_op_new_with_vtable(self, op):
clsbox = op.args[0]
assert isinstance(clsbox, ConstObj)
- cls = clsbox.getobj()
+ cls = clsbox.getref_base()
descr = self.cpu.class_sizes[cls]
assert isinstance(descr, runner.TypeDescr)
clitype = descr.get_clitype()
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/runner.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/runner.py Thu Aug 27 16:21:54 2009
@@ -162,7 +162,7 @@
#assert len(args) == 1 # but we don't need it, so ignore
assert descr is None
assert len(args) == 1
- cls = args[0].getobj()
+ cls = args[0].getref_base()
typedescr = self.class_sizes[cls]
return typedescr.create()
@@ -173,7 +173,7 @@
def do_runtimenew(self, args, descr):
classbox = args[0]
- classobj = ootype.cast_from_object(ootype.Class, classbox.getobj())
+ classobj = classbox.getref(ootype.Class)
res = ootype.runtimenew(classobj)
return BoxObj(ootype.cast_to_object(res))
@@ -296,21 +296,21 @@
n = lengthbox.getint()
return boxresult(ARRAY, ootype.oonewarray(ARRAY, n))
def getarrayitem(arraybox, ibox):
- array = ootype.cast_from_object(ARRAY, arraybox.getobj())
+ array = arraybox.getref(ARRAY)
i = ibox.getint()
if TYPE is not ootype.Void:
return boxresult(TYPE, array.ll_getitem_fast(i))
def setarrayitem(arraybox, ibox, valuebox):
- array = ootype.cast_from_object(ARRAY, arraybox.getobj())
+ array = arraybox.getref(ARRAY)
i = ibox.getint()
value = unwrap(TYPE, valuebox)
array.ll_setitem_fast(i, value)
def getarraylength(arraybox):
- array = ootype.cast_from_object(ARRAY, arraybox.getobj())
+ array = arraybox.getref(ARRAY)
return boxresult(ootype.Signed, array.ll_length())
def instanceof(box):
if isinstance(TYPE, ootype.Instance):
- obj = ootype.cast_from_object(ootype.ROOT, box.getobj())
+ obj = box.getref(ootype.ROOT)
return BoxInt(ootype.instanceof(obj, TYPE))
return None
self.create = create
@@ -351,7 +351,7 @@
from pypy.jit.backend.llgraph.runner import boxresult, make_getargs
getargs = make_getargs(FUNC.ARGS)
def callfunc(funcbox, argboxes):
- funcobj = ootype.cast_from_object(FUNC, funcbox.getobj())
+ funcobj = funcbox.getref(FUNC)
funcargs = getargs(argboxes)
res = funcobj(*funcargs)
if RESULT is not ootype.Void:
@@ -394,7 +394,7 @@
METH = ootype.typeOf(meth)
getargs = make_getargs(METH.ARGS)
def callmeth(selfbox, argboxes):
- selfobj = ootype.cast_from_object(SELFTYPE, selfbox.getobj())
+ selfobj = selfbox.getref(SELFTYPE)
meth = getattr(selfobj, methname)
methargs = getargs(argboxes)
res = meth(*methargs)
@@ -443,11 +443,11 @@
from pypy.jit.metainterp.warmspot import unwrap
_, T = TYPE._lookup_field(fieldname)
def getfield(objbox):
- obj = ootype.cast_from_object(TYPE, objbox.getobj())
+ obj = objbox.getref(TYPE)
value = getattr(obj, fieldname)
return boxresult(T, value)
def setfield(objbox, valuebox):
- obj = ootype.cast_from_object(TYPE, objbox.getobj())
+ obj = objbox.getref(TYPE)
value = unwrap(T, valuebox)
setattr(obj, fieldname, value)
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llgraph/runner.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llgraph/runner.py Thu Aug 27 16:21:54 2009
@@ -278,34 +278,34 @@
# ---------- the backend-dependent operations ----------
def do_arraylen_gc(self, args, arraydescr):
- array = args[0].getptr_base()
+ array = args[0].getref_base()
return history.BoxInt(llimpl.do_arraylen_gc(arraydescr, array))
def do_strlen(self, args, descr=None):
assert descr is None
- string = args[0].getptr_base()
+ string = args[0].getref_base()
return history.BoxInt(llimpl.do_strlen(0, string))
def do_strgetitem(self, args, descr=None):
assert descr is None
- string = args[0].getptr_base()
+ string = args[0].getref_base()
index = args[1].getint()
return history.BoxInt(llimpl.do_strgetitem(0, string, index))
def do_unicodelen(self, args, descr=None):
assert descr is None
- string = args[0].getptr_base()
+ string = args[0].getref_base()
return history.BoxInt(llimpl.do_unicodelen(0, string))
def do_unicodegetitem(self, args, descr=None):
assert descr is None
- string = args[0].getptr_base()
+ string = args[0].getref_base()
index = args[1].getint()
return history.BoxInt(llimpl.do_unicodegetitem(0, string, index))
def do_getarrayitem_gc(self, args, arraydescr):
assert isinstance(arraydescr, Descr)
- array = args[0].getptr_base()
+ array = args[0].getref_base()
index = args[1].getint()
if arraydescr.typeinfo == 'p':
return history.BoxPtr(llimpl.do_getarrayitem_gc_ptr(array, index))
@@ -315,7 +315,7 @@
def do_getfield_gc(self, args, fielddescr):
assert isinstance(fielddescr, Descr)
- struct = args[0].getptr_base()
+ struct = args[0].getref_base()
if fielddescr.typeinfo == 'p':
return history.BoxPtr(llimpl.do_getfield_gc_ptr(struct,
fielddescr.ofs))
@@ -355,10 +355,10 @@
def do_setarrayitem_gc(self, args, arraydescr):
assert isinstance(arraydescr, Descr)
- array = args[0].getptr_base()
+ array = args[0].getref_base()
index = args[1].getint()
if arraydescr.typeinfo == 'p':
- newvalue = args[2].getptr_base()
+ newvalue = args[2].getref_base()
llimpl.do_setarrayitem_gc_ptr(array, index, newvalue)
else:
newvalue = args[2].getint()
@@ -367,9 +367,9 @@
def do_setfield_gc(self, args, fielddescr):
assert isinstance(fielddescr, Descr)
- struct = args[0].getptr_base()
+ struct = args[0].getref_base()
if fielddescr.typeinfo == 'p':
- newvalue = args[1].getptr_base()
+ newvalue = args[1].getref_base()
llimpl.do_setfield_gc_ptr(struct, fielddescr.ofs, newvalue)
else:
newvalue = args[1].getint()
@@ -380,7 +380,7 @@
assert isinstance(fielddescr, Descr)
struct = self.cast_int_to_adr(args[0].getint())
if fielddescr.typeinfo == 'p':
- newvalue = args[1].getptr_base()
+ newvalue = args[1].getref_base()
llimpl.do_setfield_raw_ptr(struct, fielddescr.ofs, newvalue,
self.memo_cast)
else:
@@ -403,14 +403,14 @@
def do_strsetitem(self, args, descr=None):
assert descr is None
- string = args[0].getptr_base()
+ string = args[0].getref_base()
index = args[1].getint()
newvalue = args[2].getint()
llimpl.do_strsetitem(0, string, index, newvalue)
def do_unicodesetitem(self, args, descr=None):
assert descr is None
- string = args[0].getptr_base()
+ string = args[0].getref_base()
index = args[1].getint()
newvalue = args[2].getint()
llimpl.do_unicodesetitem(0, string, index, newvalue)
@@ -421,7 +421,7 @@
for arg in args[1:]:
if (isinstance(arg, history.BoxPtr) or
isinstance(arg, history.ConstPtr)):
- llimpl.do_call_pushptr(arg.getptr_base())
+ llimpl.do_call_pushptr(arg.getref_base())
else:
llimpl.do_call_pushint(arg.getint())
if calldescr.typeinfo == 'p':
@@ -439,7 +439,7 @@
def do_cast_ptr_to_int(self, args, descr=None):
assert descr is None
- return history.BoxInt(llimpl.cast_to_int(args[0].getptr_base(),
+ return history.BoxInt(llimpl.cast_to_int(args[0].getref_base(),
self.memo_cast))
class OOtypeCPU(BaseCPU):
@@ -497,7 +497,7 @@
def do_new_with_vtable(self, args, descr=None):
assert descr is None
assert len(args) == 1
- cls = args[0].getobj()
+ cls = args[0].getref_base()
typedescr = self.class_sizes[cls]
return typedescr.create()
@@ -514,7 +514,7 @@
def do_runtimenew(self, args, descr):
"NOT_RPYTHON"
classbox = args[0]
- classobj = ootype.cast_from_object(ootype.Class, classbox.getobj())
+ classobj = classbox.getref(ootype.Class)
res = ootype.runtimenew(classobj)
return history.BoxObj(ootype.cast_to_object(res))
@@ -628,7 +628,7 @@
self.FUNC = FUNC
getargs = make_getargs(FUNC.ARGS)
def callfunc(funcbox, argboxes):
- funcobj = ootype.cast_from_object(FUNC, funcbox.getobj())
+ funcobj = funcbox.getref(FUNC)
funcargs = getargs(argboxes)
res = llimpl.call_maybe_on_top_of_llinterp(funcobj, funcargs)
if RESULT is not ootype.Void:
@@ -650,7 +650,7 @@
RESULT = METH.RESULT
getargs = make_getargs(METH.ARGS)
def callmeth(selfbox, argboxes):
- selfobj = ootype.cast_from_object(SELFTYPE, selfbox.getobj())
+ selfobj = selfbox.getref(SELFTYPE)
meth = getattr(selfobj, methname)
methargs = getargs(argboxes)
res = llimpl.call_maybe_on_top_of_llinterp(meth, methargs)
@@ -676,22 +676,22 @@
return boxresult(ARRAY, ootype.oonewarray(ARRAY, n))
def getarrayitem(arraybox, ibox):
- array = ootype.cast_from_object(ARRAY, arraybox.getobj())
+ array = arraybox.getref(ARRAY)
i = ibox.getint()
return boxresult(TYPE, array.ll_getitem_fast(i))
def setarrayitem(arraybox, ibox, valuebox):
- array = ootype.cast_from_object(ARRAY, arraybox.getobj())
+ array = arraybox.getref(ARRAY)
i = ibox.getint()
value = unwrap(TYPE, valuebox)
array.ll_setitem_fast(i, value)
def getarraylength(arraybox):
- array = ootype.cast_from_object(ARRAY, arraybox.getobj())
+ array = arraybox.getref(ARRAY)
return boxresult(ootype.Signed, array.ll_length())
def instanceof(box):
- obj = ootype.cast_from_object(ootype.ROOT, box.getobj())
+ obj = box.getref(ootype.ROOT)
return history.BoxInt(ootype.instanceof(obj, TYPE))
self.create = create
@@ -720,11 +720,11 @@
_, T = TYPE._lookup_field(fieldname)
def getfield(objbox):
- obj = ootype.cast_from_object(TYPE, objbox.getobj())
+ obj = objbox.getref(TYPE)
value = getattr(obj, fieldname)
return boxresult(T, value)
def setfield(objbox, valuebox):
- obj = ootype.cast_from_object(TYPE, objbox.getobj())
+ obj = objbox.getref(TYPE)
value = unwrap(T, valuebox)
setattr(obj, fieldname, value)
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llgraph/test/test_llgraph.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llgraph/test/test_llgraph.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llgraph/test/test_llgraph.py Thu Aug 27 16:21:54 2009
@@ -109,7 +109,7 @@
[BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, b)), BoxInt(3)],
descr_B)
assert isinstance(x, BoxPtr)
- assert x.getptr(lltype.Ptr(A)) == a
+ assert x.getref(lltype.Ptr(A)) == a
#
s = rstr.mallocstr(6)
x = cpu.do_strlen(
@@ -142,7 +142,7 @@
[BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s))],
descrfld_y)
assert isinstance(x, BoxPtr)
- assert x.getptr(lltype.Ptr(A)) == a
+ assert x.getref(lltype.Ptr(A)) == a
#
s.y = lltype.nullptr(A)
cpu.do_setfield_gc(
@@ -171,7 +171,7 @@
[BoxInt(cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(rs)))],
descrfld_ry)
assert isinstance(x, BoxPtr)
- assert x.getptr(lltype.Ptr(A)) == a
+ assert x.getref(lltype.Ptr(A)) == a
#
rs.y = lltype.nullptr(A)
cpu.do_setfield_raw(
@@ -182,7 +182,7 @@
descrsize = cpu.sizeof(S)
x = cpu.do_new([], descrsize)
assert isinstance(x, BoxPtr)
- x.getptr(lltype.Ptr(S))
+ x.getref(lltype.Ptr(S))
#
descrsize2 = cpu.sizeof(rclass.OBJECT)
vtable2 = lltype.malloc(rclass.OBJECT_VTABLE, immortal=True)
@@ -190,29 +190,29 @@
cpu.set_class_sizes({vtable2_int: descrsize2})
x = cpu.do_new_with_vtable([ConstInt(vtable2_int)])
assert isinstance(x, BoxPtr)
- assert x.getptr(rclass.OBJECTPTR).typeptr == vtable2
+ assert x.getref(rclass.OBJECTPTR).typeptr == vtable2
#
arraydescr = cpu.arraydescrof(A)
x = cpu.do_new_array([BoxInt(7)], arraydescr)
assert isinstance(x, BoxPtr)
- assert len(x.getptr(lltype.Ptr(A))) == 7
+ assert len(x.getref(lltype.Ptr(A))) == 7
#
cpu.do_setarrayitem_gc(
[x, BoxInt(5), BoxInt(ord('*'))], descr_A)
- assert x.getptr(lltype.Ptr(A))[5] == '*'
+ assert x.getref(lltype.Ptr(A))[5] == '*'
#
cpu.do_setarrayitem_gc(
[BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, b)),
BoxInt(1), x],
descr_B)
- assert b[1] == x.getptr(lltype.Ptr(A))
+ assert b[1] == x.getref(lltype.Ptr(A))
#
x = cpu.do_newstr([BoxInt(5)])
assert isinstance(x, BoxPtr)
- assert len(x.getptr(lltype.Ptr(rstr.STR)).chars) == 5
+ assert len(x.getref(lltype.Ptr(rstr.STR)).chars) == 5
#
cpu.do_strsetitem([x, BoxInt(4), BoxInt(ord('/'))])
- assert x.getptr(lltype.Ptr(rstr.STR)).chars[4] == '/'
+ assert x.getref(lltype.Ptr(rstr.STR)).chars[4] == '/'
class TestLLTypeLLGraph(LLtypeBackendTest, LLGraphTests):
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llvm/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llvm/runner.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llvm/runner.py Thu Aug 27 16:21:54 2009
@@ -456,37 +456,37 @@
# do_xxx methods
def do_arraylen_gc(self, args, arraydescr):
- array = args[0].getptr_base()
+ array = args[0].getref_base()
p = rffi.cast(lltype.Ptr(self.gcarray_signed), array)
res = len(p)
return BoxInt(res)
def do_strlen(self, args, descr=None):
- s = args[0].getptr_base()
+ s = args[0].getref_base()
p = lltype.cast_opaque_ptr(lltype.Ptr(rstr.STR), s)
res = len(p.chars)
return BoxInt(res)
def do_strgetitem(self, args, descr=None):
- s = args[0].getptr_base()
+ s = args[0].getref_base()
p = lltype.cast_opaque_ptr(lltype.Ptr(rstr.STR), s)
res = ord(p.chars[args[1].getint()])
return BoxInt(res)
def do_unicodelen(self, args, descr=None):
- s = args[0].getptr_base()
+ s = args[0].getref_base()
p = lltype.cast_opaque_ptr(lltype.Ptr(rstr.UNICODE), s)
res = len(p.chars)
return BoxInt(res)
def do_unicodegetitem(self, args, descr=None):
- s = args[0].getptr_base()
+ s = args[0].getref_base()
p = lltype.cast_opaque_ptr(lltype.Ptr(rstr.UNICODE), s)
res = ord(p.chars[args[1].getint()])
return BoxInt(res)
def do_getarrayitem_gc(self, args, arraydescr):
- array = args[0].getptr_base()
+ array = args[0].getref_base()
index = args[1].getint()
assert isinstance(arraydescr, ArrayDescr)
itemsize_index = arraydescr.itemsize_index
@@ -529,7 +529,7 @@
return BoxInt(res)
def do_getfield_gc(self, args, fielddescr):
- struct = args[0].getptr_base()
+ struct = args[0].getref_base()
return self._do_getfield(struct, fielddescr)
def do_getfield_raw(self, args, fielddescr):
@@ -566,13 +566,13 @@
self.array_index_length)
def do_setarrayitem_gc(self, args, arraydescr):
- array = args[0].getptr_base()
+ array = args[0].getref_base()
index = args[1].getint()
assert isinstance(arraydescr, ArrayDescr)
itemsize_index = arraydescr.itemsize_index
if itemsize_index == self.SIZE_GCPTR:
p = rffi.cast(lltype.Ptr(self.gcarray_gcref), array)
- res = args[2].getptr_base()
+ res = args[2].getref_base()
p[index] = res
elif itemsize_index == self.SIZE_INT:
p = rffi.cast(lltype.Ptr(self.gcarray_signed), array)
@@ -595,7 +595,7 @@
size_index = fielddescr.size_index
if size_index == self.SIZE_GCPTR:
p = rffi.cast(rffi.CArrayPtr(llmemory.GCREF), struct)
- res = v_value.getptr_base()
+ res = v_value.getref_base()
p[fielddescr.offset / rffi.sizeof(llmemory.GCREF)] = res
elif size_index == self.SIZE_INT:
p = rffi.cast(rffi.CArrayPtr(lltype.Signed), struct)
@@ -613,7 +613,7 @@
raise BadSizeError
def do_setfield_gc(self, args, fielddescr):
- struct = args[0].getptr_base()
+ struct = args[0].getref_base()
self._do_setfield(struct, args[1], fielddescr)
def do_setfield_raw(self, args, fielddescr):
@@ -631,13 +631,13 @@
self.unicode_index_length)
def do_strsetitem(self, args, descr=None):
- s = args[0].getptr_base()
+ s = args[0].getref_base()
res = chr(args[2].getint())
p = lltype.cast_opaque_ptr(lltype.Ptr(rstr.STR), s)
p.chars[args[1].getint()] = res
def do_unicodesetitem(self, args, descr=None):
- s = args[0].getptr_base()
+ s = args[0].getref_base()
res = unichr(args[2].getint())
p = lltype.cast_opaque_ptr(lltype.Ptr(rstr.UNICODE), s)
p.chars[args[1].getint()] = res
@@ -689,7 +689,7 @@
return BoxPtr(res)
def do_cast_ptr_to_int(self, args, descr=None):
- ptr = args[0].getptr_base()
+ ptr = args[0].getref_base()
res = rffi.cast(lltype.Signed, ptr)
return BoxInt(res)
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/test/runner_test.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/test/runner_test.py Thu Aug 27 16:21:54 2009
@@ -24,10 +24,10 @@
self.cpu.set_future_value_int(j, box.getint())
j += 1
elif isinstance(box, BoxPtr):
- self.cpu.set_future_value_ptr(j, box.getptr_base())
+ self.cpu.set_future_value_ptr(j, box.getref_base())
j += 1
elif isinstance(box, BoxObj):
- self.cpu.set_future_value_obj(j, box.getobj())
+ self.cpu.set_future_value_obj(j, box.getref_base())
j += 1
res = self.cpu.execute_operations(loop)
if res is loop.operations[-1]:
@@ -118,7 +118,7 @@
assert x.value == 142
if self.type_system == 'lltype':
s = execute(cpu, rop.NEWSTR, [BoxInt(8)])
- assert len(s.getptr(lltype.Ptr(rstr.STR)).chars) == 8
+ assert len(s.getref(lltype.Ptr(rstr.STR)).chars) == 8
def test_lshift(self):
res = execute(self.cpu, rop.INT_LSHIFT, [BoxInt(10), ConstInt(4)])
@@ -728,7 +728,7 @@
[BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, b)), BoxInt(3)],
descr_B)
assert isinstance(x, BoxPtr)
- assert x.getptr(lltype.Ptr(A)) == a
+ assert x.getref(lltype.Ptr(A)) == a
#
s = rstr.mallocstr(6)
x = cpu.do_strlen(
@@ -761,7 +761,7 @@
[BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s))],
descrfld_y)
assert isinstance(x, BoxPtr)
- assert x.getptr(lltype.Ptr(A)) == a
+ assert x.getref(lltype.Ptr(A)) == a
#
s.y = lltype.nullptr(A)
cpu.do_setfield_gc(
@@ -792,7 +792,7 @@
# [BoxInt(cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(rs)))],
# descrfld_ry)
#assert isinstance(x, BoxPtr)
- #assert x.getptr(lltype.Ptr(A)) == a
+ #assert x.getref(lltype.Ptr(A)) == a
#
#rs.y = lltype.nullptr(A)
#cpu.do_setfield_raw(
@@ -803,7 +803,7 @@
descrsize = cpu.sizeof(S)
x = cpu.do_new([], descrsize)
assert isinstance(x, BoxPtr)
- x.getptr(lltype.Ptr(S))
+ x.getref(lltype.Ptr(S))
#
descrsize2 = cpu.sizeof(rclass.OBJECT)
vtable2 = lltype.malloc(rclass.OBJECT_VTABLE, immortal=True)
@@ -812,29 +812,29 @@
x = cpu.do_new_with_vtable([ConstInt(vtable2_int)])
assert isinstance(x, BoxPtr)
# well...
- #assert x.getptr(rclass.OBJECTPTR).typeptr == vtable2
+ #assert x.getref(rclass.OBJECTPTR).typeptr == vtable2
#
arraydescr = cpu.arraydescrof(A)
x = cpu.do_new_array([BoxInt(7)], arraydescr)
assert isinstance(x, BoxPtr)
- assert len(x.getptr(lltype.Ptr(A))) == 7
+ assert len(x.getref(lltype.Ptr(A))) == 7
#
cpu.do_setarrayitem_gc(
[x, BoxInt(5), BoxInt(ord('*'))], descr_A)
- assert x.getptr(lltype.Ptr(A))[5] == '*'
+ assert x.getref(lltype.Ptr(A))[5] == '*'
#
cpu.do_setarrayitem_gc(
[BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, b)),
BoxInt(1), x],
descr_B)
- assert b[1] == x.getptr(lltype.Ptr(A))
+ assert b[1] == x.getref(lltype.Ptr(A))
#
x = cpu.do_newstr([BoxInt(5)])
assert isinstance(x, BoxPtr)
- assert len(x.getptr(lltype.Ptr(rstr.STR)).chars) == 5
+ assert len(x.getref(lltype.Ptr(rstr.STR)).chars) == 5
#
cpu.do_strsetitem([x, BoxInt(4), BoxInt(ord('/'))])
- assert x.getptr(lltype.Ptr(rstr.STR)).chars[4] == '/'
+ assert x.getref(lltype.Ptr(rstr.STR)).chars[4] == '/'
#
x = cpu.do_newstr([BoxInt(5)])
y = cpu.do_cast_ptr_to_int([x])
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/test/test_ll_random.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/test/test_ll_random.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/test/test_ll_random.py Thu Aug 27 16:21:54 2009
@@ -263,7 +263,7 @@
class GetArrayItemOperation(ArrayOperation):
def field_descr(self, builder, r):
v, A = builder.get_arrayptr_var(r)
- array = v.getptr(lltype.Ptr(A))
+ array = v.getref(lltype.Ptr(A))
v_index = builder.get_index(len(array), r)
descr = self.array_descr(builder, A)
return v, A, v_index, descr
@@ -344,7 +344,7 @@
current = getattr(builder, self.builder_cache)
if current and r.random() < .8:
v_string = r.choice(current)
- string = v_string.getptr(self.ptr)
+ string = v_string.getref(self.ptr)
else:
string = self.alloc(builder.get_index(500, r).getint())
v_string = ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF, string))
@@ -357,13 +357,13 @@
class AbstractGetItemOperation(AbstractStringOperation):
def produce_into(self, builder, r):
v_string = self.get_string(builder, r)
- v_index = builder.get_index(len(v_string.getptr(self.ptr).chars), r)
+ v_index = builder.get_index(len(v_string.getref(self.ptr).chars), r)
v_result = builder.do(self.opnum, [v_string, v_index])
class AbstractSetItemOperation(AbstractStringOperation):
def produce_into(self, builder, r):
v_string = self.get_string(builder, r)
- v_index = builder.get_index(len(v_string.getptr(self.ptr).chars), r)
+ v_index = builder.get_index(len(v_string.getref(self.ptr).chars), r)
v_target = ConstInt(r.random_integer() % self.max)
builder.do(self.opnum, [v_string, v_index, v_target])
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/x86/runner.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/x86/runner.py Thu Aug 27 16:21:54 2009
@@ -281,13 +281,13 @@
def do_arraylen_gc(self, args, arraydescr):
ofs = self.gc_ll_descr.array_length_ofs
- gcref = args[0].getptr(llmemory.GCREF)
+ gcref = args[0].getref(llmemory.GCREF)
length = rffi.cast(rffi.CArrayPtr(lltype.Signed), gcref)[ofs/WORD]
return BoxInt(length)
def do_getarrayitem_gc(self, args, arraydescr):
field = args[1].getint()
- gcref = args[0].getptr(llmemory.GCREF)
+ gcref = args[0].getref(llmemory.GCREF)
shift, ofs, ptr = self.unpack_arraydescr(arraydescr)
size = 1 << shift
if size == 1:
@@ -305,7 +305,7 @@
def do_setarrayitem_gc(self, args, arraydescr):
field = args[1].getint()
- gcref = args[0].getptr(llmemory.GCREF)
+ gcref = args[0].getref(llmemory.GCREF)
shift, ofs, ptr = self.unpack_arraydescr(arraydescr)
size = 1 << shift
vbox = args[2]
@@ -317,7 +317,7 @@
a = rffi.cast(rffi.CArrayPtr(lltype.Signed), gcref)
a[ofs/WORD + field] = vbox.getint()
else:
- ptr = vbox.getptr(llmemory.GCREF)
+ ptr = vbox.getref(llmemory.GCREF)
self.gc_ll_descr.do_write_barrier(gcref, ptr)
a = rffi.cast(rffi.CArrayPtr(lltype.Signed), gcref)
a[ofs/WORD + field] = self.cast_gcref_to_int(ptr)
@@ -328,7 +328,7 @@
def do_strlen(self, args, descr=None):
basesize, itemsize, ofs_length = symbolic.get_array_token(TP,
self.translate_support_code)
- gcref = args[0].getptr(llmemory.GCREF)
+ gcref = args[0].getref(llmemory.GCREF)
v = rffi.cast(rffi.CArrayPtr(lltype.Signed), gcref)[ofs_length/WORD]
return BoxInt(v)
return do_strlen
@@ -339,7 +339,7 @@
def do_strgetitem(self, args, descr=None):
basesize, itemsize, ofs_length = symbolic.get_array_token(rstr.STR,
self.translate_support_code)
- gcref = args[0].getptr(llmemory.GCREF)
+ gcref = args[0].getref(llmemory.GCREF)
i = args[1].getint()
v = rffi.cast(rffi.CArrayPtr(lltype.Char), gcref)[basesize + i]
return BoxInt(ord(v))
@@ -347,7 +347,7 @@
def do_unicodegetitem(self, args, descr=None):
basesize, itemsize, ofs_length = symbolic.get_array_token(rstr.UNICODE,
self.translate_support_code)
- gcref = args[0].getptr(llmemory.GCREF)
+ gcref = args[0].getref(llmemory.GCREF)
i = args[1].getint()
basesize = basesize // itemsize
v = rffi.cast(rffi.CArrayPtr(lltype.UniChar), gcref)[basesize + i]
@@ -370,7 +370,7 @@
return BoxInt(v)
def do_getfield_gc(self, args, fielddescr):
- gcref = args[0].getptr(llmemory.GCREF)
+ gcref = args[0].getref(llmemory.GCREF)
return self._base_do_getfield(gcref, fielddescr)
def do_getfield_raw(self, args, fielddescr):
@@ -389,7 +389,7 @@
if ptr:
assert lltype.typeOf(gcref) is not lltype.Signed, (
"can't handle write barriers for setfield_raw")
- ptr = vbox.getptr(llmemory.GCREF)
+ ptr = vbox.getref(llmemory.GCREF)
self.gc_ll_descr.do_write_barrier(gcref, ptr)
a = rffi.cast(rffi.CArrayPtr(lltype.Signed), gcref)
a[ofs/WORD] = self.cast_gcref_to_int(ptr)
@@ -400,7 +400,7 @@
raise NotImplementedError("size = %d" % size)
def do_setfield_gc(self, args, fielddescr):
- gcref = args[0].getptr(llmemory.GCREF)
+ gcref = args[0].getref(llmemory.GCREF)
self._base_do_setfield(fielddescr, gcref, args[1])
def do_setfield_raw(self, args, fielddescr):
@@ -441,7 +441,7 @@
self.translate_support_code)
index = args[1].getint()
v = args[2].getint()
- a = args[0].getptr(llmemory.GCREF)
+ a = args[0].getref(llmemory.GCREF)
rffi.cast(rffi.CArrayPtr(lltype.Char), a)[index + basesize] = chr(v)
def do_unicodesetitem(self, args, descr=None):
@@ -449,7 +449,7 @@
self.translate_support_code)
index = args[1].getint()
v = args[2].getint()
- a = args[0].getptr(llmemory.GCREF)
+ a = args[0].getref(llmemory.GCREF)
basesize = basesize // itemsize
rffi.cast(rffi.CArrayPtr(lltype.UniChar), a)[index + basesize] = unichr(v)
@@ -470,7 +470,7 @@
return BoxInt(self.get_latest_value_int(0))
def do_cast_ptr_to_int(self, args, descr=None):
- return BoxInt(self.cast_gcref_to_int(args[0].getptr_base()))
+ return BoxInt(self.cast_gcref_to_int(args[0].getref_base()))
def do_cast_int_to_ptr(self, args, descr=None):
return BoxPtr(self.cast_int_to_gcref(args[0].getint()))
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/compile.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/compile.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/compile.py Thu Aug 27 16:21:54 2009
@@ -158,7 +158,7 @@
result = metainterp_sd.cpu.get_latest_value_ptr(0)
else:
assert isinstance(resultbox, history.Const)
- result = resultbox.getptr_base()
+ result = resultbox.getref_base()
raise metainterp_sd.DoneWithThisFramePtr(result)
class DoneWithThisFrameDescrObj(AbstractDescr):
@@ -169,7 +169,7 @@
result = metainterp_sd.cpu.get_latest_value_obj(0)
else:
assert isinstance(resultbox, history.Const)
- result = resultbox.getobj()
+ result = resultbox.getref_base()
raise metainterp_sd.DoneWithThisFrameObj(result)
class ExitFrameWithExceptionDescrPtr(AbstractDescr):
@@ -180,7 +180,7 @@
value = metainterp_sd.cpu.get_latest_value_ptr(0)
else:
assert isinstance(valuebox, history.Const)
- value = valuebox.getptr_base()
+ value = valuebox.getref_base()
raise metainterp_sd.ExitFrameWithExceptionPtr(value)
class ExitFrameWithExceptionDescrObj(AbstractDescr):
@@ -191,7 +191,7 @@
value = metainterp_sd.cpu.get_latest_value_obj(0)
else:
assert isinstance(valuebox, history.Const)
- value = valuebox.getobj()
+ value = valuebox.getref_base()
raise metainterp_sd.ExitFrameWithExceptionObj(value)
done_with_this_frame_descr_void = DoneWithThisFrameDescrVoid()
@@ -297,11 +297,11 @@
if isinstance(dstbox, BoxInt):
dstbox.changevalue_int(srcbox.getint())
elif not metainterp_sd.cpu.is_oo and isinstance(dstbox, BoxPtr):
- dstbox.changevalue_ptr(srcbox.getptr_base())
+ dstbox.changevalue_ptr(srcbox.getref_base())
elif isinstance(dstbox, Const):
pass
elif metainterp_sd.cpu.is_oo and isinstance(dstbox, BoxObj):
- dstbox.changevalue_obj(srcbox.getobj())
+ dstbox.changevalue_obj(srcbox.getref_base())
else:
assert False
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/executor.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/executor.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/executor.py Thu Aug 27 16:21:54 2009
@@ -107,10 +107,10 @@
if tp == INT:
x = bool(args[0].getint())
elif tp == PTR:
- x = bool(args[0].getptr_base())
+ x = bool(args[0].getref_base())
else:
assert tp == OBJ
- x = bool(args[0].getobj())
+ x = bool(args[0].getref_base())
return ConstInt(x)
def do_ooisnull(cpu, args, descr=None):
@@ -118,10 +118,10 @@
if tp == INT:
x = bool(args[0].getint())
elif tp == PTR:
- x = bool(args[0].getptr_base())
+ x = bool(args[0].getref_base())
else:
assert tp == OBJ
- x = bool(args[0].getobj())
+ x = bool(args[0].getref_base())
return ConstInt(not x)
def do_oois(cpu, args, descr=None):
@@ -130,10 +130,10 @@
if tp == INT:
x = args[0].getint() == args[1].getint()
elif tp == PTR:
- x = args[0].getptr_base() == args[1].getptr_base()
+ x = args[0].getref_base() == args[1].getref_base()
else:
assert tp == OBJ
- x = args[0].getobj() == args[1].getobj()
+ x = args[0].getref_base() == args[1].getref_base()
return ConstInt(x)
def do_ooisnot(cpu, args, descr=None):
@@ -142,22 +142,22 @@
if tp == INT:
x = args[0].getint() != args[1].getint()
elif tp == PTR:
- x = args[0].getptr_base() != args[1].getptr_base()
+ x = args[0].getref_base() != args[1].getref_base()
else:
assert tp == OBJ
- x = args[0].getobj() != args[1].getobj()
+ x = args[0].getref_base() != args[1].getref_base()
return ConstInt(x)
def do_ooidentityhash(cpu, args, descr=None):
- obj = args[0].getobj()
+ obj = args[0].getref_base()
return ConstInt(ootype.ooidentityhash(obj))
def do_subclassof(self, args, descr=None):
assert len(args) == 2
box1, box2 = args
- cls1 = ootype.cast_from_object(ootype.Class, box1.getobj())
- cls2 = ootype.cast_from_object(ootype.Class, box2.getobj())
+ cls1 = box1.getref(ootype.Class)
+ cls2 = box2.getref(ootype.Class)
res = ootype.subclassof(cls1, cls2)
return BoxInt(res)
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/history.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/history.py Thu Aug 27 16:21:54 2009
@@ -80,15 +80,12 @@
def getint(self):
raise NotImplementedError
- def getptr_base(self):
+ def getref_base(self):
raise NotImplementedError
- def getptr(self, PTR):
- return lltype.cast_opaque_ptr(PTR, self.getptr_base())
- getptr._annspecialcase_ = 'specialize:arg(1)'
-
- def getobj(self):
+ def getref(self, TYPE):
raise NotImplementedError
+ getref._annspecialcase_ = 'specialize:arg(1)'
def get_(self):
raise NotImplementedError
@@ -296,9 +293,13 @@
nonconstbox = clonebox
- def getptr_base(self):
+ def getref_base(self):
return self.value
+ def getref(self, PTR):
+ return lltype.cast_opaque_ptr(PTR, self.getref_base())
+ getref._annspecialcase_ = 'specialize:arg(1)'
+
def get_(self):
return lltype.cast_ptr_to_int(self.value)
@@ -312,7 +313,7 @@
cpu.set_future_value_ptr(j, self.value)
def equals(self, other):
- return self.value == other.getptr_base()
+ return self.value == other.getref_base()
_getrepr_ = repr_pointer
@@ -338,9 +339,13 @@
nonconstbox = clonebox
- def getobj(self):
+ def getref_base(self):
return self.value
+ def getref(self, OBJ):
+ return ootype.cast_from_object(OBJ, self.getref_base())
+ getref._annspecialcase_ = 'specialize:arg(1)'
+
def get_(self):
if self.value:
return ootype.ooidentityhash(self.value) # XXX: check me
@@ -360,7 +365,7 @@
## return self.value
def equals(self, other):
- return self.value == other.getobj()
+ return self.value == other.getref_base()
_getrepr_ = repr_object
@@ -479,9 +484,13 @@
def constbox(self):
return ConstPtr(self.value)
- def getptr_base(self):
+ def getref_base(self):
return self.value
+ def getref(self, PTR):
+ return lltype.cast_opaque_ptr(PTR, self.getref_base())
+ getref._annspecialcase_ = 'specialize:arg(1)'
+
def getaddr(self, cpu):
return llmemory.cast_ptr_to_adr(self.value)
@@ -498,7 +507,7 @@
return repr_rpython(self, 'bp')
def changevalue_box(self, srcbox):
- self.changevalue_ptr(srcbox.getptr_base())
+ self.changevalue_ptr(srcbox.getref_base())
_getrepr_ = repr_pointer
changevalue_ptr = __init__
@@ -520,9 +529,13 @@
def constbox(self):
return ConstObj(self.value)
- def getobj(self):
+ def getref_base(self):
return self.value
+ def getref(self, OBJ):
+ return ootype.cast_from_object(OBJ, self.getref_base())
+ getref._annspecialcase_ = 'specialize:arg(1)'
+
def get_(self):
if self.value:
return ootype.ooidentityhash(self.value) # XXX: check me
@@ -539,7 +552,7 @@
return repr_rpython(self, 'bo')
def changevalue_box(self, srcbox):
- self.changevalue_obj(srcbox.getobj())
+ self.changevalue_obj(srcbox.getref_base())
_getrepr_ = repr_object
changevalue_obj = __init__
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/optimizeopt.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/optimizeopt.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/optimizeopt.py Thu Aug 27 16:21:54 2009
@@ -343,7 +343,7 @@
if not self.is_constant(box):
return box
if not self.cpu.is_oo and box.type == PTR:
- value = box.getptr_base()
+ value = box.getref_base()
key = lltype.cast_ptr_to_int(value)
try:
return self.interned_ptrs[key]
@@ -351,7 +351,7 @@
self.interned_ptrs[key] = box
return box
elif self.cpu.is_oo and box.type == OBJ:
- value = box.getobj()
+ value = box.getref_base()
try:
return self.interned_objs[value]
except KeyError:
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/pyjitpl.py Thu Aug 27 16:21:54 2009
@@ -715,7 +715,7 @@
box = self.implement_guard_value(pc, box)
cpu = self.metainterp.cpu
if cpu.is_oo:
- key = box.getobj()
+ key = box.getref_base()
else:
key = box.getaddr(cpu)
jitcode = indirectcallset.bytecode_for_address(key)
@@ -729,7 +729,7 @@
clsbox = self.cls_of_box(objbox)
if isinstance(objbox, Box):
self.generate_guard(pc, rop.GUARD_CLASS, objbox, [clsbox])
- oocls = ootype.cast_from_object(ootype.Class, clsbox.getobj())
+ oocls = clsbox.getref(ootype.Class)
jitcode = methdescr.get_jitcode_for_class(oocls)
return self.perform_call(jitcode, varargs)
@@ -1140,9 +1140,9 @@
elif sd.result_type == 'int':
raise sd.DoneWithThisFrameInt(resultbox.getint())
elif sd.result_type == 'ptr':
- raise sd.DoneWithThisFramePtr(resultbox.getptr_base())
+ raise sd.DoneWithThisFramePtr(resultbox.getref_base())
elif self.cpu.is_oo and sd.result_type == 'obj':
- raise sd.DoneWithThisFrameObj(resultbox.getobj())
+ raise sd.DoneWithThisFrameObj(resultbox.getref_base())
else:
assert False
@@ -1170,9 +1170,9 @@
if not self.is_blackholing():
self.compile_exit_frame_with_exception(excvaluebox)
if self.cpu.is_oo:
- raise self.staticdata.ExitFrameWithExceptionObj(excvaluebox.getobj())
+ raise self.staticdata.ExitFrameWithExceptionObj(excvaluebox.getref_base())
else:
- raise self.staticdata.ExitFrameWithExceptionPtr(excvaluebox.getptr_base())
+ raise self.staticdata.ExitFrameWithExceptionPtr(excvaluebox.getref_base())
def raise_overflow_error(self):
etype, evalue = self.cpu.get_overflow_error()
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/test/test_optimizeopt.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/test/test_optimizeopt.py Thu Aug 27 16:21:54 2009
@@ -1155,10 +1155,9 @@
tag, resolved, fieldstext = virtuals[varname]
if tag[0] == 'virtual':
if not self.cpu.is_oo:
- assert box.getptr(rclass.OBJECTPTR).typeptr == tag[1]
+ assert box.getref(rclass.OBJECTPTR).typeptr == tag[1]
else:
- root = box.getobj()
- root = ootype.cast_from_object(ootype.ROOT, root)
+ root = box.getref(ootype.ROOT)
assert ootype.classof(root) == tag[1]
elif tag[0] == 'varray':
pass # xxx check arraydescr
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/typesystem.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/typesystem.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/typesystem.py Thu Aug 27 16:21:54 2009
@@ -56,7 +56,7 @@
return llmemory.cast_ptr_to_adr(fnptr)
def cls_of_box(self, cpu, box):
- obj = box.getptr(lltype.Ptr(rclass.OBJECT))
+ obj = box.getref(lltype.Ptr(rclass.OBJECT))
cls = llmemory.cast_ptr_to_adr(obj.typeptr)
return history.ConstInt(cpu.cast_adr_to_int(cls))
@@ -75,7 +75,7 @@
def get_exception_obj(self, evaluebox):
# only works when translated
- obj = evaluebox.getptr(lltype.Ptr(rclass.OBJECT))
+ obj = evaluebox.getref(lltype.Ptr(rclass.OBJECT))
return cast_base_ptr_to_instance(Exception, obj)
def clean_box(self, box):
@@ -116,13 +116,13 @@
return ootype.cast_to_object(fnptr)
def cls_of_box(self, cpu, box):
- obj = ootype.cast_from_object(ootype.ROOT, box.getobj())
+ obj = box.getref(ootype.ROOT)
oocls = ootype.classof(obj)
return history.ConstObj(ootype.cast_to_object(oocls))
def subclassOf(self, cpu, clsbox1, clsbox2):
- cls1 = ootype.cast_from_object(ootype.Class, clsbox1.getobj())
- cls2 = ootype.cast_from_object(ootype.Class, clsbox2.getobj())
+ cls1 = clsbox1.getref(ootype.Class)
+ cls2 = clsbox2.getref(ootype.Class)
return ootype.subclassof(cls1, cls2)
def get_exception_box(self, etype):
@@ -133,7 +133,7 @@
def get_exception_obj(self, evaluebox):
# only works when translated
- obj = ootype.cast_from_object(ootype.ROOT, evaluebox.getobj())
+ obj = evaluebox.getref(ootype.ROOT)
return cast_base_ptr_to_instance(Exception, obj)
def clean_box(self, box):
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/virtualizable.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/virtualizable.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/virtualizable.py Thu Aug 27 16:21:54 2009
@@ -186,10 +186,9 @@
def unwrap_virtualizable_box(self, virtualizable_box):
if not self.is_oo:
- return virtualizable_box.getptr(self.VTYPEPTR)
+ return virtualizable_box.getref(self.VTYPEPTR)
else:
- obj = virtualizable_box.getobj()
- return ootype.cast_from_object(self.VTYPE, obj)
+ return virtualizable_box.getref(self.VTYPE)
def cast_to_vtype(self, virtualizable):
if not self.is_oo:
Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/warmspot.py (original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/warmspot.py Thu Aug 27 16:21:54 2009
@@ -579,9 +579,9 @@
if TYPE is lltype.Void:
return None
if isinstance(TYPE, lltype.Ptr):
- return box.getptr(TYPE)
+ return box.getref(TYPE)
if isinstance(TYPE, ootype.OOType):
- return ootype.cast_from_object(TYPE, box.getobj())
+ return box.getref(TYPE)
else:
return lltype.cast_primitive(TYPE, box.getint())
unwrap._annspecialcase_ = 'specialize:arg(0)'
More information about the Pypy-commit
mailing list