[pypy-svn] r67798 - in pypy/branch/execute-star-args-jit/pypy/jit/metainterp: . test
pedronis at codespeak.net
pedronis at codespeak.net
Sat Sep 19 14:27:08 CEST 2009
Author: pedronis
Date: Sat Sep 19 14:27:08 2009
New Revision: 67798
Modified:
pypy/branch/execute-star-args-jit/pypy/jit/metainterp/history.py
pypy/branch/execute-star-args-jit/pypy/jit/metainterp/pyjitpl.py
pypy/branch/execute-star-args-jit/pypy/jit/metainterp/test/test_jitprof.py
Log:
fix profiler op counting, some more testing
Modified: pypy/branch/execute-star-args-jit/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/branch/execute-star-args-jit/pypy/jit/metainterp/history.py (original)
+++ pypy/branch/execute-star-args-jit/pypy/jit/metainterp/history.py Sat Sep 19 14:27:08 2009
@@ -8,7 +8,6 @@
from pypy.conftest import option
from pypy.jit.metainterp.resoperation import ResOperation, rop
-from pypy.jit.metainterp.jitprof import BLACKHOLED_OPS, RECORDED_OPS
import py
from pypy.tool.ansi_print import ansi_log
Modified: pypy/branch/execute-star-args-jit/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/execute-star-args-jit/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/execute-star-args-jit/pypy/jit/metainterp/pyjitpl.py Sat Sep 19 14:27:08 2009
@@ -10,7 +10,8 @@
from pypy.jit.metainterp.resoperation import rop
from pypy.jit.metainterp import codewriter, executor
from pypy.jit.backend.logger import Logger
-from pypy.jit.metainterp.jitprof import EmptyProfiler, GUARDS
+from pypy.jit.metainterp.jitprof import EmptyProfiler, BLACKHOLED_OPS
+from pypy.jit.metainterp.jitprof import GUARDS, RECORDED_OPS
from pypy.rlib.rarithmetic import intmask
from pypy.rlib.objectmodel import specialize
@@ -1220,6 +1221,7 @@
profiler.count_ops(opnum)
resbox = executor.execute(self.cpu, opnum, descr, *argboxes)
if self.is_blackholing():
+ profiler.count_ops(opnum, BLACKHOLED_OPS)
return resbox
if rop._ALWAYS_PURE_FIRST <= opnum <= rop._ALWAYS_PURE_LAST:
return self._record_helper_pure(opnum, resbox, descr, *argboxes)
@@ -1240,7 +1242,9 @@
profiler = self.staticdata.profiler
profiler.count_ops(opnum)
resbox = executor.execute_varargs(self.cpu, opnum, argboxes, descr)
- if not self.is_blackholing():
+ if self.is_blackholing():
+ profiler.count_ops(opnum, BLACKHOLED_OPS)
+ else:
if require_attention:
require_attention = self.after_residual_call()
# check if the operation can be constant-folded away
@@ -1274,6 +1278,8 @@
def _record_helper_nonpure_varargs(self, opnum, resbox, descr, argboxes):
assert resbox is None or isinstance(resbox, Box)
# record the operation
+ profiler = self.staticdata.profiler
+ profiler.count_ops(opnum, RECORDED_OPS)
op = self.history.record(opnum, argboxes, resbox, descr)
self.attach_debug_info(op)
return resbox
Modified: pypy/branch/execute-star-args-jit/pypy/jit/metainterp/test/test_jitprof.py
==============================================================================
--- pypy/branch/execute-star-args-jit/pypy/jit/metainterp/test/test_jitprof.py (original)
+++ pypy/branch/execute-star-args-jit/pypy/jit/metainterp/test/test_jitprof.py Sat Sep 19 14:27:08 2009
@@ -1,6 +1,6 @@
from pypy.jit.metainterp.warmspot import ll_meta_interp
-from pypy.rlib.jit import JitDriver, dont_look_inside
+from pypy.rlib.jit import JitDriver, dont_look_inside, purefunction
from pypy.jit.metainterp.test.test_basic import LLJitMixin
from pypy.jit.metainterp import pyjitpl
from pypy.jit.metainterp.jitprof import *
@@ -78,3 +78,24 @@
# calls = (executed, recorded, blackholed) x (inpure, pure)
assert profiler.calls == [[1, 0], [1, 0], [0, 0]]
+ def test_blackhole_pure(self):
+ @purefunction
+ def g(n):
+ return n+1
+
+ myjitdriver = JitDriver(greens = ['z'], reds = ['y', 'x','res'])
+ def f(x, y, z):
+ res = 0
+ while y > 0:
+ myjitdriver.can_enter_jit(x=x, y=y, res=res, z=z)
+ myjitdriver.jit_merge_point(x=x, y=y, res=res, z=z)
+ res += x
+ if y == 1:
+ res += g(z)
+ y -= 1
+ return res * 2
+ res = self.meta_interp(f, [6, 7, 2])
+ assert res == 90
+ profiler = pyjitpl._warmrunnerdesc.metainterp_sd.profiler
+ # calls = (executed, recorded, blackholed) x (inpure, pure)
+ assert profiler.calls == [[0, 1], [0, 0], [0, 1]]
More information about the Pypy-commit
mailing list