[pypy-svn] r52609 - in pypy/branch/jit-hotpath/pypy/jit: hintannotator rainbow rainbow/test
arigo at codespeak.net
arigo at codespeak.net
Sun Mar 16 17:13:44 CET 2008
Author: arigo
Date: Sun Mar 16 17:13:43 2008
New Revision: 52609
Modified:
pypy/branch/jit-hotpath/pypy/jit/hintannotator/bookkeeper.py
pypy/branch/jit-hotpath/pypy/jit/rainbow/codewriter.py
pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hp_interpreter.py
Log:
Metacall stubs.
Modified: pypy/branch/jit-hotpath/pypy/jit/hintannotator/bookkeeper.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/hintannotator/bookkeeper.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/hintannotator/bookkeeper.py Sun Mar 16 17:13:43 2008
@@ -101,6 +101,7 @@
newgraph = FunctionGraph('%s_%s' % (graph.name, suffix), newstartblock)
newgraph.getreturnvar().concretetype = v_res.concretetype
newstartblock.closeblock(Link([v_res], newgraph.returnblock))
+ newgraph.ts_stub_for = graph
return newgraph
Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/codewriter.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/codewriter.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/codewriter.py Sun Mar 16 17:13:43 2008
@@ -301,6 +301,11 @@
colororder = None
owncalldesc = CallDesc(self.RGenOp, self.exceptiondesc,
lltype.Ptr(FUNCTYPE), colororder)
+ # detect the special ts_stub or ts_metacall graphs and replace
+ # a real function pointer to them with a function pointer to
+ # the graph they are stubs for
+ if hasattr(graph, 'ts_stub_for'):
+ graph = graph.ts_stub_for
ownfnptr = lltype.functionptr(FUNCTYPE, graph.name, graph=graph)
gv_ownfnptr = self.RGenOp.constPrebuiltGlobal(ownfnptr)
return owncalldesc, gv_ownfnptr
Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hp_interpreter.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hp_interpreter.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hp_interpreter.py Sun Mar 16 17:13:43 2008
@@ -3,7 +3,7 @@
from pypy.rlib.jit import JitDriver, hint, JitHintError
from pypy.rlib.debug import ll_assert
from pypy.rlib.objectmodel import keepalive_until_here
-from pypy.jit.hintannotator.policy import StopAtXPolicy
+from pypy.jit.hintannotator.policy import HintAnnotatorPolicy, StopAtXPolicy
from pypy.jit.rainbow.test import test_hotpath
import sys
@@ -1919,7 +1919,6 @@
assert res == 56 - 90
def test_simple_substitute_graph(self):
- py.test.skip("fix this test")
class MetaG:
def __init__(self, codewriter):
@@ -1935,13 +1934,29 @@
bbox.getgenvar(jitstate))
return IntRedBox(abox.kind, gv_result)
+ class MyJitDriver(JitDriver):
+ greens = []
+ reds = ['a', 'b', 'i', 'res']
+
+ A = lltype.GcArray(lltype.Signed)
+
def g(a, b):
return a + b
def f(a, b):
- x = g(a, b)
- y = g(b, a)
- return x + y
+ res = lltype.malloc(A, 20)
+ i = 0
+ while i < 10:
+ #
+ x = g(a, b)
+ y = g(b, a)
+ res[2*i] = x
+ res[2*i+1] = y
+ #
+ MyJitDriver.jit_merge_point(a=a, b=b, res=res, i=i)
+ MyJitDriver.can_enter_jit(a=a, b=b, res=res, i=i)
+ i += 1
+ return res
class MyPolicy(HintAnnotatorPolicy):
novirtualcontainer = True
@@ -1952,9 +1967,11 @@
else:
return True
- res = self.interpret(f, [3, 6], policy=MyPolicy())
- assert res == 0
- self.check_insns({'int_add': 1, 'int_sub': 2})
+ res = self.run(f, [7, 1], threshold=3, policy=MyPolicy())
+ assert list(res) == [8, 8, 8, 8, 8, 8, # direct run
+ 8, 8, 8, 8, # fallback interp run
+ 6, -6, 6, -6, 6, -6, 6, -6, 6, -6] # compiled
+ self.check_insns_in_loops(int_sub=2)
def test_substitute_graph_void(self):
py.test.skip("fix this test")
More information about the Pypy-commit
mailing list