Propagates context to all api interface methods that aren't constant (#502)

This prepares for exposing operations like Memory.Grow while keeping the
ability to trace what did that, by adding a `context.Context` initial
parameter. This adds this to all API methods that mutate or return
mutated data.

Before, we made a change to trace functions and general lifecycle
commands, but we missed this part. Ex. We track functions, but can't
track what closed the module, changed memory or a mutable constant.
Changing to do this now is not only more consistent, but helps us
optimize at least the interpreter to help users identify otherwise
opaque code that can cause harm. This is critical before we add more
functions that can cause harm, such as Memory.Grow.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2022-04-25 08:13:18 +08:00
committed by GitHub
parent 98676fbc64
commit 45ff2fe12f
44 changed files with 1059 additions and 746 deletions

View File

@@ -29,7 +29,7 @@ func Example() {
if err != nil {
log.Fatal(err)
}
defer mod.Close()
defer mod.Close(ctx)
// Get a function that can be reused until its module is closed:
add := mod.ExportedFunction("add")