diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-04-27 16:04:56 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-04-28 20:16:36 +0000 |
commit | b36596b14f8d3bee586479323c56b5db416a49e5 (patch) | |
tree | 3a1c6f695e50e811844070decfc8b1e1d26e086b /src/runtime/time_windows_amd64.s | |
parent | 07e006dd9322cc484303e1bef3d58c7e51d4f92c (diff) | |
download | go-b36596b14f8d3bee586479323c56b5db416a49e5.tar.gz go-b36596b14f8d3bee586479323c56b5db416a49e5.zip |
runtime: move Windows time.now implementations into separate files
This is a step toward separating whether time.now is implemented in
assembly from whether we are using faketime.
Change-Id: I8bf059b44a103b034835e3d3b799319cc05e9552
Reviewed-on: https://go-review.googlesource.com/c/go/+/314273
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/time_windows_amd64.s')
-rw-r--r-- | src/runtime/time_windows_amd64.s | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/runtime/time_windows_amd64.s b/src/runtime/time_windows_amd64.s new file mode 100644 index 0000000000..7d1fcfbcf5 --- /dev/null +++ b/src/runtime/time_windows_amd64.s @@ -0,0 +1,53 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "go_asm.h" +#include "textflag.h" +#include "time_windows.h" + +TEXT time·now(SB),NOSPLIT,$0-24 + CMPB runtime·useQPCTime(SB), $0 + JNE useQPC + MOVQ $_INTERRUPT_TIME, DI +loop: + MOVL time_hi1(DI), AX + MOVL time_lo(DI), BX + MOVL time_hi2(DI), CX + CMPL AX, CX + JNE loop + SHLQ $32, AX + ORQ BX, AX + IMULQ $100, AX + MOVQ AX, mono+16(FP) + + MOVQ $_SYSTEM_TIME, DI +wall: + MOVL time_hi1(DI), AX + MOVL time_lo(DI), BX + MOVL time_hi2(DI), CX + CMPL AX, CX + JNE wall + SHLQ $32, AX + ORQ BX, AX + MOVQ $116444736000000000, DI + SUBQ DI, AX + IMULQ $100, AX + + // generated code for + // func f(x uint64) (uint64, uint64) { return x/1000000000, x%100000000 } + // adapted to reduce duplication + MOVQ AX, CX + MOVQ $1360296554856532783, AX + MULQ CX + ADDQ CX, DX + RCRQ $1, DX + SHRQ $29, DX + MOVQ DX, sec+0(FP) + IMULQ $1000000000, DX + SUBQ DX, CX + MOVL CX, nsec+8(FP) + RET +useQPC: + JMP runtime·nowQPC(SB) + RET |