[pypy-svn] r67196 - in pypy/branch/pyjitpl5/pypy/jit: backend backend/cli backend/llvm backend/x86 metainterp

arigo at codespeak.net arigo at codespeak.net
Tue Aug 25 16:09:03 CEST 2009


Author: arigo
Date: Tue Aug 25 16:09:02 2009
New Revision: 67196

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py
   pypy/branch/pyjitpl5/pypy/jit/backend/llvm/runner.py
   pypy/branch/pyjitpl5/pypy/jit/backend/logger.py
   pypy/branch/pyjitpl5/pypy/jit/backend/model.py
   pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py
   pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
Log:
Push and pull all over the place to get the logger class
to optimize.py.


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py	Tue Aug 25 16:09:02 2009
@@ -1,7 +1,6 @@
 import py
 import os
 from pypy.tool.pairtype import extendabletype
-from pypy.rlib.objectmodel import compute_unique_id
 from pypy.rpython.ootypesystem import ootype
 from pypy.translator.cli import dotnet
 from pypy.translator.cli.dotnet import CLR
@@ -34,6 +33,7 @@
         return AbstractLogger.repr_of_descr(self, descr)
     
 logger = CliLogger()
+runner.CliCPU.logger_cls = CliLogger     # xxx hack
 
 class __extend__(AbstractValue):
     __metaclass__ = extendabletype
@@ -163,8 +163,7 @@
 
         # ----
         logger.create_log()
-        logger.eventually_log_operations(loop.inputargs, loop.operations, None,
-                                         compute_unique_id(loop))
+        logger.eventually_log_loop(loop)
         # ----
         self.box2type = {}
         if self.nocast:

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llvm/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llvm/runner.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llvm/runner.py	Tue Aug 25 16:09:02 2009
@@ -16,6 +16,7 @@
 
 class LLVMCPU(object):
     is_oo = False
+    logger_cls = None
     RAW_VALUE = rffi.CFixedArray(rffi.ULONGLONG, 1)
     SIGNED_VALUE = rffi.CFixedArray(lltype.Signed, 1)
     POINTER_VALUE = rffi.CFixedArray(llmemory.GCREF, 1)

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/logger.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/logger.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/logger.py	Tue Aug 25 16:09:02 2009
@@ -11,13 +11,13 @@
     def __init__(self):
         self._log_fd = -1
 
-    def create_log(self):
+    def create_log(self, extension='.ops'):
         if self._log_fd != -1:
             return self._log_fd
         s = os.environ.get('PYPYJITLOG')
         if not s:
             return -1
-        s += '.ops'
+        s += extension
         try:
             flags = os.O_WRONLY|os.O_CREAT|os.O_TRUNC
             self._log_fd = os.open(s, flags, 0666)
@@ -26,6 +26,10 @@
             return -1
         return self._log_fd
 
+    def eventually_log_loop(self, loop):
+        self.eventually_log_operations(loop.inputargs, loop.operations, None,
+                                       compute_unique_id(loop))
+
     def repr_of_descr(self, descr):
         return ''
 

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/model.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/model.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/model.py	Tue Aug 25 16:09:02 2009
@@ -1,4 +1,6 @@
 class AbstractCPU(object):
+    logger_cls = None
+
     def set_class_sizes(self, class_sizes):
         self.class_sizes = class_sizes
 

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py	Tue Aug 25 16:09:02 2009
@@ -9,7 +9,7 @@
 from pypy.tool.uid import fixid
 from pypy.jit.backend.x86.regalloc import (RegAlloc, WORD, REGS, TempBox,
                                            lower_byte, stack_pos)
-from pypy.rlib.objectmodel import we_are_translated, specialize, compute_unique_id
+from pypy.rlib.objectmodel import we_are_translated, specialize
 from pypy.jit.backend.x86 import codebuf
 from pypy.jit.backend.x86.ri386 import *
 from pypy.jit.metainterp.resoperation import rop
@@ -192,8 +192,7 @@
         self.tree = tree
         self.make_sure_mc_exists()
         inputargs = tree.inputargs
-        self.logger.eventually_log_operations(tree.inputargs, tree.operations, None,
-                                              compute_unique_id(tree))
+        self.logger.eventually_log_loop(tree)
         regalloc = RegAlloc(self, tree, self.cpu.translate_support_code)
         self._regalloc = regalloc
         regalloc.walk_operations(tree)

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py	Tue Aug 25 16:09:02 2009
@@ -12,6 +12,7 @@
 from pypy.jit.metainterp.history import (ResOperation, Box, Const,
      ConstInt, ConstPtr, BoxInt, BoxPtr, ConstAddr, AbstractDescr)
 from pypy.jit.backend.x86.assembler import Assembler386, WORD, MAX_FAIL_BOXES
+from pypy.jit.backend.x86.assembler import x86Logger
 from pypy.jit.backend.x86 import symbolic
 from pypy.jit.metainterp.resoperation import rop, opname
 from pypy.rlib.objectmodel import r_dict
@@ -48,6 +49,7 @@
 class CPU386(object):
     debug = True
     is_oo = False
+    logger_cls = x86Logger
 
     BOOTSTRAP_TP = lltype.FuncType([], lltype.Signed)
 

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py	Tue Aug 25 16:09:02 2009
@@ -753,6 +753,7 @@
 # ----------------------------------------------------------------
 
 class Options:
+    logger_noopt = None
     def __init__(self, specialize=True, listops=False, inline=False):
         self.specialize = specialize
         self.listops = listops

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py	Tue Aug 25 16:09:02 2009
@@ -10,7 +10,8 @@
             return old_loops[0]
         else:
             return None
-    #loop.dump()
+    if options.logger_noopt is not None:
+        options.logger_noopt.eventually_log_loop(loop)
     finder = PerfectSpecializationFinder()
     finder.find_nodes_loop(loop)
     for old_loop in old_loops:
@@ -27,6 +28,8 @@
 def optimize_bridge(options, old_loops, bridge, cpu):
     if not options.specialize:         # for tests only
         return old_loops[0]
+    if options.logger_noopt is not None:
+        options.logger_noopt.eventually_log_loop(bridge)
     finder = BridgeSpecializationFinder()
     finder.find_nodes_bridge(bridge)
     for old_loop in old_loops:

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py	Tue Aug 25 16:09:02 2009
@@ -993,6 +993,8 @@
         self.cpu = cpu
         self.stats = stats
         self.options = options
+        if cpu.logger_cls is not None:
+            options.logger_noopt = cpu.logger_cls()
 
         RESULT = portal_graph.getreturnvar().concretetype
         self.result_type = history.getkind(RESULT)
@@ -1049,6 +1051,8 @@
                 self.profiler.start()
                 self.profiler.initialized = True
             self.globaldata.initialized = True
+            if self.options.logger_noopt is not None:
+                self.options.logger_noopt.create_log('.noopt')
 
     def _setup_class_sizes(self):
         class_sizes = {}



More information about the Pypy-commit mailing list