Skip to content

Instantly share code, notes, and snippets.

@alexcrichton
Created June 9, 2020 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexcrichton/2f228efd7c8df6b52aa54bb5abea810e to your computer and use it in GitHub Desktop.
Save alexcrichton/2f228efd7c8df6b52aa54bb5abea810e to your computer and use it in GitHub Desktop.
--- before.wast 2020-06-09 12:49:42.448000829 -0700
+++ tests/local/module-linking/a.wast 2020-06-09 12:50:29.456176376 -0700
@@ -3,42 +3,42 @@
;; boilerplate, it is proportional in size to only the *direct* dependencies.
(module $A
- (type $Wasi (instance ...))
+ (type $Wasi (instance ))
(import "wasi" (instance (type $Wasi)))
- (func (export "a") ...)
+ (func (export "a") )
)
(module $B
- (type $Wasi (instance ...))
+ (type $Wasi (instance ))
(import "wasi" (instance $wasi (type $Wasi)))
(import "A:1.x" (module $A
(import "wasi" (instance (type $Wasi)))
(export "a" (func))
))
(instance $a (instantiate $A (instance $wasi)))
- (func (export "b") ...)
+ (func (export "b") )
)
(module $C
- (type $Wasi (instance ...))
+ (type $Wasi (instance ))
(import "wasi" (instance $wasi (type $Wasi)))
(import "B:1.x" (module $B
(import "wasi" (instance $wasi (type $Wasi)))
(export "b" (func))
))
(instance $b (instantiate $B (instance $wasi)))
- (func (export "c") ...)
+ (func (export "c") )
)
(module $D
- (type $Wasi (instance ...))
+ (type $Wasi (instance ))
(import "wasi" (instance $wasi (type $Wasi)))
(import "C:1.x" (module $C
(import "wasi" (instance $wasi (type $Wasi)))
(export "c" (func))
))
(instance $c (instantiate $C (instance $wasi)))
- (func (export "d") ...)
+ (func (export "d") )
)
;; Invoking 'link' on $D produces the following linked module. Notice that the amount of module-type-y
@@ -46,13 +46,14 @@
;; wrapper modules, it would be O(n^2).
(module
- (type $Wasi (instance ...))
+ (type $Wasi (instance ))
+ (import "wasi" (instance $wasi (type $Wasi)))
- (import "A:1.0.0:sha256..." (module $A
+ (import "A:1.0.0:sha256" (module $A
(import "wasi" (instance (type $Wasi)))
(export "a" (func $a))
))
- (import "B:1.0.0:sha256..." (module $B
+ (import "B:1.0.0:sha256" (module $B
(import "wasi" (instance (type $Wasi)))
(import "A:1.x" (module
(import "wasi" (instance (type $Wasi)))
@@ -60,12 +61,7 @@
))
(export "b" (func $b))
))
- (module $B_wrap
- (import "wasi" (instance $wasi (type $Wasi)))
- (instance $b (instantiate $B (instance $wasi) (module $A)))
- (export "b" (func $b.$b))
- )
- (import "C:1.0.0:sha256..." (module $C
+ (import "C:1.0.0:sha256" (module $C
(import "wasi" (instance (type $Wasi)))
(import "B:1.x" (module
(import "wasi" (instance $wasi (type $Wasi)))
@@ -73,12 +69,7 @@
))
(export "c" (func $c))
))
- (module $C_wrap
- (import "wasi" (instance $wasi (type $Wasi)))
- (instance $c (instantiate $C (instance $wasi) (module $B_wrap)))
- (export "c" (func $c.$c))
- )
- (import "D:1.0.0:sha256..." (module $D
+ (import "D:1.0.0:sha256" (module $D
(import "wasi" (instance (type $Wasi)))
(import "C:1.x" (module
(import "wasi" (instance $wasi (type $Wasi)))
@@ -86,6 +77,16 @@
))
(export "d" (func))
))
+ (module $B_wrap
+ (import "wasi" (instance $wasi (type $Wasi)))
+ (instance $b (instantiate $B (instance $wasi) (module $A)))
+ (export "b" (func $b.$b))
+ )
+ (module $C_wrap
+ (import "wasi" (instance $wasi (type $Wasi)))
+ (instance $c (instantiate $C (instance $wasi) (module $B_wrap)))
+ (export "c" (func $c.$c))
+ )
(instance $d (instantiate $D (instance $wasi) (module $C_wrap)))
(export $d)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment