[pypy-svn] r65001 - in pypy/branch/pyjitpl5/pypy/jit: backend backend/x86 metainterp

arigo at codespeak.net arigo at codespeak.net
Sun May 3 17:17:23 CEST 2009


Author: arigo
Date: Sun May  3 17:17:21 2009
New Revision: 65001

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/model.py
   pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
Log:
Change the one-time runtime initialization to give the cpu a
chance to do it too.  Useful for llvm.


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	Sun May  3 17:17:21 2009
@@ -1,5 +1,9 @@
 class AbstractCPU(object):
 
+    def setup_once(self):
+        """Called once by the front-end when the program starts."""
+        pass
+
     def compile_operations(self, loop):
         """Assemble the given list of operations."""
         raise NotImplementedError

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	Sun May  3 17:17:21 2009
@@ -182,6 +182,9 @@
 #    def set_meta_interp(self, metainterp):
 #        self.metainterp = metainterp
 
+    def setup_once(self):
+        pass
+
     def get_exception(self):
         self.assembler.make_sure_mc_exists()
         return self.assembler._exception_bck[0]

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	Sun May  3 17:17:21 2009
@@ -870,12 +870,19 @@
     def _freeze_(self):
         return True
 
-    def _recompute_class_sizes(self):
-        if self.cpu.class_sizes is None:
-            cs = {}
-            for key, value in self._class_sizes:
-                cs[key] = value
-            self.cpu.class_sizes = cs
+    def _setup_once(self):
+        """Runtime setup needed by the various components of the JIT."""
+        if not self.globaldata.initialized:
+            if self.cpu.class_sizes is None:
+                cs = {}
+                for key, value in self._class_sizes:
+                    cs[key] = value
+                self.cpu.class_sizes = cs
+            self.cpu.setup_once()
+            if not self.profiler.initialized:
+                self.profiler.start()
+                self.profiler.initialized = True
+            self.globaldata.initialized = True
 
     def generate_bytecode(self, policy, ts):
         self._codewriter = codewriter.CodeWriter(self, policy, ts)
@@ -906,6 +913,7 @@
         self._debug_history = []
         self.compiled_merge_points = r_dict(history.mp_eq, history.mp_hash)
                  # { greenkey: list-of-MergePoints }
+        self.initialized = False
 
 # ____________________________________________________________
 
@@ -1244,8 +1252,8 @@
                                         *args[1:])
 
     def initialize_state_from_start(self, *args):
+        self.staticdata._setup_once()
         self.staticdata.profiler.start_tracing()
-        self.staticdata._recompute_class_sizes()
         self.create_empty_history()
         num_green_args = self.staticdata.num_green_args
         original_boxes = []

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py	Sun May  3 17:17:21 2009
@@ -589,9 +589,6 @@
                     return
                 #interp.debug_trace("jit_compile", *greenargs)
                 metainterp_sd = warmrunnerdesc.metainterp_sd
-                if not metainterp_sd.profiler.initialized:
-                    metainterp_sd.profiler.start()
-                    metainterp_sd.profiler.initialized = True
                 metainterp = MetaInterp(metainterp_sd)
                 loop = metainterp.compile_and_run_once(*args)
             else:



More information about the Pypy-commit mailing list