[pypy-svn] r31691 - in pypy/dist/pypy: jit/timeshifter rpython rpython/ootypesystem
ac at codespeak.net
ac at codespeak.net
Sat Aug 26 18:42:50 CEST 2006
Author: ac
Date: Sat Aug 26 18:42:49 2006
New Revision: 31691
Modified:
pypy/dist/pypy/jit/timeshifter/rtyper.py
pypy/dist/pypy/rpython/llinterp.py
pypy/dist/pypy/rpython/ootypesystem/exceptiondata.py
pypy/dist/pypy/rpython/ootypesystem/ootype.py
pypy/dist/pypy/rpython/typesystem.py
Log:
(arre, pedronis)
check in llinterp that in direct_calls graph types and lowlevel callable
object types (usually func ptr types) match.
fix the timeshifter which was producing graphs when timeshifting direct_calls
with mismatched graph/ptr types.
Modified: pypy/dist/pypy/jit/timeshifter/rtyper.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rtyper.py (original)
+++ pypy/dist/pypy/jit/timeshifter/rtyper.py Sat Aug 26 18:42:49 2006
@@ -231,11 +231,17 @@
graph = bk.get_graph_for_call(fnobj.graph, False, args_hs)
args_r = [self.getrepr(hs) for hs in args_hs]
args_v = hop.inputargs(*args_r)
- fnptr = self.getcallable(graph)
+ ARGS = [ts.r_ResidualGraphBuilder.lowleveltype,
+ ts.r_JITState.lowleveltype]
+ ARGS += [r.lowleveltype for r in args_r]
+ RESULT = ts.r_ResidualGraphBuilder.lowleveltype
+ fnptr = lltype.functionptr(lltype.FuncType(ARGS, RESULT),
+ graph.name,
+ graph=graph,
+ _callable = graph.func)
self.timeshifter.schedule_graph(graph)
args_v[:0] = [hop.llops.genconst(fnptr), v_builder, v_jitstate]
- v_newbuilder = hop.genop('direct_call', args_v,
- ts.r_ResidualGraphBuilder.lowleveltype)
+ v_newbuilder = hop.genop('direct_call', args_v, RESULT)
return hop.llops.genmixlevelhelpercall(rtimeshift.after_call,
[ts.s_JITState, ts.s_ResidualGraphBuilder],
[v_jitstate, v_newbuilder],
Modified: pypy/dist/pypy/rpython/llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/llinterp.py (original)
+++ pypy/dist/pypy/rpython/llinterp.py Sat Aug 26 18:42:49 2006
@@ -481,18 +481,30 @@
write_barrier = gc.get_funcptr_write_barrier()
self.op_direct_call(write_barrier, *args)
- def op_direct_call(self, f, *args):
- obj = self.llinterpreter.typer.type_system.deref(f)
- has_callable = getattr(obj, '_callable', None) is not None
- if has_callable and getattr(obj._callable, 'suggested_primitive', False):
+
+ def perform_call(self, f, ARGS, args):
+ fobj = self.llinterpreter.typer.type_system.deref(f)
+ has_callable = getattr(fobj, '_callable', None) is not None
+ if has_callable and getattr(fobj._callable, 'suggested_primitive', False):
return self.invoke_callable_with_pyexceptions(f, *args)
- if hasattr(obj, 'graph'):
- graph = obj.graph
+ if hasattr(fobj, 'graph'):
+ graph = fobj.graph
else:
assert has_callable, "don't know how to execute %r" % f
return self.invoke_callable_with_pyexceptions(f, *args)
+ args_v = graph.getargs()
+ if len(ARGS) != len(args_v):
+ raise TypeError("graph with %d args called with wrong func ptr type: %r" %(len(args_v), ARGS))
+ for T, v in zip(ARGS, args_v):
+ if not lltype.isCompatibleType(T, v.concretetype):
+ raise TypeError("graph with %d args called with wrong func ptr type: %r" %
+ (tuple([v.concretetype for v in args_v]), ARGS))
frame = self.__class__(graph, args, self.llinterpreter, self)
- return frame.eval()
+ return frame.eval()
+
+ def op_direct_call(self, f, *args):
+ FTYPE = self.llinterpreter.typer.type_system.derefType(lltype.typeOf(f))
+ return self.perform_call(f, FTYPE.ARGS, args)
op_safe_call = op_direct_call
@@ -788,7 +800,7 @@
args = m._checkargs(args, check_callable=False)
if getattr(m, 'abstract', False):
raise RuntimeError("calling abstract method %r" % (m,))
- return self.op_direct_call(m, inst, *args)
+ return self.perform_call(m, (lltype.typeOf(inst),)+lltype.typeOf(m).ARGS, [inst]+args)
def op_ooupcast(self, INST, inst):
return ootype.ooupcast(INST, inst)
Modified: pypy/dist/pypy/rpython/ootypesystem/exceptiondata.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/exceptiondata.py (original)
+++ pypy/dist/pypy/rpython/ootypesystem/exceptiondata.py Sat Aug 26 18:42:49 2006
@@ -93,6 +93,7 @@
# expects a low-level callable (_meth, _static_meth), so we just
# fake it here.
FakeCallableType = ootype.OOType()
+ FakeCallableType.ARGS = ()
class fake_callable(object):
def __init__(self, fn):
self._TYPE = FakeCallableType
Modified: pypy/dist/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/ootype.py (original)
+++ pypy/dist/pypy/rpython/ootypesystem/ootype.py Sat Aug 26 18:42:49 2006
@@ -199,7 +199,7 @@
return null(self)
def __repr__(self):
- return "<StaticMethod(%s, %s)>" % (list(self.ARGS), self.RESULT)
+ return "<%s(%s, %s)>" % (self.__class__.__name__, list(self.ARGS), self.RESULT)
def _specialize(self, generic_types):
ARGS = tuple([self._specialize_type(ARG, generic_types)
Modified: pypy/dist/pypy/rpython/typesystem.py
==============================================================================
--- pypy/dist/pypy/rpython/typesystem.py (original)
+++ pypy/dist/pypy/rpython/typesystem.py Sat Aug 26 18:42:49 2006
@@ -29,6 +29,9 @@
raise AttributeError(name)
+ def derefType(self, T):
+ raise NotImplementedError()
+
def deref(self, obj):
"""Dereference `obj' to concrete object."""
raise NotImplementedError()
@@ -74,6 +77,10 @@
name = "lltypesystem"
callable_trait = (lltype.FuncType, lltype.functionptr)
+ def derefType(self, T):
+ assert isinstance(T, lltype.Ptr)
+ return T.TO
+
def deref(self, obj):
assert isinstance(lltype.typeOf(obj), lltype.Ptr)
return obj._obj
@@ -111,6 +118,10 @@
name = "ootypesystem"
callable_trait = (ootype.StaticMethod, ootype.static_meth)
+ def derefType(self, T):
+ assert isinstance(T, ootype.OOType)
+ return T
+
def deref(self, obj):
assert isinstance(ootype.typeOf(obj), ootype.OOType)
return obj
More information about the Pypy-commit
mailing list