restrain-jit icon indicating copy to clipboard operation
restrain-jit copied to clipboard

Abstract implementation for generators(stack-less coroutines)

Open thautwarm opened this issue 5 years ago • 1 comments

TODO at here: https://github.com/thautwarm/restrain-jit/blob/master/restrain_jit/abs_compiler/from_bc.py#L88

It's straightforward but needs some efforts.

def f(x):
     yield 1
     for i in x:
         yield i

->

%c = %point == 0
jmpif  <yield 0>,  %c

%c = %point ==1
jmpif  <yield 1>,  %c

%c = %point == 2
%c = jmpif  <in loop>,  %c


label <entry>
%1 = Const(1)
%2 = x
%3 = self # function ptr
%env = mk_tuple(%3, %2)
%point = 1 
%ret = mk_tuple(%1, %env)
return %ret
label <yield 1>
...

thautwarm avatar Sep 18 '19 08:09 thautwarm

Also, I haven't found a way to use indirect jump of llvm in Julia. If there is a chance, we might gain better performance.

thautwarm avatar Sep 18 '19 08:09 thautwarm