[pypy-commit] lang-smalltalk default: moved the tracing printing code to have also the information of argcount,
lwassermann
noreply at buildbot.pypy.org
Tue Apr 16 14:10:34 CEST 2013
Author: Lars Wassermann <lars.wassermann at gmail.com>
Branch:
Changeset: r277:fe9a3d548b2c
Date: 2013-04-12 17:33 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/fe9a3d548b2c/
Log: moved the tracing printing code to have also the information of
argcount, printing arguments now
diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -79,10 +79,6 @@
s_new_context = p.s_new_context
def c_loop(self, s_context):
- # ######################################################################
- if self.trace:
- padding = ' ' * (self.max_stack_depth - self.remaining_stack_depth)
- print padding + s_context.short_str()
old_pc = 0
if not jit.we_are_jitted():
self.quick_check_for_interrupt(s_context)
@@ -112,9 +108,9 @@
def _get_adapted_tick_counter(self):
# Normally, the tick counter is decremented by 1 for every message send.
# Since we don't know how many messages are called during this trace, we
- # just decrement by 10th of the trace length (num of bytecodes).
+ # just decrement by 100th of the trace length (num of bytecodes).
trace_length = jit.current_trace_length()
- decr_by = int(trace_length // 10)
+ decr_by = int(trace_length // 100)
return max(decr_by, 1)
def stack_frame(self, s_new_frame):
@@ -325,6 +321,7 @@
def _sendSelector(self, w_selector, argcount, interp,
receiver, receiverclassshadow):
+ assert isinstance(w_selector, model.W_BytesObject)
if interp.should_trace():
print "%sSending selector %r to %r with: %r" % (
interp._last_indent, w_selector.as_string(), receiver,
@@ -344,9 +341,9 @@
func = primitives.prim_holder.prim_table[code]
# ##################################################################
if interp.trace:
- print "%s calling primitive %d \t(in #%s)" % (
+ print "%s calling primitive %d \t(in #%s, named #%s)" % (
' ' * (interp.max_stack_depth - interp.remaining_stack_depth),
- code, self.w_method()._likely_methodname)
+ code, self.w_method()._likely_methodname, w_selector.as_string())
try:
# note: argcount does not include rcvr
return func(interp, self, argcount)
@@ -368,6 +365,12 @@
arguments = self.pop_and_return_n(argcount)
s_frame = s_method.create_frame(self.space, receiver, arguments, self)
self.pop() # receiver
+
+ # ######################################################################
+ if interp.trace:
+ padding = ' ' * (interp.max_stack_depth - interp.remaining_stack_depth)
+ print padding + s_frame.short_str(argcount)
+
return interp.stack_frame(s_frame)
def _doesNotUnderstand(self, w_selector, argcount, interp, receiver):
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -28,7 +28,6 @@
# completes, and returns a result, or throws a PrimitiveFailedError.
def make_failing(code):
def raise_failing_default(interp, s_frame, argument_count):
-# print "Primitive failed", code
raise PrimitiveFailedError
return raise_failing_default
@@ -527,7 +526,7 @@
INPUT_SEMAPHORE = 93
GET_NEXT_EVENT = 94
INPUT_WORD = 95
-BITBLT_COPY_BITS = 96 # OBSOLETE_INDEXED = 96
+BITBLT_COPY_BITS = 96
SNAPSHOT = 97
STORE_IMAGE_SEGMENT = 98
LOAD_IMAGE_SEGMENT = 99
@@ -542,7 +541,6 @@
KBD_NEXT = 108
KBD_PEEK = 109
-
@expose_primitive(MOUSE_POINT, unwrap_spec=[object])
def func(interp, s_frame, w_rcvr):
x, y = interp.space.get_display().mouse_point()
diff --git a/spyvm/shadow.py b/spyvm/shadow.py
--- a/spyvm/shadow.py
+++ b/spyvm/shadow.py
@@ -798,7 +798,7 @@
# A blockcontext doesn't have any temps
return 0
- def short_str(self):
+ def short_str(self, argcount):
return 'BlockContext of %s (%s) [%d]' % (
self.w_method().get_identifier_string(),
self.w_receiver().as_repr_string(),
@@ -947,13 +947,17 @@
retval += "\nStack : " + str(self.stack())
return retval
- def short_str(self):
+ def short_str(self, argcount):
block = '[] of ' if self.is_closure_context() else ''
- return '%s%s (rcvr: %s) [pc: %d]' % (
+ args = '%d' % argcount
+ for i in range(argcount - 1, -1, -1):
+ args += ': %s' % self.peek(i).as_repr_string()
+ return '%s%s (rcvr: %s) [pc: %d] (%s)' % (
block,
self.w_method().get_identifier_string(),
self.w_receiver().as_repr_string(),
- self.pc() + 1
+ self.pc() + 1,
+ args
)
class CompiledMethodShadow(object):
diff --git a/spyvm/test/test_primitives.py b/spyvm/test/test_primitives.py
--- a/spyvm/test/test_primitives.py
+++ b/spyvm/test/test_primitives.py
@@ -637,6 +637,7 @@
assert w_1 is not w_2
def test_primitive_be_display():
+ py.test.fail("This test leads to a Segfault.")
assert space.objtable["w_display"] is None
mock_display = model.W_PointersObject(space, space.w_Point, 4)
w_wordbmp = model.W_WordsObject(space, space.w_Array, 100)
@@ -670,6 +671,7 @@
assert mock_display.fetch(space, 0) is w_bitmap
def test_primitive_force_display_update(monkeypatch):
+ py.test.fail("This test leads to a Segfault.")
mock_display = model.W_PointersObject(space, space.w_Point, 4)
w_wordbmp = model.W_WordsObject(space, space.w_Array, 100)
mock_display.store(space, 0, w_wordbmp) # bitmap
More information about the pypy-commit
mailing list