Skip to content

Commit dd6ac7d

Browse files
committed
reflect: use abi.FuncPCABIInternal
Use abi.FuncPCABIInternal instead of going through assembly or unsafe.Pointer hacks. For golang#38783
1 parent b29468b commit dd6ac7d

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

src/reflect/asm_amd64.s

+1-8
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$312
8282
// at any of the initial call instructions. The entry point is used to determine
8383
// the closure which implements the method.
8484
// No preamble of any kind, we need to do things manually.
85-
TEXT ·dispatchToMethod(SB),(NOSPLIT|NOFRAME),$0-0
85+
TEXT ·dispatchToMethod<ABIInternal>(SB),(NOSPLIT|NOFRAME),$0-0
8686
CALL ·dispatchLabel(SB)
8787
CALL ·dispatchLabel(SB)
8888
CALL ·dispatchLabel(SB)
@@ -913,10 +913,3 @@ TEXT ·dispatchLabel(SB),(NOSPLIT|NOFRAME),$0-0
913913
// Currently, (DX) is always makeFuncStub, but this method of dispatch
914914
// might have other clients in the future, so we leave the indirect jump in.
915915
JMP (DX)
916-
917-
// getDispatchToMethodAddr simply returns the address of the actual code of
918-
// dispatchToMethod. This needs to be in ASM since trying to get the address
919-
// from Go yields the address ABI conversion wrapper instead.
920-
TEXT ·getDispatchToMethodAddr<ABIInternal>(SB),(NOSPLIT|NOFRAME),$0-0
921-
MOVQ $·dispatchToMethod(SB), AX
922-
RET

src/reflect/makefunc.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,8 @@ func dispatchToMethod()
195195
// assembly used in the implementation of dispatchToMethod.
196196
func dispatchLabel()
197197

198-
// getDispatchToMethodAddr returns the address of the actual code of
199-
// dispatchToMethod. This must happen in ASM to obtain the correct
200-
// address independet of the used ABI.
201-
func getDispatchToMethodAddr() uintptr
202-
203198
// dispatchToMethodAddr is the address of the actual code of dispatchToMethod.
204-
var dispatchToMethodAddr = getDispatchToMethodAddr()
199+
var dispatchToMethodAddr = abi.FuncPCABIInternal(dispatchToMethod)
205200

206201
// currentMethodKey is the most recent method key used for creating a method
207202
// at runtime. Initially, it's the actual code address of dispatchToMethod.
@@ -242,8 +237,7 @@ func allocMethodSlot(closure unsafe.Pointer) unsafe.Pointer {
242237
newKey := atomic.AddUintptr(&currentMethodKey, dispatchStep)
243238
if newKey > dispatchToMethodAddr+dispatchLimit {
244239
atomic.AddUintptr(&currentMethodKey, ^uintptr(dispatchStep)+1)
245-
dummy := methodSlotsExhausted
246-
return unsafe.Pointer(**(**uintptr)(unsafe.Pointer(&dummy)))
240+
return unsafe.Pointer(abi.FuncPCABIInternal(methodSlotsExhausted))
247241
}
248242
methodMap.Store(newKey, closure)
249243
return unsafe.Pointer(newKey - dispatchStep)

0 commit comments

Comments
 (0)