Author: Maciej Fijalkowski <[email protected]>
Branch: jit-threshold-hooks
Changeset: r66331:46acbfad8195
Date: 2013-08-26 20:44 +0100
http://bitbucket.org/pypy/pypy/changeset/46acbfad8195/
Log: a test and a fix
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
@@ -176,8 +176,9 @@
For testing. Set the threshold for this code object at position pos
at value given.
"""
- jitcell = w_code.jit_cells[pos << 1]
- if not jitcell:
+ try:
+ jitcell = w_code.jit_cells[pos << 1]
+ except KeyError:
ref = jit_hooks.new_jitcell()
jitcell = cast_base_ptr_to_instance(BaseJitCell, ref)
w_code.jit_cells[pos << 1] = jitcell
diff --git a/pypy/module/pypyjit/test/test_jit_hook.py
b/pypy/module/pypyjit/test/test_jit_hook.py
--- a/pypy/module/pypyjit/test/test_jit_hook.py
+++ b/pypy/module/pypyjit/test/test_jit_hook.py
@@ -272,3 +272,11 @@
assert isinstance(stats.w_counters, dict)
assert sorted(stats.w_counters.keys()) == self.sorted_keys
+ def test_set_local_threshold(self):
+ import pypyjit
+
+ def f():
+ pass
+
+ pypyjit.set_local_threshold(f.__code__, 0, 0)
+ # assert did not crash
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit