aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/internal/obj/wasm/wasmobj.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/cmd/internal/obj/wasm/wasmobj.go b/src/cmd/internal/obj/wasm/wasmobj.go
index 28ecd20cd0..48eee4e3ea 100644
--- a/src/cmd/internal/obj/wasm/wasmobj.go
+++ b/src/cmd/internal/obj/wasm/wasmobj.go
@@ -974,6 +974,10 @@ func genWasmExportWrapper(s *obj.LSym, appendp func(p *obj.Prog, as obj.As, args
Sym: s, // PC_F
Offset: 1, // PC_B=1, past the prologue, so we have the right SP delta
}
+ if framesize == 0 {
+ // Frameless function, no prologue.
+ retAddr.Offset = 0
+ }
p = appendp(p, AI64Const, retAddr)
p = appendp(p, AI64Store, constAddr(0))
// Set PC_B parameter to function entry
@@ -1014,11 +1018,13 @@ func genWasmExportWrapper(s *obj.LSym, appendp func(p *obj.Prog, as obj.As, args
}
// Epilogue. Cannot use ARET as we don't follow Go calling convention.
- // SP += framesize
- p = appendp(p, AGet, regAddr(REG_SP))
- p = appendp(p, AI32Const, constAddr(framesize))
- p = appendp(p, AI32Add)
- p = appendp(p, ASet, regAddr(REG_SP))
+ if framesize > 0 {
+ // SP += framesize
+ p = appendp(p, AGet, regAddr(REG_SP))
+ p = appendp(p, AI32Const, constAddr(framesize))
+ p = appendp(p, AI32Add)
+ p = appendp(p, ASet, regAddr(REG_SP))
+ }
p = appendp(p, AReturn)
}