Skip to content

Commit

Permalink
jit optmizations
Browse files Browse the repository at this point in the history
  • Loading branch information
halgari committed Aug 13, 2012
1 parent 440e69d commit 3f14f2b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 6 additions & 5 deletions system/interpreter.py
Expand Up @@ -26,7 +26,7 @@ def get_location(ip, func, interp):


jitdriver = JitDriver(greens=['ip', 'func', 'interp'],
reds=['stack', 'args'],
reds=['stack', 'stack1', 'args'],
get_printable_location = get_location
)

Expand Down Expand Up @@ -77,7 +77,7 @@ def cur_arg_stack(self):
return self._arg_stack.getFirst()

def get_arg(self, offset):
return self.cur_arg_stack().getNth(W_Int(offset))
return self.cur_arg_stack().getNthInterp(offset)

def pop_arg_stack(self):
self._arg_stack = self._arg_stack.getNext()
Expand Down Expand Up @@ -121,7 +121,8 @@ def main_loop(self, *args):
jitdriver.jit_merge_point(ip = self._ip,
func = self.top_func(),
args = self.cur_arg(),
stack = self._sp,
stack = self._stack[self._sp - 1],
stack1 = self._stack[self._sp - 2],
interp = self)

b = self.get_bcode()
Expand All @@ -131,7 +132,7 @@ def main_loop(self, *args):
self.push(s_sub(self.pop(), self.pop()))
elif b == LOAD_CONST:
c = self.get_bcode()
self.push(self.top_func()._consts[c])
self.push(self.top_func()._consts.getNthInterp(c))
elif b == LOAD_ARG:
c = self.get_bcode()
self.push(self.get_arg(c))
Expand Down Expand Up @@ -179,7 +180,7 @@ class Function(Object):
def __init__(self, bcode, args = None, consts = None):
self._bcode = bcode
self._args = args
self._consts = consts
self._consts = W_Array(consts)
def toString(self):
return "Function"

Expand Down
8 changes: 6 additions & 2 deletions system/objspace.py
Expand Up @@ -161,8 +161,12 @@ def __init__(self, items_w):
self._items_w = items_w

@elidable
def getNth(self, nth):
return self._items_w[s_unwrap_int(nth)]
def getNth(self, w_nth):
return self._items_w[s_unwrap_int(w_nth)]

@elidable
def getNthInterp(self, nth):
return self._items_w[nth]

@elidable
def getCount(self):
Expand Down

0 comments on commit 3f14f2b

Please sign in to comment.