Commit b42c2142 by Stefan Marr

Avoid pop when not necessary, but might keep objects alive, let them escape

Signed-off-by: Stefan Marr <git@stefan-marr.de>
1 parent afdcafac
......@@ -69,9 +69,15 @@ class Frame(object):
def get_number_of_arguments(self):
return self._method.get_number_of_arguments()
def top(self):
stack_pointer = jit.promote(self._stack_pointer)
assert 0 <= stack_pointer < len(self._stack)
return self._stack[stack_pointer]
def pop(self):
""" Pop an object from the expression stack and return it """
stack_pointer = self._stack_pointer
stack_pointer = jit.promote(self._stack_pointer)
assert 0 <= stack_pointer < len(self._stack)
self._stack_pointer = stack_pointer - 1
result = self._stack[stack_pointer]
self._stack[stack_pointer] = None
......@@ -81,6 +87,7 @@ class Frame(object):
def push(self, value):
""" Push an object onto the expression stack """
stack_pointer = jit.promote(self._stack_pointer) + 1
assert 0 <= stack_pointer < len(self._stack)
self._stack[stack_pointer] = value
self._stack_pointer = stack_pointer
......
......@@ -106,12 +106,12 @@ class Interpreter(object):
receiver.send_does_not_understand(frame, signature, self._universe, self)
def _do_return_local(self, frame):
return frame.pop()
return frame.top()
@jit.unroll_safe
def _do_return_non_local(self, frame):
# get result from stack
result = frame.pop()
result = frame.top()
# Compute the context for the non-local return
context = frame.get_outer_context()
......@@ -127,7 +127,7 @@ class Interpreter(object):
# ... and execute the escapedBlock message instead
sender.send_escaped_block(frame, block, self._universe, self)
return frame.pop()
return frame.top()
raise ReturnException(result, context)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!