Comments (3)
i like this; but is that super trace supposed to actually contain a copy of (some of) the IR of the parent trace, or is it just an abstract construct for better optimizations? if it's a copy, then the exit from the parent trace would need to jump to middle of the new (super) trace. if it's abstract, then i don't see how the loop optimization would work.
hum... thinking a little on this; the current loop otimization is the only case of a jump to the midpoint of a trace. not hard to admit because its from the end of the same trace, so it's well contained. but this kinda opens the door to having a loop directly jump from the end of the side trace to the middle of the parent trace. might be possible if the snapshot history is carefully taken care of. maybe the (abstract?) copy of parent's IR would precisely help with that
from raptorjit.
@javierguerragiraldez Thanks for playing along. Let's see if we can tease this picture out.
Let me throw some ascii art out. Suppose we have a program like this:
while true do
A()
if root then
B()
else
C()
end
end
Then today it would compile to a looping root trace and a side trace like this:
ROOT: SIDE:
A.........
B C
LOOP: ->ROOT
A'
B'
->LOOP
And it seems to me that with this change we would make this instead:
ROOT: SIDE:
A.........
B C
LOOP: SLOOP:
A' A'
B' C'
->LOOP ->SLOOP
Right?
One missing part of this picture is how the side trace can reconnect with the root trace or otherwise handle the case where B
needs to execute instead of C
.
from raptorjit.
Just reflecting more. Here is an idea for how to step-by-step build the looping side trace above.
First we record the instructions that only execute in the side trace:
SIDE:
C
Then we replay the instructions that were already executed in the parent trace, just for reference in a location before the entry point into the side trace:
INHERIT:
A
SIDE:
C
Then we apply the standard loop optimization:
INHERIT:
A
SIDE:
C
LOOP:
A'
C'
Now we can prune the unused instructions before the SIDE
entry point:
SIDE:
C
LOOP:
A'
C'
Then we have the looping side trace.
So this leaves me with two questions:
- How do these looping traces connect with other traces? (Could be complicated / messy / prone to combinatorial explosion?)
- How come the JIT currently sets up side traces by taking values from snapshots rather than by replaying the parent instructions? Is this for important reasons or only historical ones? See "super side trace" #108.
from raptorjit.
Related Issues (20)
- Idea: Remove Lua C-API HOT 41
- Philosophy: Who is RaptorJIT for? HOT 1
- RaptorJIT language side evolution and Lua compatibility HOT 3
- A world on FFI HOT 6
- Benchmark: FFI
- Idea: Separate snapshot for each function call
- raptorjit release version confusion HOT 2
- Idea: Write Lua parser and bytecode compiler in Lua HOT 19
- Question: How to send relevant fixes to LuaJIT?
- Document VM bootstrap, code generation, build process HOT 2
- Idea: CNEWI sinking across trace boundaries HOT 4
- Demo: Over 50x slowdown on pointer arithmetic due to single branch
- Windows support HOT 2
- Openresty HOT 8
- Optimization: lambda lifting HOT 7
- Initial port of RaptorJIT bytecode interpreter to C
- Filling the gap with Lua 5.3 HOT 2
- Apply to GitHub sponsorship HOT 3
- LuaJIT/RaptorJIT at FOSDEM 2020?
- Linking failed on ArchLinux HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raptorjit.