Skip to content

Releases: wasmerio/wasmer-go

v1.0.4

12 Aug 14:34
Compare
Choose a tag to compare

Added

  • #230 Test against the nightly version of Wasmer everyday at 2am.
  • #229 Showcase how to get Instance inside a host function.

Changed

  • #276 Update the underlying runtime to Wasmer 2.0, which provides improved performances, and better stability.
  • #268 and #247 Update all Rust dependencies.

Fixed

  • #277 Force finalizers to explore the graph of objects.
  • #264 Update the store field when deserializing a Module.
  • #244 Place imports in Instance to prevent them being freed during function execution.
  • #242 Correctly handle I64 (and other) values returned from imported functions.

v1.0.3

26 Feb 10:40
5f7cd99
Compare
Choose a tag to compare

Added

  • #213 Add the CompilerKind, EngineKind, IsCompilerAvailable and IsEngineAvailable symbols.
  • #206 Use parameterized tests to check all available configurations.
  • #204 Add Config.UseSinglepassCompiler.
  • #193, #190 and #211 Add the custom_wasmer_runtime build tag.
  • #192 Add missing documentation.

Changed

(nothing)

Fixed

  • #220 Test with more compilers and more engines.
  • #209 Fix documentation format.
  • #207 Avoid calling Function.Type() for every function call.
  • #198 Update shared libraries to fix a bug with CpuFeatures.Add.
  • #197 Force go mod vendor to copy the packaged/ directory.

v1.0.2

26 Feb 10:28
Compare
Choose a tag to compare

Added

  • #190, #193 Add the custom_wasmer_runtime tag to use a specific Wasmer shared library object if the one you need is missing from the pre-compiled set.
  • #192 Improved the
    documentation by covering the entire API

v1.0.1

26 Feb 10:28
Compare
Choose a tag to compare

Changed

  • Fix the instructions in the README.md

v1.0.0

05 Feb 21:49
0316d3f
Compare
Choose a tag to compare

Added

  • Implement traps
  • Allow choosing an engine and a compiler through the configuration
  • Added support for aarch64
  • Implement WASI
  • Implement cross-compilation
  • Add support for host function environment

Changed

  • Update to Wasmer 1.0.2

v1.0.0-beta2

05 Jan 21:52
9e6cf99
Compare
Choose a tag to compare

Update to Wasmer 1.0.0

v1.0.0-beta1

03 Dec 20:22
61605b6
Compare
Choose a tag to compare

Changed

  • The whole API changed to better match Wasmer and Wasm C API

    // Create an Engine
    engine := wasmer.NewEngine()
    
    // Create a Store
    store := wasmer.NewStore(engine)
    
    fmt.Println("Compiling module...")
    module, err := wasmer.NewModule(store, wasmBytes)
    
    if err != nil {	 
        fmt.Println("Failed to compile module:", err)
    }
    
    // Create an empty import object.
    importObject := wasmer.NewImportObject()
    
    fmt.Println("Instantiating module...")
    // Let's instantiate the Wasm module.
    instance, err := wasmer.NewInstance(module, importObject)
    
    if err != nil {	 
        panic(fmt.Sprintln("Failed to instantiate the module:", err))
    }

    Please refer to the examples and documentation to learn more about the changes.

0.3.1

03 Mar 10:58
Compare
Choose a tag to compare

Changed

  • Replace godoc.org by pkg.go.dev (#122 by @Hywan)
  • Do everything to publish the package on pkg.go.dev.

0.3.0

02 Mar 12:18
Compare
Choose a tag to compare

Added

  • Memory can be imported, thus making the distinction between owned and borrowed memory (#119 by @koponen-styra).

    The main new methods are Imports.AppendMemory, and NewMemory to create a new memory with bounds (in pages).

    The Imports.Append method is now deprecated in favor of Imports.AppendFunction.

    // Compile a WebAssembly module
    module, _ := wasm.Compile(wasmBytes)
    
    // Create a new memory (that's new!)
    memory, _ := wasm.NewMemory(/* min page */ 1, /* max page */ 2)
    
    // Create an import object
    imports := wasm.NewImports().Namespace("env").AppendMemory("memory", memory)
    importObject := wasm.NewImportObject()
    _ = importObject.Extend(*imports)
    
    instance, _ := module.InstantiateWithImportObject(importObject)
    defer instance.Close()
    
    // Now we can read or write the memory with `memory.Data()` as usual
  • Add Bazel files to build the project with Bazel (#108 by @joesonw)

  • Support multiple WASI version with WasiGetVersion, NewDefaultWasiImportObjectForVersion, NewWasiImportObjectForVersion and WasiVersion (#92 by @Hywan).

    Supported version are:

    • Latest,
    • Snapshot0,
    • Snapshot1,
    • Unknown (in case of error).
    // Compile a WebAssembly module
    module, _ = wasm.Compile(wasmBytes)
    
    // Read the WASI version required for this module
    wasiVersion = wasm.WasiGetVersion(module)
    
    // Create an import object
    importObject := wasm.NewDefaultWasiImportObjectForVersion(wasiVersion)
    
    // Extend the import object with the imports
    imports, _ := wasm.NewImports().Namespace("env").AppendFunction("sum", sum, C.sum)
    _ = importObject.Extend(*imports)
    
    // Instantiate the module with the import object
    instante, _ := module.InstantiateWithImportObject(importObject)
  • InstanceContext supports user data with any reference types or types that include any reference types or other Go pointers (#85 and #94 by @AdamSLevy)

    type logMessageContext struct {
        message string
        slice []string // that wasn't possible before
        ptr *string    // that wasn't possible before
    }
    
    str := "test"
    contextData = logMessageContext {
        message: "first",
        slice:   []string{str, str},
        ptr:     &str,
    }
    
    instance.SetContextData(&contextData)
  • WASI is now supported (#72 by @MarkMcCaskey)

    // Compile a WebAssembly module
    module, _ = wasm.Compile(wasmBytes)
    
    // Declare imports as usual
    imports, _ := wasm.NewImports().Namespace("env").AppendFunction("sum", sum, C.sum)
    
    // Create an import object
    importObject := wasm.NewDefaultWasiImportObject()
    
    // Extend the import object with the imports
    _ = importObject.Extend(*imports)
    
    // Instantiate the module with the import object
    instance, _ = wasm.InstantiateWithImportObject(importObject)
    defer instance.Close()
    
    // Run the module
    instance.Exports["_start"]()
  • Instance supports optional memory, i.e. a WebAssembly module that does not have an exported memory, and provides a new HasMemory method (#63 by @Hywan)

Changed

Fixed

0.2.0

16 Jul 09:48
Compare
Choose a tag to compare

Features

  • #55 Add the Memory.Grow method (@Hywan)

  • #42 Improve error messages when instantiating (@Hywan)

  • #38 Support import descriptors (@Hywan)

    var module, _ = wasm.Compile(bytes)
    
    assert.Equal(…, "log_message", module.Imports[0].Name)
    assert.Equal(…, "env", module.Imports[0].Namespace)
  • #37 Support export descriptors (@Hywan)

    var module, _ = wasm.Compile(bytes)
    
    assert.Equal(…, "sum", module.Exports[7].Name)
  • #34 Support module serialization and deserialization (@Hywan)

    // Compiles the bytes into a WebAssembly module.
    module1, _ := wasm.Compile(GetBytes())
    defer module1.Close()
    
    // Serializes the module into a sequence of bytes.
    serialization, _ := module1.Serialize()
    
    // Do something with `serialization`.
    // Then later…
    
    // Deserializes the module.
    module2, _ := wasm.DeserializeModule(serialization)
    defer module2.Close()
    // And enjoy!
    
    // Instantiates the WebAssembly module.
    instance, _ := module2.Instantiate()
    defer instance.Close()
    
    // Gets an exported function.
    sum, functionExists := instance.Exports["sum"]
    
    fmt.Println(functionExists)
    
    // Calls the `sum` exported function with Go values.
    result, _ := sum(1, 2)
    
    fmt.Println(result)
    
    // Output:
    // true
    // 3
  • #33 Add Compile, Module.Instantiate* and Module.Close (@Hywan)

  • #30 Support instance context data (@Hywan)

    //export logMessageWithContextData
    func logMessageWithContextData(context unsafe.Pointer, pointer int32, length int32) {
            var instanceContext = wasm.IntoInstanceContext(context)
            var memory = instanceContext.Memory().Data()
            var logMessage = (*logMessageContext)(instanceContext.Data())
    
            logMessage.message = string(memory[pointer : pointer+length])
    }
    
    type logMessageContext struct {
            message string
    }
    
    func testImportInstanceContextData(t *testing.T) {
            imports, err := wasm.NewImports().Append("log_message", logMessageWithContextData, C.logMessageWithContextData)
            assert.NoError(t, err)
    
            instance, err := wasm.NewInstanceWithImports(getImportedFunctionBytes("log.wasm"), imports)
            assert.NoError(t, err)
    
            defer instance.Close()
    
            contextData := logMessageContext{message: "first"}
            instance.SetContextData(unsafe.Pointer(&contextData))
    
            doSomething := instance.Exports["do_something"]
    
            result, err := doSomething()
    
            assert.NoError(t, err)
            assert.Equal(t, wasm.TypeVoid, result.GetType())
            assert.Equal(t, "hello", contextData.message)
    }
  • #29 Add Imports.Namespace to set the current import namespace (@Hywan)

    // By default, the namespace is `"env"`. Change it to `"ns"`.
    wasm.NewImports().Namespace("ns").Append("f", f, C.f)
  • #26 Support instance context API (@Hywan)

Bug/security fixes

Documentation/Test

  • #51 Test that all Wasm types can be used in imported functions (@Hywan)
  • #36 Improve the Benchmarks Section (@Hywan)
  • #32 Move examples in the root directory for godoc.org (@Hywan)
  • #31 Fix example namespaces for godoc.org (@Hywan)
  • #30 Increase the cgocheck level (@Hywan)

Chore