Adds support for multi tables (#517)
This commit adds support for multiple tables per module. Notably, if the WithFeatureReferenceTypes is enabled, call_indirect, table.init and table.copy instructions can reference non-zero indexed tables. part of #484 Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
38
config.go
38
config.go
@@ -27,12 +27,13 @@ type RuntimeConfig interface {
|
||||
//
|
||||
// Here are the notable effects:
|
||||
// * Adds `memory.fill`, `memory.init`, `memory.copy` and `data.drop` instructions.
|
||||
// * Adds `table.fill`, `table.init`, `table.copy` and `elem.drop` instructions.
|
||||
// * Adds `table.init`, `table.copy` and `elem.drop` instructions.
|
||||
// * Introduces a "passive" form of element and data segments.
|
||||
// * Stops checking "active" element and data segment boundaries at compile-time, meaning they can error at runtime.
|
||||
//
|
||||
// Note: "bulk-memory-operations" is mixed with the "reference-types" proposal
|
||||
// due to the WebAssembly Working Group merging them "mutually dependent".
|
||||
// Therefore, enabling this feature results in enabling WithFeatureReferenceTypes, and vice-versa.
|
||||
// See https://github.com/WebAssembly/spec/blob/main/proposals/bulk-memory-operations/Overview.md
|
||||
// See https://github.com/WebAssembly/spec/blob/main/proposals/reference-types/Overview.md
|
||||
// See https://github.com/WebAssembly/spec/pull/1287
|
||||
@@ -71,6 +72,30 @@ type RuntimeConfig interface {
|
||||
// See https://github.com/WebAssembly/spec/blob/main/proposals/nontrapping-float-to-int-conversion/Overview.md
|
||||
WithFeatureNonTrappingFloatToIntConversion(bool) RuntimeConfig
|
||||
|
||||
// WithFeatureReferenceTypes enables various instructions and features related to table and new reference types.
|
||||
//
|
||||
// * Introduction of new value types: `funcref` and `externref`.
|
||||
// * Support for the following new instructions:
|
||||
// * `ref.null`
|
||||
// * `ref.func`
|
||||
// * `ref.is_null`
|
||||
// * `table.fill`
|
||||
// * `table.get`
|
||||
// * `table.grow`
|
||||
// * `table.set`
|
||||
// * `table.size`
|
||||
// * Support for multiple tables per module:
|
||||
// * `call_indirect`, `table.init`, `table.copy` and `elem.drop` instructions can take non-zero table index.
|
||||
// * Element segments can take non-zero table index.
|
||||
//
|
||||
// Note: "reference-types" is mixed with the "bulk-memory-operations" proposal
|
||||
// due to the WebAssembly Working Group merging them "mutually dependent".
|
||||
// Therefore, enabling this feature results in enabling WithFeatureBulkMemoryOperations, and vice-versa.
|
||||
// See https://github.com/WebAssembly/spec/blob/main/proposals/bulk-memory-operations/Overview.md
|
||||
// See https://github.com/WebAssembly/spec/blob/main/proposals/reference-types/Overview.md
|
||||
// See https://github.com/WebAssembly/spec/pull/1287
|
||||
WithFeatureReferenceTypes(enabled bool) RuntimeConfig
|
||||
|
||||
// WithFeatureSignExtensionOps enables sign extension instructions ("sign-extension-ops"). This defaults to false
|
||||
// as the feature was not in WebAssembly 1.0.
|
||||
//
|
||||
@@ -166,6 +191,8 @@ func NewRuntimeConfigInterpreter() RuntimeConfig {
|
||||
func (c *runtimeConfig) WithFeatureBulkMemoryOperations(enabled bool) RuntimeConfig {
|
||||
ret := *c // copy
|
||||
ret.enabledFeatures = ret.enabledFeatures.Set(wasm.FeatureBulkMemoryOperations, enabled)
|
||||
// bulk-memory-operations proposal is mutually-dependant with reference-types proposal.
|
||||
ret.enabledFeatures = ret.enabledFeatures.Set(wasm.FeatureReferenceTypes, enabled)
|
||||
return &ret
|
||||
}
|
||||
|
||||
@@ -190,6 +217,15 @@ func (c *runtimeConfig) WithFeatureNonTrappingFloatToIntConversion(enabled bool)
|
||||
return &ret
|
||||
}
|
||||
|
||||
// WithFeatureReferenceTypes implements RuntimeConfig.WithFeatureReferenceTypes
|
||||
func (c *runtimeConfig) WithFeatureReferenceTypes(enabled bool) RuntimeConfig {
|
||||
ret := *c // copy
|
||||
ret.enabledFeatures = ret.enabledFeatures.Set(wasm.FeatureReferenceTypes, enabled)
|
||||
// reference-types proposal is mutually-dependant with bulk-memory-operations proposal.
|
||||
ret.enabledFeatures = ret.enabledFeatures.Set(wasm.FeatureBulkMemoryOperations, enabled)
|
||||
return &ret
|
||||
}
|
||||
|
||||
// WithFeatureSignExtensionOps implements RuntimeConfig.WithFeatureSignExtensionOps
|
||||
func (c *runtimeConfig) WithFeatureSignExtensionOps(enabled bool) RuntimeConfig {
|
||||
ret := *c // copy
|
||||
|
||||
Reference in New Issue
Block a user