Commit 0765a44e authored by Stefan Marr's avatar Stefan Marr

Set Frame stack pointer in the constructor

Avoids need to call reset on it, and might help RPython to figure out that frame does not escape (making it more functional like this often helped in the past)
Signed-off-by: 's avatarStefan Marr <git@stefan-marr.de>
parent 1728e5c3
......@@ -15,11 +15,11 @@ class Frame(object):
_immutable_fields_ = ["_method", "_context", "_stack"]
def __init__(self, nilObject, num_elements, method, context, previous_frame):
def __init__(self, num_elements, method, context, previous_frame):
self._method = method
self._context = context
self._stack = [None] * num_elements
self._stack_pointer = 0
self._stack_pointer = self._get_initial_stack_pointer()
self._previous_frame = previous_frame
def get_previous_frame(self):
......@@ -88,7 +88,10 @@ class Frame(object):
""" Set the stack pointer to its initial value thereby clearing
the stack """
# arguments are stored in front of local variables
self._stack_pointer = (self.get_number_of_arguments() +
self._stack_pointer = self._get_initial_stack_pointer()
def _get_initial_stack_pointer(self):
return (self.get_number_of_arguments() +
self.get_method().get_number_of_locals().get_embedded_integer() - 1)
def get_stack_element(self, index):
......
......@@ -338,7 +338,8 @@ class Universe(object):
result.set_class(class_class)
return result
def new_frame(self, previous_frame, method, context):
@staticmethod
def new_frame(previous_frame, method, context):
# Compute the maximum number of stack locations (including arguments,
# locals and extra buffer to support doesNotUnderstand) and set the
# number of indexable fields accordingly
......@@ -346,9 +347,7 @@ class Universe(object):
method.get_number_of_locals().get_embedded_integer() +
method.get_maximum_number_of_stack_elements().get_embedded_integer() + 2)
result = Frame(self.nilObject, length, method, context, previous_frame)
result.reset_stack_pointer()
return result
return Frame(length, method, context, previous_frame)
def new_method(self, signature, num_bytecodes, literals,
num_locals, maximum_number_of_stack_elements):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment