near-vm: Pick a consistent location to store instance/artifact data #8951
Labels
A-contract-runtime
Area: contract compilation and execution, virtual machines, etc
C-housekeeping
Category: Refactoring, cleanups, code quality
T-contract-runtime
Team: issues relevant to the contract runtime team
Today when loading/instantiating an
Artifct
, we store some information with theEngine
(i.e. maps with the machine code,VMSharedSignature
s, etc.) and some of the information is contained within theArtifact
itself.This makes consistent management of lifetime difficult – dropping the Artifact will drop a lot of information about a wasm module, but not the data allocated into the Engine (as far as I know.)
We should pick a consistent strategy and either allocate everything into an
Engine
(this requires implementing custom lifetime management, but allows us to ultra-optimize the performance characteristics by utilizing e.g. arena allocators), or keeping everything with theArtifact
instances (straightforward data lifetime management.)This in part also extends to
Instance
s. TodayInstance
internally contains data about values of globals and similar runtime structures, while referencing the information from theEngine
for e.g. machine code.Worth noting that storing stuff into
Engine
(or aStore
in the parlance of the WebAssembly specification) is what the WebAssembly specification calls for. It would be necessary to make things like webassembly module linking proposal work at all.The text was updated successfully, but these errors were encountered: