[pypy-commit] pypy default: Move the _check_sse2() call out of assembler.setup() and into the

arigo noreply at buildbot.pypy.org
Fri Feb 24 11:32:29 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r52844:e2ced9ddf804
Date: 2012-02-24 11:32 +0100
http://bitbucket.org/pypy/pypy/changeset/e2ced9ddf804/

Log:	Move the _check_sse2() call out of assembler.setup() and into the
	very early phases of running the process.

diff --git a/pypy/jit/backend/x86/assembler.py b/pypy/jit/backend/x86/assembler.py
--- a/pypy/jit/backend/x86/assembler.py
+++ b/pypy/jit/backend/x86/assembler.py
@@ -104,7 +104,6 @@
         self._debug = v
 
     def setup_once(self):
-        self._check_sse2()
         # the address of the function called by 'new'
         gc_ll_descr = self.cpu.gc_ll_descr
         gc_ll_descr.initialize()
@@ -165,6 +164,9 @@
     _CHECK_SSE2_FUNC_PTR = lltype.Ptr(lltype.FuncType([], lltype.Signed))
 
     def _check_sse2(self):
+        """This function is called early in the execution of the program.
+        It checks if the CPU really supports SSE2.  It is only invoked in
+        translated versions for now."""
         if WORD == 8:
             return     # all x86-64 CPUs support SSE2
         if not self.cpu.supports_floats:
diff --git a/pypy/jit/backend/x86/runner.py b/pypy/jit/backend/x86/runner.py
--- a/pypy/jit/backend/x86/runner.py
+++ b/pypy/jit/backend/x86/runner.py
@@ -63,6 +63,9 @@
         self.assembler.finish_once()
         self.profile_agent.shutdown()
 
+    def early_initialization(self):
+        self.assembler._check_sse2()
+
     def dump_loop_token(self, looptoken):
         """
         NOT_RPYTHON
diff --git a/pypy/jit/metainterp/warmspot.py b/pypy/jit/metainterp/warmspot.py
--- a/pypy/jit/metainterp/warmspot.py
+++ b/pypy/jit/metainterp/warmspot.py
@@ -13,6 +13,7 @@
 from pypy.rlib.debug import fatalerror
 from pypy.rlib.rstackovf import StackOverflow
 from pypy.translator.simplify import get_functype
+from pypy.translator.unsimplify import call_initial_function
 from pypy.translator.unsimplify import call_final_function
 
 from pypy.jit.metainterp import history, pyjitpl, gc, memmgr
@@ -850,6 +851,9 @@
         checkgraph(origportalgraph)
 
     def add_finish(self):
+        def start():
+            self.cpu.early_initialization()
+
         def finish():
             if self.metainterp_sd.profiler.initialized:
                 self.metainterp_sd.profiler.finish()
@@ -858,6 +862,9 @@
         if self.cpu.translate_support_code:
             call_final_function(self.translator, finish,
                                 annhelper = self.annhelper)
+            if hasattr(self.cpu, 'early_initialization'):
+                call_initial_function(self.translator, start,
+                                      annhelper = self.annhelper)
 
     def rewrite_set_param(self):
         from pypy.rpython.lltypesystem.rstr import STR


More information about the pypy-commit mailing list