Author: Maciej Fijalkowski <[email protected]>
Branch: look-into-all-modules
Changeset: r74133:595ae5e38a7d
Date: 2014-10-23 16:19 +0200
http://bitbucket.org/pypy/pypy/changeset/595ae5e38a7d/
Log: enough to make the translation work
diff --git a/pypy/goal/targetpypystandalone.py
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -304,7 +304,8 @@
return self.get_entry_point(config)
def jitpolicy(self, driver):
- from pypy.module.pypyjit.policy import PyPyJitPolicy, pypy_hooks
+ from pypy.module.pypyjit.policy import PyPyJitPolicy
+ from pypy.module.pypyjit.hooks import pypy_hooks
return PyPyJitPolicy(pypy_hooks)
def get_entry_point(self, config):
diff --git a/pypy/module/pypyjit/__init__.py b/pypy/module/pypyjit/__init__.py
--- a/pypy/module/pypyjit/__init__.py
+++ b/pypy/module/pypyjit/__init__.py
@@ -24,7 +24,7 @@
def setup_after_space_initialization(self):
# force the __extend__ hacks to occur early
from pypy.module.pypyjit.interp_jit import pypyjitdriver
- from pypy.module.pypyjit.policy import pypy_hooks
+ from pypy.module.pypyjit.hooks import pypy_hooks
# add the 'defaults' attribute
from rpython.rlib.jit import PARAMETERS
space = self.space
diff --git a/pypy/module/pypyjit/hooks.py b/pypy/module/pypyjit/hooks.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/pypyjit/hooks.py
@@ -0,0 +1,89 @@
+
+from rpython.rlib import jit_hooks
+from rpython.rlib.jit import JitHookInterface, Counters
+
+from pypy.interpreter.error import OperationError
+from pypy.module.pypyjit.interp_resop import (Cache, wrap_greenkey,
+ WrappedOp, W_JitLoopInfo, wrap_oplist)
+
+class PyPyJitIface(JitHookInterface):
+ def on_abort(self, reason, jitdriver, greenkey, greenkey_repr, logops,
operations):
+ space = self.space
+ cache = space.fromcache(Cache)
+ if cache.in_recursion:
+ return
+ if space.is_true(cache.w_abort_hook):
+ cache.in_recursion = True
+ oplist_w = wrap_oplist(space, logops, operations)
+ try:
+ try:
+ space.call_function(cache.w_abort_hook,
+ space.wrap(jitdriver.name),
+ wrap_greenkey(space, jitdriver, greenkey,
greenkey_repr),
+ space.wrap(Counters.counter_names[reason]),
+ space.newlist(oplist_w)
+ )
+ except OperationError, e:
+ e.write_unraisable(space, "jit hook ", cache.w_abort_hook)
+ finally:
+ cache.in_recursion = False
+
+ def after_compile(self, debug_info):
+ self._compile_hook(debug_info, is_bridge=False)
+
+ def after_compile_bridge(self, debug_info):
+ self._compile_hook(debug_info, is_bridge=True)
+
+ def before_compile(self, debug_info):
+ self._optimize_hook(debug_info, is_bridge=False)
+
+ def before_compile_bridge(self, debug_info):
+ self._optimize_hook(debug_info, is_bridge=True)
+
+ def _compile_hook(self, debug_info, is_bridge):
+ space = self.space
+ cache = space.fromcache(Cache)
+ if cache.in_recursion:
+ return
+ if space.is_true(cache.w_compile_hook):
+ w_debug_info = W_JitLoopInfo(space, debug_info, is_bridge)
+ cache.in_recursion = True
+ try:
+ try:
+ space.call_function(cache.w_compile_hook,
+ space.wrap(w_debug_info))
+ except OperationError, e:
+ e.write_unraisable(space, "jit hook ",
cache.w_compile_hook)
+ finally:
+ cache.in_recursion = False
+
+ def _optimize_hook(self, debug_info, is_bridge=False):
+ space = self.space
+ cache = space.fromcache(Cache)
+ if cache.in_recursion:
+ return
+ if space.is_true(cache.w_optimize_hook):
+ w_debug_info = W_JitLoopInfo(space, debug_info, is_bridge)
+ cache.in_recursion = True
+ try:
+ try:
+ w_res = space.call_function(cache.w_optimize_hook,
+ space.wrap(w_debug_info))
+ if space.is_w(w_res, space.w_None):
+ return
+ l = []
+ for w_item in space.listview(w_res):
+ item = space.interp_w(WrappedOp, w_item)
+ l.append(jit_hooks._cast_to_resop(item.op))
+ del debug_info.operations[:] # modifying operations above
is
+ # probably not a great idea since types may not work
+ # and we'll end up with half-working list and
+ # a segfault/fatal RPython error
+ for elem in l:
+ debug_info.operations.append(elem)
+ except OperationError, e:
+ e.write_unraisable(space, "jit hook ",
cache.w_compile_hook)
+ finally:
+ cache.in_recursion = False
+
+pypy_hooks = PyPyJitIface()
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
@@ -1,93 +1,4 @@
from rpython.jit.codewriter.policy import JitPolicy
-from rpython.rlib import jit_hooks
-from rpython.rlib.jit import JitHookInterface, Counters
-
-from pypy.interpreter.error import OperationError
-from pypy.module.pypyjit.interp_resop import (Cache, wrap_greenkey,
- WrappedOp, W_JitLoopInfo, wrap_oplist)
-
-
-class PyPyJitIface(JitHookInterface):
- def on_abort(self, reason, jitdriver, greenkey, greenkey_repr, logops,
operations):
- space = self.space
- cache = space.fromcache(Cache)
- if cache.in_recursion:
- return
- if space.is_true(cache.w_abort_hook):
- cache.in_recursion = True
- oplist_w = wrap_oplist(space, logops, operations)
- try:
- try:
- space.call_function(cache.w_abort_hook,
- space.wrap(jitdriver.name),
- wrap_greenkey(space, jitdriver, greenkey,
greenkey_repr),
- space.wrap(Counters.counter_names[reason]),
- space.newlist(oplist_w)
- )
- except OperationError, e:
- e.write_unraisable(space, "jit hook ", cache.w_abort_hook)
- finally:
- cache.in_recursion = False
-
- def after_compile(self, debug_info):
- self._compile_hook(debug_info, is_bridge=False)
-
- def after_compile_bridge(self, debug_info):
- self._compile_hook(debug_info, is_bridge=True)
-
- def before_compile(self, debug_info):
- self._optimize_hook(debug_info, is_bridge=False)
-
- def before_compile_bridge(self, debug_info):
- self._optimize_hook(debug_info, is_bridge=True)
-
- def _compile_hook(self, debug_info, is_bridge):
- space = self.space
- cache = space.fromcache(Cache)
- if cache.in_recursion:
- return
- if space.is_true(cache.w_compile_hook):
- w_debug_info = W_JitLoopInfo(space, debug_info, is_bridge)
- cache.in_recursion = True
- try:
- try:
- space.call_function(cache.w_compile_hook,
- space.wrap(w_debug_info))
- except OperationError, e:
- e.write_unraisable(space, "jit hook ",
cache.w_compile_hook)
- finally:
- cache.in_recursion = False
-
- def _optimize_hook(self, debug_info, is_bridge=False):
- space = self.space
- cache = space.fromcache(Cache)
- if cache.in_recursion:
- return
- if space.is_true(cache.w_optimize_hook):
- w_debug_info = W_JitLoopInfo(space, debug_info, is_bridge)
- cache.in_recursion = True
- try:
- try:
- w_res = space.call_function(cache.w_optimize_hook,
- space.wrap(w_debug_info))
- if space.is_w(w_res, space.w_None):
- return
- l = []
- for w_item in space.listview(w_res):
- item = space.interp_w(WrappedOp, w_item)
- l.append(jit_hooks._cast_to_resop(item.op))
- del debug_info.operations[:] # modifying operations above
is
- # probably not a great idea since types may not work
- # and we'll end up with half-working list and
- # a segfault/fatal RPython error
- for elem in l:
- debug_info.operations.append(elem)
- except OperationError, e:
- e.write_unraisable(space, "jit hook ",
cache.w_compile_hook)
- finally:
- cache.in_recursion = False
-
-pypy_hooks = PyPyJitIface()
class PyPyJitPolicy(JitPolicy):
@@ -103,7 +14,7 @@
return True
if '.' in modname:
modname, rest = modname.split('.', 1)
- if modname in ['unicodedata', 'gc']:
+ if modname in ['unicodedata', 'gc', '_minimal_curses', 'cpyext']:
return False
else:
rest = ''
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit