Skip to content

Abstract implementation for generators(stack-less coroutines)  #4

@thautwarm

Description

@thautwarm

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>
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    infrnecessary facilities to runtime restrain-jit

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions