[pypy-svn] r52237 - pypy/branch/jit-refactoring/pypy/jit/rainbow
arigo at codespeak.net
arigo at codespeak.net
Fri Mar 7 10:24:31 CET 2008
Author: arigo
Date: Fri Mar 7 10:24:30 2008
New Revision: 52237
Modified:
pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py
pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py
Log:
For debugging at the C level.
Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py (original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py Fri Mar 7 10:24:30 2008
@@ -10,9 +10,11 @@
from pypy.jit.timeshifter import oop
from pypy.jit.timeshifter.greenkey import KeyDesc
from pypy.jit.rainbow.interpreter import JitCode, JitInterpreter
+from pypy.jit.rainbow.interpreter import DEBUG_JITCODES
from pypy.translator.backendopt.removenoops import remove_same_as
from pypy.translator.backendopt.ssa import SSA_to_SSI
from pypy.translator.unsimplify import varoftype
+from cStringIO import StringIO
def residual_exception_nontranslated(jitstate, e, rtyper):
# since we have a normal exception instance here
@@ -227,6 +229,10 @@
bytecode._interpreter = self.interpreter
bytecode._labelpos = labelpos
bytecode.dump()
+ if DEBUG_JITCODES:
+ f = StringIO()
+ bytecode.dump(f)
+ bytecode.dump_copy = f.getvalue()
if is_portal:
self.finish_all_graphs()
self.interpreter.set_num_global_mergepoints(
Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py (original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py Fri Mar 7 10:24:30 2008
@@ -5,6 +5,9 @@
from pypy.jit.timeshifter.greenkey import empty_key, GreenKey, newgreendict
from pypy.rpython.lltypesystem import lltype, llmemory
+DEBUG_JITCODES = True # store a dump() of all JitCodes
+ # in the translated program
+
class JitCode(object):
"""
normal operations have the following format:
@@ -18,6 +21,7 @@
green consts are negative indexes
"""
is_portal = False
+ dump_copy = None
def __init__(self, name, code, constants, typekinds, redboxclasses,
keydescs, structtypedescs, fielddescs, arrayfielddescs,
@@ -190,6 +194,8 @@
self.portalstate = None
self.num_global_mergepoints = -1
self.global_state_dicts = None
+ if DEBUG_JITCODES:
+ self.find_opcode("trace") # force it to be compiled in
def set_portalstate(self, portalstate):
assert self.portalstate is None
@@ -379,6 +385,20 @@
self.frame = None
# operation implementations
+ @arguments()
+ def opimpl_trace(self):
+ # Prints the current frame position and a dump if available.
+ # Although this opcode is not actually generated by
+ # codewriter.py so far, it can be called manually in a C-level
+ # debugger. More importantly it forces the .name and .dump_copy
+ # attributes of JitCode objects to be included in the C
+ # executable.
+ bytecode = self.frame.bytecode
+ print '*** opimpl_trace: in %s position %d ***' % (bytecode.name,
+ self.frame.pc)
+ if bytecode.dump_copy is not None:
+ print bytecode.dump_copy
+
@arguments("green", "2byte", returns="red")
def opimpl_make_redbox(self, genconst, typeid):
redboxcls = self.frame.bytecode.redboxclasses[typeid]
More information about the pypy-svn
mailing list