1
0
mirror of https://github.com/golang/go synced 2024-11-11 22:10:22 -07:00

runtime: call nanotimeQPC from nanotime1 normally

Currently we call runtimeQPC as ABIInternal because it shaves off 24
bytes by not having an extra wrapper, and at the time we were exceeding
the nosplit stack limit in some cases.

However, this code was written before we had the regabiargs GOEXPERIMENT
flag, and wasn't properly flagged. Naturally, with regabiargs enabled,
it leads to garbage being returned, because it needs to store
runtimeQPC's result to the stack.

We didn't notice this because today runtimeQPC is only used in Wine, not
on any native Windows platform.

Back when I wrote this code, it appeared to be necessary on even native
Windows, but it turns out that's not true anymore. Turn it back into a
native call through a wrapper.

For #40724.

Change-Id: Ia2e5901965ef46c5f299daccef49952026854fe6
Reviewed-on: https://go-review.googlesource.com/c/go/+/312429
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Michael Anthony Knyszek 2021-04-21 20:45:44 +00:00 committed by Michael Knyszek
parent 7e97e4e8cc
commit 6639bb894d

View File

@ -367,13 +367,7 @@ loop:
MOVQ CX, ret+0(FP)
RET
useQPC:
// Call with ABIInternal because we could be
// very deep in a nosplit context and the wrapper
// adds stack space.
// TODO(#40724): The result from nanotimeQPC will
// be passed in a register, so store that to the
// stack so we can return through a wrapper.
JMP runtime·nanotimeQPC<ABIInternal>(SB)
JMP runtime·nanotimeQPC(SB)
RET
TEXT time·now(SB),NOSPLIT,$0-24