Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(17)

Side by Side Diff: src/pkg/runtime/asm_386.s

Issue 160200044: [dev.power64] code review 160200044: build: merge default into dev.power64 (Closed)
Patch Set: diff -r be0c14f62257b42485019e9e1db23cf40d2e249f https://code.google.com/p/go Created 10 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/runtime/arch_arm.go ('k') | src/pkg/runtime/asm_amd64.s » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 #include "zasm_GOOS_GOARCH.h" 5 #include "zasm_GOOS_GOARCH.h"
6 #include "funcdata.h" 6 #include "funcdata.h"
7 #include "../../cmd/ld/textflag.h" 7 #include "textflag.h"
8 8
9 TEXT _rt0_go(SB),NOSPLIT,$0 9 TEXT runtime·rt0_go(SB),NOSPLIT,$0
10 // copy arguments forward on an even stack 10 // copy arguments forward on an even stack
11 MOVL argc+0(FP), AX 11 MOVL argc+0(FP), AX
12 MOVL argv+4(FP), BX 12 MOVL argv+4(FP), BX
13 SUBL $128, SP // plenty of scratch 13 SUBL $128, SP // plenty of scratch
14 ANDL $~15, SP 14 ANDL $~15, SP
15 MOVL AX, 120(SP) // save argc, argv away 15 MOVL AX, 120(SP) // save argc, argv away
16 MOVL BX, 124(SP) 16 MOVL BX, 124(SP)
17 17
18 // set default stack bounds. 18 // set default stack bounds.
19 // _cgo_init may update stackguard. 19 // _cgo_init may update stackguard.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 CALL runtime·check(SB) 86 CALL runtime·check(SB)
87 87
88 // saved argc, argv 88 // saved argc, argv
89 MOVL 120(SP), AX 89 MOVL 120(SP), AX
90 MOVL AX, 0(SP) 90 MOVL AX, 0(SP)
91 MOVL 124(SP), AX 91 MOVL 124(SP), AX
92 MOVL AX, 4(SP) 92 MOVL AX, 4(SP)
93 CALL runtime·args(SB) 93 CALL runtime·args(SB)
94 CALL runtime·osinit(SB) 94 CALL runtime·osinit(SB)
95 CALL runtime·hashinit(SB)
96 CALL runtime·schedinit(SB) 95 CALL runtime·schedinit(SB)
97 96
98 // create a new goroutine to start program 97 // create a new goroutine to start program
99 PUSHL $runtime·main·f(SB) // entry 98 PUSHL $runtime·main·f(SB) // entry
100 PUSHL $0 // arg size 99 PUSHL $0 // arg size
101 ARGSIZE(8) 100 ARGSIZE(8)
102 CALL runtime·newproc(SB) 101 CALL runtime·newproc(SB)
103 ARGSIZE(-1) 102 ARGSIZE(-1)
104 POPL AX 103 POPL AX
105 POPL AX 104 POPL AX
(...skipping 21 matching lines...) Expand all
127 POPL AX 126 POPL AX
128 RET 127 RET
129 128
130 /* 129 /*
131 * go-routine 130 * go-routine
132 */ 131 */
133 132
134 // void gosave(Gobuf*) 133 // void gosave(Gobuf*)
135 // save state in Gobuf; setjmp 134 // save state in Gobuf; setjmp
136 TEXT runtime·gosave(SB), NOSPLIT, $0-4 135 TEXT runtime·gosave(SB), NOSPLIT, $0-4
137 » MOVL» 4(SP), AX» » // gobuf 136 » MOVL» buf+0(FP), AX» » // gobuf
138 » LEAL» 4(SP), BX» » // caller's SP 137 » LEAL» buf+0(FP), BX» » // caller's SP
139 MOVL BX, gobuf_sp(AX) 138 MOVL BX, gobuf_sp(AX)
140 MOVL 0(SP), BX // caller's PC 139 MOVL 0(SP), BX // caller's PC
141 MOVL BX, gobuf_pc(AX) 140 MOVL BX, gobuf_pc(AX)
142 MOVL $0, gobuf_ret(AX) 141 MOVL $0, gobuf_ret(AX)
143 MOVL $0, gobuf_ctxt(AX) 142 MOVL $0, gobuf_ctxt(AX)
144 get_tls(CX) 143 get_tls(CX)
145 MOVL g(CX), BX 144 MOVL g(CX), BX
146 MOVL BX, gobuf_g(AX) 145 MOVL BX, gobuf_g(AX)
147 RET 146 RET
148 147
149 // void gogo(Gobuf*) 148 // void gogo(Gobuf*)
150 // restore state from Gobuf; longjmp 149 // restore state from Gobuf; longjmp
151 TEXT runtime·gogo(SB), NOSPLIT, $0-4 150 TEXT runtime·gogo(SB), NOSPLIT, $0-4
152 » MOVL» 4(SP), BX» » // gobuf 151 » MOVL» buf+0(FP), BX» » // gobuf
153 MOVL gobuf_g(BX), DX 152 MOVL gobuf_g(BX), DX
154 MOVL 0(DX), CX // make sure g != nil 153 MOVL 0(DX), CX // make sure g != nil
155 get_tls(CX) 154 get_tls(CX)
156 MOVL DX, g(CX) 155 MOVL DX, g(CX)
157 MOVL gobuf_sp(BX), SP // restore SP 156 MOVL gobuf_sp(BX), SP // restore SP
158 MOVL gobuf_ret(BX), AX 157 MOVL gobuf_ret(BX), AX
159 MOVL gobuf_ctxt(BX), DX 158 MOVL gobuf_ctxt(BX), DX
160 MOVL $0, gobuf_sp(BX) // clear to help garbage collector 159 MOVL $0, gobuf_sp(BX) // clear to help garbage collector
161 MOVL $0, gobuf_ret(BX) 160 MOVL $0, gobuf_ret(BX)
162 MOVL $0, gobuf_ctxt(BX) 161 MOVL $0, gobuf_ctxt(BX)
163 MOVL gobuf_pc(BX), BX 162 MOVL gobuf_pc(BX), BX
164 JMP BX 163 JMP BX
165 164
166 // void mcall(void (*fn)(G*)) 165 // func mcall(fn func(*g))
167 // Switch to m->g0's stack, call fn(g). 166 // Switch to m->g0's stack, call fn(g).
168 // Fn must never return. It should gogo(&g->sched) 167 // Fn must never return. It should gogo(&g->sched)
169 // to keep running g. 168 // to keep running g.
170 TEXT runtime·mcall(SB), NOSPLIT, $0-4 169 TEXT runtime·mcall(SB), NOSPLIT, $0-4
171 MOVL fn+0(FP), DI 170 MOVL fn+0(FP), DI
172 ········ 171 ········
173 get_tls(CX) 172 get_tls(CX)
174 MOVL g(CX), AX // save state in g->sched 173 MOVL g(CX), AX // save state in g->sched
175 MOVL 0(SP), BX // caller's PC 174 MOVL 0(SP), BX // caller's PC
176 MOVL BX, (g_sched+gobuf_pc)(AX) 175 MOVL BX, (g_sched+gobuf_pc)(AX)
177 » LEAL» 4(SP), BX» // caller's SP 176 » LEAL» fn+0(FP), BX» // caller's SP
178 MOVL BX, (g_sched+gobuf_sp)(AX) 177 MOVL BX, (g_sched+gobuf_sp)(AX)
179 MOVL AX, (g_sched+gobuf_g)(AX) 178 MOVL AX, (g_sched+gobuf_g)(AX)
180 179
181 // switch to m->g0 & its stack, call fn 180 // switch to m->g0 & its stack, call fn
182 MOVL g(CX), BX 181 MOVL g(CX), BX
183 MOVL g_m(BX), BX 182 MOVL g_m(BX), BX
184 MOVL m_g0(BX), SI 183 MOVL m_g0(BX), SI
185 CMPL SI, AX // if g == m->g0 call badmcall 184 CMPL SI, AX // if g == m->g0 call badmcall
186 JNE 3(PC) 185 JNE 3(PC)
187 MOVL $runtime·badmcall(SB), AX 186 MOVL $runtime·badmcall(SB), AX
188 JMP AX 187 JMP AX
189 MOVL SI, g(CX) // g = m->g0 188 MOVL SI, g(CX) // g = m->g0
190 MOVL (g_sched+gobuf_sp)(SI), SP // sp = m->g0->sched.sp 189 MOVL (g_sched+gobuf_sp)(SI), SP // sp = m->g0->sched.sp
191 PUSHL AX 190 PUSHL AX
191 MOVL DI, DX
192 MOVL 0(DI), DI
192 CALL DI 193 CALL DI
193 POPL AX 194 POPL AX
194 MOVL $runtime·badmcall2(SB), AX 195 MOVL $runtime·badmcall2(SB), AX
195 JMP AX 196 JMP AX
196 RET 197 RET
197 198
198 // switchtoM is a dummy routine that onM leaves at the bottom 199 // switchtoM is a dummy routine that onM leaves at the bottom
199 // of the G stack. We need to distinguish the routine that 200 // of the G stack. We need to distinguish the routine that
200 // lives at the bottom of the G stack from the one that lives 201 // lives at the bottom of the G stack from the one that lives
201 // at the top of the M stack because the one at the top of 202 // at the top of the M stack because the one at the top of
202 // the M stack terminates the stack walk (see topofstack()). 203 // the M stack terminates the stack walk (see topofstack()).
203 TEXT runtime·switchtoM(SB), NOSPLIT, $0-4 204 TEXT runtime·switchtoM(SB), NOSPLIT, $0-4
204 RET 205 RET
205 206
206 // void onM(void (*fn)()) 207 // func onM(fn func())
207 // calls fn() on the M stack.
208 // switches to the M stack if not already on it, and
209 // switches back when fn() returns.
210 TEXT runtime·onM(SB), NOSPLIT, $0-4 208 TEXT runtime·onM(SB), NOSPLIT, $0-4
211 MOVL fn+0(FP), DI // DI = fn 209 MOVL fn+0(FP), DI // DI = fn
212 get_tls(CX) 210 get_tls(CX)
213 MOVL g(CX), AX // AX = g 211 MOVL g(CX), AX // AX = g
214 MOVL g_m(AX), BX // BX = m 212 MOVL g_m(AX), BX // BX = m
213
215 MOVL m_g0(BX), DX // DX = g0 214 MOVL m_g0(BX), DX // DX = g0
216 CMPL AX, DX 215 CMPL AX, DX
217 JEQ onm 216 JEQ onm
218 217
218 MOVL m_curg(BX), BP
219 CMPL AX, BP
220 JEQ oncurg
221 ········
222 // Not g0, not curg. Must be gsignal, but that's not allowed.
223 // Hide call from linker nosplit analysis.
224 MOVL $runtime·badonm(SB), AX
225 CALL AX
226
227 oncurg:
219 // save our state in g->sched. Pretend to 228 // save our state in g->sched. Pretend to
220 // be switchtoM if the G stack is scanned. 229 // be switchtoM if the G stack is scanned.
221 MOVL $runtime·switchtoM(SB), (g_sched+gobuf_pc)(AX) 230 MOVL $runtime·switchtoM(SB), (g_sched+gobuf_pc)(AX)
222 MOVL SP, (g_sched+gobuf_sp)(AX) 231 MOVL SP, (g_sched+gobuf_sp)(AX)
223 MOVL AX, (g_sched+gobuf_g)(AX) 232 MOVL AX, (g_sched+gobuf_g)(AX)
224 233
225 // switch to g0 234 // switch to g0
226 MOVL DX, g(CX) 235 MOVL DX, g(CX)
227 » MOVL» (g_sched+gobuf_sp)(DX), SP 236 » MOVL» (g_sched+gobuf_sp)(DX), BX
237 » // make it look like mstart called onM on g0, to stop traceback
238 » SUBL» $4, BX
239 » MOVL» $runtime·mstart(SB), DX
240 » MOVL» DX, 0(BX)
241 » MOVL» BX, SP
228 242
229 // call target function 243 // call target function
230 ARGSIZE(0) 244 ARGSIZE(0)
245 MOVL DI, DX
246 MOVL 0(DI), DI
231 CALL DI 247 CALL DI
232 248
233 // switch back to g 249 // switch back to g
234 get_tls(CX) 250 get_tls(CX)
235 MOVL g(CX), AX 251 MOVL g(CX), AX
236 MOVL g_m(AX), BX 252 MOVL g_m(AX), BX
237 MOVL m_curg(BX), AX 253 MOVL m_curg(BX), AX
238 MOVL AX, g(CX) 254 MOVL AX, g(CX)
239 MOVL (g_sched+gobuf_sp)(AX), SP 255 MOVL (g_sched+gobuf_sp)(AX), SP
240 MOVL $0, (g_sched+gobuf_sp)(AX) 256 MOVL $0, (g_sched+gobuf_sp)(AX)
241 RET 257 RET
242 258
243 onm: 259 onm:
244 // already on m stack, just call directly 260 // already on m stack, just call directly
261 MOVL DI, DX
262 MOVL 0(DI), DI
245 CALL DI 263 CALL DI
246 RET 264 RET
247 265
248 /* 266 /*
249 * support for morestack 267 * support for morestack
250 */ 268 */
251 269
252 // Called during function prolog when more stack is needed. 270 // Called during function prolog when more stack is needed.
253 // 271 //
254 // The traceback routines see morestack on a g0 as being 272 // The traceback routines see morestack on a g0 as being
255 // the top of a stack (for example, morestack calling newstack 273 // the top of a stack (for example, morestack calling newstack
256 // calling the scheduler calling newm calling gc), so we must 274 // calling the scheduler calling newm calling gc), so we must
257 // record an argument size. For that purpose, it has no arguments. 275 // record an argument size. For that purpose, it has no arguments.
258 TEXT runtime·morestack(SB),NOSPLIT,$0-0 276 TEXT runtime·morestack(SB),NOSPLIT,$0-0
259 // Cannot grow scheduler stack (m->g0). 277 // Cannot grow scheduler stack (m->g0).
260 get_tls(CX) 278 get_tls(CX)
261 MOVL g(CX), BX 279 MOVL g(CX), BX
262 MOVL g_m(BX), BX 280 MOVL g_m(BX), BX
263 MOVL m_g0(BX), SI 281 MOVL m_g0(BX), SI
264 CMPL g(CX), SI 282 CMPL g(CX), SI
265 JNE 2(PC) 283 JNE 2(PC)
266 INT $3 284 INT $3
267 285
286 // Cannot grow signal stack.
287 MOVL m_gsignal(BX), SI
288 CMPL g(CX), SI
289 JNE 2(PC)
290 INT $3
291
268 // frame size in DI 292 // frame size in DI
269 // arg size in AX 293 // arg size in AX
270 // Save in m. 294 // Save in m.
271 MOVL DI, m_moreframesize(BX) 295 MOVL DI, m_moreframesize(BX)
272 MOVL AX, m_moreargsize(BX) 296 MOVL AX, m_moreargsize(BX)
273 297
274 // Called from f. 298 // Called from f.
275 // Set m->morebuf to f's caller. 299 // Set m->morebuf to f's caller.
276 MOVL 4(SP), DI // f's caller's PC 300 MOVL 4(SP), DI // f's caller's PC
277 MOVL DI, (m_morebuf+gobuf_pc)(BX) 301 MOVL DI, (m_morebuf+gobuf_pc)(BX)
(...skipping 19 matching lines...) Expand all
297 MOVL -4(AX), BX // fault if CALL would, before smashing SP 321 MOVL -4(AX), BX // fault if CALL would, before smashing SP
298 MOVL AX, SP 322 MOVL AX, SP
299 CALL runtime·newstack(SB) 323 CALL runtime·newstack(SB)
300 MOVL $0, 0x1003 // crash if newstack returns 324 MOVL $0, 0x1003 // crash if newstack returns
301 RET 325 RET
302 326
303 TEXT runtime·morestack_noctxt(SB),NOSPLIT,$0-0 327 TEXT runtime·morestack_noctxt(SB),NOSPLIT,$0-0
304 MOVL $0, DX 328 MOVL $0, DX
305 JMP runtime·morestack(SB) 329 JMP runtime·morestack(SB)
306 330
307 // Called from panic. Mimics morestack,
308 // reuses stack growth code to create a frame
309 // with the desired args running the desired function.
310 //
311 // func call(fn *byte, arg *byte, argsize uint32).
312 TEXT runtime·newstackcall(SB), NOSPLIT, $0-12
313 get_tls(CX)
314 MOVL g(CX), BX
315 MOVL g_m(BX), BX
316
317 // Save our caller's state as the PC and SP to
318 // restore when returning from f.
319 MOVL 0(SP), AX // our caller's PC
320 MOVL AX, (m_morebuf+gobuf_pc)(BX)
321 LEAL 4(SP), AX // our caller's SP
322 MOVL AX, (m_morebuf+gobuf_sp)(BX)
323 MOVL g(CX), AX
324 MOVL AX, (m_morebuf+gobuf_g)(BX)
325
326 // Save our own state as the PC and SP to restore
327 // if this goroutine needs to be restarted.
328 MOVL $runtime·newstackcall(SB), (g_sched+gobuf_pc)(AX)
329 MOVL SP, (g_sched+gobuf_sp)(AX)
330
331 // Set up morestack arguments to call f on a new stack.
332 // We set f's frame size to 1, as a hint to newstack
333 // that this is a call from runtime·newstackcall.
334 // If it turns out that f needs a larger frame than
335 // the default stack, f's usual stack growth prolog will
336 // allocate a new segment (and recopy the arguments).
337 MOVL 4(SP), AX // fn
338 MOVL 8(SP), DX // arg frame
339 MOVL 12(SP), CX // arg size
340
341 MOVL AX, m_cret(BX) // f's PC
342 MOVL DX, m_moreargp(BX) // f's argument pointer
343 MOVL CX, m_moreargsize(BX) // f's argument size
344 MOVL $1, m_moreframesize(BX) // f's frame size
345
346 // Call newstack on m->g0's stack.
347 MOVL m_g0(BX), BP
348 get_tls(CX)
349 MOVL BP, g(CX)
350 MOVL (g_sched+gobuf_sp)(BP), SP
351 CALL runtime·newstack(SB)
352 MOVL $0, 0x1103 // crash if newstack returns
353 RET
354
355 // reflect·call: call a function with the given argument list 331 // reflect·call: call a function with the given argument list
356 // func call(f *FuncVal, arg *byte, argsize uint32). 332 // func call(f *FuncVal, arg *byte, argsize, retoffset uint32).
357 // we don't have variable-sized frames, so we use a small number 333 // we don't have variable-sized frames, so we use a small number
358 // of constant-sized-frame functions to encode a few bits of size in the pc. 334 // of constant-sized-frame functions to encode a few bits of size in the pc.
359 // Caution: ugly multiline assembly macros in your future! 335 // Caution: ugly multiline assembly macros in your future!
360 336
361 #define DISPATCH(NAME,MAXSIZE) \ 337 #define DISPATCH(NAME,MAXSIZE) \
362 CMPL CX, $MAXSIZE; \ 338 CMPL CX, $MAXSIZE; \
363 JA 3(PC); \ 339 JA 3(PC); \
364 » MOVL» $NAME(SB), AX;» \ 340 » MOVL» $NAME(SB), AX;» » \
365 JMP AX 341 JMP AX
366 // Note: can't just "JMP NAME(SB)" - bad inlining results. 342 // Note: can't just "JMP NAME(SB)" - bad inlining results.
367 343
368 TEXT reflect·call(SB), NOSPLIT, $0-16 344 TEXT reflect·call(SB), NOSPLIT, $0-16
369 MOVL argsize+8(FP), CX 345 MOVL argsize+8(FP), CX
370 DISPATCH(runtime·call16, 16) 346 DISPATCH(runtime·call16, 16)
371 DISPATCH(runtime·call32, 32) 347 DISPATCH(runtime·call32, 32)
372 DISPATCH(runtime·call64, 64) 348 DISPATCH(runtime·call64, 64)
373 DISPATCH(runtime·call128, 128) 349 DISPATCH(runtime·call128, 128)
374 DISPATCH(runtime·call256, 256) 350 DISPATCH(runtime·call256, 256)
(...skipping 15 matching lines...) Expand all
390 DISPATCH(runtime·call16777216, 16777216) 366 DISPATCH(runtime·call16777216, 16777216)
391 DISPATCH(runtime·call33554432, 33554432) 367 DISPATCH(runtime·call33554432, 33554432)
392 DISPATCH(runtime·call67108864, 67108864) 368 DISPATCH(runtime·call67108864, 67108864)
393 DISPATCH(runtime·call134217728, 134217728) 369 DISPATCH(runtime·call134217728, 134217728)
394 DISPATCH(runtime·call268435456, 268435456) 370 DISPATCH(runtime·call268435456, 268435456)
395 DISPATCH(runtime·call536870912, 536870912) 371 DISPATCH(runtime·call536870912, 536870912)
396 DISPATCH(runtime·call1073741824, 1073741824) 372 DISPATCH(runtime·call1073741824, 1073741824)
397 MOVL $runtime·badreflectcall(SB), AX 373 MOVL $runtime·badreflectcall(SB), AX
398 JMP AX 374 JMP AX
399 375
400 // Argument map for the callXX frames. Each has one 376 // Argument map for the callXX frames. Each has one stack map.
401 // stack map (for the single call) with 3 arguments.
402 DATA gcargs_reflectcall<>+0x00(SB)/4, $1 // 1 stackmap 377 DATA gcargs_reflectcall<>+0x00(SB)/4, $1 // 1 stackmap
403 DATA gcargs_reflectcall<>+0x04(SB)/4, $6 // 3 args 378 DATA gcargs_reflectcall<>+0x04(SB)/4, $8 // 4 words
404 DATA gcargs_reflectcall<>+0x08(SB)/4, $(const_BitsPointer+(const_BitsPointer<<2) +(const_BitsScalar<<4)) 379 DATA gcargs_reflectcall<>+0x08(SB)/1, $(const_BitsPointer+(const_BitsPointer<<2) +(const_BitsScalar<<4)+(const_BitsScalar<<6))
405 GLOBL gcargs_reflectcall<>(SB),RODATA,$12 380 GLOBL gcargs_reflectcall<>(SB),RODATA,$12
406 381
407 // callXX frames have no locals 382 // callXX frames have no locals
408 DATA gclocals_reflectcall<>+0x00(SB)/4, $1 // 1 stackmap 383 DATA gclocals_reflectcall<>+0x00(SB)/4, $1 // 1 stackmap
409 DATA gclocals_reflectcall<>+0x04(SB)/4, $0 // 0 locals 384 DATA gclocals_reflectcall<>+0x04(SB)/4, $0 // 0 locals
410 GLOBL gclocals_reflectcall<>(SB),RODATA,$8 385 GLOBL gclocals_reflectcall<>(SB),RODATA,$8
411 386
412 #define CALLFN(NAME,MAXSIZE) \ 387 #define CALLFN(NAME,MAXSIZE) \
413 TEXT NAME(SB), WRAPPER, $MAXSIZE-16; \ 388 TEXT NAME(SB), WRAPPER, $MAXSIZE-16; \
414 FUNCDATA $FUNCDATA_ArgsPointerMaps,gcargs_reflectcall<>(SB); \ 389 FUNCDATA $FUNCDATA_ArgsPointerMaps,gcargs_reflectcall<>(SB); \
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 MOVL AX, m_cret(BX) 449 MOVL AX, m_cret(BX)
475 450
476 // Call oldstack on m->g0's stack. 451 // Call oldstack on m->g0's stack.
477 MOVL m_g0(BX), BP 452 MOVL m_g0(BX), BP
478 MOVL BP, g(CX) 453 MOVL BP, g(CX)
479 MOVL (g_sched+gobuf_sp)(BP), SP 454 MOVL (g_sched+gobuf_sp)(BP), SP
480 CALL runtime·oldstack(SB) 455 CALL runtime·oldstack(SB)
481 MOVL $0, 0x1004 // crash if oldstack returns 456 MOVL $0, 0x1004 // crash if oldstack returns
482 RET 457 RET
483 458
484
485 // bool cas(int32 *val, int32 old, int32 new) 459 // bool cas(int32 *val, int32 old, int32 new)
486 // Atomically: 460 // Atomically:
487 // if(*val == old){ 461 // if(*val == old){
488 // *val = new; 462 // *val = new;
489 // return 1; 463 // return 1;
490 // }else 464 // }else
491 // return 0; 465 // return 0;
492 TEXT runtime·cas(SB), NOSPLIT, $0-12 466 TEXT runtime·cas(SB), NOSPLIT, $0-13
493 » MOVL» 4(SP), BX 467 » MOVL» ptr+0(FP), BX
494 » MOVL» 8(SP), AX 468 » MOVL» old+4(FP), AX
495 » MOVL» 12(SP), CX 469 » MOVL» new+8(FP), CX
496 LOCK 470 LOCK
497 CMPXCHGL CX, 0(BX) 471 CMPXCHGL CX, 0(BX)
498 » JZ 3(PC) 472 » JZ 4(PC)
499 MOVL $0, AX 473 MOVL $0, AX
474 MOVB AX, ret+12(FP)
500 RET 475 RET
501 MOVL $1, AX 476 MOVL $1, AX
477 MOVB AX, ret+12(FP)
502 RET 478 RET
503 479
480 TEXT runtime·casuintptr(SB), NOSPLIT, $0-13
481 JMP runtime·cas(SB)
482
483 TEXT runtime·atomicloaduintptr(SB), NOSPLIT, $0-8
484 JMP runtime·atomicload(SB)
485
486 TEXT runtime·atomicloaduint(SB), NOSPLIT, $0-8
487 JMP runtime·atomicload(SB)
488
504 // bool runtime·cas64(uint64 *val, uint64 old, uint64 new) 489 // bool runtime·cas64(uint64 *val, uint64 old, uint64 new)
505 // Atomically: 490 // Atomically:
506 // if(*val == *old){ 491 // if(*val == *old){
507 // *val = new; 492 // *val = new;
508 // return 1; 493 // return 1;
509 // } else { 494 // } else {
510 // return 0; 495 // return 0;
511 // } 496 // }
512 TEXT runtime·cas64(SB), NOSPLIT, $0-20 497 TEXT runtime·cas64(SB), NOSPLIT, $0-21
513 » MOVL» 4(SP), BP 498 » MOVL» ptr+0(FP), BP
514 » MOVL» 8(SP), AX 499 » MOVL» old_lo+4(FP), AX
515 » MOVL» 12(SP), DX 500 » MOVL» old_hi+8(FP), DX
516 » MOVL» 16(SP), BX 501 » MOVL» new_lo+12(FP), BX
517 » MOVL» 20(SP), CX 502 » MOVL» new_hi+16(FP), CX
518 LOCK 503 LOCK
519 CMPXCHG8B 0(BP) 504 CMPXCHG8B 0(BP)
520 JNZ cas64_fail 505 JNZ cas64_fail
521 MOVL $1, AX 506 MOVL $1, AX
507 MOVB AX, ret+20(FP)
522 RET 508 RET
523 cas64_fail: 509 cas64_fail:
524 MOVL $0, AX 510 MOVL $0, AX
511 MOVB AX, ret+20(FP)
525 RET 512 RET
526 513
527 // bool casp(void **p, void *old, void *new) 514 // bool casp(void **p, void *old, void *new)
528 // Atomically: 515 // Atomically:
529 // if(*p == old){ 516 // if(*p == old){
530 // *p = new; 517 // *p = new;
531 // return 1; 518 // return 1;
532 // }else 519 // }else
533 // return 0; 520 // return 0;
534 TEXT runtime·casp(SB), NOSPLIT, $0-12 521 TEXT runtime·casp(SB), NOSPLIT, $0-13
535 » MOVL» 4(SP), BX 522 » MOVL» ptr+0(FP), BX
536 » MOVL» 8(SP), AX 523 » MOVL» old+4(FP), AX
537 » MOVL» 12(SP), CX 524 » MOVL» new+8(FP), CX
538 LOCK 525 LOCK
539 CMPXCHGL CX, 0(BX) 526 CMPXCHGL CX, 0(BX)
540 » JZ 3(PC) 527 » JZ 4(PC)
541 MOVL $0, AX 528 MOVL $0, AX
529 MOVB AX, ret+12(FP)
542 RET 530 RET
543 MOVL $1, AX 531 MOVL $1, AX
532 MOVB AX, ret+12(FP)
544 RET 533 RET
545 534
546 // uint32 xadd(uint32 volatile *val, int32 delta) 535 // uint32 xadd(uint32 volatile *val, int32 delta)
547 // Atomically: 536 // Atomically:
548 // *val += delta; 537 // *val += delta;
549 // return *val; 538 // return *val;
550 TEXT runtime·xadd(SB), NOSPLIT, $0-8 539 TEXT runtime·xadd(SB), NOSPLIT, $0-12
551 » MOVL» 4(SP), BX 540 » MOVL» ptr+0(FP), BX
552 » MOVL» 8(SP), AX 541 » MOVL» delta+4(FP), AX
553 MOVL AX, CX 542 MOVL AX, CX
554 LOCK 543 LOCK
555 XADDL AX, 0(BX) 544 XADDL AX, 0(BX)
556 ADDL CX, AX 545 ADDL CX, AX
546 MOVL AX, ret+8(FP)
557 RET 547 RET
558 548
559 TEXT runtime·xchg(SB), NOSPLIT, $0-8 549 TEXT runtime·xchg(SB), NOSPLIT, $0-12
560 » MOVL» 4(SP), BX 550 » MOVL» ptr+0(FP), BX
561 » MOVL» 8(SP), AX 551 » MOVL» new+4(FP), AX
562 XCHGL AX, 0(BX) 552 XCHGL AX, 0(BX)
553 MOVL AX, ret+8(FP)
563 RET 554 RET
564 555
565 TEXT runtime·xchgp(SB), NOSPLIT, $0-8 556 TEXT runtime·xchgp(SB), NOSPLIT, $0-12
566 » MOVL» 4(SP), BX 557 » MOVL» ptr+0(FP), BX
567 » MOVL» 8(SP), AX 558 » MOVL» new+4(FP), AX
568 XCHGL AX, 0(BX) 559 XCHGL AX, 0(BX)
560 MOVL AX, ret+8(FP)
569 RET 561 RET
570 562
563 TEXT runtime·xchguintptr(SB), NOSPLIT, $0-12
564 JMP runtime·xchg(SB)
565
571 TEXT runtime·procyield(SB),NOSPLIT,$0-0 566 TEXT runtime·procyield(SB),NOSPLIT,$0-0
572 » MOVL» 4(SP), AX 567 » MOVL» cycles+0(FP), AX
573 again: 568 again:
574 PAUSE 569 PAUSE
575 SUBL $1, AX 570 SUBL $1, AX
576 JNZ again 571 JNZ again
577 RET 572 RET
578 573
579 TEXT runtime·atomicstorep(SB), NOSPLIT, $0-8 574 TEXT runtime·atomicstorep(SB), NOSPLIT, $0-8
580 » MOVL» 4(SP), BX 575 » MOVL» ptr+0(FP), BX
581 » MOVL» 8(SP), AX 576 » MOVL» val+4(FP), AX
582 XCHGL AX, 0(BX) 577 XCHGL AX, 0(BX)
583 RET 578 RET
584 579
585 TEXT runtime·atomicstore(SB), NOSPLIT, $0-8 580 TEXT runtime·atomicstore(SB), NOSPLIT, $0-8
586 » MOVL» 4(SP), BX 581 » MOVL» ptr+0(FP), BX
587 » MOVL» 8(SP), AX 582 » MOVL» val+4(FP), AX
588 XCHGL AX, 0(BX) 583 XCHGL AX, 0(BX)
589 RET 584 RET
590 585
591 // uint64 atomicload64(uint64 volatile* addr); 586 // uint64 atomicload64(uint64 volatile* addr);
592 // so actually 587 TEXT runtime·atomicload64(SB), NOSPLIT, $0-12
593 // void atomicload64(uint64 *res, uint64 volatile *addr); 588 » MOVL» ptr+0(FP), AX
594 TEXT runtime·atomicload64(SB), NOSPLIT, $0-8 589 » LEAL» ret_lo+4(FP), BX
595 » MOVL» 4(SP), BX
596 » MOVL» 8(SP), AX
597 // MOVQ (%EAX), %MM0 590 // MOVQ (%EAX), %MM0
598 BYTE $0x0f; BYTE $0x6f; BYTE $0x00 591 BYTE $0x0f; BYTE $0x6f; BYTE $0x00
599 // MOVQ %MM0, 0(%EBX) 592 // MOVQ %MM0, 0(%EBX)
600 BYTE $0x0f; BYTE $0x7f; BYTE $0x03 593 BYTE $0x0f; BYTE $0x7f; BYTE $0x03
601 // EMMS 594 // EMMS
602 BYTE $0x0F; BYTE $0x77 595 BYTE $0x0F; BYTE $0x77
603 RET 596 RET
604 597
605 // void runtime·atomicstore64(uint64 volatile* addr, uint64 v); 598 // void runtime·atomicstore64(uint64 volatile* addr, uint64 v);
606 TEXT runtime·atomicstore64(SB), NOSPLIT, $0-12 599 TEXT runtime·atomicstore64(SB), NOSPLIT, $0-12
607 » MOVL» 4(SP), AX 600 » MOVL» ptr+0(FP), AX
608 // MOVQ and EMMS were introduced on the Pentium MMX. 601 // MOVQ and EMMS were introduced on the Pentium MMX.
609 // MOVQ 0x8(%ESP), %MM0 602 // MOVQ 0x8(%ESP), %MM0
610 BYTE $0x0f; BYTE $0x6f; BYTE $0x44; BYTE $0x24; BYTE $0x08 603 BYTE $0x0f; BYTE $0x6f; BYTE $0x44; BYTE $0x24; BYTE $0x08
611 // MOVQ %MM0, (%EAX) 604 // MOVQ %MM0, (%EAX)
612 BYTE $0x0f; BYTE $0x7f; BYTE $0x00· 605 BYTE $0x0f; BYTE $0x7f; BYTE $0x00·
613 // EMMS 606 // EMMS
614 BYTE $0x0F; BYTE $0x77 607 BYTE $0x0F; BYTE $0x77
615 // This is essentially a no-op, but it provides required memory fencing. 608 // This is essentially a no-op, but it provides required memory fencing.
616 // It can be replaced with MFENCE, but MFENCE was introduced only on the Pentium4 (SSE2). 609 // It can be replaced with MFENCE, but MFENCE was introduced only on the Pentium4 (SSE2).
617 MOVL $0, AX 610 MOVL $0, AX
618 LOCK 611 LOCK
619 XADDL AX, (SP) 612 XADDL AX, (SP)
620 RET 613 RET
621 614
615 // void runtime·atomicor8(byte volatile*, byte);
616 TEXT runtime·atomicor8(SB), NOSPLIT, $0-5
617 MOVL ptr+0(FP), AX
618 MOVB val+4(FP), BX
619 LOCK
620 ORB BX, (AX)
621 RET
622
622 // void jmpdefer(fn, sp); 623 // void jmpdefer(fn, sp);
623 // called from deferreturn. 624 // called from deferreturn.
624 // 1. pop the caller 625 // 1. pop the caller
625 // 2. sub 5 bytes from the callers return 626 // 2. sub 5 bytes from the callers return
626 // 3. jmp to the argument 627 // 3. jmp to the argument
627 TEXT runtime·jmpdefer(SB), NOSPLIT, $0-8 628 TEXT runtime·jmpdefer(SB), NOSPLIT, $0-8
628 » MOVL» 4(SP), DX» // fn 629 » MOVL» fv+0(FP), DX» // fn
629 » MOVL» 8(SP), BX» // caller sp 630 » MOVL» argp+4(FP), BX» // caller sp
630 LEAL -4(BX), SP // caller sp after CALL 631 LEAL -4(BX), SP // caller sp after CALL
631 SUBL $5, (SP) // return to CALL again 632 SUBL $5, (SP) // return to CALL again
632 MOVL 0(DX), BX 633 MOVL 0(DX), BX
633 JMP BX // but first run the deferred function 634 JMP BX // but first run the deferred function
634 635
635 // Save state of caller into g->sched. 636 // Save state of caller into g->sched.
636 TEXT gosave<>(SB),NOSPLIT,$0 637 TEXT gosave<>(SB),NOSPLIT,$0
637 PUSHL AX 638 PUSHL AX
638 PUSHL BX 639 PUSHL BX
639 get_tls(BX) 640 get_tls(BX)
640 MOVL g(BX), BX 641 MOVL g(BX), BX
641 LEAL arg+0(FP), AX 642 LEAL arg+0(FP), AX
642 MOVL AX, (g_sched+gobuf_sp)(BX) 643 MOVL AX, (g_sched+gobuf_sp)(BX)
643 MOVL -4(AX), AX 644 MOVL -4(AX), AX
644 MOVL AX, (g_sched+gobuf_pc)(BX) 645 MOVL AX, (g_sched+gobuf_pc)(BX)
645 MOVL $0, (g_sched+gobuf_ret)(BX) 646 MOVL $0, (g_sched+gobuf_ret)(BX)
646 MOVL $0, (g_sched+gobuf_ctxt)(BX) 647 MOVL $0, (g_sched+gobuf_ctxt)(BX)
647 POPL BX 648 POPL BX
648 POPL AX 649 POPL AX
649 RET 650 RET
650 651
651 // asmcgocall(void(*fn)(void*), void *arg) 652 // asmcgocall(void(*fn)(void*), void *arg)
652 // Call fn(arg) on the scheduler stack, 653 // Call fn(arg) on the scheduler stack,
653 // aligned appropriately for the gcc ABI. 654 // aligned appropriately for the gcc ABI.
654 // See cgocall.c for more details. 655 // See cgocall.c for more details.
655 TEXT runtime·asmcgocall(SB),NOSPLIT,$0-8 656 TEXT runtime·asmcgocall(SB),NOSPLIT,$0-8
656 MOVL fn+0(FP), AX 657 MOVL fn+0(FP), AX
657 MOVL arg+4(FP), BX 658 MOVL arg+4(FP), BX
659 CALL asmcgocall<>(SB)
660 RET
661
662 TEXT runtime·asmcgocall_errno(SB),NOSPLIT,$0-12
663 MOVL fn+0(FP), AX
664 MOVL arg+4(FP), BX
665 CALL asmcgocall<>(SB)
666 MOVL AX, ret+8(FP)
667 RET
668
669 TEXT asmcgocall<>(SB),NOSPLIT,$0-12
670 // fn in AX, arg in BX
658 MOVL SP, DX 671 MOVL SP, DX
659 672
660 // Figure out if we need to switch to m->g0 stack. 673 // Figure out if we need to switch to m->g0 stack.
661 // We get called to create new OS threads too, and those 674 // We get called to create new OS threads too, and those
662 // come in on the m->g0 stack already. 675 // come in on the m->g0 stack already.
663 get_tls(CX) 676 get_tls(CX)
664 MOVL g(CX), BP 677 MOVL g(CX), BP
665 MOVL g_m(BP), BP 678 MOVL g_m(BP), BP
666 MOVL m_g0(BP), SI 679 MOVL m_g0(BP), SI
667 MOVL g(CX), DI 680 MOVL g(CX), DI
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 // for the duration of the call. Since the call is over, return it with dropm. 802 // for the duration of the call. Since the call is over, return it with dropm.
790 CMPL DX, $0 803 CMPL DX, $0
791 JNE 3(PC) 804 JNE 3(PC)
792 MOVL $runtime·dropm(SB), AX 805 MOVL $runtime·dropm(SB), AX
793 CALL AX 806 CALL AX
794 807
795 // Done! 808 // Done!
796 RET 809 RET
797 810
798 // void setg(G*); set g. for use by needm. 811 // void setg(G*); set g. for use by needm.
799 TEXT runtime·setg(SB), NOSPLIT, $0-8 812 TEXT runtime·setg(SB), NOSPLIT, $0-4
800 MOVL gg+0(FP), BX 813 MOVL gg+0(FP), BX
801 #ifdef GOOS_windows 814 #ifdef GOOS_windows
802 CMPL BX, $0 815 CMPL BX, $0
803 JNE settls 816 JNE settls
804 MOVL $0, 0x14(FS) 817 MOVL $0, 0x14(FS)
805 RET 818 RET
806 settls: 819 settls:
807 MOVL g_m(BX), AX 820 MOVL g_m(BX), AX
808 LEAL m_tls(AX), AX 821 LEAL m_tls(AX), AX
809 MOVL AX, 0x14(FS) 822 MOVL AX, 0x14(FS)
(...skipping 14 matching lines...) Expand all
824 get_tls(CX) 837 get_tls(CX)
825 MOVL g(CX), AX 838 MOVL g(CX), AX
826 CMPL g_stackbase(AX), SP 839 CMPL g_stackbase(AX), SP
827 JHI 2(PC) 840 JHI 2(PC)
828 INT $3 841 INT $3
829 CMPL SP, g_stackguard(AX) 842 CMPL SP, g_stackguard(AX)
830 JHI 2(PC) 843 JHI 2(PC)
831 INT $3 844 INT $3
832 RET 845 RET
833 846
834 TEXT runtime·getcallerpc(SB),NOSPLIT,$0-4 847 TEXT runtime·getcallerpc(SB),NOSPLIT,$0-8
835 » MOVL» x+0(FP),AX» » // addr of first arg 848 » MOVL» argp+0(FP),AX» » // addr of first arg
836 MOVL -4(AX),AX // get calling pc 849 MOVL -4(AX),AX // get calling pc
850 MOVL AX, ret+4(FP)
837 RET 851 RET
838 852
839 TEXT runtime·gogetcallerpc(SB),NOSPLIT,$0-8 853 TEXT runtime·gogetcallerpc(SB),NOSPLIT,$0-8
840 MOVL p+0(FP),AX // addr of first arg 854 MOVL p+0(FP),AX // addr of first arg
841 MOVL -4(AX),AX // get calling pc 855 MOVL -4(AX),AX // get calling pc
842 MOVL AX, ret+4(FP) 856 MOVL AX, ret+4(FP)
843 RET 857 RET
844 858
845 TEXT runtime·setcallerpc(SB),NOSPLIT,$0-8 859 TEXT runtime·setcallerpc(SB),NOSPLIT,$0-8
846 » MOVL» x+0(FP),AX» » // addr of first arg 860 » MOVL» argp+0(FP),AX» » // addr of first arg
847 » MOVL» x+4(FP), BX 861 » MOVL» pc+4(FP), BX
848 MOVL BX, -4(AX) // set calling pc 862 MOVL BX, -4(AX) // set calling pc
849 RET 863 RET
850 864
851 TEXT runtime·getcallersp(SB), NOSPLIT, $0-4 865 TEXT runtime·getcallersp(SB), NOSPLIT, $0-8
852 » MOVL» sp+0(FP), AX 866 » MOVL» argp+0(FP), AX
867 » MOVL» AX, ret+4(FP)
868 » RET
869
870 // func gogetcallersp(p unsafe.Pointer) uintptr
871 TEXT runtime·gogetcallersp(SB),NOSPLIT,$0-8
872 » MOVL» p+0(FP),AX» » // addr of first arg
873 » MOVL» AX, ret+4(FP)
853 RET 874 RET
854 875
855 // int64 runtime·cputicks(void), so really 876 // int64 runtime·cputicks(void), so really
856 // void runtime·cputicks(int64 *ticks) 877 // void runtime·cputicks(int64 *ticks)
857 TEXT runtime·cputicks(SB),NOSPLIT,$0-4 878 TEXT runtime·cputicks(SB),NOSPLIT,$0-8
858 RDTSC 879 RDTSC
859 » MOVL» ret+0(FP), DI 880 » MOVL» AX, ret_lo+0(FP)
860 » MOVL» AX, 0(DI) 881 » MOVL» DX, ret_hi+4(FP)
861 » MOVL» DX, 4(DI) 882 » RET
883
884 TEXT runtime·gocputicks(SB),NOSPLIT,$0-8
885 » RDTSC
886 » MOVL AX, ret_lo+0(FP)
887 » MOVL DX, ret_hi+4(FP)
862 RET 888 RET
863 889
864 TEXT runtime·ldt0setup(SB),NOSPLIT,$16-0 890 TEXT runtime·ldt0setup(SB),NOSPLIT,$16-0
865 // set up ldt 7 to point at tls0 891 // set up ldt 7 to point at tls0
866 // ldt 1 would be fine on Linux, but on OS X, 7 is as low as we can go. 892 // ldt 1 would be fine on Linux, but on OS X, 7 is as low as we can go.
867 // the entry number is just a hint. setldt will set up GS with what it used. 893 // the entry number is just a hint. setldt will set up GS with what it used.
868 MOVL $7, 0(SP) 894 MOVL $7, 0(SP)
869 LEAL runtime·tls0(SB), AX 895 LEAL runtime·tls0(SB), AX
870 MOVL AX, 4(SP) 896 MOVL AX, 4(SP)
871 MOVL $32, 8(SP) // sizeof(tls array) 897 MOVL $32, 8(SP) // sizeof(tls array)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 PSHUFB shifts<>(SB)(CX*8), X1 975 PSHUFB shifts<>(SB)(CX*8), X1
950 partial: 976 partial:
951 // incorporate partial block into hash 977 // incorporate partial block into hash
952 AESENC X3, X0 978 AESENC X3, X0
953 AESENC X1, X0 979 AESENC X1, X0
954 finalize:······· 980 finalize:·······
955 // finalize hash 981 // finalize hash
956 AESENC X2, X0 982 AESENC X2, X0
957 AESENC X3, X0 983 AESENC X3, X0
958 AESENC X2, X0 984 AESENC X2, X0
959 » MOVL» X0, res+12(FP) 985 » MOVL» X0, ret+12(FP)
960 RET 986 RET
961 987
962 TEXT runtime·aeshash32(SB),NOSPLIT,$0-16 988 TEXT runtime·aeshash32(SB),NOSPLIT,$0-16
963 MOVL p+0(FP), AX // ptr to data 989 MOVL p+0(FP), AX // ptr to data
964 // s+4(FP) is ignored, it is always sizeof(int32) 990 // s+4(FP) is ignored, it is always sizeof(int32)
965 MOVL h+8(FP), X0 // seed 991 MOVL h+8(FP), X0 // seed
966 PINSRD $1, (AX), X0 // data 992 PINSRD $1, (AX), X0 // data
967 AESENC runtime·aeskeysched+0(SB), X0 993 AESENC runtime·aeskeysched+0(SB), X0
968 AESENC runtime·aeskeysched+16(SB), X0 994 AESENC runtime·aeskeysched+16(SB), X0
969 AESENC runtime·aeskeysched+0(SB), X0 995 AESENC runtime·aeskeysched+0(SB), X0
970 » MOVL» X0, res+12(FP) 996 » MOVL» X0, ret+12(FP)
971 RET 997 RET
972 998
973 TEXT runtime·aeshash64(SB),NOSPLIT,$0-16 999 TEXT runtime·aeshash64(SB),NOSPLIT,$0-16
974 MOVL p+0(FP), AX // ptr to data 1000 MOVL p+0(FP), AX // ptr to data
975 // s+4(FP) is ignored, it is always sizeof(int64) 1001 // s+4(FP) is ignored, it is always sizeof(int64)
976 MOVQ (AX), X0 // data 1002 MOVQ (AX), X0 // data
977 PINSRD $2, h+8(FP), X0 // seed 1003 PINSRD $2, h+8(FP), X0 // seed
978 AESENC runtime·aeskeysched+0(SB), X0 1004 AESENC runtime·aeskeysched+0(SB), X0
979 AESENC runtime·aeskeysched+16(SB), X0 1005 AESENC runtime·aeskeysched+16(SB), X0
980 AESENC runtime·aeskeysched+0(SB), X0 1006 AESENC runtime·aeskeysched+0(SB), X0
981 » MOVL» X0, res+12(FP) 1007 » MOVL» X0, ret+12(FP)
982 RET 1008 RET
983 1009
984 // simple mask to get rid of data in the high part of the register. 1010 // simple mask to get rid of data in the high part of the register.
985 DATA masks<>+0x00(SB)/4, $0x00000000 1011 DATA masks<>+0x00(SB)/4, $0x00000000
986 DATA masks<>+0x04(SB)/4, $0x00000000 1012 DATA masks<>+0x04(SB)/4, $0x00000000
987 DATA masks<>+0x08(SB)/4, $0x00000000 1013 DATA masks<>+0x08(SB)/4, $0x00000000
988 DATA masks<>+0x0c(SB)/4, $0x00000000 1014 DATA masks<>+0x0c(SB)/4, $0x00000000
989 ········ 1015 ········
990 DATA masks<>+0x10(SB)/4, $0x000000ff 1016 DATA masks<>+0x10(SB)/4, $0x000000ff
991 DATA masks<>+0x14(SB)/4, $0x00000000 1017 DATA masks<>+0x14(SB)/4, $0x00000000
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 DATA shifts<>+0xe8(SB)/4, $0x0d0c0b0a 1168 DATA shifts<>+0xe8(SB)/4, $0x0d0c0b0a
1143 DATA shifts<>+0xec(SB)/4, $0xffff0f0e 1169 DATA shifts<>+0xec(SB)/4, $0xffff0f0e
1144 ········ 1170 ········
1145 DATA shifts<>+0xf0(SB)/4, $0x04030201 1171 DATA shifts<>+0xf0(SB)/4, $0x04030201
1146 DATA shifts<>+0xf4(SB)/4, $0x08070605 1172 DATA shifts<>+0xf4(SB)/4, $0x08070605
1147 DATA shifts<>+0xf8(SB)/4, $0x0c0b0a09 1173 DATA shifts<>+0xf8(SB)/4, $0x0c0b0a09
1148 DATA shifts<>+0xfc(SB)/4, $0xff0f0e0d 1174 DATA shifts<>+0xfc(SB)/4, $0xff0f0e0d
1149 1175
1150 GLOBL shifts<>(SB),RODATA,$256 1176 GLOBL shifts<>(SB),RODATA,$256
1151 1177
1152 TEXT runtime·memeq(SB),NOSPLIT,$0-12 1178 TEXT runtime·memeq(SB),NOSPLIT,$0-13
1153 » MOVL» a+0(FP), SI
1154 » MOVL» b+4(FP), DI
1155 » MOVL» count+8(FP), BX
1156 » JMP» runtime·memeqbody(SB)
1157
1158 TEXT runtime·gomemeq(SB),NOSPLIT,$0-13
1159 MOVL a+0(FP), SI 1179 MOVL a+0(FP), SI
1160 MOVL b+4(FP), DI 1180 MOVL b+4(FP), DI
1161 MOVL size+8(FP), BX 1181 MOVL size+8(FP), BX
1162 CALL runtime·memeqbody(SB) 1182 CALL runtime·memeqbody(SB)
1163 MOVB AX, ret+12(FP) 1183 MOVB AX, ret+12(FP)
1164 RET 1184 RET
1165 1185
1166 // eqstring tests whether two strings are equal. 1186 // eqstring tests whether two strings are equal.
1167 // See runtime_test.go:eqstring_generic for 1187 // See runtime_test.go:eqstring_generic for
1168 // equivlaent Go code. 1188 // equivalent Go code.
1169 TEXT runtime·eqstring(SB),NOSPLIT,$0-17 1189 TEXT runtime·eqstring(SB),NOSPLIT,$0-17
1170 MOVL s1len+4(FP), AX 1190 MOVL s1len+4(FP), AX
1171 MOVL s2len+12(FP), BX 1191 MOVL s2len+12(FP), BX
1172 CMPL AX, BX 1192 CMPL AX, BX
1173 JNE different 1193 JNE different
1174 MOVL s1str+0(FP), SI 1194 MOVL s1str+0(FP), SI
1175 MOVL s2str+8(FP), DI 1195 MOVL s2str+8(FP), DI
1176 CMPL SI, DI 1196 CMPL SI, DI
1177 JEQ same 1197 JEQ same
1178 CALL runtime·memeqbody(SB) 1198 CALL runtime·memeqbody(SB)
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 SHRL CX, DI 1308 SHRL CX, DI
1289 di_finish: 1309 di_finish:
1290 1310
1291 SUBL SI, DI 1311 SUBL SI, DI
1292 SHLL CX, DI 1312 SHLL CX, DI
1293 equal: 1313 equal:
1294 SETEQ AX 1314 SETEQ AX
1295 RET 1315 RET
1296 1316
1297 TEXT runtime·cmpstring(SB),NOSPLIT,$0-20 1317 TEXT runtime·cmpstring(SB),NOSPLIT,$0-20
1298 » MOVL» s1+0(FP), SI 1318 » MOVL» s1_base+0(FP), SI
1299 » MOVL» s1+4(FP), BX 1319 » MOVL» s1_len+4(FP), BX
1300 » MOVL» s2+8(FP), DI 1320 » MOVL» s2_base+8(FP), DI
1301 » MOVL» s2+12(FP), DX 1321 » MOVL» s2_len+12(FP), DX
1302 CALL runtime·cmpbody(SB) 1322 CALL runtime·cmpbody(SB)
1303 » MOVL» AX, res+16(FP) 1323 » MOVL» AX, ret+16(FP)
1304 RET 1324 RET
1305 1325
1306 TEXT bytes·Compare(SB),NOSPLIT,$0-28 1326 TEXT runtime·cmpbytes(SB),NOSPLIT,$0-28
1307 MOVL s1+0(FP), SI 1327 MOVL s1+0(FP), SI
1308 MOVL s1+4(FP), BX 1328 MOVL s1+4(FP), BX
1309 MOVL s2+12(FP), DI 1329 MOVL s2+12(FP), DI
1310 MOVL s2+16(FP), DX 1330 MOVL s2+16(FP), DX
1311 CALL runtime·cmpbody(SB) 1331 CALL runtime·cmpbody(SB)
1312 » MOVL» AX, res+24(FP) 1332 » MOVL» AX, ret+24(FP)
1313 RET 1333 RET
1314 1334
1315 TEXT bytes·IndexByte(SB),NOSPLIT,$0 1335 TEXT bytes·IndexByte(SB),NOSPLIT,$0
1316 MOVL s+0(FP), SI 1336 MOVL s+0(FP), SI
1317 MOVL s_len+4(FP), CX 1337 MOVL s_len+4(FP), CX
1318 MOVB c+12(FP), AL 1338 MOVB c+12(FP), AL
1319 MOVL SI, DI 1339 MOVL SI, DI
1320 CLD; REPN; SCASB 1340 CLD; REPN; SCASB
1321 JZ 3(PC) 1341 JZ 3(PC)
1322 MOVL $-1, ret+16(FP) 1342 MOVL $-1, ret+16(FP)
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
2247 MOVL (SI),CX 2267 MOVL (SI),CX
2248 ADDL $4,SI 2268 ADDL $4,SI
2249 MOVL CX,(DI) 2269 MOVL CX,(DI)
2250 ADDL $4,DI 2270 ADDL $4,DI
2251 ········ 2271 ········
2252 RET 2272 RET
2253 2273
2254 TEXT runtime·timenow(SB), NOSPLIT, $0-0 2274 TEXT runtime·timenow(SB), NOSPLIT, $0-0
2255 JMP time·now(SB) 2275 JMP time·now(SB)
2256 2276
2257 TEXT runtime·fastrand2(SB), NOSPLIT, $0-4 2277 TEXT runtime·fastrand1(SB), NOSPLIT, $0-4
2258 get_tls(CX) 2278 get_tls(CX)
2259 MOVL g(CX), AX 2279 MOVL g(CX), AX
2260 MOVL g_m(AX), AX 2280 MOVL g_m(AX), AX
2261 MOVL m_fastrand(AX), DX 2281 MOVL m_fastrand(AX), DX
2262 ADDL DX, DX 2282 ADDL DX, DX
2263 MOVL DX, BX 2283 MOVL DX, BX
2264 XORL $0x88888eef, DX 2284 XORL $0x88888eef, DX
2265 CMOVLMI BX, DX 2285 CMOVLMI BX, DX
2266 MOVL DX, m_fastrand(AX) 2286 MOVL DX, m_fastrand(AX)
2267 MOVL DX, ret+0(FP) 2287 MOVL DX, ret+0(FP)
2268 RET 2288 RET
2269 2289
2270 // The goeq trampoline is necessary while we have 2290 TEXT runtime·return0(SB), NOSPLIT, $0
2271 // both Go and C calls to alg functions. Once we move all call 2291 » MOVL» $0, AX
2272 // sites to Go, we can redo the eq functions to use the
2273 // Go calling convention and remove this.
2274
2275 // convert call to:
2276 // func (alg unsafe.Pointer, p, q unsafe.Pointer, size uintptr) bool
2277 // to:
2278 // func (eq *bool, size uintptr, p, q unsafe.Pointer)
2279 TEXT runtime·goeq(SB), NOSPLIT, $16-17
2280 » FUNCDATA $FUNCDATA_ArgsPointerMaps,gcargs_goeq<>(SB)
2281 » FUNCDATA $FUNCDATA_LocalsPointerMaps,gclocals_goeq<>(SB)
2282 » MOVL» alg+0(FP), AX
2283 » MOVL» alg_equal(AX), AX
2284 » MOVL» p+4(FP), CX
2285 » MOVL» q+8(FP), DX
2286 » MOVL» size+12(FP), DI
2287 » LEAL» ret+16(FP), SI
2288 » MOVL» SI, 0(SP)
2289 » MOVL» DI, 4(SP)
2290 » MOVL» CX, 8(SP)
2291 » MOVL» DX, 12(SP)
2292 » PCDATA $PCDATA_StackMapIndex, $0
2293 » CALL» *AX
2294 RET 2292 RET
2295
2296 DATA gcargs_goeq<>+0x00(SB)/4, $1 // 1 stackmap
2297 DATA gcargs_goeq<>+0x04(SB)/4, $10 // 5 args
2298 DATA gcargs_goeq<>+0x08(SB)/4, $(const_BitsPointer+(const_BitsPointer<<2)+(const _BitsPointer<<4))
2299 GLOBL gcargs_goeq<>(SB),RODATA,$12
2300
2301 DATA gclocals_goeq<>+0x00(SB)/4, $1 // 1 stackmap
2302 DATA gclocals_goeq<>+0x04(SB)/4, $0 // 0 locals
2303 GLOBL gclocals_goeq<>(SB),RODATA,$8
OLDNEW
« no previous file with comments | « src/pkg/runtime/arch_arm.go ('k') | src/pkg/runtime/asm_amd64.s » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b