Right now, the language supports global state declaration, but no global state initialization, e.g.:
i32 count; // totally fine
count = 20; // WILL NOT WORK
<rules>
This is because some modules do not have Wasm start functions defined.
If a start function doesn't exist, there is no obvious place to emit the global state initialization logic.
Declarations are easy since it's just putting a new global into the module!
Possible workarounds:
If no start function exists, emit one! It will be run on startup and initialize global state. It's possible that some use cases won't support a start function...so this may not be a solution for "all programs we instrument".
Instrument all functions in the module to check if global state has been initialized. If it hasn't yet, call the function that we emit to initialize the global state! This would work anywhere, but it would add a bool check to the start of every function, so it would have a higher performance impact.
Solution number 1 is clearly the best choice, if it's possible for the domain we're instrumenting within.
Right now, the language supports global state declaration, but no global state initialization, e.g.:
This is because some modules do not have Wasm
start
functions defined. If astart
function doesn't exist, there is no obvious place to emit the global state initialization logic. Declarations are easy since it's just putting a new global into the module!Possible workarounds:
start
function exists, emit one! It will be run on startup and initialize global state. It's possible that some use cases won't support astart
function...so this may not be a solution for "all programs we instrument".bool
check to the start of every function, so it would have a higher performance impact.Solution number 1 is clearly the best choice, if it's possible for the domain we're instrumenting within.