aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj/wasm
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-09-20 23:29:20 -0400
committerCherry Zhang <cherryyz@google.com>2020-09-28 21:30:01 +0000
commitaf18bce87cc7ee1ffc68f91abefa241ab209539e (patch)
tree61998d0ad04ff13fd25f4466a5bcfa627b9d7569 /src/cmd/internal/obj/wasm
parentad0ab812f8b80416c92ed227974e3194e98f4cdc (diff)
downloadgo-af18bce87cc7ee1ffc68f91abefa241ab209539e.tar.xz
cmd/link: consider interface conversions only in reachable code
The linker prunes methods that are not directly reachable if the receiver type is never converted to interface. Currently, this "never" is too strong: it is invalidated even if the interface conversion is in an unreachable function. This CL improves it by only considering interface conversions in reachable code. To do that, we introduce a marker relocation R_USEIFACE, which marks the target symbol as UsedInIface if the source symbol is reached. binary size before after cmd/compile 18897528 18887400 cmd/go 13607372 13470652 Change-Id: I66c6b69eeff9ae02d84d2e6f2bc7f1b29dd53910 Reviewed-on: https://go-review.googlesource.com/c/go/+/256797 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd/internal/obj/wasm')
-rw-r--r--src/cmd/internal/obj/wasm/wasmobj.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/cmd/internal/obj/wasm/wasmobj.go b/src/cmd/internal/obj/wasm/wasmobj.go
index 70e8e51e65..a9e093a8ad 100644
--- a/src/cmd/internal/obj/wasm/wasmobj.go
+++ b/src/cmd/internal/obj/wasm/wasmobj.go
@@ -1007,6 +1007,7 @@ func assemble(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
panic("bad name for Call")
}
r := obj.Addrel(s)
+ r.Siz = 1 // actually variable sized
r.Off = int32(w.Len())
r.Type = objabi.R_CALL
if p.Mark&WasmImport != 0 {
@@ -1033,6 +1034,7 @@ func assemble(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
case AI32Const, AI64Const:
if p.From.Name == obj.NAME_EXTERN {
r := obj.Addrel(s)
+ r.Siz = 1 // actually variable sized
r.Off = int32(w.Len())
r.Type = objabi.R_ADDR
r.Sym = p.From.Sym