4 ms·
Yes, your intuition is correct. The way it works in Dart VM is like so: Each loop has an interruption point somewhere (e.g. in the header). If a very hot loop
by mraleph 8y ago
Yes, your intuition is correct. The way it works in Dart VM is like so:
Each loop has an interruption point somewhere (e.g. in the header). If a very hot loop is found VM would enter runtime at that interruption point, where it would synchronously initiate compilation of an optimized version of the function for OSR at this particular interruption point.
After unoptimized IL is contsructed it is "shaken": a matching interruption point is found in the graph and everything not reachable from it is shaken (which drops all code before the loop).
After then the graph is transformed a bit - for each local variable alive at the interrupt point we introduce artificial parameter - so that we could simply treat OSR substitution kinda like a call.
Then graph is optimized and compiled.
Finally when we return back to the original unoptimized code we would do a tail call to the new optimized version.
(I will cover this in the "Introduction to Dart VM" in more details and with some drawings, when I reach this).