[pypy-svn] r76368 - in pypy/branch/improved-asm-logging/pypy/jit/backend/x86: . test

fijal at codespeak.net fijal at codespeak.net
Tue Jul 27 16:15:23 CEST 2010


Author: fijal
Date: Tue Jul 27 16:15:22 2010
New Revision: 76368

Modified:
   pypy/branch/improved-asm-logging/pypy/jit/backend/x86/assembler.py
   pypy/branch/improved-asm-logging/pypy/jit/backend/x86/runner.py
   pypy/branch/improved-asm-logging/pypy/jit/backend/x86/test/test_runner.py
Log:
Dump statistics to a file if PYPYLOG is set


Modified: pypy/branch/improved-asm-logging/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/improved-asm-logging/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/improved-asm-logging/pypy/jit/backend/x86/assembler.py	Tue Jul 27 16:15:22 2010
@@ -17,6 +17,7 @@
 from pypy.jit.backend.x86.support import values_array
 from pypy.rlib.debug import debug_print
 from pypy.rlib import rgc
+from pypy.rlib.streamio import open_file_as_stream
 
 # our calling convention - we pass first 6 args in registers
 # and the rest stays on the stack
@@ -99,6 +100,7 @@
     mc_size = MachineCodeBlockWrapper.MC_DEFAULT_SIZE
     _float_constants = None
     _regalloc = None
+    _output_loop_log = None
 
     def __init__(self, cpu, translate_support_code=False,
                             failargs_limit=1000):
@@ -165,9 +167,19 @@
                 self._build_float_constants()
             if hasattr(gc_ll_descr, 'get_malloc_fixedsize_slowpath_addr'):
                 self._build_malloc_fixedsize_slowpath()
-            s = os.environ.get('PYPYJITLOG')
+            s = os.environ.get('PYPYLOG')
             if s:
                 self.set_debug(True)
+                self._output_loop_log = s + ".count"
+
+    def finish_once(self):
+        if self._debug:
+            assert self._output_loop_log is not None
+            f = open_file_as_stream(self._output_loop_log, "w")
+            for i in range(self._loop_counter):
+                f.write(self.loop_names[i] + ":" +
+                        str(self.loop_run_counter.getitem(i)) + "\n")
+            f.close()
 
     def _build_float_constants(self):
         # 11 words: 8 words for the data, and up to 3 words for alignment

Modified: pypy/branch/improved-asm-logging/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/improved-asm-logging/pypy/jit/backend/x86/runner.py	(original)
+++ pypy/branch/improved-asm-logging/pypy/jit/backend/x86/runner.py	Tue Jul 27 16:15:22 2010
@@ -44,6 +44,7 @@
         self.profile_agent.startup()
 
     def finish_once(self):
+        self.assembler.finish_once()
         self.profile_agent.shutdown()
 
     def compile_loop(self, inputargs, operations, looptoken):

Modified: pypy/branch/improved-asm-logging/pypy/jit/backend/x86/test/test_runner.py
==============================================================================
--- pypy/branch/improved-asm-logging/pypy/jit/backend/x86/test/test_runner.py	(original)
+++ pypy/branch/improved-asm-logging/pypy/jit/backend/x86/test/test_runner.py	Tue Jul 27 16:15:22 2010
@@ -10,8 +10,10 @@
 from pypy.jit.metainterp.executor import execute
 from pypy.jit.backend.test.runner_test import LLtypeBackendTest
 from pypy.jit.metainterp.test.oparser import parse
+from pypy.tool.udir import udir
 import ctypes
 import sys
+import os
 
 class FakeStats(object):
     pass
@@ -394,8 +396,15 @@
 
 class TestDebuggingAssembler(object):
     def setup_method(self, meth):
+        self.pypylog = os.environ.get('PYPYLOG', None)
+        self.logfile = str(udir.join('x86_runner.log'))
+        os.environ['PYPYLOG'] = self.logfile
         self.cpu = CPU(rtyper=None, stats=FakeStats())
 
+    def teardown_method(self, meth):
+        if self.pypylog is not None:
+            os.environ['PYPYLOG'] = self.pypylog
+
     def test_debugger_on(self):
         loop = """
         [i0]
@@ -413,3 +422,6 @@
         # check debugging info
         assert self.cpu.assembler.loop_names == ["xyz"]
         assert self.cpu.assembler.loop_run_counter.getitem(0) == 10
+        self.cpu.finish_once()
+        lines = py.path.local(self.logfile + ".count").readlines()
+        assert lines[0] == 'xyz:10\n'



More information about the Pypy-commit mailing list