Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors store and adds ReleaseModuleInstance. #294

Merged
merged 1 commit into from
Mar 1, 2022
Merged

Conversation

mathetake
Copy link
Member

@mathetake mathetake commented Feb 25, 2022

This PR refactors store.go and adds store.ReleaseModuleInstance.
Notably, this removes the "rollback" functions in InstantiateModule
which we had used to rollback the mutated state when we encounter
the initialization failure. Instead, we separate out the validation from
initialization and migrate most of the validation logics into module.go

As for ReleaseModuleInstance, that is necessary to complete #293,
will be leveraged to make it possible for store to be used for long-running
processes and environment.

@mathetake
Copy link
Member Author

note to myself: move refcounters to store

@mathetake
Copy link
Member Author

I will rework a bit so that we have refcount per moduleInstance rather than per each instance (memory, function, etc) as the latter needlessly makes the code complex while we benefit a little

Copy link
Contributor

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the work so far!

internal/wasm/store.go Outdated Show resolved Hide resolved
internal/wasm/store.go Outdated Show resolved Hide resolved
@mathetake mathetake force-pushed the releaseemodule branch 2 times, most recently from 782fc21 to 5e091d6 Compare February 28, 2022 02:38
@mathetake
Copy link
Member Author

so I need to do backfilling tests a lot..

@mathetake
Copy link
Member Author

some assert_invalid failing but almost there

@mathetake
Copy link
Member Author

ok passed spectests.. will polish

internal/wasm/module.go Outdated Show resolved Hide resolved
internal/wasm/module.go Outdated Show resolved Hide resolved
@mathetake
Copy link
Member Author

so I will stop caring about concurrency in this PR as it bloats further more


func (m *Module) validateTables(tables []*TableType, globals []*GlobalType) error {
if len(tables) > 1 {
return fmt.Errorf("multiple tables are not supported")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codefromthecrypt fyi now this is the place we enforce at most one table (before instantiation phase)

@mathetake
Copy link
Member Author

ok needs to fix amd64 then..

@mathetake mathetake changed the title Adds store.ReleaseModuleInstance Refactors store and adds ReleaseModuleInstance. Mar 1, 2022
@mathetake
Copy link
Member Author

some of the funcs lacks godoc but eagerly mark this ready for review

@mathetake mathetake marked this pull request as ready for review March 1, 2022 01:27
Copy link
Contributor

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding some comments because the uint64 thing shouldn't survive another PR

internal/wasm/func_validation.go Outdated Show resolved Hide resolved
internal/wasm/func_validation.go Outdated Show resolved Hide resolved
internal/wasm/func_validation.go Outdated Show resolved Hide resolved
internal/wasm/interpreter/interpreter.go Show resolved Hide resolved
internal/wasm/jit/engine.go Show resolved Hide resolved
internal/wasm/store.go Outdated Show resolved Hide resolved
internal/wasm/store.go Outdated Show resolved Hide resolved
internal/wasm/store.go Outdated Show resolved Hide resolved
internal/wasm/store.go Outdated Show resolved Hide resolved
internal/wasm/store.go Outdated Show resolved Hide resolved
Copy link
Contributor

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work!

I would probably move validate* functions to validate.go and validate_test.go even if they have a module target. At some point we will export more of these to ensure source context is correct on failure.

wasm.go Show resolved Hide resolved
tests/spectest/spec_test.go Outdated Show resolved Hide resolved
internal/wazeroir/compiler.go Outdated Show resolved Hide resolved
internal/wasm/store_test.go Outdated Show resolved Hide resolved
internal/wasm/store.go Outdated Show resolved Hide resolved
for codeIndex := range m.FunctionSection {
funcIdx := Index(importCount + uint32(len(functions)))
// Seek to see if there's a better name than "unknown"
name := "unknown"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably better to default to $funcIdx and set that after the loop so we don't allocate unless we found no name.

internal/wasm/module.go Outdated Show resolved Hide resolved
internal/wasm/module_test.go Outdated Show resolved Hide resolved
internal/wasm/store.go Outdated Show resolved Hide resolved
internal/wasm/store.go Outdated Show resolved Hide resolved
Signed-off-by: Takeshi Yoneda <[email protected]>
@mathetake mathetake merged commit 31a69e8 into main Mar 1, 2022
@mathetake mathetake deleted the releaseemodule branch March 1, 2022 02:46
@mathetake
Copy link
Member Author

Thanks for the look!

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.

3 participants