[pypy-svn] r71067 - in pypy/branch/oprofile-support/pypy: config jit/backend/x86
cfbolz at codespeak.net
cfbolz at codespeak.net
Tue Feb 2 17:40:30 CET 2010
Author: cfbolz
Date: Tue Feb 2 17:40:30 2010
New Revision: 71067
Modified:
pypy/branch/oprofile-support/pypy/config/translationoption.py
pypy/branch/oprofile-support/pypy/jit/backend/x86/oprofile.py
pypy/branch/oprofile-support/pypy/jit/backend/x86/profagent.py
pypy/branch/oprofile-support/pypy/jit/backend/x86/runner.py
Log:
integrate oprofile
Modified: pypy/branch/oprofile-support/pypy/config/translationoption.py
==============================================================================
--- pypy/branch/oprofile-support/pypy/config/translationoption.py (original)
+++ pypy/branch/oprofile-support/pypy/config/translationoption.py Tue Feb 2 17:40:30 2010
@@ -108,6 +108,9 @@
["off", "profile", "steps", "detailed"],
default="profile", # XXX for now
cmdline="--jit-debug"),
+ ChoiceOption("jit_profiler", "integrate profiler support into the JIT",
+ ["off", "oprofile"],
+ default="off"),
# misc
BoolOption("verbose", "Print extra information", default=False),
Modified: pypy/branch/oprofile-support/pypy/jit/backend/x86/oprofile.py
==============================================================================
--- pypy/branch/oprofile-support/pypy/jit/backend/x86/oprofile.py (original)
+++ pypy/branch/oprofile-support/pypy/jit/backend/x86/oprofile.py Tue Feb 2 17:40:30 2010
@@ -3,6 +3,7 @@
from pypy.translator.tool.cbuild import ExternalCompilationInfo
from pypy.rlib.objectmodel import we_are_translated
from pypy.rlib.rposix import get_errno
+from pypy.jit.backend.x86 import profagent
class OProfileError(Exception):
def __init__(self, errno, where):
@@ -39,28 +40,29 @@
rffi.INT,
compilation_info=eci)
-def startup(cpu):
- if not OPROFILE_AVAILABLE:
- return
- agent = op_open_agent()
- if not agent:
- cpu._oprofile_agent = rffi.cast(rffi.VOIDP, 0)
- raise OProfileError(get_errno(), "startup")
- cpu._oprofile_agent = agent
-
-def shutdown(cpu):
- if not OPROFILE_AVAILABLE:
- return
- if cpu._oprofile_agent:
- success = op_close_agent(cpu._oprofile_agent)
+
+class OProfileAgent(profagent.ProfileAgent):
+
+ def startup(self):
+ if not OPROFILE_AVAILABLE:
+ return
+ agent = op_open_agent()
+ if not agent:
+ raise OProfileError(get_errno(), "startup")
+ self.agent = agent
+
+ def shutdown(self):
+ if not OPROFILE_AVAILABLE:
+ return
+ success = op_close_agent(self.agent)
if success != 0:
raise OProfileError(get_errno(), "shutdown")
-def native_code_written(cpu, name, address, size):
- assert size > 0
- if not OPROFILE_AVAILABLE:
- return
- uaddress = rffi.cast(rffi.ULONG, address)
- success = op_write_native_code(cpu._oprofile_agent, name, uaddress, rffi.cast(rffi.VOIDP, 0), size)
- if success != 0:
- raise OProfileError(get_errno(), "write")
+ def native_code_written(self, name, address, size):
+ assert size > 0
+ if not OPROFILE_AVAILABLE:
+ return
+ uaddress = rffi.cast(rffi.ULONG, address)
+ success = op_write_native_code(self.agent, name, uaddress, rffi.cast(rffi.VOIDP, 0), size)
+ if success != 0:
+ raise OProfileError(get_errno(), "write")
Modified: pypy/branch/oprofile-support/pypy/jit/backend/x86/profagent.py
==============================================================================
--- pypy/branch/oprofile-support/pypy/jit/backend/x86/profagent.py (original)
+++ pypy/branch/oprofile-support/pypy/jit/backend/x86/profagent.py Tue Feb 2 17:40:30 2010
@@ -8,5 +8,5 @@
def shutdown(self):
pass
def native_code_written(self, name, address, size):
- raise NotImplementedError
+ pass
Modified: pypy/branch/oprofile-support/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/oprofile-support/pypy/jit/backend/x86/runner.py (original)
+++ pypy/branch/oprofile-support/pypy/jit/backend/x86/runner.py Tue Feb 2 17:40:30 2010
@@ -7,6 +7,7 @@
from pypy.jit.metainterp import history
from pypy.jit.backend.x86.assembler import Assembler386
from pypy.jit.backend.x86.regalloc import FORCE_INDEX_OFS
+from pypy.jit.backend.x86.profagent import ProfileAgent
from pypy.jit.backend.llsupport.llmodel import AbstractLLCPU
class CPU386(AbstractLLCPU):
@@ -20,13 +21,15 @@
gcdescr=None):
AbstractLLCPU.__init__(self, rtyper, stats, opts,
translate_support_code, gcdescr)
- profile_agent = None
+
+ profile_agent = ProfileAgent()
if rtyper is not None:
config = rtyper.annotator.translator.config
if config.translation.jit_profiler == "oprofile":
from pypy.jit.backend.x86 import oprofile
profile_agent = oprofile.OProfileAgent()
- self._profile_agent = profile_agent
+
+ self.profile_agent = profile_agent
def setup(self):
if self.opts is not None:
@@ -40,12 +43,10 @@
return self.assembler.leave_jitted_hook
def setup_once(self):
- if self._profile_agent is not None:
- self._profile_agent.setup()
+ self.profile_agent.startup()
def finish_once(self):
- if self._profile_agent is not None:
- self._profile_agent.shutdown()
+ self.profile_agent.shutdown()
def compile_loop(self, inputargs, operations, looptoken):
self.assembler.assemble_loop(inputargs, operations, looptoken)
More information about the Pypy-commit
mailing list