Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r80023:4f21ee6823f2
Date: 2015-10-07 17:12 +0100
http://bitbucket.org/pypy/pypy/changeset/4f21ee6823f2/

Log:    Expose to app-level the stats (two numbers) maintained by
        AsmMemoryManager

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
@@ -15,6 +15,7 @@
         'set_compile_hook': 'interp_resop.set_compile_hook',
         'set_abort_hook': 'interp_resop.set_abort_hook',
         'get_stats_snapshot': 'interp_resop.get_stats_snapshot',
+        'get_stats_asmmemmgr': 'interp_resop.get_stats_asmmemmgr',
         # those things are disabled because they have bugs, but if
         # they're found to be useful, fix test_ztranslation_jit_stats
         # in the backend first. get_stats_snapshot still produces
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
@@ -333,6 +333,13 @@
     return space.wrap(W_JitInfoSnapshot(space, w_times, w_counters,
                                         w_counter_times))
 
+def get_stats_asmmemmgr(space):
+    """Returns the raw memory currently used by the JIT backend,
+    as a pair (total_memory_allocated, memory_in_use)."""
+    m1 = jit_hooks.stats_asmmemmgr_allocated(None)
+    m2 = jit_hooks.stats_asmmemmgr_used(None)
+    return space.newtuple([space.wrap(m1), space.wrap(m2)])
+
 def enable_debug(space):
     """ Set the jit debugging - completely necessary for some stats to work,
     most notably assembler counters.
diff --git a/rpython/jit/backend/llsupport/asmmemmgr.py 
b/rpython/jit/backend/llsupport/asmmemmgr.py
--- a/rpython/jit/backend/llsupport/asmmemmgr.py
+++ b/rpython/jit/backend/llsupport/asmmemmgr.py
@@ -25,6 +25,10 @@
         self.free_blocks_end = {}  # map {stop: start}
         self.blocks_by_size = [[] for i in range(self.num_indices)]
 
+    def get_stats(self):
+        """Returns stats for rlib.jit.jit_hooks.stats_asmmemmgr_*()."""
+        return (self.total_memory_allocated, self.total_mallocs)
+
     def malloc(self, minsize, maxsize):
         """Allocate executable memory, between minsize and maxsize bytes,
         and return a pair (start, stop).  Does not perform any rounding
diff --git a/rpython/rlib/jit_hooks.py b/rpython/rlib/jit_hooks.py
--- a/rpython/rlib/jit_hooks.py
+++ b/rpython/rlib/jit_hooks.py
@@ -129,6 +129,14 @@
 def stats_get_loop_run_times(warmrunnerdesc):
     return warmrunnerdesc.metainterp_sd.cpu.get_all_loop_runs()
 
+@register_helper(annmodel.SomeInteger(unsigned=True))
+def stats_asmmemmgr_allocated(warmrunnerdesc):
+    return warmrunnerdesc.metainterp_sd.cpu.asmmemmgr.get_stats()[0]
+
+@register_helper(annmodel.SomeInteger(unsigned=True))
+def stats_asmmemmgr_used(warmrunnerdesc):
+    return warmrunnerdesc.metainterp_sd.cpu.asmmemmgr.get_stats()[1]
+
 # ---------------------- jitcell interface ----------------------
 
 def _new_hook(name, resulttype):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to