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

commonly used JIT builtin modules

Open thautwarm opened this issue 5 years ago • 1 comments

We can provide a module exporting native versions of foreach, map, tailrec, etc.

At current stage the performance of some control flow constructs is bad:

  • for loop: due to the loop convention of Python bytecode instructions, some of the stack emulations seem cannot get eliminated by Julia. We have to introduce an actual stack in: https://github.com/thautwarm/RestrainJIT.jl/blob/master/src/codegen.jl#L410

  • try catch: due to the exception handling convention of Python, we have to introduce an emulated exception stack for this: https://github.com/thautwarm/RestrainJIT.jl/blob/master/src/codegen.jl#L439

thautwarm avatar Sep 18 '19 09:09 thautwarm

With introducing such a module, we can easily write fast codes:

from restrain_jit import Res
from restrain_jit.literals import L, T
import numpy as np
@jit
def f(x):
    @Res.map(x)
     def each_did(e):
            return e + T[np.int64](1)
     return each_did

thautwarm avatar Sep 18 '19 09:09 thautwarm