[pypy-commit] lang-smalltalk storage-refactoring-virtual-pc: Added common superclass for ProcessSwitch and StackOverflow.
anton_gulenko
noreply at buildbot.pypy.org
Wed May 14 14:51:07 CEST 2014
Author: Anton Gulenko <anton.gulenko at googlemail.com>
Branch: storage-refactoring-virtual-pc
Changeset: r821:6d70e836aec8
Date: 2014-05-14 13:30 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/6d70e836aec8/
Log: Added common superclass for ProcessSwitch and StackOverflow.
diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -72,7 +72,7 @@
self.loop_bytecodes(s_new_context)
raise Exception("loop_bytecodes left without raising...")
except StackOverflow, e:
- s_new_context = e.s_context
+ s_new_context = e.s_new_context
except Return, nlr:
s_new_context = s_sender
while s_new_context is not nlr.s_target_context:
@@ -221,22 +221,27 @@
def __init__(self, object):
self.object = object
-class StackOverflow(Exception):
- _attrs_ = ["s_context"]
- def __init__(self, s_top_context):
- self.s_context = s_top_context
-
class Return(Exception):
_attrs_ = ["value", "s_target_context"]
- def __init__(self, object, s_context):
- self.value = object
- self.s_target_context = s_context
+ def __init__(self, s_target_context, w_result):
+ self.value = w_result
+ self.s_target_context = s_target_context
-class ProcessSwitch(Exception):
+class ContextSwitchException(Exception):
+ """General Exception that causes the interpreter to leave
+ the current context. The current pc is required in order to update
+ the context object that we are leaving."""
_attrs_ = ["s_new_context"]
- def __init__(self, s_context):
- self.s_new_context = s_context
+ def __init__(self, s_new_context):
+ self.s_new_context = s_new_context
+class StackOverflow(ContextSwitchException):
+ """This causes the current jit-loop to be left.
+ This is an experimental mechanism to avoid stack-overflow errors
+ on OS level, and we suspect it breaks jit performance at least sometimes."""
+
+class ProcessSwitch(ContextSwitchException):
+ """This causes the interpreter to switch the executed context."""
def make_call_primitive_bytecode(primitive, selector, argcount):
def callPrimitive(self, interp, current_bytecode):
@@ -443,7 +448,7 @@
if interp.trace:
print '%s<- %s' % (interp.padding(), return_value.as_repr_string())
- raise Return(return_value, s_return_to)
+ raise Return(s_return_to, return_value)
def activate_unwind_context(self, interp):
# the first temp is executed flag for both #ensure: and #ifCurtailed:
diff --git a/spyvm/test/test_interpreter.py b/spyvm/test/test_interpreter.py
--- a/spyvm/test/test_interpreter.py
+++ b/spyvm/test/test_interpreter.py
@@ -1008,7 +1008,7 @@
interp._loop = True
interp.loop_bytecodes(w_method.create_frame(space, space.wrap_int(0), []))
except interpreter.StackOverflow, e:
- assert isinstance(e.s_context, shadow.MethodContextShadow)
+ assert isinstance(e.s_new_context, shadow.MethodContextShadow)
except interpreter.ReturnFromTopLevel, e:
assert False
More information about the pypy-commit
mailing list