mirror of
https://github.com/golang/go
synced 2024-09-04 23:44:16 +00:00
[dev.typeparams] reflect: implement register ABI for MakeFunc etc. on ARM64
Implement register ABI for reflect.MakeFunc and method Value Call on ARM64. Change-Id: I5487febb9ea764af5ccf5d7c94858ab0acec7cac Reviewed-on: https://go-review.googlesource.com/c/go/+/323936 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
2e4b79949f
commit
0c123cdf8b
|
@ -5,34 +5,75 @@
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
#include "funcdata.h"
|
#include "funcdata.h"
|
||||||
|
|
||||||
|
// The frames of each of the two functions below contain two locals, at offsets
|
||||||
|
// that are known to the runtime.
|
||||||
|
//
|
||||||
|
// The first local is a bool called retValid with a whole pointer-word reserved
|
||||||
|
// for it on the stack. The purpose of this word is so that the runtime knows
|
||||||
|
// whether the stack-allocated return space contains valid values for stack
|
||||||
|
// scanning.
|
||||||
|
//
|
||||||
|
// The second local is an abi.RegArgs value whose offset is also known to the
|
||||||
|
// runtime, so that a stack map for it can be constructed, since it contains
|
||||||
|
// pointers visible to the GC.
|
||||||
|
#define LOCAL_RETVALID 40
|
||||||
|
#define LOCAL_REGARGS 48
|
||||||
|
|
||||||
|
// The frame size of the functions below is
|
||||||
|
// 32 (args of callReflect) + 8 (bool + padding) + 392 (abi.RegArgs) = 432.
|
||||||
|
|
||||||
// makeFuncStub is the code half of the function returned by MakeFunc.
|
// makeFuncStub is the code half of the function returned by MakeFunc.
|
||||||
// See the comment on the declaration of makeFuncStub in makefunc.go
|
// See the comment on the declaration of makeFuncStub in makefunc.go
|
||||||
// for more details.
|
// for more details.
|
||||||
// No arg size here, runtime pulls arg map out of the func value.
|
// No arg size here, runtime pulls arg map out of the func value.
|
||||||
TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$40
|
TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$432
|
||||||
NO_LOCAL_POINTERS
|
NO_LOCAL_POINTERS
|
||||||
|
// NO_LOCAL_POINTERS is a lie. The stack map for the two locals in this
|
||||||
|
// frame is specially handled in the runtime. See the comment above LOCAL_RETVALID.
|
||||||
|
ADD $LOCAL_REGARGS, RSP, R20
|
||||||
|
CALL runtime·spillArgs(SB)
|
||||||
|
MOVD R26, 32(RSP) // outside of moveMakeFuncArgPtrs's arg area
|
||||||
|
MOVD R26, 8(RSP)
|
||||||
|
MOVD R20, 16(RSP)
|
||||||
|
CALL ·moveMakeFuncArgPtrs(SB)
|
||||||
|
MOVD 32(RSP), R26
|
||||||
MOVD R26, 8(RSP)
|
MOVD R26, 8(RSP)
|
||||||
MOVD $argframe+0(FP), R3
|
MOVD $argframe+0(FP), R3
|
||||||
MOVD R3, 16(RSP)
|
MOVD R3, 16(RSP)
|
||||||
MOVB $0, 40(RSP)
|
MOVB $0, LOCAL_RETVALID(RSP)
|
||||||
ADD $40, RSP, R3
|
ADD $LOCAL_RETVALID, RSP, R3
|
||||||
MOVD R3, 24(RSP)
|
MOVD R3, 24(RSP)
|
||||||
MOVD $0, 32(RSP)
|
ADD $LOCAL_REGARGS, RSP, R3
|
||||||
BL ·callReflect(SB)
|
MOVD R3, 32(RSP)
|
||||||
|
CALL ·callReflect(SB)
|
||||||
|
ADD $LOCAL_REGARGS, RSP, R20
|
||||||
|
CALL runtime·unspillArgs(SB)
|
||||||
RET
|
RET
|
||||||
|
|
||||||
// methodValueCall is the code half of the function returned by makeMethodValue.
|
// methodValueCall is the code half of the function returned by makeMethodValue.
|
||||||
// See the comment on the declaration of methodValueCall in makefunc.go
|
// See the comment on the declaration of methodValueCall in makefunc.go
|
||||||
// for more details.
|
// for more details.
|
||||||
// No arg size here; runtime pulls arg map out of the func value.
|
// No arg size here; runtime pulls arg map out of the func value.
|
||||||
TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$40
|
TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$432
|
||||||
NO_LOCAL_POINTERS
|
NO_LOCAL_POINTERS
|
||||||
|
// NO_LOCAL_POINTERS is a lie. The stack map for the two locals in this
|
||||||
|
// frame is specially handled in the runtime. See the comment above LOCAL_RETVALID.
|
||||||
|
ADD $LOCAL_REGARGS, RSP, R20
|
||||||
|
CALL runtime·spillArgs(SB)
|
||||||
|
MOVD R26, 32(RSP) // outside of moveMakeFuncArgPtrs's arg area
|
||||||
|
MOVD R26, 8(RSP)
|
||||||
|
MOVD R20, 16(RSP)
|
||||||
|
CALL ·moveMakeFuncArgPtrs(SB)
|
||||||
|
MOVD 32(RSP), R26
|
||||||
MOVD R26, 8(RSP)
|
MOVD R26, 8(RSP)
|
||||||
MOVD $argframe+0(FP), R3
|
MOVD $argframe+0(FP), R3
|
||||||
MOVD R3, 16(RSP)
|
MOVD R3, 16(RSP)
|
||||||
MOVB $0, 40(RSP)
|
MOVB $0, LOCAL_RETVALID(RSP)
|
||||||
ADD $40, RSP, R3
|
ADD $LOCAL_RETVALID, RSP, R3
|
||||||
MOVD R3, 24(RSP)
|
MOVD R3, 24(RSP)
|
||||||
MOVD $0, 32(RSP)
|
ADD $LOCAL_REGARGS, RSP, R3
|
||||||
BL ·callMethod(SB)
|
MOVD R3, 32(RSP)
|
||||||
|
CALL ·callMethod(SB)
|
||||||
|
ADD $LOCAL_REGARGS, RSP, R20
|
||||||
|
CALL runtime·unspillArgs(SB)
|
||||||
RET
|
RET
|
||||||
|
|
|
@ -1318,11 +1318,11 @@ func getStackMap(frame *stkframe, cache *pcvalueCache, debug bool) (locals, args
|
||||||
}
|
}
|
||||||
|
|
||||||
// stack objects.
|
// stack objects.
|
||||||
if GOARCH == "amd64" && unsafe.Sizeof(abi.RegArgs{}) > 0 && frame.argmap != nil {
|
if (GOARCH == "amd64" || GOARCH == "arm64") && unsafe.Sizeof(abi.RegArgs{}) > 0 && frame.argmap != nil {
|
||||||
// argmap is set when the function is reflect.makeFuncStub or reflect.methodValueCall.
|
// argmap is set when the function is reflect.makeFuncStub or reflect.methodValueCall.
|
||||||
// We don't actually use argmap in this case, but we need to fake the stack object
|
// We don't actually use argmap in this case, but we need to fake the stack object
|
||||||
// record for these frames which contain an internal/abi.RegArgs at a hard-coded offset
|
// record for these frames which contain an internal/abi.RegArgs at a hard-coded offset.
|
||||||
// on amd64.
|
// This offset matches the assembly code on amd64 and arm64.
|
||||||
objs = methodValueCallFrameObjs
|
objs = methodValueCallFrameObjs
|
||||||
} else {
|
} else {
|
||||||
p := funcdata(f, _FUNCDATA_StackObjects)
|
p := funcdata(f, _FUNCDATA_StackObjects)
|
||||||
|
|
Loading…
Reference in a new issue