Author: Maciej Fijalkowski <[email protected]>
Branch: better-jit-hooks
Changeset: r51105:76c53cca9b18
Date: 2012-01-07 13:48 +0200
http://bitbucket.org/pypy/pypy/changeset/76c53cca9b18/
Log: add stuff to test_ztranslation and make it pass
diff --git a/pypy/jit/metainterp/test/test_ztranslation.py
b/pypy/jit/metainterp/test/test_ztranslation.py
--- a/pypy/jit/metainterp/test/test_ztranslation.py
+++ b/pypy/jit/metainterp/test/test_ztranslation.py
@@ -3,7 +3,9 @@
from pypy.jit.backend.llgraph import runner
from pypy.rlib.jit import JitDriver, unroll_parameters, set_param
from pypy.rlib.jit import PARAMETERS, dont_look_inside, hint
+from pypy.rlib.jit_hooks import boxint_new, resop_new, resop_opnum
from pypy.jit.metainterp.jitprof import Profiler
+from pypy.jit.metainterp.resoperation import rop
from pypy.rpython.lltypesystem import lltype, llmemory
class TranslationTest:
@@ -22,6 +24,7 @@
# - jitdriver hooks
# - two JITs
# - string concatenation, slicing and comparison
+ # - jit hooks interface
class Frame(object):
_virtualizable2_ = ['l[*]']
@@ -91,7 +94,9 @@
return f.i
#
def main(i, j):
- return f(i) - f2(i+j, i, j)
+ op = resop_new(rop.INT_ADD, [boxint_new(3), boxint_new(5)],
+ boxint_new(8))
+ return f(i) - f2(i+j, i, j) + resop_opnum(op)
res = ll_meta_interp(main, [40, 5], CPUClass=self.CPUClass,
type_system=self.type_system,
listops=True)
diff --git a/pypy/jit/metainterp/warmspot.py b/pypy/jit/metainterp/warmspot.py
--- a/pypy/jit/metainterp/warmspot.py
+++ b/pypy/jit/metainterp/warmspot.py
@@ -1,4 +1,5 @@
import sys, py
+from pypy.tool.sourcetools import func_with_new_name
from pypy.rpython.lltypesystem import lltype, llmemory
from pypy.rpython.annlowlevel import llhelper, MixLevelHelperAnnotator,\
cast_base_ptr_to_instance, hlstr
@@ -634,10 +635,14 @@
def rewrite_access_helper(self, op):
ARGS = [arg.concretetype for arg in op.args[2:]]
RESULT = op.result.concretetype
- ptr = self.helper_func(lltype.Ptr(lltype.FuncType(ARGS, RESULT)),
- op.args[1].value)
+ FUNCPTR = lltype.Ptr(lltype.FuncType(ARGS, RESULT))
+ # make sure we make a copy of function so it no longer belongs
+ # to extregistry
+ func = op.args[1].value
+ func = func_with_new_name(func, func.func_name + '_compiled')
+ ptr = self.helper_func(FUNCPTR, func)
op.opname = 'direct_call'
- op.args = [Constant(ptr, lltype.Void)] + op.args[2:]
+ op.args = [Constant(ptr, FUNCPTR)] + op.args[2:]
def rewrite_jit_merge_points(self, policy):
for jd in self.jitdrivers_sd:
diff --git a/pypy/rlib/jit_hooks.py b/pypy/rlib/jit_hooks.py
--- a/pypy/rlib/jit_hooks.py
+++ b/pypy/rlib/jit_hooks.py
@@ -5,6 +5,7 @@
from pypy.rpython.lltypesystem import rclass
from pypy.rpython.annlowlevel import cast_instance_to_base_ptr,\
cast_base_ptr_to_instance
+from pypy.rlib.objectmodel import specialize
def register_helper(helper, s_result):
@@ -36,6 +37,7 @@
ptr = lltype.cast_opaque_ptr(rclass.OBJECTPTR, llref)
return cast_base_ptr_to_instance(AbstractResOp, ptr)
[email protected](0)
def _cast_to_gcref(obj):
return lltype.cast_opaque_ptr(llmemory.GCREF,
cast_instance_to_base_ptr(obj))
@@ -43,7 +45,7 @@
def resop_new(no, llargs, llres):
from pypy.jit.metainterp.history import ResOperation
- args = [_cast_to_box(llarg) for llarg in llargs]
+ args = [_cast_to_box(llargs[i]) for i in range(len(llargs))]
res = _cast_to_box(llres)
return _cast_to_gcref(ResOperation(no, args, res))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit