Commit a3b12f70 authored by Stefan Marr's avatar Stefan Marr

Merge pull request #3 from cfbolz/master

Two more small optimizations
parents 0130fa97 0f300232
......@@ -18,7 +18,7 @@ class Frame(object):
def __init__(self, nilObject, num_elements, method, context, previous_frame):
self._method = method
self._context = context
self._stack = [nilObject] * num_elements
self._stack = [None] * num_elements
self._stack_pointer = 0
self._previous_frame = previous_frame
......@@ -73,7 +73,10 @@ class Frame(object):
""" Pop an object from the expression stack and return it """
stack_pointer = self._stack_pointer
self._stack_pointer = stack_pointer - 1
return self._stack[stack_pointer]
result = self._stack[stack_pointer]
self._stack[stack_pointer] = None
assert result is not None
return result
def push(self, value):
""" Push an object onto the expression stack """
......@@ -91,7 +94,9 @@ class Frame(object):
def get_stack_element(self, index):
# Get the stack element with the given index
# (an index of zero yields the top element)
return self._stack[self._stack_pointer - index]
result = self._stack[self._stack_pointer - index]
assert result is not None
return result
def set_stack_element(self, index, value):
# Set the stack element with the given index to the given value
......@@ -136,9 +141,12 @@ class Frame(object):
for i in range(0, num_args):
self._stack[i] = frame.get_stack_element(num_args - 1 - i)
@jit.unroll_safe
def pop_old_arguments_and_push_result(self, method, result):
num_args = method.get_number_of_arguments()
self._stack_pointer = self._stack_pointer - num_args
jit.promote(self._stack_pointer)
for i in range(self._stack_pointer - num_args, self._stack_pointer):
self.pop()
self.push(result)
def print_stack_trace(self, bytecode_index):
......
......@@ -221,20 +221,23 @@ def _toDo(ivkbl, frame, interpreter):
block = frame.pop()
limit = frame.pop()
self = frame.pop() # we do leave it on there
block_method = block.get_method()
context = block.get_context()
for i in range(self.get_embedded_integer(), limit.get_embedded_integer() + 1):
i = self.get_embedded_integer()
top = limit.get_embedded_integer()
while i <= top:
jitdriver.jit_merge_point(interpreter=interpreter,
block_method=block_method)
b = universe.new_block(block_method, context)
frame.push(b)
frame.push(universe.new_integer(i))
block_evaluate(b, interpreter, frame)
frame.pop()
i += 1
frame.push(self)
class IntegerPrimitives(Primitives):
......
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