Skip to content

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

Merged
dvander merged 6 commits into
masterfrom
cfg
May 28, 2018
Merged

JIT off the control-flow graph, rather than instruction stream.#217
dvander merged 6 commits into
masterfrom
cfg

Conversation

@dvander
Copy link
Copy Markdown
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.

dvander added 6 commits May 27, 2018 14:59
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
@kevyonan
Copy link
Copy Markdown

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
Copy Markdown
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.

@kevyonan
Copy link
Copy Markdown

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.

2 participants