A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
;;! target = "x86_64"
;;! test = 'compile'
;;! filter = "function"
;;! flags = "-C inlining=n -Wconcurrency-support=n"
;; Same as `direct-adapter-calls.wat` but shows full compilation down to x86_64
;; so that we can exercise our linker's ability to resolve relocations for
;; direct calls across Wasm modules.
(component
(component $A
(core module $M
(func (export "f'") (param i32) (result i32)
(i32.add (local.get 0) (i32.const 42))
)
)
(core instance $m (instantiate $M))
(func (export "f") (param "x" u32) (result u32)
(canon lift (core func $m "f'"))
)
)
(component $B
(import "f" (func $f (param "x" u32) (result u32)))
(core func $f' (canon lower (func $f)))
(core module $N
(import "" "f'" (func $f' (param i32) (result i32)))
(func (export "g'") (result i32)
(call $f' (i32.const 1234))
)
)
(core instance $n
(instantiate $N
(with "" (instance (export "f'" (func $f'))))
)
)
(func (export "g") (result u32)
(canon lift (core func $n "g'"))
)
)
(instance $a (instantiate $A))
(instance $b
(instantiate $B
(with "f" (func $a "f"))
)
)
(export "g" (func $b "g"))
)
;; wasm[0]::function[0]:
;; pushq %rbp
;; movq %rsp, %rbp
;; leal 0x2a(%rdx), %eax
;; movq %rbp, %rsp
;; popq %rbp
;; retq
;;
;; wasm[1]::function[1]:
;; pushq %rbp
;; movq %rsp, %rbp
;; movq 8(%rdi), %r10
;; movq 0x18(%r10), %r10
;; addq $0x10, %r10
;; cmpq %rsp, %r10
;; ja 0x4f
;; 39: movq %rdi, %rsi
;; movq 0x48(%rdi), %rdi
;; movl $0x4d2, %edx
;; callq 0x60
;; movq %rbp, %rsp
;; popq %rbp
;; retq
;; 4f: ud2
;;
;; wasm[2]::function[3]:
;; pushq %rbp
;; movq %rsp, %rbp
;; movq 8(%rdi), %r10
;; movq 0x18(%r10), %r10
;; addq $0x50, %r10
;; cmpq %rsp, %r10
;; ja 0xe6
;; 79: subq $0x40, %rsp
;; movq %rbx, 0x10(%rsp)
;; movq %r12, 0x18(%rsp)
;; movq %r13, 0x20(%rsp)
;; movq %r14, 0x28(%rsp)
;; movq %r15, 0x30(%rsp)
;; movq %rdi, (%rsp)
;; movq (%rsp), %rdi
;; movq 0xa8(%rdi), %r10
;; movl (%r10), %r10d
;; testl %r10d, %r10d
;; je 0xe8
;; b1: movq (%rsp), %rdi
;; movq 0x48(%rdi), %rdi
;; movq (%rsp), %rsi
;; callq 0
;; ├─╼ exception frame offset: SP = FP - 0x40
;; ╰─╼ exception handler: default handler, context at [SP+0x0], handler=0xe4
;; movq 0x10(%rsp), %rbx
;; movq 0x18(%rsp), %r12
;; movq 0x20(%rsp), %r13
;; movq 0x28(%rsp), %r14
;; movq 0x30(%rsp), %r15
;; addq $0x40, %rsp
;; movq %rbp, %rsp
;; popq %rbp
;; retq
;; e4: ud2
;; e6: ud2
;; e8: ud2