@@ -122,36 +122,34 @@ TEXT runtime·madvise(SB), NOSPLIT, $0
122
122
// OS X comm page time offsets
123
123
// https://opensource.apple.com/source/xnu/xnu-4570.1.46/osfmk/i386/cpu_capabilities.h
124
124
125
- #define commpage_version 0x1e
126
-
127
- #define v12_nt_tsc_base 0x50
128
- #define v12_nt_scale 0x58
129
- #define v12_nt_shift 0x5c
130
- #define v12_nt_ns_base 0x60
131
- #define v12_nt_generation 0x68
132
- #define v12_gtod_generation 0x6c // obsolete since High Sierra (v13)
133
- #define v12_gtod_ns_base 0x70 // obsolete since High Sierra (v13)
134
- #define v12_gtod_sec_base 0x78 // obsolete since High Sierra (v13)
135
-
136
- #define v13_gtod_ns_base 0xd0
137
- #define v13_gtod_sec_ofs 0xd8
138
- #define v13_gtod_frac_ofs 0xe0
139
- #define v13_gtod_scale 0xe8
140
- #define v13_gtod_tkspersec 0xf0
125
+ #define nt_tsc_base 0x50
126
+ #define nt_scale 0x58
127
+ #define nt_shift 0x5c
128
+ #define nt_ns_base 0x60
129
+ #define nt_generation 0x68
130
+ #define gtod_generation 0x6c // obsolete since Darwin v17 (High Sierra)
131
+ #define gtod_ns_base 0x70 // obsolete since Darwin v17 (High Sierra)
132
+ #define gtod_sec_base 0x78 // obsolete since Darwin v17 (High Sierra)
133
+
134
+ #define v17_gtod_ns_base 0xd0
135
+ #define v17_gtod_sec_ofs 0xd8
136
+ #define v17_gtod_frac_ofs 0xe0
137
+ #define v17_gtod_scale 0xe8
138
+ #define v17_gtod_tkspersec 0xf0
141
139
142
140
TEXT runtime·nanotime(SB),NOSPLIT,$0 -8
143
141
MOVQ $0x7fffffe00000 , BP /* comm page base */
144
142
// Loop trying to take a consistent snapshot
145
143
// of the time parameters.
146
144
timeloop:
147
- MOVL v12_nt_generation (BP), R9
145
+ MOVL nt_generation (BP), R9
148
146
TESTL R9, R9
149
147
JZ timeloop
150
148
RDTSC
151
- MOVQ v12_nt_tsc_base (BP), R10
152
- MOVL v12_nt_scale (BP), R11
153
- MOVQ v12_nt_ns_base (BP), R12
154
- CMPL v12_nt_generation (BP), R9
149
+ MOVQ nt_tsc_base (BP), R10
150
+ MOVL nt_scale (BP), R11
151
+ MOVQ nt_ns_base (BP), R12
152
+ CMPL nt_generation (BP), R9
155
153
JNE timeloop
156
154
157
155
// Gathered all the data we need. Compute monotonic time:
@@ -173,32 +171,32 @@ TEXT time·now(SB), NOSPLIT, $32-24
173
171
// are used in the systime fallback, as the timeval address
174
172
// filled in by the system call.
175
173
MOVQ $0x7fffffe00000 , BP /* comm page base */
176
- CMPW commpage_version(BP ), $13
177
- JB v12 /* sierra and older */
174
+ CMPQ runtime·darwinVersion(SB ), $17
175
+ JB legacy /* sierra and older */
178
176
179
- // This is the new code, for macOS High Sierra (v13 ) and newer.
180
- v13 :
177
+ // This is the new code, for macOS High Sierra (Darwin v17 ) and newer.
178
+ v17 :
181
179
// Loop trying to take a consistent snapshot
182
180
// of the time parameters.
183
- timeloop13 :
184
- MOVQ v13_gtod_ns_base (BP), R12
181
+ timeloop17 :
182
+ MOVQ v17_gtod_ns_base (BP), R12
185
183
186
- MOVL v12_nt_generation (BP), CX
184
+ MOVL nt_generation (BP), CX
187
185
TESTL CX, CX
188
- JZ timeloop13
186
+ JZ timeloop17
189
187
RDTSC
190
- MOVQ v12_nt_tsc_base (BP), SI
191
- MOVL v12_nt_scale (BP), DI
192
- MOVQ v12_nt_ns_base (BP), BX
193
- CMPL v12_nt_generation (BP), CX
194
- JNE timeloop13
195
-
196
- MOVQ v13_gtod_sec_ofs (BP), R8
197
- MOVQ v13_gtod_frac_ofs (BP), R9
198
- MOVQ v13_gtod_scale (BP), R10
199
- MOVQ v13_gtod_tkspersec (BP), R11
200
- CMPQ v13_gtod_ns_base (BP), R12
201
- JNE timeloop13
188
+ MOVQ nt_tsc_base (BP), SI
189
+ MOVL nt_scale (BP), DI
190
+ MOVQ nt_ns_base (BP), BX
191
+ CMPL nt_generation (BP), CX
192
+ JNE timeloop17
193
+
194
+ MOVQ v17_gtod_sec_ofs (BP), R8
195
+ MOVQ v17_gtod_frac_ofs (BP), R9
196
+ MOVQ v17_gtod_scale (BP), R10
197
+ MOVQ v17_gtod_tkspersec (BP), R11
198
+ CMPQ v17_gtod_ns_base (BP), R12
199
+ JNE timeloop17
202
200
203
201
// Compute monotonic time
204
202
// mono = ((tsc - nt_tsc_base) * nt_scale) >> 32 + nt_ns_base
@@ -240,24 +238,24 @@ timeloop13:
240
238
MOVQ DX, nsec+8 (FP)
241
239
RET
242
240
243
- // This is the legacy code needed for macOS Sierra (v12 ) and older.
244
- v12 :
241
+ // This is the legacy code needed for macOS Sierra (Darwin v16 ) and older.
242
+ legacy :
245
243
// Loop trying to take a consistent snapshot
246
244
// of the time parameters.
247
245
timeloop:
248
- MOVL v12_gtod_generation (BP), R8
249
- MOVL v12_nt_generation (BP), R9
246
+ MOVL gtod_generation (BP), R8
247
+ MOVL nt_generation (BP), R9
250
248
TESTL R9, R9
251
249
JZ timeloop
252
250
RDTSC
253
- MOVQ v12_nt_tsc_base (BP), R10
254
- MOVL v12_nt_scale (BP), R11
255
- MOVQ v12_nt_ns_base (BP), R12
256
- CMPL v12_nt_generation (BP), R9
251
+ MOVQ nt_tsc_base (BP), R10
252
+ MOVL nt_scale (BP), R11
253
+ MOVQ nt_ns_base (BP), R12
254
+ CMPL nt_generation (BP), R9
257
255
JNE timeloop
258
- MOVQ v12_gtod_ns_base (BP), R13
259
- MOVQ v12_gtod_sec_base (BP), R14
260
- CMPL v12_gtod_generation (BP), R8
256
+ MOVQ gtod_ns_base (BP), R13
257
+ MOVQ gtod_sec_base (BP), R14
258
+ CMPL gtod_generation (BP), R8
261
259
JNE timeloop
262
260
263
261
// Gathered all the data we need. Compute:
0 commit comments