[pypy-svn] rev 2376 - pypy/trunk/src/pypy/objspace
tomek at codespeak.net
tomek at codespeak.net
Tue Dec 16 15:34:47 CET 2003
Author: tomek
Date: Tue Dec 16 15:34:45 2003
New Revision: 2376
Modified:
pypy/trunk/src/pypy/objspace/trace.py
Log:
one morge intermediate check-in, after merge
Modified: pypy/trunk/src/pypy/objspace/trace.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/trace.py (original)
+++ pypy/trunk/src/pypy/objspace/trace.py Tue Dec 16 15:34:45 2003
@@ -17,14 +17,6 @@
#print "XXX %s, %s" % frame.examineop()
self.space.notify_on_bytecode(frame)
-
- def dump(self):
- bytecodes = self.list_of_bytecodes
- self.list_of_bytecodes = []
- return bytecodes
-
-
-
class Logger(object):
def __init__(self, name, fn, space, printme):
self.fn = fn
@@ -69,16 +61,13 @@
l = logger_cls(key, item, self, "class method")
setattr(self, key, new.instancemethod(l, self, TraceObjSpace))
-
def start_tracing(self):
self.tracing = 1
self.log_list = []
-
def stop_tracing(self):
self.tracing = 0
-
def createexecutioncontext(self):
"Factory function for execution contexts."
return TraceExecutionContext(self)
@@ -94,17 +83,32 @@
if self.tracing:
self.log_list[-1][1].append((name, args))
-
def dump(self):
return self.log_list
-
+ def rdump(self):
+ bytecodes = []
+ res = []
+ for bytecode, ops in self.log_list:
+ bytecodes.append(bytecode)
+ if ops:
+ op = ops.pop(0)
+ res.append((op, bytecodes))
+ bytecodes = []
+ for op in ops:
+ res.append((op, []))
+
+ #the rest
+ res.append((None, bytecodes))
+ return res
+
+
return TraceObjSpace()
Space = Trace
-s = Trace(TrivialObjSpace)
-#print dir(s)
+#s = Trace(TrivialObjSpace)
+s = Trace()
# ______________________________________________________________________
# End of trace.py
@@ -115,7 +119,6 @@
w_func = space.wrap(func)
space.setitem(w_globals, w_func_name, w_func)
-
def run_function(space, func, *args):
# Get execution context and globals
ec = space.getexecutioncontext()
@@ -128,11 +131,10 @@
args_w = [space.wrap(ii) for ii in args]
code = func.func_code
code = PyCode()._from_code(code)
-
# Create frame
frame = code.create_frame(space, w_globals)
frame.setfastscope(args_w)
-
+
# start/stop tracing while running frame
space.start_tracing()
res = frame.run()
@@ -152,4 +154,8 @@
print run_function(s, a, 3)
print ">>>>>>"
- print s.dump()
+ for line in s.dump():
+ print line
+ print ">>>>>>"
+ for line in s.rdump():
+ print line
More information about the Pypy-commit
mailing list