[pypy-commit] pypy better-jit-hooks: add name attribute to jitdrivers. start shifting code around in module/pypyjit
fijal
noreply at buildbot.pypy.org
Thu Jan 5 22:30:51 CET 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: better-jit-hooks
Changeset: r51047:032bbe1b32c3
Date: 2012-01-05 23:30 +0200
http://bitbucket.org/pypy/pypy/changeset/032bbe1b32c3/
Log: add name attribute to jitdrivers. start shifting code around in
module/pypyjit
diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -16,24 +16,28 @@
virtualizables=['frame'],
reds=['result_size', 'frame', 'ri', 'self', 'result'],
get_printable_location=signature.new_printable_location('numpy'),
+ name='numpy',
)
all_driver = jit.JitDriver(
greens=['shapelen', 'sig'],
virtualizables=['frame'],
reds=['frame', 'self', 'dtype'],
get_printable_location=signature.new_printable_location('all'),
+ name='numpy_all',
)
any_driver = jit.JitDriver(
greens=['shapelen', 'sig'],
virtualizables=['frame'],
reds=['frame', 'self', 'dtype'],
get_printable_location=signature.new_printable_location('any'),
+ name='numpy_any',
)
slice_driver = jit.JitDriver(
greens=['shapelen', 'sig'],
virtualizables=['frame'],
reds=['self', 'frame', 'source', 'res_iter'],
get_printable_location=signature.new_printable_location('slice'),
+ name='numpy_slice',
)
def _find_shape_and_elems(space, w_iterable):
@@ -297,6 +301,7 @@
greens=['shapelen', 'sig'],
reds=['result', 'idx', 'frame', 'self', 'cur_best', 'dtype'],
get_printable_location=signature.new_printable_location(op_name),
+ name='numpy_' + op_name,
)
def loop(self):
sig = self.find_sig()
diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -14,6 +14,7 @@
virtualizables = ["frame"],
reds = ["frame", "self", "dtype", "value", "obj"],
get_printable_location=new_printable_location('reduce'),
+ name='numpy_reduce',
)
class W_Ufunc(Wrappable):
diff --git a/pypy/module/pypyjit/interp_jit.py b/pypy/module/pypyjit/interp_jit.py
--- a/pypy/module/pypyjit/interp_jit.py
+++ b/pypy/module/pypyjit/interp_jit.py
@@ -13,11 +13,8 @@
from pypy.interpreter.pycode import PyCode, CO_GENERATOR
from pypy.interpreter.pyframe import PyFrame
from pypy.interpreter.pyopcode import ExitFrame
-from pypy.interpreter.gateway import unwrap_spec
from opcode import opmap
from pypy.rlib.nonconst import NonConstant
-from pypy.jit.metainterp.resoperation import rop
-from pypy.module.pypyjit.interp_resop import debug_merge_point_from_boxes
PyFrame._virtualizable2_ = ['last_instr', 'pycode',
'valuestackdepth', 'locals_stack_w[*]',
@@ -51,72 +48,19 @@
def should_unroll_one_iteration(next_instr, is_being_profiled, bytecode):
return (bytecode.co_flags & CO_GENERATOR) != 0
-def wrap_oplist(space, logops, operations):
- list_w = []
- for op in operations:
- if op.getopnum() == rop.DEBUG_MERGE_POINT:
- list_w.append(space.wrap(debug_merge_point_from_boxes(
- op.getarglist())))
- else:
- list_w.append(space.wrap(logops.repr_of_resop(op)))
- return list_w
-
class PyPyJitDriver(JitDriver):
reds = ['frame', 'ec']
greens = ['next_instr', 'is_being_profiled', 'pycode']
virtualizables = ['frame']
- def on_compile(self, logger, looptoken, operations, type, next_instr,
- is_being_profiled, ll_pycode):
- from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
-
- space = self.space
- cache = space.fromcache(Cache)
- if cache.in_recursion:
- return
- if space.is_true(cache.w_compile_hook):
- logops = logger._make_log_operations()
- list_w = wrap_oplist(space, logops, operations)
- pycode = cast_base_ptr_to_instance(PyCode, ll_pycode)
- cache.in_recursion = True
- try:
- space.call_function(cache.w_compile_hook,
- space.wrap('main'),
- space.wrap(type),
- space.newtuple([pycode,
- space.wrap(next_instr),
- space.wrap(is_being_profiled)]),
- space.newlist(list_w))
- except OperationError, e:
- e.write_unraisable(space, "jit hook ", cache.w_compile_hook)
- cache.in_recursion = False
-
- def on_compile_bridge(self, logger, orig_looptoken, operations, n):
- space = self.space
- cache = space.fromcache(Cache)
- if cache.in_recursion:
- return
- if space.is_true(cache.w_compile_hook):
- logops = logger._make_log_operations()
- list_w = wrap_oplist(space, logops, operations)
- cache.in_recursion = True
- try:
- space.call_function(cache.w_compile_hook,
- space.wrap('main'),
- space.wrap('bridge'),
- space.wrap(n),
- space.newlist(list_w))
- except OperationError, e:
- e.write_unraisable(space, "jit hook ", cache.w_compile_hook)
- cache.in_recursion = False
-
pypyjitdriver = PyPyJitDriver(get_printable_location = get_printable_location,
get_jitcell_at = get_jitcell_at,
set_jitcell_at = set_jitcell_at,
confirm_enter_jit = confirm_enter_jit,
can_never_inline = can_never_inline,
should_unroll_one_iteration =
- should_unroll_one_iteration)
+ should_unroll_one_iteration,
+ name='pypyjit')
class __extend__(PyFrame):
diff --git a/pypy/module/pypyjit/interp_resop.py b/pypy/module/pypyjit/interp_resop.py
--- a/pypy/module/pypyjit/interp_resop.py
+++ b/pypy/module/pypyjit/interp_resop.py
@@ -6,6 +6,17 @@
from pypy.rpython.lltypesystem import lltype
from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
from pypy.rpython.lltypesystem.rclass import OBJECT
+from pypy.jit.metainterp.resoperation import rop
+
+def wrap_oplist(space, logops, operations):
+ list_w = []
+ for op in operations:
+ if op.getopnum() == rop.DEBUG_MERGE_POINT:
+ list_w.append(space.wrap(debug_merge_point_from_boxes(
+ op.getarglist())))
+ else:
+ list_w.append(space.wrap(logops.repr_of_resop(op)))
+ return list_w
class W_DebugMergePoint(Wrappable):
""" A class representing debug_merge_point JIT operation
diff --git a/pypy/module/pypyjit/policy.py b/pypy/module/pypyjit/policy.py
--- a/pypy/module/pypyjit/policy.py
+++ b/pypy/module/pypyjit/policy.py
@@ -3,6 +3,8 @@
from pypy.module.pypyjit.interp_jit import Cache
from pypy.interpreter.error import OperationError
from pypy.jit.metainterp.jitprof import counter_names
+from pypy.module.pypyjit.interp_resop import wrap_oplist
+from pypy.interpreter.pycode import PyCode
class PyPyPortal(JitPortal):
def on_abort(self, reason, jitdriver, greenkey):
@@ -19,6 +21,51 @@
e.write_unraisable(space, "jit hook ", cache.w_abort_hook)
cache.in_recursion = False
+ def on_compile(self, jitdriver, logger, looptoken, operations, type,
+ greenkey, asmstart, asmlen):
+ from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
+
+ space = self.space
+ cache = space.fromcache(Cache)
+ if cache.in_recursion:
+ return
+ if space.is_true(cache.w_compile_hook):
+ logops = logger._make_log_operations()
+ list_w = wrap_oplist(space, logops, operations)
+ pycode = cast_base_ptr_to_instance(PyCode, ll_pycode)
+ cache.in_recursion = True
+ try:
+ space.call_function(cache.w_compile_hook,
+ space.wrap('main'),
+ space.wrap(type),
+ space.newtuple([pycode,
+ space.wrap(next_instr),
+ space.wrap(is_being_profiled)]),
+ space.newlist(list_w))
+ except OperationError, e:
+ e.write_unraisable(space, "jit hook ", cache.w_compile_hook)
+ cache.in_recursion = False
+
+ def on_compile_bridge(self, jitdriver, logger, orig_looptoken, operations,
+ n, asm, asmlen):
+ space = self.space
+ cache = space.fromcache(Cache)
+ if cache.in_recursion:
+ return
+ if space.is_true(cache.w_compile_hook):
+ logops = logger._make_log_operations()
+ list_w = wrap_oplist(space, logops, operations)
+ cache.in_recursion = True
+ try:
+ space.call_function(cache.w_compile_hook,
+ space.wrap('main'),
+ space.wrap('bridge'),
+ space.wrap(n),
+ space.newlist(list_w))
+ except OperationError, e:
+ e.write_unraisable(space, "jit hook ", cache.w_compile_hook)
+ cache.in_recursion = False
+
pypy_portal = PyPyPortal()
class PyPyJitPolicy(JitPolicy):
diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py
--- a/pypy/rlib/jit.py
+++ b/pypy/rlib/jit.py
@@ -409,13 +409,16 @@
active = True # if set to False, this JitDriver is ignored
virtualizables = []
+ name = 'jitdriver'
def __init__(self, greens=None, reds=None, virtualizables=None,
get_jitcell_at=None, set_jitcell_at=None,
get_printable_location=None, confirm_enter_jit=None,
- can_never_inline=None, should_unroll_one_iteration=None):
+ can_never_inline=None, should_unroll_one_iteration=None,
+ name='jitdriver'):
if greens is not None:
self.greens = greens
+ self.name = name
if reds is not None:
self.reds = reds
if not hasattr(self, 'greens') or not hasattr(self, 'reds'):
diff --git a/pypy/rlib/rsre/rsre_jit.py b/pypy/rlib/rsre/rsre_jit.py
--- a/pypy/rlib/rsre/rsre_jit.py
+++ b/pypy/rlib/rsre/rsre_jit.py
@@ -5,7 +5,7 @@
active = True
def __init__(self, name, debugprint, **kwds):
- JitDriver.__init__(self, **kwds)
+ JitDriver.__init__(self, name='rsre_' + name, **kwds)
#
def get_printable_location(*args):
# we print based on indices in 'args'. We first print
More information about the pypy-commit
mailing list