Skip to content

Latest commit

 

History

History
454 lines (337 loc) · 14.7 KB

CHANGELOG.md

File metadata and controls

454 lines (337 loc) · 14.7 KB

Changelog

All notable changes to this project will be documented in this file.

Table of Contents

1.0.4 - 2021-08-12

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.

1.0.3 - 2021-02-26

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

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.

1.0.2 - 2021-02-08

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

1.0.1 - 2021-02-06

Changed

  • Fix the instructions in the README.md

1.0.0 - 2021-02-05

Added

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

Changed

  • Update to Wasmer 1.0.2

1.0.0-beta2 - 2021-01-05

Changed

  • Update to Wasmer 1.0.0

1.0.0-beta1 - 2020-12-03

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 - 2020-02-03

Changed

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

0.3.0 - 2020-02-02

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 - 2019-07-16

Added

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

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

  • Support import descriptors (#38 by @Hywan)

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

    var module, _ = wasm.Compile(bytes)
    
    assert.Equal(…, "sum", module.Exports[7].Name)
  • Support module serialization and deserialization (#34 by @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
  • Add Compile, Module.Instantiate* and Module.Close (#33 by @Hywan)

  • Support instance context data (#30 by @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)
    }
  • Add Imports.Namespace to set the current import namespace (#29 by @Hywan)

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

Changed

  • Update Wasmer to 0.5.5 (#56 by @Hywan)
  • Test that all Wasm types can be used in imported functions (#51 by @Hywan)
  • Improve the Benchmarks Section (#36 by @Hywan)
  • Move examples in the root directory for godoc.org (#32 by @Hywan)
  • Fix example namespaces for godoc.org (#31 by @Hywan)
  • Increase the cgocheck level (#30 by @Hywan)
  • Reorganize bridge.go (#54 by @Hywan)
  • Build and test on macOS (#15 by @Hywan)

0.1.0 - 2019-05-29

First release.