JITing non looping interpreted functions

Let's say I have a bit of interpreter level code code that does something as simple as reduce: acc = None for x in range(10000): acc = interpret(func, wrap(x)) return acc The problem I seem to be hitting is that since there isn't a loop inside the code (in the func variable) interpret is running, I don't seem to be getting an efficient trace. In essence I want the trace to start at the call to interpret, and inline enough of the above loop to end the trace at the next call to interpret. What's the best way to go about doing something like that? Thanks, Tim

So, one solution is to simply write this loop in the interpreted language (this is what I did for Topaz, methods such as Array#each are just some ruby code). An alternative is to make a JitDriver for that function, see can see this pattern in pypy/objspace/std/setobject.py Alex On Sun, Sep 28, 2014 at 7:28 PM, Timothy Baldridge <tbaldridge@gmail.com> wrote:
-- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084

Hi Alex, On 29 September 2014 01:31, Alex Gaynor <alex.gaynor@gmail.com> wrote:
That's a strange example. Maybe fijal can explain why a jit_driver with no arguments at all is still useful.
For this use case, I'd go with a jit_driver with the "func" as a green argument (or the function's bytecode, if there is one). Then you get one loop compiled for every "func", which is what you want here. A bientôt, Armin.
participants (3)
-
Alex Gaynor
-
Armin Rigo
-
Timothy Baldridge