-
Notifications
You must be signed in to change notification settings - Fork 39
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
internal: split vmgen
/linker state from TCtx
#843
internal: split vmgen
/linker state from TCtx
#843
Conversation
Move emission of the `Ret` instruction into `vmgen.genExpr` and have the `genExpr` procedure in `vmjit` emit an 'eof' instruction. This brings the shape of the latter closer to that of `genStmt`.
The state and required contextual data is moved into the new `CodeGenCtx` type owned by `vmgen`. All types only referenced by the now-moved code are moved with it.
The field doesn't exist anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I like how vmdef
is becoming more focused and the modules become more independent of each other.
I did find a comment typo, but it's non-blocking. The suggestion for documenting the invariant is also non-blocking, just occurred to me that the trick with more DOD style approaches is signalling cardinality/relationships of the data contained therein -- I might be mistaken.
Co-authored-by: Saem Ghani <saemghani+github@gmail.com>
/merge |
Merge requested by: @saem Contents after the first section break of the PR description has been removed and preserved below:
|
Summary
Move much of the data and associated types for the VM code generator and
linker into
vmgen
and the newvmlinker
module. Having the code-generation-related state in the
vmgen
module, means that the VM code-generator state can now depend on modules that should not be a
transitive dependency (through
vmdef
) of all other VM-related modules.Details
The linker-related types
IdentPattern
andLinkIndex
plus theroutines for working with them are moved to the
vmlinker
module -- thelinker-related state is moved into the new
LinkerData
type. Duevmcompilerserdes
currently requiring access to the link table, theLinkerData
instance has to be still stored withTCtx
instead ofthe more correct
JitState
.For the VM code generator, all relevant types, except for the
diagnostics, are moved from
vmdef
intovmgen
. TheTCtx
used byvmgen
is now an alias to the newCodeGenCtx
type, which stores allthe input, output, and other contextual state required for code
generation.
When using
vmjit
, much of the data read or written to by the codegenerator is part of the VM execution environment (
TCtx
), and in orderto not having to either use pointers or pass all of it along as
procedure parameters, the relevant data is swapped between
TCtx
andCodeGenCtx
both before and after invoking the code generator.vmjit.genExpr
is slightly adjusted for this to work uniformly acrossthe
genX
procedures: it now also emits anEof
instruction.vmbackend
now stores an instance ofCodeGenCtx
instead ofTCtx
.Once code generation is finished, a temporary VM execution environment
is set-up, populated, and then serialized.
Finally,
vmrunner
is updated to not rely on (now non-existent)TCtx.callbackKeys
field. The list of expected override patterns isinstead taken from the packed context and passed to
registerCallbacks
directly.