[pypy-svn] r49885 - in pypy/dist/pypy/jit/hintannotator: . test
antocuni at codespeak.net
antocuni at codespeak.net
Tue Dec 18 14:18:47 CET 2007
Author: antocuni
Date: Tue Dec 18 14:18:47 2007
New Revision: 49885
Modified:
pypy/dist/pypy/jit/hintannotator/model.py
pypy/dist/pypy/jit/hintannotator/test/test_annotator.py
Log:
one more test for oosend (when equivalent to direct_call)
Modified: pypy/dist/pypy/jit/hintannotator/model.py
==============================================================================
--- pypy/dist/pypy/jit/hintannotator/model.py (original)
+++ pypy/dist/pypy/jit/hintannotator/model.py Tue Dec 18 14:18:47 2007
@@ -30,6 +30,7 @@
oois
subclassof
instanceof
+ oostring
""".split()
BINARY_OPERATIONS = """int_add int_sub int_mul int_mod int_and int_rshift
@@ -104,6 +105,8 @@
v_callable = self.spaceop.args[0]
retdeps = greenorigindependencies.setdefault(self, [])
retdeps.append(v_callable)
+ elif self.spaceop.opname == 'oosend':
+ args = self.spaceop.args[1:]
else:
raise AssertionError(self.spaceop.opname)
@@ -468,21 +471,25 @@
# normal call
if not hasattr(fnobj, 'graph'):
raise NotImplementedError("XXX call to externals or primitives")
- if not bookkeeper.annotator.policy.look_inside_graph(fnobj.graph):
- return cannot_follow_call(bookkeeper, fnobj.graph, args_hs,
- lltype.typeOf(fnobj).RESULT)
+
+ return hs_f1._call_single_graph(fnobj.graph, lltype.typeOf(fnobj).RESULT, *args_hs)
+
+ def _call_single_graph(hs_f1, graph, RESULT, *args_hs):
+ bookkeeper = getbookkeeper()
+ if not bookkeeper.annotator.policy.look_inside_graph(graph):
+ return cannot_follow_call(bookkeeper, graph, args_hs, RESULT)
# recursive call from the entry point to itself: ignore them and
# just hope the annotations are correct
- if (bookkeeper.getdesc(fnobj.graph)._cache.get(None, None) is
+ if (bookkeeper.getdesc(graph)._cache.get(None, None) is
bookkeeper.annotator.translator.graphs[0]):
- return variableoftype(lltype.typeOf(fnobj).RESULT)
+ return variableoftype(RESULT)
myorigin = bookkeeper.myorigin()
myorigin.__class__ = CallOpOriginFlags # thud
fixed = myorigin.read_fixed()
tsgraphs_accum = []
- hs_res = bookkeeper.graph_call(fnobj.graph, fixed, args_hs,
+ hs_res = bookkeeper.graph_call(graph, fixed, args_hs,
tsgraphs_accum)
myorigin.any_called_graph = tsgraphs_accum[0]
@@ -503,6 +510,7 @@
def oosend(hs_c1, hs_name, *args_hs):
TYPE = hs_c1.concretetype
name = hs_name.const
+ _, meth = TYPE._lookup(name)
graph_list = TYPE._lookup_graphs(name)
if not graph_list:
# it's a method of a BuiltinType
@@ -515,7 +523,14 @@
myorigin = origin)
# if hs_c1.is_constant(): ...
return hs_res
- #import pdb;pdb.set_trace()
+ elif len(graph_list) == 1:
+ # like a direct_call
+ graph = graph_list.pop()
+ METH = lltype.typeOf(meth)
+ return hs_c1._call_single_graph(graph, METH.RESULT, hs_c1, *args_hs) # prepend hs_c1 to the args
+ else:
+ # like an indirect_call
+ XXX fixme
def getfield(hs_c1, hs_fieldname):
S = hs_c1.concretetype.TO
Modified: pypy/dist/pypy/jit/hintannotator/test/test_annotator.py
==============================================================================
--- pypy/dist/pypy/jit/hintannotator/test/test_annotator.py (original)
+++ pypy/dist/pypy/jit/hintannotator/test/test_annotator.py Tue Dec 18 14:18:47 2007
@@ -323,6 +323,18 @@
assert hs.concretetype == lltype.Signed
assert len(hs.origins) == 5
+ def test_simple_method_call(self):
+ class A:
+ def ll2(self, x, y, z):
+ return x + (y + 42)
+ obj = A()
+ def ll1(x, y, z):
+ return obj.ll2(x, y - z, x + y + z)
+ hs = self.hannotate(ll1, [int, int, int], policy=P_NOVIRTUAL)
+ assert isinstance(hs, SomeLLAbstractConstant)
+ assert hs.concretetype == lltype.Signed
+ assert len(hs.origins) == 5
+
def test_simple_list_operations(self):
def ll_function(x, y, index):
l = [x]
@@ -693,7 +705,6 @@
hs = self.hannotate(ll_function, [int, int], policy=P_NOVIRTUAL)
assert not hs.is_green()
-
def test_indirect_sometimes_residual_pure_red_call(self):
def h1(x):
return x-2
More information about the Pypy-commit
mailing list