[MEGA HAX] useful stack during template evaluation #1085
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead of pulling the normal generator loop, this compiles each template block into a threaded function that drives the VM instead.
This essentially unrolls the core VM loop into normal imperative JavaScript code and function calls. This means we can use all the debugger functionalities (stepping, jumping between stack frames, watch expressions, etc) normally.
This uses indirect eval (
new Function
) and is intended for debug mode only.Currently it passes all JIT tests for me locally but it breaks just about everything else. It also has lots of MEGA HAX, so it's really just a proof-of-concept at this point.
To try it, clone the branch, find a JIT test,
introduce an erroradd a{{debugger}}
statement somewhere in a template in the test, run the test with LOCAL_SHOULD_LOG, without try/catch, and with the debugger open.I recommend the "correct scope - complex yield" test for this purpose as it has a good amount of nesting that show cases the usefulness of this feature well.
If you are lucky, maybe this URL will bring you there: http://localhost:4200/tests/index.html?enable_local_should_log&filter=jit&testId=2780f765
The easiest way to introduce an error is to invoke a component that doesn't exists. Once you have done it and refresh, you should be paused in the debugger (assuming you have pause on uncaught exceptions enabled) where the error is thrown.(Just use{{debugger}}
, it's easier.)You can go up the stack and see exactly the opcode execution sequence that got you here, with the nesting information. You can set a breakpoint anywhere in the opcodes before the error, refresh the page and be paused in the right location. You can even use conditional breakpoints, adding watch expressions for
vm.pc
,vm.stack.peek()
, etc and have them update live as you step through the code.