-
Notifications
You must be signed in to change notification settings - Fork 40
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
PoC: Introduce host modules #484
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Edoardo Vacchi <[email protected]>
Signed-off-by: Edoardo Vacchi <[email protected]>
Signed-off-by: Edoardo Vacchi <[email protected]>
Signed-off-by: Edoardo Vacchi <[email protected]>
evacchi
force-pushed
the
wasip1-host-modules
branch
from
August 22, 2024 16:50
c72cadb
to
6f5c189
Compare
Signed-off-by: Edoardo Vacchi <[email protected]>
evacchi
force-pushed
the
wasip1-host-modules
branch
from
August 23, 2024 07:50
6f5c189
to
697b4a7
Compare
Signed-off-by: Edoardo Vacchi <[email protected]>
Signed-off-by: Edoardo Vacchi <[email protected]>
evacchi
commented
Aug 23, 2024
Comment on lines
+15
to
+16
List<ValueType> paramTypes, | ||
List<ValueType> returnTypes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self: we already have FunctionType!
I am closing this because it slightly drifted and for now it is not necessary. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a PoC meant for discussion, it is not necessarily meant for merging.
Addresses #482 and potentially #464.
This PR refactors Wasip1 as a means to show an example and it introduces
(temporarily in thea few types:wasi
package)HostModule
andHostModule.Builder
. TheHostModule
interface represents a bundle ofFunctionSignature
s with a name (the name of the module). TheHostModule.Builder
returns a concrete implementation calledFunctionSignatureBundle
.HostModuleInstance
is an interface representing an instance of aHostModule
; it owns a reference to its host module "prototype" and it collects theHostFunction
s that belong to that instance, matching with the signatures given in theHostModule
. TheHostModuleInstance
can be alsoclose()
d (and potentially other lifecycle actions could be added, e.g.instantiate()
). TheHostModuleInstance.Builder
constructs a concrete implementation calledHostFunctionBundle
.FunctionSignature
is a representation of a (Host) Function's signature. This is essentially a different representation for aFunctionImport
so the two might collapse somehow, or at least share an ancestor.FunctionSignatureBundle
implementsHostModule
as explained above.HostFunctionBundle
implementsHostModuleInstance
as explained above.A
HostModule
can be constructed using the builder as such:Notice how the
HostModule
does not define any implementation for the functions. The implementations are given at instantiation time. In order to create aHostModuleInstance
we can use theHostModuleInstance.Builder
as such:Notice:
WasiPreview1
so that such instance is bound to the lifecycle of theHostModuleInstance
.Runnable
, so it is possible to e.g.close()
multiple object instances if necessary:This API is slightly more verbose than just creating the
HostFunction
s explicitly, however, it can be code-generated, or a reflection-based API can be provided on top of it, as described in #482, except: