diff --git a/src/internal/abi/abi_amd64.go b/src/internal/abi/abi_amd64.go index 77589d4c34..07c3ec1aab 100644 --- a/src/internal/abi/abi_amd64.go +++ b/src/internal/abi/abi_amd64.go @@ -10,16 +10,12 @@ package abi const ( // See abi_generic.go. - // Currently these values are zero because whatever uses - // them will expect the register ABI, which isn't ready - // yet. - // RAX, RBX, RCX, RDI, RSI, R8, R9, R10, R11. - IntArgRegs = 0 // 9 + IntArgRegs = 9 // X0 -> X14. - FloatArgRegs = 0 // 15 + FloatArgRegs = 15 // We use SSE2 registers which support 64-bit float operations. - EffectiveFloatRegSize = 0 // 8 + EffectiveFloatRegSize = 8 ) diff --git a/src/reflect/abi.go b/src/reflect/abi.go index 36d6b3095b..618efd0980 100644 --- a/src/reflect/abi.go +++ b/src/reflect/abi.go @@ -9,6 +9,30 @@ import ( "unsafe" ) +// These variables are used by the register assignment +// algorithm in this file. +// +// They should be modified with care (no other reflect code +// may be executing) and are generally only modified +// when testing this package. +// +// They should never be set higher than their internal/abi +// constant counterparts, because the system relies on a +// structure that is at least large enough to hold the +// registers the system supports. +// +// Currently they're set to zero because using the actual +// constants will break every part of the toolchain that +// uses reflect to call functions (e.g. go test, or anything +// that uses text/template). The values that are currently +// commented out there should be the actual values once +// we're ready to use the register ABI everywhere. +var ( + intArgRegs = 0 // abi.IntArgRegs + floatArgRegs = 0 // abi.FloatArgRegs + floatRegSize = uintptr(0) // uintptr(abi.EffectiveFloatRegSize) +) + // abiStep represents an ABI "instruction." Each instruction // describes one part of how to translate between a Go value // in memory and a call frame. @@ -226,7 +250,7 @@ func (a *abiSeq) assignIntN(offset, size uintptr, n int, ptrMap uint8) bool { if ptrMap != 0 && size != ptrSize { panic("non-empty pointer map passed for non-pointer-size values") } - if a.iregs+n > abi.IntArgRegs { + if a.iregs+n > intArgRegs { return false } for i := 0; i < n; i++ { @@ -255,7 +279,7 @@ func (a *abiSeq) assignFloatN(offset, size uintptr, n int) bool { if n < 0 { panic("invalid n") } - if a.fregs+n > abi.FloatArgRegs || abi.EffectiveFloatRegSize < size { + if a.fregs+n > floatArgRegs || floatRegSize < size { return false } for i := 0; i < n; i++ { diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s index 517c5a9d3e..ddd6a5bd5b 100644 --- a/src/runtime/asm_amd64.s +++ b/src/runtime/asm_amd64.s @@ -442,10 +442,7 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT,$0 MOVL $0, DX JMP runtime·morestack(SB) -// REFLECTCALL_USE_REGABI is not defined. It must be defined in conjunction with the -// register constants in the internal/abi package. - -#ifdef REFLECTCALL_USE_REGABI +#ifdef GOEXPERIMENT_REGABI // spillArgs stores return values from registers to a *internal/abi.RegArgs in R12. TEXT spillArgs<>(SB),NOSPLIT,$0-0 MOVQ AX, 0(R12)