[pypy-svn] r64505 - in pypy/branch/pyjitpl5-simplify/pypy/jit: backend/llgraph metainterp metainterp/test
antocuni at codespeak.net
antocuni at codespeak.net
Tue Apr 21 13:50:35 CEST 2009
Author: antocuni
Date: Tue Apr 21 13:50:34 2009
New Revision: 64505
Modified:
pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py
pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_send.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/typesystem.py
Log:
(arigo, antocuni) put a guard_class before the oosend, and whack a lot to make all of this
possible :-)
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py Tue Apr 21 13:50:34 2009
@@ -696,11 +696,17 @@
def op_call(self, calldescr, func, *args):
sm = ootype.cast_from_object(calldescr.FUNC, func)
- res = sm(*args)
+ res = call_maybe_on_top_of_llinterp(sm, args)
if isinstance(calldescr.FUNC.RESULT, ootype.OOType):
return ootype.cast_to_object(res)
return res
+ def op_guard_class(self, _, value, expected_class):
+ value = ootype.cast_from_object(ootype.ROOT, value)
+ expected_class = ootype.cast_from_object(ootype.Class, expected_class)
+ if ootype.classof(value) is not expected_class:
+ raise GuardFailed
+
# ____________________________________________________________
def cast_to_int(x, memocast):
@@ -1014,6 +1020,20 @@
x = _do_call_common(f, memocast, lltype.nullptr(llmemory.GCREF.TO))
return cast_to_ptr(x)
+
+# for ootype meth and staticmeth
+def call_maybe_on_top_of_llinterp(meth, args):
+ if hasattr(meth, 'graph'):
+ llinterp = _llinterp # it's a global set here by CPU.__init__()
+ try:
+ result = llinterp.eval_graph(meth.graph, args)
+ except LLException, e:
+ _last_exception = e
+ result = err_result # XXX?
+ else:
+ result = meth(*args) # no exception support in this case
+ return result
+
# ____________________________________________________________
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py Tue Apr 21 13:50:34 2009
@@ -503,7 +503,7 @@
def callfunc(funcbox, argboxes):
funcobj = ootype.cast_from_object(FUNC, funcbox.getobj())
funcargs = getargs(argboxes)
- res = funcobj(*funcargs)
+ res = llimpl.call_maybe_on_top_of_llinterp(funcobj, funcargs)
if RESULT is not ootype.Void:
return boxresult(RESULT, res)
self.callfunc = callfunc
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py Tue Apr 21 13:50:34 2009
@@ -554,6 +554,8 @@
serialize_op_cast_unichar_to_int = serialize_op_same_as
serialize_op_cast_int_to_unichar = serialize_op_same_as
serialize_op_resume_point = serialize_op_same_as
+ serialize_op_oodowncast = serialize_op_same_as
+ serialize_op_ooupcast = serialize_op_same_as
_defl = default_serialize_op
def serialize_op_char_eq(self, op): self._defl(op, 'int_eq')
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py Tue Apr 21 13:50:34 2009
@@ -15,6 +15,7 @@
from pypy.jit.metainterp.heaptracker import (get_vtable_for_gcstruct,
populate_type_cache)
from pypy.jit.metainterp import codewriter, executor
+from pypy.jit.metainterp import typesystem
from pypy.rlib.rarithmetic import intmask
from pypy.rlib.objectmodel import specialize
@@ -520,10 +521,11 @@
@arguments("orgpc", "methdesc", "varargs")
def opimpl_oosend(self, pc, methdesc, varargs):
objbox = varargs[0]
- obj = ootype.cast_from_object(ootype.ROOT, objbox.getobj())
- oocls = ootype.classof(obj)
+ 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())
jitcode = methdesc.get_jitcode_for_class(oocls)
- # XXX put a guard on the class (in some way)
cpu = self.metainterp.cpu
f = self.metainterp.newframe(jitcode)
f.setup_call(varargs)
@@ -756,9 +758,7 @@
return box # no promotion needed, already a Const
def cls_of_box(self, box):
- obj = box.getptr(lltype.Ptr(rclass.OBJECT))
- cls = llmemory.cast_ptr_to_adr(obj.typeptr)
- return ConstInt(self.metainterp.cpu.cast_adr_to_int(cls))
+ return self.metainterp.staticdata.ts.cls_of_box(self.metainterp.cpu, box)
@specialize.arg(1)
def execute(self, opnum, argboxes, descr=None):
@@ -808,6 +808,11 @@
self.optimize_loop = optimize.optimize_loop
self.optimize_bridge = optimize.optimize_bridge
+ if self.cpu.is_oo:
+ self.ts = typesystem.oohelper
+ else:
+ self.ts = typesystem.llhelper
+
def _freeze_(self):
return True
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_send.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_send.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_send.py Tue Apr 21 13:50:34 2009
@@ -455,8 +455,20 @@
res = self.meta_interp(f, [20, 0])
assert hlstr(res) == "string"
-#class TestOOtype(SendTests, OOJitMixin):
-# pass
+class TestOOtype(SendTests, OOJitMixin):
+ def skip(self):
+ py.test.skip('in-progress')
+
+ test_red_builtin_send = skip
+ test_send_to_single_target_method = skip
+ test_red_send_to_green_receiver = skip
+ test_oosend_base = skip
+ test_oosend_different_initial_class = skip
+ test_indirect_call_unknown_object_1 = skip
+ test_three_cases = skip
+ test_three_classes = skip
+ test_recursive_call_to_portal_from_blackhole = skip
+
class TestLLtype(SendTests, LLJitMixin):
pass
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/typesystem.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/typesystem.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/typesystem.py Tue Apr 21 13:50:34 2009
@@ -1,8 +1,9 @@
#from pypy.rpython.annlowlevel import base_ptr_lltype, base_obj_ootype
#from pypy.rpython.annlowlevel import cast_instance_to_base_ptr
#from pypy.rpython.annlowlevel import cast_instance_to_base_obj
-from pypy.rpython.lltypesystem import lltype, llmemory
+from pypy.rpython.lltypesystem import lltype, llmemory, rclass
from pypy.rpython.ootypesystem import ootype
+from pypy.jit.metainterp import history
def deref(T):
if isinstance(T, lltype.Ptr):
@@ -47,6 +48,11 @@
def cast_fnptr_to_root(self, fnptr):
return llmemory.cast_ptr_to_adr(fnptr)
+ def cls_of_box(self, cpu, box):
+ obj = box.getptr(lltype.Ptr(rclass.OBJECT))
+ cls = llmemory.cast_ptr_to_adr(obj.typeptr)
+ return history.ConstInt(cpu.cast_adr_to_int(cls))
+
class OOTypeHelper(TypeSystemHelper):
name = 'ootype'
@@ -65,3 +71,11 @@
def cast_fnptr_to_root(self, fnptr):
return ootype.cast_to_object(fnptr)
+
+ def cls_of_box(self, cpu, box):
+ obj = ootype.cast_from_object(ootype.ROOT, box.getobj())
+ oocls = ootype.classof(obj)
+ return history.ConstObj(ootype.cast_to_object(oocls))
+
+llhelper = LLTypeHelper()
+oohelper = OOTypeHelper()
More information about the Pypy-commit
mailing list