Skip to content

Add Component function calls and runtime values - #290

Draft
JDLondon7 wants to merge 3 commits into
bytecodealliance:mainfrom
JDLondon7:tradepit/upstream/w010-component-call-values
Draft

Add Component function calls and runtime values#290
JDLondon7 wants to merge 3 commits into
bytecodealliance:mainfrom
JDLondon7:tradepit/upstream/w010-component-call-values

Conversation

@JDLondon7

Copy link
Copy Markdown

Failing test

upstream/main exposes component loading and instantiation, but it has no API to retrieve or invoke an exported component function and no runtime component value representation. The added tests call an exported function repeatedly with list<u8> values and exercise owned primitive and composite values.

General correction

  • Add ComponentInstance.GetFunc and synchronous ComponentFunc.Call bindings.
  • Add an owned ComponentVal representation for primitives, lists, records, tuples, variants, options, results, enums, and flags.
  • Clone values returned by the C API so Go values have explicit, independent ownership.
  • Give ComponentFuncType explicit close/finalizer behavior consistent with the existing bindings.

This draft intentionally does not add ComponentValType composite wrappers. That work is already under review in #283. It tracks the M1 work in #280 and can be rebased as the existing type series lands.

Validation

With the v47.0.0 release artifacts restored as ignored build inputs:

go test -tags wasmtime_component_model ./...
golangci-lint run --build-tags wasmtime_component_model --new-from-rev upstream/main --whole-files

Both commands pass on Windows amd64; lint reports 0 issues.

Compatibility and security impact

The API is additive and synchronous. It wraps the existing Wasmtime C component API and does not change core-module behavior. Returned values are cloned before the C-owned result vector is deleted, avoiding borrowed pointers escaping into Go.

Documentation

Public types and methods include Go documentation. The tests demonstrate call and ownership behavior.

Downstream removal condition

Downstream users can remove equivalent local bindings after an upstream release contains these APIs and their component call/value fixtures pass unchanged.

This change contains no TradePit product concepts or private data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant