aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_windows_amd64.s
diff options
context:
space:
mode:
authorqmuntal <quimmuntal@gmail.com>2024-02-12 12:38:37 +0100
committerQuim Muntal <quimmuntal@gmail.com>2024-02-19 07:24:08 +0000
commit35fa852d6dda69ce367e449fff78b3fc09834c97 (patch)
tree60c0b405754a4ce87602174de600fb61a155403c /src/runtime/sys_windows_amd64.s
parentaf5943f90cc919c38188067bbe006bdc148b576c (diff)
downloadgo-35fa852d6dda69ce367e449fff78b3fc09834c97.tar.xz
runtime: use the right number of parameters in syscall_SyscallX on Windows
The syscall_SyscallX functions currently discard the nargs parameter when calling syscall_SyscallN. This precludes some optimizations down the line. For example, on amd64, a syscall that takes 0 arguments don't need to set any of the params passing registers (CX, DX, R8, and R9). This CL updates all syscall_SyscallX functions so they call syscall_SyscallN with an argument slice of the right length. While here, remove the hack in syscall_SyscallN to support less than 4 arguments, and update instead asmstdcall on amd64 to properly handle this case. Change-Id: I0328e14f34c2b000fde06cc6a579b09e8c32f2b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/563315 TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/runtime/sys_windows_amd64.s')
-rw-r--r--src/runtime/sys_windows_amd64.s33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/runtime/sys_windows_amd64.s b/src/runtime/sys_windows_amd64.s
index c1b78e3976..56a2dc0bcf 100644
--- a/src/runtime/sys_windows_amd64.s
+++ b/src/runtime/sys_windows_amd64.s
@@ -33,14 +33,12 @@ TEXT runtimeĀ·asmstdcall(SB),NOSPLIT,$16
SUBQ $(const_maxArgs*8), SP // room for args
- // Fast version, do not store args on the stack nor
- // load them into registers.
- CMPL CX, $0
- JE docall
-
// Fast version, do not store args on the stack.
- CMPL CX, $4
- JLE loadregs
+ CMPL CX, $0; JE _0args
+ CMPL CX, $1; JE _1args
+ CMPL CX, $2; JE _2args
+ CMPL CX, $3; JE _3args
+ CMPL CX, $4; JE _4args
// Check we have enough room for args.
CMPL CX, $const_maxArgs
@@ -53,22 +51,25 @@ TEXT runtimeĀ·asmstdcall(SB),NOSPLIT,$16
REP; MOVSQ
MOVQ SP, SI
-loadregs:
// Load first 4 args into correspondent registers.
- MOVQ 0(SI), CX
- MOVQ 8(SI), DX
- MOVQ 16(SI), R8
- MOVQ 24(SI), R9
// Floating point arguments are passed in the XMM
// registers. Set them here in case any of the arguments
// are floating point values. For details see
// https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170
- MOVQ CX, X0
- MOVQ DX, X1
- MOVQ R8, X2
+_4args:
+ MOVQ 24(SI), R9
MOVQ R9, X3
+_3args:
+ MOVQ 16(SI), R8
+ MOVQ R8, X2
+_2args:
+ MOVQ 8(SI), DX
+ MOVQ DX, X1
+_1args:
+ MOVQ 0(SI), CX
+ MOVQ CX, X0
+_0args:
-docall:
// Call stdcall function.
CALL AX