I have an interpreter inner loop that looks something like this:
jitdriver = JitDriver(greens=['ip', 'tos', 'bytecodes', 'consts'],
reds=['locals', 'stack'])
def interpret(code, args):
assert isinstance(code, Code)
bytecodes = code.bytecodes
consts = code.consts
vars = code.vars
locals = array_of_size(code.locals)
ip = 0
stack = array_of_size(code.stacksize)
tos = -1
while True:
jitdriver.jit_merge_point(ip=ip, tos=tos, bytecodes=bytecodes,
consts=consts, locals=locals, stack=stack)
op = ord(bytecodes[ip])
if op == POP:
stack[tos] = None
tos -= 1
ip += 1
continue
elif op == PUSH_CONST:
arg = ord(bytecodes[ip + 1])
tos += 1
stack[tos] = consts[arg]
ip += 2
continue
The jit traces from this aren't bad, but it insists on maintaining the
stack and locals arrays. Since these arrays are reference arrays, my
primitive types (Integers for example) are allocated when math is being
performed. What can I do to force the JIT to not maintain a stack/locals
array. Or should I construct the stack in a different way?
I tried digging into the PyPy source to find how how this is done there,
but I haven't been able to find it yet.
Timothy
_______________________________________________
pypy-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-dev