From 88ea8a5fe0526bc53e944420c42cf75fc7b11c4f Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Wed, 29 Sep 2021 09:49:54 -0700 Subject: runtime: extract text address calculation into a separate method Pure code movement. Change-Id: I7216e50fe14afa3d19c5047c92e515c90838f834 Reviewed-on: https://go-review.googlesource.com/c/go/+/353129 Trust: Josh Bleecher Snyder Trust: Brad Fitzpatrick Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick Reviewed-by: Cherry Mui --- src/runtime/type.go | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'src/runtime/type.go') diff --git a/src/runtime/type.go b/src/runtime/type.go index ad01d5095e..e609acbc1e 100644 --- a/src/runtime/type.go +++ b/src/runtime/type.go @@ -288,34 +288,7 @@ func (t *_type) textOff(off textOff) unsafe.Pointer { } return res } - res := uintptr(0) - - // The text, or instruction stream is generated as one large buffer. The off (offset) for a method is - // its offset within this buffer. If the total text size gets too large, there can be issues on platforms like ppc64 if - // the target of calls are too far for the call instruction. To resolve the large text issue, the text is split - // into multiple text sections to allow the linker to generate long calls when necessary. When this happens, the vaddr - // for each text section is set to its offset within the text. Each method's offset is compared against the section - // vaddrs and sizes to determine the containing section. Then the section relative offset is added to the section's - // relocated baseaddr to compute the method addess. - - if len(md.textsectmap) > 1 { - for i := range md.textsectmap { - sectaddr := md.textsectmap[i].vaddr - sectlen := md.textsectmap[i].length - if uintptr(off) >= sectaddr && uintptr(off) < sectaddr+sectlen { - res = md.textsectmap[i].baseaddr + uintptr(off) - uintptr(md.textsectmap[i].vaddr) - break - } - } - } else { - // single text section - res = md.text + uintptr(off) - } - - if res > md.etext && GOARCH != "wasm" { // on wasm, functions do not live in the same address space as the linear memory - println("runtime: textOff", hex(off), "out of range", hex(md.text), "-", hex(md.etext)) - throw("runtime: text offset out of range") - } + res := md.textAddr(uintptr(off)) return unsafe.Pointer(res) } -- cgit v1.3-5-g45d5