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
Merged

Conversation

dvander
Copy link
Member

@dvander 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.

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
@dvander dvander deleted the cfg branch May 28, 2018 04:14
@assyrianic
Copy link

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
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
Copy link

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants