Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT off the control-flow graph, rather than instruction stream. #217

Merged
merged 6 commits into from May 28, 2018

Conversation

@dvander
Copy link
Member

dvander commented May 28, 2018

It is much simpler to generate bytecode off basic blocks, instead of the raw instruction stream. We don't need to store the gross and memory-intensive jump map. Instead, the address of every target is contained in the target block itself.

dvander added 6 commits May 27, 2018
Both the interpreter and JIT require validation, but the JIT needs the graph to
actually operate. We now separate these two cases, rather than unnecessarily
keep the control flow graph around or compute it twice.
@dvander dvander merged commit ed2265f into master May 28, 2018
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@dvander dvander deleted the cfg branch May 28, 2018
@assyrianic

This comment has been minimized.

Copy link

assyrianic commented May 29, 2018

sounds like a good idea, what are the design pros and cons of JITing the graph blocks as opposed to the regular instruction stream?

@dvander

This comment has been minimized.

Copy link
Member Author

dvander commented May 29, 2018

The old way the JIT worked was to keep a hashtable with the address of every instruction, so we could find all the locations of jump targets. It's super gross and there was never any rigorous error checking that the hash table was filled (i.e., that jump targets were valid).

Working directly off the CFG eliminates that whole mess. The target of a jump or switch is just a block now. No need to cache and lookup addresses.

@assyrianic

This comment has been minimized.

Copy link

assyrianic commented May 29, 2018

makes sense, there's no gotos to worry about so the only jump areas are if-else-statements, loops, and the switch statement which always contain their own inner blocks of code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.