Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 1 | // Copyright 2009 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
Russ Cox | 5588940 | 2011-12-19 15:51:13 -0500 | [diff] [blame] | 5 | #include "zasm_GOOS_GOARCH.h" |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 6 | #include "funcdata.h" |
Russ Cox | cb040d5 | 2014-09-04 23:05:18 -0400 | [diff] [blame] | 7 | #include "textflag.h" |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 8 | |
Russ Cox | 7ba41e9 | 2014-09-03 11:11:16 -0400 | [diff] [blame] | 9 | TEXT runtime·rt0_go(SB),NOSPLIT,$0 |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 10 | // copy arguments forward on an even stack |
Russ Cox | dfc22e29 | 2013-03-07 19:57:10 -0800 | [diff] [blame] | 11 | MOVL argc+0(FP), AX |
| 12 | MOVL argv+4(FP), BX |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 13 | SUBL $128, SP // plenty of scratch |
Russ Cox | 133a158 | 2009-10-03 10:37:12 -0700 | [diff] [blame] | 14 | ANDL $~15, SP |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 15 | MOVL AX, 120(SP) // save argc, argv away |
| 16 | MOVL BX, 124(SP) |
| 17 | |
Dmitriy Vyukov | 428062d | 2011-12-07 16:53:17 +0300 | [diff] [blame] | 18 | // set default stack bounds. |
Russ Cox | f8d49b5 | 2013-02-28 16:24:38 -0500 | [diff] [blame] | 19 | // _cgo_init may update stackguard. |
Dmitriy Vyukov | 428062d | 2011-12-07 16:53:17 +0300 | [diff] [blame] | 20 | MOVL $runtime·g0(SB), BP |
| 21 | LEAL (-64*1024+104)(SP), BX |
Dmitriy Vyukov | f5becf4 | 2013-06-03 12:28:24 +0400 | [diff] [blame] | 22 | MOVL BX, g_stackguard0(BP) |
Russ Cox | 15b76ad | 2014-09-09 13:39:57 -0400 | [diff] [blame] | 23 | MOVL BX, g_stackguard1(BP) |
| 24 | MOVL BX, (g_stack+stack_lo)(BP) |
| 25 | MOVL SP, (g_stack+stack_hi)(BP) |
Dmitriy Vyukov | 428062d | 2011-12-07 16:53:17 +0300 | [diff] [blame] | 26 | |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 27 | // find out information about the processor we're on |
| 28 | MOVL $0, AX |
| 29 | CPUID |
| 30 | CMPL AX, $0 |
| 31 | JE nocpuinfo |
| 32 | MOVL $1, AX |
| 33 | CPUID |
| 34 | MOVL CX, runtime·cpuid_ecx(SB) |
| 35 | MOVL DX, runtime·cpuid_edx(SB) |
| 36 | nocpuinfo: |
| 37 | |
Russ Cox | f8d49b5 | 2013-02-28 16:24:38 -0500 | [diff] [blame] | 38 | // if there is an _cgo_init, call it to let it |
Russ Cox | 133a158 | 2009-10-03 10:37:12 -0700 | [diff] [blame] | 39 | // initialize and to set up GS. if not, |
| 40 | // we set up GS ourselves. |
Russ Cox | f8d49b5 | 2013-02-28 16:24:38 -0500 | [diff] [blame] | 41 | MOVL _cgo_init(SB), AX |
Russ Cox | 133a158 | 2009-10-03 10:37:12 -0700 | [diff] [blame] | 42 | TESTL AX, AX |
Dmitriy Vyukov | fbfed49 | 2011-11-09 23:11:48 +0300 | [diff] [blame] | 43 | JZ needtls |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 44 | MOVL $setg_gcc<>(SB), BX |
Russ Cox | 6a70f9d | 2013-03-25 18:14:02 -0400 | [diff] [blame] | 45 | MOVL BX, 4(SP) |
Russ Cox | 3b85b72 | 2013-03-11 00:51:42 -0400 | [diff] [blame] | 46 | MOVL BP, 0(SP) |
Russ Cox | 133a158 | 2009-10-03 10:37:12 -0700 | [diff] [blame] | 47 | CALL AX |
Russ Cox | 15b76ad | 2014-09-09 13:39:57 -0400 | [diff] [blame] | 48 | |
Dmitriy Vyukov | f5becf4 | 2013-06-03 12:28:24 +0400 | [diff] [blame] | 49 | // update stackguard after _cgo_init |
| 50 | MOVL $runtime·g0(SB), CX |
Russ Cox | 15b76ad | 2014-09-09 13:39:57 -0400 | [diff] [blame] | 51 | MOVL (g_stack+stack_lo)(CX), AX |
| 52 | ADDL $const_StackGuard, AX |
| 53 | MOVL AX, g_stackguard0(CX) |
| 54 | MOVL AX, g_stackguard1(CX) |
| 55 | |
Russ Cox | f8d49b5 | 2013-02-28 16:24:38 -0500 | [diff] [blame] | 56 | // skip runtime·ldt0setup(SB) and tls test after _cgo_init for non-windows |
Wei Guangjing | 1aa2d88 | 2011-01-20 10:22:20 -0500 | [diff] [blame] | 57 | CMPL runtime·iswindows(SB), $0 |
| 58 | JEQ ok |
Dmitriy Vyukov | fbfed49 | 2011-11-09 23:11:48 +0300 | [diff] [blame] | 59 | needtls: |
Yuval Pavel Zholkover | 2aa2ceb | 2011-07-25 12:25:41 -0400 | [diff] [blame] | 60 | // skip runtime·ldt0setup(SB) and tls test on Plan 9 in all cases |
| 61 | CMPL runtime·isplan9(SB), $1 |
| 62 | JEQ ok |
| 63 | |
Russ Cox | 1b14bdb | 2009-09-22 16:28:32 -0700 | [diff] [blame] | 64 | // set up %gs |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 65 | CALL runtime·ldt0setup(SB) |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 66 | |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 67 | // store through it, to make sure it works |
Hector Chu | 6bfe5f5 | 2010-01-06 17:58:55 -0800 | [diff] [blame] | 68 | get_tls(BX) |
| 69 | MOVL $0x123, g(BX) |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 70 | MOVL runtime·tls0(SB), AX |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 71 | CMPL AX, $0x123 |
| 72 | JEQ ok |
Russ Cox | 133a158 | 2009-10-03 10:37:12 -0700 | [diff] [blame] | 73 | MOVL AX, 0 // abort |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 74 | ok: |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 75 | // set up m and g "registers" |
Hector Chu | 6bfe5f5 | 2010-01-06 17:58:55 -0800 | [diff] [blame] | 76 | get_tls(BX) |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 77 | LEAL runtime·g0(SB), CX |
Hector Chu | 6bfe5f5 | 2010-01-06 17:58:55 -0800 | [diff] [blame] | 78 | MOVL CX, g(BX) |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 79 | LEAL runtime·m0(SB), AX |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 80 | |
| 81 | // save m->g0 = g0 |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 82 | MOVL CX, m_g0(AX) |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 83 | // save g0->m = m0 |
| 84 | MOVL AX, g_m(CX) |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 85 | |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 86 | CALL runtime·emptyfunc(SB) // fault if stack check is wrong |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 87 | |
| 88 | // convention is D is always cleared |
| 89 | CLD |
| 90 | |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 91 | CALL runtime·check(SB) |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 92 | |
| 93 | // saved argc, argv |
| 94 | MOVL 120(SP), AX |
| 95 | MOVL AX, 0(SP) |
| 96 | MOVL 124(SP), AX |
| 97 | MOVL AX, 4(SP) |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 98 | CALL runtime·args(SB) |
| 99 | CALL runtime·osinit(SB) |
| 100 | CALL runtime·schedinit(SB) |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 101 | |
| 102 | // create a new goroutine to start program |
Russ Cox | 1903ad7 | 2013-02-21 17:01:13 -0500 | [diff] [blame] | 103 | PUSHL $runtime·main·f(SB) // entry |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 104 | PUSHL $0 // arg size |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 105 | ARGSIZE(8) |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 106 | CALL runtime·newproc(SB) |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 107 | ARGSIZE(-1) |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 108 | POPL AX |
| 109 | POPL AX |
| 110 | |
| 111 | // start this M |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 112 | CALL runtime·mstart(SB) |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 113 | |
| 114 | INT $3 |
| 115 | RET |
| 116 | |
Russ Cox | 1903ad7 | 2013-02-21 17:01:13 -0500 | [diff] [blame] | 117 | DATA runtime·main·f+0(SB)/4,$runtime·main(SB) |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 118 | GLOBL runtime·main·f(SB),RODATA,$4 |
Russ Cox | 1903ad7 | 2013-02-21 17:01:13 -0500 | [diff] [blame] | 119 | |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 120 | TEXT runtime·breakpoint(SB),NOSPLIT,$0-0 |
Russ Cox | 1b14bdb | 2009-09-22 16:28:32 -0700 | [diff] [blame] | 121 | INT $3 |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 122 | RET |
| 123 | |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 124 | TEXT runtime·asminit(SB),NOSPLIT,$0-0 |
Carl Shapiro | 019c8fc | 2013-04-02 13:45:56 -0700 | [diff] [blame] | 125 | // Linux and MinGW start the FPU in extended double precision. |
Russ Cox | 1707a99 | 2012-02-14 01:23:15 -0500 | [diff] [blame] | 126 | // Other operating systems use double precision. |
| 127 | // Change to double precision to match them, |
| 128 | // and to match other hardware that only has double. |
| 129 | PUSHL $0x27F |
| 130 | FLDCW 0(SP) |
| 131 | POPL AX |
| 132 | RET |
| 133 | |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 134 | /* |
| 135 | * go-routine |
| 136 | */ |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 137 | |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 138 | // void gosave(Gobuf*) |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 139 | // save state in Gobuf; setjmp |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 140 | TEXT runtime·gosave(SB), NOSPLIT, $0-4 |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 141 | MOVL buf+0(FP), AX // gobuf |
| 142 | LEAL buf+0(FP), BX // caller's SP |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 143 | MOVL BX, gobuf_sp(AX) |
| 144 | MOVL 0(SP), BX // caller's PC |
| 145 | MOVL BX, gobuf_pc(AX) |
Russ Cox | d67e7e3 | 2013-06-12 15:22:26 -0400 | [diff] [blame] | 146 | MOVL $0, gobuf_ret(AX) |
| 147 | MOVL $0, gobuf_ctxt(AX) |
Hector Chu | 6bfe5f5 | 2010-01-06 17:58:55 -0800 | [diff] [blame] | 148 | get_tls(CX) |
| 149 | MOVL g(CX), BX |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 150 | MOVL BX, gobuf_g(AX) |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 151 | RET |
| 152 | |
Ian Lance Taylor | 0627248 | 2013-06-12 15:05:10 -0700 | [diff] [blame] | 153 | // void gogo(Gobuf*) |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 154 | // restore state from Gobuf; longjmp |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 155 | TEXT runtime·gogo(SB), NOSPLIT, $0-4 |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 156 | MOVL buf+0(FP), BX // gobuf |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 157 | MOVL gobuf_g(BX), DX |
| 158 | MOVL 0(DX), CX // make sure g != nil |
Hector Chu | 6bfe5f5 | 2010-01-06 17:58:55 -0800 | [diff] [blame] | 159 | get_tls(CX) |
| 160 | MOVL DX, g(CX) |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 161 | MOVL gobuf_sp(BX), SP // restore SP |
Russ Cox | d67e7e3 | 2013-06-12 15:22:26 -0400 | [diff] [blame] | 162 | MOVL gobuf_ret(BX), AX |
| 163 | MOVL gobuf_ctxt(BX), DX |
| 164 | MOVL $0, gobuf_sp(BX) // clear to help garbage collector |
| 165 | MOVL $0, gobuf_ret(BX) |
| 166 | MOVL $0, gobuf_ctxt(BX) |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 167 | MOVL gobuf_pc(BX), BX |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 168 | JMP BX |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 169 | |
Russ Cox | 012ceed | 2014-09-03 11:35:22 -0400 | [diff] [blame] | 170 | // func mcall(fn func(*g)) |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 171 | // Switch to m->g0's stack, call fn(g). |
Russ Cox | 370276a | 2011-04-27 23:21:12 -0400 | [diff] [blame] | 172 | // Fn must never return. It should gogo(&g->sched) |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 173 | // to keep running g. |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 174 | TEXT runtime·mcall(SB), NOSPLIT, $0-4 |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 175 | MOVL fn+0(FP), DI |
| 176 | |
| 177 | get_tls(CX) |
Russ Cox | 528534c | 2013-06-05 07:16:53 -0400 | [diff] [blame] | 178 | MOVL g(CX), AX // save state in g->sched |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 179 | MOVL 0(SP), BX // caller's PC |
| 180 | MOVL BX, (g_sched+gobuf_pc)(AX) |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 181 | LEAL fn+0(FP), BX // caller's SP |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 182 | MOVL BX, (g_sched+gobuf_sp)(AX) |
| 183 | MOVL AX, (g_sched+gobuf_g)(AX) |
| 184 | |
| 185 | // switch to m->g0 & its stack, call fn |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 186 | MOVL g(CX), BX |
| 187 | MOVL g_m(BX), BX |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 188 | MOVL m_g0(BX), SI |
| 189 | CMPL SI, AX // if g == m->g0 call badmcall |
Keith Randall | 32b770b | 2013-08-29 15:53:34 -0700 | [diff] [blame] | 190 | JNE 3(PC) |
| 191 | MOVL $runtime·badmcall(SB), AX |
| 192 | JMP AX |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 193 | MOVL SI, g(CX) // g = m->g0 |
Russ Cox | 528534c | 2013-06-05 07:16:53 -0400 | [diff] [blame] | 194 | MOVL (g_sched+gobuf_sp)(SI), SP // sp = m->g0->sched.sp |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 195 | PUSHL AX |
Russ Cox | 012ceed | 2014-09-03 11:35:22 -0400 | [diff] [blame] | 196 | MOVL DI, DX |
| 197 | MOVL 0(DI), DI |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 198 | CALL DI |
| 199 | POPL AX |
Keith Randall | 32b770b | 2013-08-29 15:53:34 -0700 | [diff] [blame] | 200 | MOVL $runtime·badmcall2(SB), AX |
| 201 | JMP AX |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 202 | RET |
| 203 | |
Keith Randall | 4aa5043 | 2014-07-30 09:01:52 -0700 | [diff] [blame] | 204 | // switchtoM is a dummy routine that onM leaves at the bottom |
| 205 | // of the G stack. We need to distinguish the routine that |
| 206 | // lives at the bottom of the G stack from the one that lives |
| 207 | // at the top of the M stack because the one at the top of |
| 208 | // the M stack terminates the stack walk (see topofstack()). |
| 209 | TEXT runtime·switchtoM(SB), NOSPLIT, $0-4 |
| 210 | RET |
| 211 | |
Russ Cox | 012ceed | 2014-09-03 11:35:22 -0400 | [diff] [blame] | 212 | // func onM(fn func()) |
Keith Randall | 4aa5043 | 2014-07-30 09:01:52 -0700 | [diff] [blame] | 213 | TEXT runtime·onM(SB), NOSPLIT, $0-4 |
| 214 | MOVL fn+0(FP), DI // DI = fn |
| 215 | get_tls(CX) |
| 216 | MOVL g(CX), AX // AX = g |
| 217 | MOVL g_m(AX), BX // BX = m |
Russ Cox | 32ecf57 | 2014-09-04 00:10:10 -0400 | [diff] [blame] | 218 | |
Keith Randall | 4aa5043 | 2014-07-30 09:01:52 -0700 | [diff] [blame] | 219 | MOVL m_g0(BX), DX // DX = g0 |
| 220 | CMPL AX, DX |
| 221 | JEQ onm |
| 222 | |
Russ Cox | 32ecf57 | 2014-09-04 00:10:10 -0400 | [diff] [blame] | 223 | MOVL m_curg(BX), BP |
| 224 | CMPL AX, BP |
| 225 | JEQ oncurg |
| 226 | |
| 227 | // Not g0, not curg. Must be gsignal, but that's not allowed. |
| 228 | // Hide call from linker nosplit analysis. |
| 229 | MOVL $runtime·badonm(SB), AX |
| 230 | CALL AX |
| 231 | |
| 232 | oncurg: |
Keith Randall | 4aa5043 | 2014-07-30 09:01:52 -0700 | [diff] [blame] | 233 | // save our state in g->sched. Pretend to |
| 234 | // be switchtoM if the G stack is scanned. |
| 235 | MOVL $runtime·switchtoM(SB), (g_sched+gobuf_pc)(AX) |
| 236 | MOVL SP, (g_sched+gobuf_sp)(AX) |
| 237 | MOVL AX, (g_sched+gobuf_g)(AX) |
| 238 | |
| 239 | // switch to g0 |
| 240 | MOVL DX, g(CX) |
Russ Cox | d16a2ad | 2014-09-04 22:48:08 -0400 | [diff] [blame] | 241 | MOVL (g_sched+gobuf_sp)(DX), BX |
| 242 | // make it look like mstart called onM on g0, to stop traceback |
| 243 | SUBL $4, BX |
| 244 | MOVL $runtime·mstart(SB), DX |
| 245 | MOVL DX, 0(BX) |
| 246 | MOVL BX, SP |
Keith Randall | 4aa5043 | 2014-07-30 09:01:52 -0700 | [diff] [blame] | 247 | |
| 248 | // call target function |
| 249 | ARGSIZE(0) |
Russ Cox | 012ceed | 2014-09-03 11:35:22 -0400 | [diff] [blame] | 250 | MOVL DI, DX |
| 251 | MOVL 0(DI), DI |
Keith Randall | 4aa5043 | 2014-07-30 09:01:52 -0700 | [diff] [blame] | 252 | CALL DI |
| 253 | |
| 254 | // switch back to g |
| 255 | get_tls(CX) |
| 256 | MOVL g(CX), AX |
| 257 | MOVL g_m(AX), BX |
| 258 | MOVL m_curg(BX), AX |
| 259 | MOVL AX, g(CX) |
| 260 | MOVL (g_sched+gobuf_sp)(AX), SP |
| 261 | MOVL $0, (g_sched+gobuf_sp)(AX) |
| 262 | RET |
| 263 | |
| 264 | onm: |
| 265 | // already on m stack, just call directly |
Russ Cox | 012ceed | 2014-09-03 11:35:22 -0400 | [diff] [blame] | 266 | MOVL DI, DX |
| 267 | MOVL 0(DI), DI |
Keith Randall | 4aa5043 | 2014-07-30 09:01:52 -0700 | [diff] [blame] | 268 | CALL DI |
| 269 | RET |
| 270 | |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 271 | /* |
| 272 | * support for morestack |
| 273 | */ |
| 274 | |
| 275 | // Called during function prolog when more stack is needed. |
Russ Cox | 58f12ff | 2013-07-18 16:53:45 -0400 | [diff] [blame] | 276 | // |
| 277 | // The traceback routines see morestack on a g0 as being |
| 278 | // the top of a stack (for example, morestack calling newstack |
| 279 | // calling the scheduler calling newm calling gc), so we must |
| 280 | // record an argument size. For that purpose, it has no arguments. |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 281 | TEXT runtime·morestack(SB),NOSPLIT,$0-0 |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 282 | // Cannot grow scheduler stack (m->g0). |
Hector Chu | 6bfe5f5 | 2010-01-06 17:58:55 -0800 | [diff] [blame] | 283 | get_tls(CX) |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 284 | MOVL g(CX), BX |
| 285 | MOVL g_m(BX), BX |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 286 | MOVL m_g0(BX), SI |
Hector Chu | 6bfe5f5 | 2010-01-06 17:58:55 -0800 | [diff] [blame] | 287 | CMPL g(CX), SI |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 288 | JNE 2(PC) |
| 289 | INT $3 |
| 290 | |
Russ Cox | f8f630f | 2014-09-05 16:51:45 -0400 | [diff] [blame] | 291 | // Cannot grow signal stack. |
| 292 | MOVL m_gsignal(BX), SI |
| 293 | CMPL g(CX), SI |
| 294 | JNE 2(PC) |
| 295 | INT $3 |
| 296 | |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 297 | // Called from f. |
| 298 | // Set m->morebuf to f's caller. |
| 299 | MOVL 4(SP), DI // f's caller's PC |
| 300 | MOVL DI, (m_morebuf+gobuf_pc)(BX) |
| 301 | LEAL 8(SP), CX // f's caller's SP |
| 302 | MOVL CX, (m_morebuf+gobuf_sp)(BX) |
Hector Chu | 6bfe5f5 | 2010-01-06 17:58:55 -0800 | [diff] [blame] | 303 | get_tls(CX) |
| 304 | MOVL g(CX), SI |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 305 | MOVL SI, (m_morebuf+gobuf_g)(BX) |
| 306 | |
Russ Cox | 6fa3c89 | 2013-06-27 11:32:01 -0400 | [diff] [blame] | 307 | // Set g->sched to context in f. |
| 308 | MOVL 0(SP), AX // f's PC |
| 309 | MOVL AX, (g_sched+gobuf_pc)(SI) |
| 310 | MOVL SI, (g_sched+gobuf_g)(SI) |
| 311 | LEAL 4(SP), AX // f's SP |
| 312 | MOVL AX, (g_sched+gobuf_sp)(SI) |
| 313 | MOVL DX, (g_sched+gobuf_ctxt)(SI) |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 314 | |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 315 | // Call newstack on m->g0's stack. |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 316 | MOVL m_g0(BX), BP |
Hector Chu | 6bfe5f5 | 2010-01-06 17:58:55 -0800 | [diff] [blame] | 317 | MOVL BP, g(CX) |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 318 | MOVL (g_sched+gobuf_sp)(BP), AX |
Russ Cox | 7e14bd8 | 2010-12-07 17:19:36 -0500 | [diff] [blame] | 319 | MOVL -4(AX), BX // fault if CALL would, before smashing SP |
| 320 | MOVL AX, SP |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 321 | CALL runtime·newstack(SB) |
Russ Cox | 8522a47 | 2009-06-17 15:15:55 -0700 | [diff] [blame] | 322 | MOVL $0, 0x1003 // crash if newstack returns |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 323 | RET |
| 324 | |
Russ Cox | c2dd33a | 2014-03-04 13:53:08 -0500 | [diff] [blame] | 325 | TEXT runtime·morestack_noctxt(SB),NOSPLIT,$0-0 |
| 326 | MOVL $0, DX |
| 327 | JMP runtime·morestack(SB) |
| 328 | |
Keith Randall | 5263198 | 2014-09-08 10:14:41 -0700 | [diff] [blame] | 329 | // reflectcall: call a function with the given argument list |
Russ Cox | 8473695 | 2014-09-06 13:19:08 -0400 | [diff] [blame] | 330 | // func call(f *FuncVal, arg *byte, argsize, retoffset uint32). |
Keith Randall | 9cd5706 | 2013-08-02 13:03:14 -0700 | [diff] [blame] | 331 | // we don't have variable-sized frames, so we use a small number |
| 332 | // of constant-sized-frame functions to encode a few bits of size in the pc. |
| 333 | // Caution: ugly multiline assembly macros in your future! |
| 334 | |
| 335 | #define DISPATCH(NAME,MAXSIZE) \ |
| 336 | CMPL CX, $MAXSIZE; \ |
| 337 | JA 3(PC); \ |
Russ Cox | f8f630f | 2014-09-05 16:51:45 -0400 | [diff] [blame] | 338 | MOVL $NAME(SB), AX; \ |
Keith Randall | 9cd5706 | 2013-08-02 13:03:14 -0700 | [diff] [blame] | 339 | JMP AX |
Rob Pike | aff7883 | 2014-07-30 10:11:44 -0700 | [diff] [blame] | 340 | // Note: can't just "JMP NAME(SB)" - bad inlining results. |
Keith Randall | 9cd5706 | 2013-08-02 13:03:14 -0700 | [diff] [blame] | 341 | |
Keith Randall | 5263198 | 2014-09-08 10:14:41 -0700 | [diff] [blame] | 342 | TEXT runtime·reflectcall(SB), NOSPLIT, $0-16 |
Keith Randall | 9cd5706 | 2013-08-02 13:03:14 -0700 | [diff] [blame] | 343 | MOVL argsize+8(FP), CX |
Rob Pike | aff7883 | 2014-07-30 10:11:44 -0700 | [diff] [blame] | 344 | DISPATCH(runtime·call16, 16) |
| 345 | DISPATCH(runtime·call32, 32) |
| 346 | DISPATCH(runtime·call64, 64) |
| 347 | DISPATCH(runtime·call128, 128) |
| 348 | DISPATCH(runtime·call256, 256) |
| 349 | DISPATCH(runtime·call512, 512) |
| 350 | DISPATCH(runtime·call1024, 1024) |
| 351 | DISPATCH(runtime·call2048, 2048) |
| 352 | DISPATCH(runtime·call4096, 4096) |
| 353 | DISPATCH(runtime·call8192, 8192) |
| 354 | DISPATCH(runtime·call16384, 16384) |
| 355 | DISPATCH(runtime·call32768, 32768) |
| 356 | DISPATCH(runtime·call65536, 65536) |
| 357 | DISPATCH(runtime·call131072, 131072) |
| 358 | DISPATCH(runtime·call262144, 262144) |
| 359 | DISPATCH(runtime·call524288, 524288) |
| 360 | DISPATCH(runtime·call1048576, 1048576) |
| 361 | DISPATCH(runtime·call2097152, 2097152) |
| 362 | DISPATCH(runtime·call4194304, 4194304) |
| 363 | DISPATCH(runtime·call8388608, 8388608) |
| 364 | DISPATCH(runtime·call16777216, 16777216) |
| 365 | DISPATCH(runtime·call33554432, 33554432) |
| 366 | DISPATCH(runtime·call67108864, 67108864) |
| 367 | DISPATCH(runtime·call134217728, 134217728) |
| 368 | DISPATCH(runtime·call268435456, 268435456) |
| 369 | DISPATCH(runtime·call536870912, 536870912) |
| 370 | DISPATCH(runtime·call1073741824, 1073741824) |
Keith Randall | 9cd5706 | 2013-08-02 13:03:14 -0700 | [diff] [blame] | 371 | MOVL $runtime·badreflectcall(SB), AX |
| 372 | JMP AX |
| 373 | |
Russ Cox | f8f630f | 2014-09-05 16:51:45 -0400 | [diff] [blame] | 374 | // Argument map for the callXX frames. Each has one stack map. |
Keith Randall | cee8bca | 2014-05-21 14:28:34 -0700 | [diff] [blame] | 375 | DATA gcargs_reflectcall<>+0x00(SB)/4, $1 // 1 stackmap |
Russ Cox | 8473695 | 2014-09-06 13:19:08 -0400 | [diff] [blame] | 376 | DATA gcargs_reflectcall<>+0x04(SB)/4, $8 // 4 words |
Russ Cox | f8f630f | 2014-09-05 16:51:45 -0400 | [diff] [blame] | 377 | DATA gcargs_reflectcall<>+0x08(SB)/1, $(const_BitsPointer+(const_BitsPointer<<2)+(const_BitsScalar<<4)+(const_BitsScalar<<6)) |
Keith Randall | cee8bca | 2014-05-21 14:28:34 -0700 | [diff] [blame] | 378 | GLOBL gcargs_reflectcall<>(SB),RODATA,$12 |
| 379 | |
| 380 | // callXX frames have no locals |
| 381 | DATA gclocals_reflectcall<>+0x00(SB)/4, $1 // 1 stackmap |
| 382 | DATA gclocals_reflectcall<>+0x04(SB)/4, $0 // 0 locals |
| 383 | GLOBL gclocals_reflectcall<>(SB),RODATA,$8 |
| 384 | |
Keith Randall | 12e46e4 | 2013-08-06 14:33:55 -0700 | [diff] [blame] | 385 | #define CALLFN(NAME,MAXSIZE) \ |
Russ Cox | 8473695 | 2014-09-06 13:19:08 -0400 | [diff] [blame] | 386 | TEXT NAME(SB), WRAPPER, $MAXSIZE-16; \ |
Keith Randall | cee8bca | 2014-05-21 14:28:34 -0700 | [diff] [blame] | 387 | FUNCDATA $FUNCDATA_ArgsPointerMaps,gcargs_reflectcall<>(SB); \ |
| 388 | FUNCDATA $FUNCDATA_LocalsPointerMaps,gclocals_reflectcall<>(SB);\ |
Keith Randall | 9cd5706 | 2013-08-02 13:03:14 -0700 | [diff] [blame] | 389 | /* copy arguments to stack */ \ |
| 390 | MOVL argptr+4(FP), SI; \ |
| 391 | MOVL argsize+8(FP), CX; \ |
| 392 | MOVL SP, DI; \ |
| 393 | REP;MOVSB; \ |
| 394 | /* call function */ \ |
| 395 | MOVL f+0(FP), DX; \ |
Russ Cox | 4a000b9 | 2014-02-25 17:00:08 -0500 | [diff] [blame] | 396 | MOVL (DX), AX; \ |
Keith Randall | cee8bca | 2014-05-21 14:28:34 -0700 | [diff] [blame] | 397 | PCDATA $PCDATA_StackMapIndex, $0; \ |
Russ Cox | 4a000b9 | 2014-02-25 17:00:08 -0500 | [diff] [blame] | 398 | CALL AX; \ |
Keith Randall | 9cd5706 | 2013-08-02 13:03:14 -0700 | [diff] [blame] | 399 | /* copy return values back */ \ |
| 400 | MOVL argptr+4(FP), DI; \ |
| 401 | MOVL argsize+8(FP), CX; \ |
Russ Cox | 72c5d5e | 2014-04-08 11:11:35 -0400 | [diff] [blame] | 402 | MOVL retoffset+12(FP), BX; \ |
Keith Randall | 9cd5706 | 2013-08-02 13:03:14 -0700 | [diff] [blame] | 403 | MOVL SP, SI; \ |
Russ Cox | 72c5d5e | 2014-04-08 11:11:35 -0400 | [diff] [blame] | 404 | ADDL BX, DI; \ |
| 405 | ADDL BX, SI; \ |
| 406 | SUBL BX, CX; \ |
Keith Randall | 9cd5706 | 2013-08-02 13:03:14 -0700 | [diff] [blame] | 407 | REP;MOVSB; \ |
| 408 | RET |
| 409 | |
Rob Pike | aff7883 | 2014-07-30 10:11:44 -0700 | [diff] [blame] | 410 | CALLFN(runtime·call16, 16) |
| 411 | CALLFN(runtime·call32, 32) |
| 412 | CALLFN(runtime·call64, 64) |
| 413 | CALLFN(runtime·call128, 128) |
| 414 | CALLFN(runtime·call256, 256) |
| 415 | CALLFN(runtime·call512, 512) |
| 416 | CALLFN(runtime·call1024, 1024) |
| 417 | CALLFN(runtime·call2048, 2048) |
| 418 | CALLFN(runtime·call4096, 4096) |
| 419 | CALLFN(runtime·call8192, 8192) |
| 420 | CALLFN(runtime·call16384, 16384) |
| 421 | CALLFN(runtime·call32768, 32768) |
| 422 | CALLFN(runtime·call65536, 65536) |
| 423 | CALLFN(runtime·call131072, 131072) |
| 424 | CALLFN(runtime·call262144, 262144) |
| 425 | CALLFN(runtime·call524288, 524288) |
| 426 | CALLFN(runtime·call1048576, 1048576) |
| 427 | CALLFN(runtime·call2097152, 2097152) |
| 428 | CALLFN(runtime·call4194304, 4194304) |
| 429 | CALLFN(runtime·call8388608, 8388608) |
| 430 | CALLFN(runtime·call16777216, 16777216) |
| 431 | CALLFN(runtime·call33554432, 33554432) |
| 432 | CALLFN(runtime·call67108864, 67108864) |
| 433 | CALLFN(runtime·call134217728, 134217728) |
| 434 | CALLFN(runtime·call268435456, 268435456) |
| 435 | CALLFN(runtime·call536870912, 536870912) |
| 436 | CALLFN(runtime·call1073741824, 1073741824) |
Russ Cox | bba278a | 2009-07-08 18:16:09 -0700 | [diff] [blame] | 437 | |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 438 | // bool cas(int32 *val, int32 old, int32 new) |
| 439 | // Atomically: |
| 440 | // if(*val == old){ |
| 441 | // *val = new; |
| 442 | // return 1; |
| 443 | // }else |
| 444 | // return 0; |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 445 | TEXT runtime·cas(SB), NOSPLIT, $0-13 |
| 446 | MOVL ptr+0(FP), BX |
| 447 | MOVL old+4(FP), AX |
| 448 | MOVL new+8(FP), CX |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 449 | LOCK |
| 450 | CMPXCHGL CX, 0(BX) |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 451 | JZ 4(PC) |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 452 | MOVL $0, AX |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 453 | MOVB AX, ret+12(FP) |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 454 | RET |
| 455 | MOVL $1, AX |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 456 | MOVB AX, ret+12(FP) |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 457 | RET |
| 458 | |
Russ Cox | d21638b | 2014-08-27 21:59:49 -0400 | [diff] [blame] | 459 | TEXT runtime·casuintptr(SB), NOSPLIT, $0-13 |
| 460 | JMP runtime·cas(SB) |
| 461 | |
Russ Cox | 3a7f664 | 2014-08-29 16:20:48 -0400 | [diff] [blame] | 462 | TEXT runtime·atomicloaduintptr(SB), NOSPLIT, $0-8 |
| 463 | JMP runtime·atomicload(SB) |
| 464 | |
Keith Randall | 47d6af2 | 2014-08-30 11:03:28 -0700 | [diff] [blame] | 465 | TEXT runtime·atomicloaduint(SB), NOSPLIT, $0-8 |
| 466 | JMP runtime·atomicload(SB) |
| 467 | |
Russ Cox | f70a19f | 2013-07-12 00:42:46 -0400 | [diff] [blame] | 468 | // bool runtime·cas64(uint64 *val, uint64 old, uint64 new) |
Dmitriy Vyukov | 4667571 | 2012-04-05 18:47:43 +0400 | [diff] [blame] | 469 | // Atomically: |
| 470 | // if(*val == *old){ |
| 471 | // *val = new; |
| 472 | // return 1; |
| 473 | // } else { |
Dmitriy Vyukov | 4667571 | 2012-04-05 18:47:43 +0400 | [diff] [blame] | 474 | // return 0; |
| 475 | // } |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 476 | TEXT runtime·cas64(SB), NOSPLIT, $0-21 |
| 477 | MOVL ptr+0(FP), BP |
| 478 | MOVL old_lo+4(FP), AX |
| 479 | MOVL old_hi+8(FP), DX |
| 480 | MOVL new_lo+12(FP), BX |
| 481 | MOVL new_hi+16(FP), CX |
Dmitriy Vyukov | 4667571 | 2012-04-05 18:47:43 +0400 | [diff] [blame] | 482 | LOCK |
| 483 | CMPXCHG8B 0(BP) |
| 484 | JNZ cas64_fail |
| 485 | MOVL $1, AX |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 486 | MOVB AX, ret+20(FP) |
Dmitriy Vyukov | 4667571 | 2012-04-05 18:47:43 +0400 | [diff] [blame] | 487 | RET |
| 488 | cas64_fail: |
Dmitriy Vyukov | fd04f05 | 2012-04-05 18:59:50 +0400 | [diff] [blame] | 489 | MOVL $0, AX |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 490 | MOVB AX, ret+20(FP) |
Dmitriy Vyukov | 4667571 | 2012-04-05 18:47:43 +0400 | [diff] [blame] | 491 | RET |
| 492 | |
Hector Chu | 6bfe5f5 | 2010-01-06 17:58:55 -0800 | [diff] [blame] | 493 | // bool casp(void **p, void *old, void *new) |
| 494 | // Atomically: |
| 495 | // if(*p == old){ |
| 496 | // *p = new; |
| 497 | // return 1; |
| 498 | // }else |
| 499 | // return 0; |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 500 | TEXT runtime·casp(SB), NOSPLIT, $0-13 |
| 501 | MOVL ptr+0(FP), BX |
| 502 | MOVL old+4(FP), AX |
| 503 | MOVL new+8(FP), CX |
Hector Chu | 6bfe5f5 | 2010-01-06 17:58:55 -0800 | [diff] [blame] | 504 | LOCK |
| 505 | CMPXCHGL CX, 0(BX) |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 506 | JZ 4(PC) |
Hector Chu | 6bfe5f5 | 2010-01-06 17:58:55 -0800 | [diff] [blame] | 507 | MOVL $0, AX |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 508 | MOVB AX, ret+12(FP) |
Hector Chu | 6bfe5f5 | 2010-01-06 17:58:55 -0800 | [diff] [blame] | 509 | RET |
| 510 | MOVL $1, AX |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 511 | MOVB AX, ret+12(FP) |
Hector Chu | 6bfe5f5 | 2010-01-06 17:58:55 -0800 | [diff] [blame] | 512 | RET |
| 513 | |
Dmitriy Vyukov | 491aa15 | 2011-07-15 11:27:16 -0400 | [diff] [blame] | 514 | // uint32 xadd(uint32 volatile *val, int32 delta) |
| 515 | // Atomically: |
| 516 | // *val += delta; |
| 517 | // return *val; |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 518 | TEXT runtime·xadd(SB), NOSPLIT, $0-12 |
| 519 | MOVL ptr+0(FP), BX |
| 520 | MOVL delta+4(FP), AX |
Dmitriy Vyukov | 491aa15 | 2011-07-15 11:27:16 -0400 | [diff] [blame] | 521 | MOVL AX, CX |
| 522 | LOCK |
| 523 | XADDL AX, 0(BX) |
| 524 | ADDL CX, AX |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 525 | MOVL AX, ret+8(FP) |
Dmitriy Vyukov | 491aa15 | 2011-07-15 11:27:16 -0400 | [diff] [blame] | 526 | RET |
| 527 | |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 528 | TEXT runtime·xchg(SB), NOSPLIT, $0-12 |
| 529 | MOVL ptr+0(FP), BX |
| 530 | MOVL new+4(FP), AX |
Dmitriy Vyukov | 4e5086b | 2011-07-29 12:44:06 -0400 | [diff] [blame] | 531 | XCHGL AX, 0(BX) |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 532 | MOVL AX, ret+8(FP) |
Dmitriy Vyukov | 4e5086b | 2011-07-29 12:44:06 -0400 | [diff] [blame] | 533 | RET |
| 534 | |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 535 | TEXT runtime·xchgp(SB), NOSPLIT, $0-12 |
| 536 | MOVL ptr+0(FP), BX |
| 537 | MOVL new+4(FP), AX |
Dmitriy Vyukov | 9cbd2fb | 2014-01-22 11:27:16 +0400 | [diff] [blame] | 538 | XCHGL AX, 0(BX) |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 539 | MOVL AX, ret+8(FP) |
Dmitriy Vyukov | 9cbd2fb | 2014-01-22 11:27:16 +0400 | [diff] [blame] | 540 | RET |
| 541 | |
Dmitriy Vyukov | 91a670d | 2014-09-04 10:04:04 +0400 | [diff] [blame] | 542 | TEXT runtime·xchguintptr(SB), NOSPLIT, $0-12 |
| 543 | JMP runtime·xchg(SB) |
| 544 | |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 545 | TEXT runtime·procyield(SB),NOSPLIT,$0-0 |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 546 | MOVL cycles+0(FP), AX |
Dmitriy Vyukov | 4e5086b | 2011-07-29 12:44:06 -0400 | [diff] [blame] | 547 | again: |
| 548 | PAUSE |
| 549 | SUBL $1, AX |
| 550 | JNZ again |
| 551 | RET |
| 552 | |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 553 | TEXT runtime·atomicstorep(SB), NOSPLIT, $0-8 |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 554 | MOVL ptr+0(FP), BX |
| 555 | MOVL val+4(FP), AX |
Dmitriy Vyukov | 86a659c | 2011-07-13 11:22:41 -0700 | [diff] [blame] | 556 | XCHGL AX, 0(BX) |
| 557 | RET |
| 558 | |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 559 | TEXT runtime·atomicstore(SB), NOSPLIT, $0-8 |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 560 | MOVL ptr+0(FP), BX |
| 561 | MOVL val+4(FP), AX |
Dmitriy Vyukov | 91f0f18 | 2011-07-29 13:47:24 -0400 | [diff] [blame] | 562 | XCHGL AX, 0(BX) |
| 563 | RET |
| 564 | |
Dmitriy Vyukov | 4667571 | 2012-04-05 18:47:43 +0400 | [diff] [blame] | 565 | // uint64 atomicload64(uint64 volatile* addr); |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 566 | TEXT runtime·atomicload64(SB), NOSPLIT, $0-12 |
| 567 | MOVL ptr+0(FP), AX |
| 568 | LEAL ret_lo+4(FP), BX |
Dmitriy Vyukov | 4667571 | 2012-04-05 18:47:43 +0400 | [diff] [blame] | 569 | // MOVQ (%EAX), %MM0 |
| 570 | BYTE $0x0f; BYTE $0x6f; BYTE $0x00 |
| 571 | // MOVQ %MM0, 0(%EBX) |
| 572 | BYTE $0x0f; BYTE $0x7f; BYTE $0x03 |
| 573 | // EMMS |
| 574 | BYTE $0x0F; BYTE $0x77 |
| 575 | RET |
| 576 | |
| 577 | // void runtime·atomicstore64(uint64 volatile* addr, uint64 v); |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 578 | TEXT runtime·atomicstore64(SB), NOSPLIT, $0-12 |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 579 | MOVL ptr+0(FP), AX |
Dmitriy Vyukov | 4667571 | 2012-04-05 18:47:43 +0400 | [diff] [blame] | 580 | // MOVQ and EMMS were introduced on the Pentium MMX. |
| 581 | // MOVQ 0x8(%ESP), %MM0 |
| 582 | BYTE $0x0f; BYTE $0x6f; BYTE $0x44; BYTE $0x24; BYTE $0x08 |
| 583 | // MOVQ %MM0, (%EAX) |
| 584 | BYTE $0x0f; BYTE $0x7f; BYTE $0x00 |
| 585 | // EMMS |
| 586 | BYTE $0x0F; BYTE $0x77 |
| 587 | // This is essentially a no-op, but it provides required memory fencing. |
| 588 | // It can be replaced with MFENCE, but MFENCE was introduced only on the Pentium4 (SSE2). |
| 589 | MOVL $0, AX |
| 590 | LOCK |
| 591 | XADDL AX, (SP) |
| 592 | RET |
| 593 | |
Dmitriy Vyukov | ff3fa1b | 2014-08-19 17:38:00 +0400 | [diff] [blame] | 594 | // void runtime·atomicor8(byte volatile*, byte); |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 595 | TEXT runtime·atomicor8(SB), NOSPLIT, $0-5 |
Dmitriy Vyukov | ff3fa1b | 2014-08-19 17:38:00 +0400 | [diff] [blame] | 596 | MOVL ptr+0(FP), AX |
| 597 | MOVB val+4(FP), BX |
| 598 | LOCK |
| 599 | ORB BX, (AX) |
| 600 | RET |
| 601 | |
Russ Cox | aa3222d8 | 2009-06-02 23:02:12 -0700 | [diff] [blame] | 602 | // void jmpdefer(fn, sp); |
| 603 | // called from deferreturn. |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 604 | // 1. pop the caller |
| 605 | // 2. sub 5 bytes from the callers return |
| 606 | // 3. jmp to the argument |
Keith Randall | a97a91d | 2013-08-07 14:03:50 -0700 | [diff] [blame] | 607 | TEXT runtime·jmpdefer(SB), NOSPLIT, $0-8 |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 608 | MOVL fv+0(FP), DX // fn |
| 609 | MOVL argp+4(FP), BX // caller sp |
Russ Cox | aa3222d8 | 2009-06-02 23:02:12 -0700 | [diff] [blame] | 610 | LEAL -4(BX), SP // caller sp after CALL |
| 611 | SUBL $5, (SP) // return to CALL again |
Russ Cox | 6066fdc | 2013-02-22 10:47:54 -0500 | [diff] [blame] | 612 | MOVL 0(DX), BX |
Russ Cox | 1903ad7 | 2013-02-21 17:01:13 -0500 | [diff] [blame] | 613 | JMP BX // but first run the deferred function |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 614 | |
Russ Cox | d67e7e3 | 2013-06-12 15:22:26 -0400 | [diff] [blame] | 615 | // Save state of caller into g->sched. |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 616 | TEXT gosave<>(SB),NOSPLIT,$0 |
Russ Cox | d67e7e3 | 2013-06-12 15:22:26 -0400 | [diff] [blame] | 617 | PUSHL AX |
| 618 | PUSHL BX |
| 619 | get_tls(BX) |
| 620 | MOVL g(BX), BX |
| 621 | LEAL arg+0(FP), AX |
| 622 | MOVL AX, (g_sched+gobuf_sp)(BX) |
| 623 | MOVL -4(AX), AX |
| 624 | MOVL AX, (g_sched+gobuf_pc)(BX) |
| 625 | MOVL $0, (g_sched+gobuf_ret)(BX) |
| 626 | MOVL $0, (g_sched+gobuf_ctxt)(BX) |
| 627 | POPL BX |
| 628 | POPL AX |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 629 | RET |
| 630 | |
| 631 | // asmcgocall(void(*fn)(void*), void *arg) |
| 632 | // Call fn(arg) on the scheduler stack, |
| 633 | // aligned appropriately for the gcc ABI. |
| 634 | // See cgocall.c for more details. |
Russ Cox | cb76724 | 2014-09-04 00:01:55 -0400 | [diff] [blame] | 635 | TEXT runtime·asmcgocall(SB),NOSPLIT,$0-8 |
Russ Cox | 54138e1 | 2014-09-03 11:36:14 -0400 | [diff] [blame] | 636 | MOVL fn+0(FP), AX |
| 637 | MOVL arg+4(FP), BX |
Russ Cox | cb76724 | 2014-09-04 00:01:55 -0400 | [diff] [blame] | 638 | CALL asmcgocall<>(SB) |
Russ Cox | 54138e1 | 2014-09-03 11:36:14 -0400 | [diff] [blame] | 639 | RET |
| 640 | |
| 641 | TEXT runtime·asmcgocall_errno(SB),NOSPLIT,$0-12 |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 642 | MOVL fn+0(FP), AX |
| 643 | MOVL arg+4(FP), BX |
Russ Cox | cb76724 | 2014-09-04 00:01:55 -0400 | [diff] [blame] | 644 | CALL asmcgocall<>(SB) |
| 645 | MOVL AX, ret+8(FP) |
| 646 | RET |
| 647 | |
| 648 | TEXT asmcgocall<>(SB),NOSPLIT,$0-12 |
| 649 | // fn in AX, arg in BX |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 650 | MOVL SP, DX |
| 651 | |
| 652 | // Figure out if we need to switch to m->g0 stack. |
| 653 | // We get called to create new OS threads too, and those |
| 654 | // come in on the m->g0 stack already. |
| 655 | get_tls(CX) |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 656 | MOVL g(CX), BP |
| 657 | MOVL g_m(BP), BP |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 658 | MOVL m_g0(BP), SI |
| 659 | MOVL g(CX), DI |
| 660 | CMPL SI, DI |
Russ Cox | d67e7e3 | 2013-06-12 15:22:26 -0400 | [diff] [blame] | 661 | JEQ 4(PC) |
| 662 | CALL gosave<>(SB) |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 663 | MOVL SI, g(CX) |
| 664 | MOVL (g_sched+gobuf_sp)(SI), SP |
| 665 | |
| 666 | // Now on a scheduling stack (a pthread-created stack). |
| 667 | SUBL $32, SP |
| 668 | ANDL $~15, SP // alignment, perhaps unnecessary |
| 669 | MOVL DI, 8(SP) // save g |
| 670 | MOVL DX, 4(SP) // save SP |
| 671 | MOVL BX, 0(SP) // first argument in x86-32 ABI |
| 672 | CALL AX |
| 673 | |
| 674 | // Restore registers, g, stack pointer. |
| 675 | get_tls(CX) |
| 676 | MOVL 8(SP), DI |
| 677 | MOVL DI, g(CX) |
| 678 | MOVL 4(SP), SP |
| 679 | RET |
| 680 | |
| 681 | // cgocallback(void (*fn)(void*), void *frame, uintptr framesize) |
Russ Cox | 3d2dfc5 | 2013-02-22 16:08:56 -0500 | [diff] [blame] | 682 | // Turn the fn into a Go func (by taking its address) and call |
| 683 | // cgocallback_gofunc. |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 684 | TEXT runtime·cgocallback(SB),NOSPLIT,$12-12 |
Russ Cox | 3d2dfc5 | 2013-02-22 16:08:56 -0500 | [diff] [blame] | 685 | LEAL fn+0(FP), AX |
| 686 | MOVL AX, 0(SP) |
| 687 | MOVL frame+4(FP), AX |
| 688 | MOVL AX, 4(SP) |
| 689 | MOVL framesize+8(FP), AX |
| 690 | MOVL AX, 8(SP) |
| 691 | MOVL $runtime·cgocallback_gofunc(SB), AX |
| 692 | CALL AX |
| 693 | RET |
| 694 | |
| 695 | // cgocallback_gofunc(FuncVal*, void *frame, uintptr framesize) |
| 696 | // See cgocall.c for more details. |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 697 | TEXT runtime·cgocallback_gofunc(SB),NOSPLIT,$12-12 |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 698 | // If g is nil, Go did not create the current thread. |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 699 | // Call needm to obtain one for temporary use. |
| 700 | // In this case, we're running on the thread stack, so there's |
| 701 | // lots of space, but the linker doesn't know. Hide the call from |
| 702 | // the linker analysis by using an indirect call through AX. |
| 703 | get_tls(CX) |
| 704 | #ifdef GOOS_windows |
Russ Cox | dba623b | 2013-07-23 18:40:02 -0400 | [diff] [blame] | 705 | MOVL $0, BP |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 706 | CMPL CX, $0 |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 707 | JEQ 2(PC) // TODO |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 708 | #endif |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 709 | MOVL g(CX), BP |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 710 | CMPL BP, $0 |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 711 | JEQ needm |
| 712 | MOVL g_m(BP), BP |
| 713 | MOVL BP, DX // saved copy of oldm |
| 714 | JMP havem |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 715 | needm: |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 716 | MOVL $0, 0(SP) |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 717 | MOVL $runtime·needm(SB), AX |
| 718 | CALL AX |
Russ Cox | f011282 | 2013-07-24 09:01:57 -0400 | [diff] [blame] | 719 | MOVL 0(SP), DX |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 720 | get_tls(CX) |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 721 | MOVL g(CX), BP |
| 722 | MOVL g_m(BP), BP |
Russ Cox | 9b73238 | 2012-03-08 12:12:40 -0500 | [diff] [blame] | 723 | |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 724 | havem: |
| 725 | // Now there's a valid m, and we're running on its m->g0. |
| 726 | // Save current m->g0->sched.sp on stack and then set it to SP. |
| 727 | // Save current sp in m->g0->sched.sp in preparation for |
| 728 | // switch back to m->curg stack. |
Russ Cox | dba623b | 2013-07-23 18:40:02 -0400 | [diff] [blame] | 729 | // NOTE: unwindm knows that the saved g->sched.sp is at 0(SP). |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 730 | MOVL m_g0(BP), SI |
Russ Cox | dba623b | 2013-07-23 18:40:02 -0400 | [diff] [blame] | 731 | MOVL (g_sched+gobuf_sp)(SI), AX |
| 732 | MOVL AX, 0(SP) |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 733 | MOVL SP, (g_sched+gobuf_sp)(SI) |
| 734 | |
Russ Cox | dba623b | 2013-07-23 18:40:02 -0400 | [diff] [blame] | 735 | // Switch to m->curg stack and call runtime.cgocallbackg. |
| 736 | // Because we are taking over the execution of m->curg |
| 737 | // but *not* resuming what had been running, we need to |
| 738 | // save that information (m->curg->sched) so we can restore it. |
Russ Cox | 528534c | 2013-06-05 07:16:53 -0400 | [diff] [blame] | 739 | // We can restore m->curg->sched.sp easily, because calling |
Alex Brainman | 72e8348 | 2011-08-18 12:17:09 -0400 | [diff] [blame] | 740 | // runtime.cgocallbackg leaves SP unchanged upon return. |
Russ Cox | 528534c | 2013-06-05 07:16:53 -0400 | [diff] [blame] | 741 | // To save m->curg->sched.pc, we push it onto the stack. |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 742 | // This has the added benefit that it looks to the traceback |
Alex Brainman | 72e8348 | 2011-08-18 12:17:09 -0400 | [diff] [blame] | 743 | // routine like cgocallbackg is going to return to that |
Russ Cox | dba623b | 2013-07-23 18:40:02 -0400 | [diff] [blame] | 744 | // PC (because the frame we allocate below has the same |
| 745 | // size as cgocallback_gofunc's frame declared above) |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 746 | // so that the traceback will seamlessly trace back into |
| 747 | // the earlier calls. |
Russ Cox | dba623b | 2013-07-23 18:40:02 -0400 | [diff] [blame] | 748 | // |
Russ Cox | f011282 | 2013-07-24 09:01:57 -0400 | [diff] [blame] | 749 | // In the new goroutine, 0(SP) holds the saved oldm (DX) register. |
| 750 | // 4(SP) and 8(SP) are unused. |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 751 | MOVL m_curg(BP), SI |
| 752 | MOVL SI, g(CX) |
Russ Cox | dba623b | 2013-07-23 18:40:02 -0400 | [diff] [blame] | 753 | MOVL (g_sched+gobuf_sp)(SI), DI // prepare stack as DI |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 754 | MOVL (g_sched+gobuf_pc)(SI), BP |
Russ Cox | dba623b | 2013-07-23 18:40:02 -0400 | [diff] [blame] | 755 | MOVL BP, -4(DI) |
Russ Cox | f011282 | 2013-07-24 09:01:57 -0400 | [diff] [blame] | 756 | LEAL -(4+12)(DI), SP |
| 757 | MOVL DX, 0(SP) |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 758 | CALL runtime·cgocallbackg(SB) |
Russ Cox | f011282 | 2013-07-24 09:01:57 -0400 | [diff] [blame] | 759 | MOVL 0(SP), DX |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 760 | |
Russ Cox | 528534c | 2013-06-05 07:16:53 -0400 | [diff] [blame] | 761 | // Restore g->sched (== m->curg->sched) from saved values. |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 762 | get_tls(CX) |
| 763 | MOVL g(CX), SI |
Russ Cox | f011282 | 2013-07-24 09:01:57 -0400 | [diff] [blame] | 764 | MOVL 12(SP), BP |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 765 | MOVL BP, (g_sched+gobuf_pc)(SI) |
Russ Cox | f011282 | 2013-07-24 09:01:57 -0400 | [diff] [blame] | 766 | LEAL (12+4)(SP), DI |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 767 | MOVL DI, (g_sched+gobuf_sp)(SI) |
| 768 | |
| 769 | // Switch back to m->g0's stack and restore m->g0->sched.sp. |
| 770 | // (Unlike m->curg, the g0 goroutine never uses sched.pc, |
| 771 | // so we do not have to restore it.) |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 772 | MOVL g(CX), BP |
| 773 | MOVL g_m(BP), BP |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 774 | MOVL m_g0(BP), SI |
| 775 | MOVL SI, g(CX) |
| 776 | MOVL (g_sched+gobuf_sp)(SI), SP |
Russ Cox | dba623b | 2013-07-23 18:40:02 -0400 | [diff] [blame] | 777 | MOVL 0(SP), AX |
| 778 | MOVL AX, (g_sched+gobuf_sp)(SI) |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 779 | |
| 780 | // If the m on entry was nil, we called needm above to borrow an m |
| 781 | // for the duration of the call. Since the call is over, return it with dropm. |
Russ Cox | f011282 | 2013-07-24 09:01:57 -0400 | [diff] [blame] | 782 | CMPL DX, $0 |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 783 | JNE 3(PC) |
| 784 | MOVL $runtime·dropm(SB), AX |
| 785 | CALL AX |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 786 | |
| 787 | // Done! |
| 788 | RET |
| 789 | |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 790 | // void setg(G*); set g. for use by needm. |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 791 | TEXT runtime·setg(SB), NOSPLIT, $0-4 |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 792 | MOVL gg+0(FP), BX |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 793 | #ifdef GOOS_windows |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 794 | CMPL BX, $0 |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 795 | JNE settls |
| 796 | MOVL $0, 0x14(FS) |
| 797 | RET |
| 798 | settls: |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 799 | MOVL g_m(BX), AX |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 800 | LEAL m_tls(AX), AX |
| 801 | MOVL AX, 0x14(FS) |
| 802 | #endif |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 803 | get_tls(CX) |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 804 | MOVL BX, g(CX) |
| 805 | RET |
| 806 | |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 807 | // void setg_gcc(G*); set g. for use by gcc |
| 808 | TEXT setg_gcc<>(SB), NOSPLIT, $0 |
Russ Cox | 6a70f9d | 2013-03-25 18:14:02 -0400 | [diff] [blame] | 809 | get_tls(AX) |
Russ Cox | 89f185f | 2014-06-26 11:54:39 -0400 | [diff] [blame] | 810 | MOVL gg+0(FP), DX |
| 811 | MOVL DX, g(AX) |
Russ Cox | 6a70f9d | 2013-03-25 18:14:02 -0400 | [diff] [blame] | 812 | RET |
| 813 | |
Russ Cox | 8ac35be | 2014-09-09 14:02:37 -0400 | [diff] [blame^] | 814 | // check that SP is in range [g->stack.lo, g->stack.hi) |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 815 | TEXT runtime·stackcheck(SB), NOSPLIT, $0-0 |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 816 | get_tls(CX) |
| 817 | MOVL g(CX), AX |
Russ Cox | 15b76ad | 2014-09-09 13:39:57 -0400 | [diff] [blame] | 818 | CMPL (g_stack+stack_hi)(AX), SP |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 819 | JHI 2(PC) |
| 820 | INT $3 |
Russ Cox | 15b76ad | 2014-09-09 13:39:57 -0400 | [diff] [blame] | 821 | CMPL SP, (g_stack+stack_lo)(AX) |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 822 | JHI 2(PC) |
| 823 | INT $3 |
| 824 | RET |
| 825 | |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 826 | TEXT runtime·getcallerpc(SB),NOSPLIT,$0-8 |
| 827 | MOVL argp+0(FP),AX // addr of first arg |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 828 | MOVL -4(AX),AX // get calling pc |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 829 | MOVL AX, ret+4(FP) |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 830 | RET |
| 831 | |
Keith Randall | 61dca94 | 2014-06-16 23:03:03 -0700 | [diff] [blame] | 832 | TEXT runtime·gogetcallerpc(SB),NOSPLIT,$0-8 |
Keith Randall | 14c8143 | 2014-06-17 21:59:50 -0700 | [diff] [blame] | 833 | MOVL p+0(FP),AX // addr of first arg |
Keith Randall | 61dca94 | 2014-06-16 23:03:03 -0700 | [diff] [blame] | 834 | MOVL -4(AX),AX // get calling pc |
Keith Randall | 14c8143 | 2014-06-17 21:59:50 -0700 | [diff] [blame] | 835 | MOVL AX, ret+4(FP) |
Keith Randall | 61dca94 | 2014-06-16 23:03:03 -0700 | [diff] [blame] | 836 | RET |
| 837 | |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 838 | TEXT runtime·setcallerpc(SB),NOSPLIT,$0-8 |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 839 | MOVL argp+0(FP),AX // addr of first arg |
| 840 | MOVL pc+4(FP), BX |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 841 | MOVL BX, -4(AX) // set calling pc |
| 842 | RET |
| 843 | |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 844 | TEXT runtime·getcallersp(SB), NOSPLIT, $0-8 |
| 845 | MOVL argp+0(FP), AX |
| 846 | MOVL AX, ret+4(FP) |
Russ Cox | 6c19601 | 2010-04-05 12:51:09 -0700 | [diff] [blame] | 847 | RET |
| 848 | |
Rémy Oudompheng | 39ffa8b | 2014-08-26 08:34:46 +0200 | [diff] [blame] | 849 | // func gogetcallersp(p unsafe.Pointer) uintptr |
| 850 | TEXT runtime·gogetcallersp(SB),NOSPLIT,$0-8 |
| 851 | MOVL p+0(FP),AX // addr of first arg |
| 852 | MOVL AX, ret+4(FP) |
| 853 | RET |
| 854 | |
Damian Gryski | 8e765da | 2012-02-02 14:09:27 -0500 | [diff] [blame] | 855 | // int64 runtime·cputicks(void), so really |
| 856 | // void runtime·cputicks(int64 *ticks) |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 857 | TEXT runtime·cputicks(SB),NOSPLIT,$0-8 |
Shenghou Ma | 6392b43 | 2012-02-06 12:49:28 -0500 | [diff] [blame] | 858 | RDTSC |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 859 | MOVL AX, ret_lo+0(FP) |
| 860 | MOVL DX, ret_hi+4(FP) |
Damian Gryski | 8e765da | 2012-02-02 14:09:27 -0500 | [diff] [blame] | 861 | RET |
| 862 | |
Dmitriy Vyukov | 684de04 | 2014-08-21 20:41:09 +0400 | [diff] [blame] | 863 | TEXT runtime·gocputicks(SB),NOSPLIT,$0-8 |
| 864 | RDTSC |
Josh Bleecher Snyder | e5a06cc | 2014-08-26 12:38:18 -0700 | [diff] [blame] | 865 | MOVL AX, ret_lo+0(FP) |
| 866 | MOVL DX, ret_hi+4(FP) |
Dmitriy Vyukov | 684de04 | 2014-08-21 20:41:09 +0400 | [diff] [blame] | 867 | RET |
| 868 | |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 869 | TEXT runtime·ldt0setup(SB),NOSPLIT,$16-0 |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 870 | // set up ldt 7 to point at tls0 |
| 871 | // ldt 1 would be fine on Linux, but on OS X, 7 is as low as we can go. |
Russ Cox | 1b14bdb | 2009-09-22 16:28:32 -0700 | [diff] [blame] | 872 | // the entry number is just a hint. setldt will set up GS with what it used. |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 873 | MOVL $7, 0(SP) |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 874 | LEAL runtime·tls0(SB), AX |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 875 | MOVL AX, 4(SP) |
| 876 | MOVL $32, 8(SP) // sizeof(tls array) |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 877 | CALL runtime·setldt(SB) |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 878 | RET |
| 879 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 880 | TEXT runtime·emptyfunc(SB),0,$0-0 |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 881 | RET |
| 882 | |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 883 | TEXT runtime·abort(SB),NOSPLIT,$0-0 |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 884 | INT $0x3 |
Russ Cox | 133a158 | 2009-10-03 10:37:12 -0700 | [diff] [blame] | 885 | |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 886 | GLOBL runtime·tls0(SB), $32 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 887 | |
| 888 | // hash function using AES hardware instructions |
Keith Randall | a2a9768 | 2014-07-31 15:07:05 -0700 | [diff] [blame] | 889 | TEXT runtime·aeshash(SB),NOSPLIT,$0-16 |
| 890 | MOVL p+0(FP), AX // ptr to data |
| 891 | MOVL s+4(FP), CX // size |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 892 | JMP runtime·aeshashbody(SB) |
| 893 | |
Keith Randall | a2a9768 | 2014-07-31 15:07:05 -0700 | [diff] [blame] | 894 | TEXT runtime·aeshashstr(SB),NOSPLIT,$0-16 |
| 895 | MOVL p+0(FP), AX // ptr to string object |
| 896 | // s+4(FP) is ignored, it is always sizeof(String) |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 897 | MOVL 4(AX), CX // length of string |
| 898 | MOVL (AX), AX // string data |
| 899 | JMP runtime·aeshashbody(SB) |
| 900 | |
| 901 | // AX: data |
| 902 | // CX: length |
Keith Randall | a2a9768 | 2014-07-31 15:07:05 -0700 | [diff] [blame] | 903 | TEXT runtime·aeshashbody(SB),NOSPLIT,$0-16 |
| 904 | MOVL h+8(FP), X0 // seed to low 32 bits of xmm0 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 905 | PINSRD $1, CX, X0 // size to next 32 bits of xmm0 |
Keith Randall | db53d97 | 2013-03-20 14:34:26 -0700 | [diff] [blame] | 906 | MOVO runtime·aeskeysched+0(SB), X2 |
| 907 | MOVO runtime·aeskeysched+16(SB), X3 |
Keith Randall | ee66972 | 2013-05-15 09:40:14 -0700 | [diff] [blame] | 908 | CMPL CX, $16 |
| 909 | JB aessmall |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 910 | aesloop: |
| 911 | CMPL CX, $16 |
Keith Randall | ee66972 | 2013-05-15 09:40:14 -0700 | [diff] [blame] | 912 | JBE aesloopend |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 913 | MOVOU (AX), X1 |
| 914 | AESENC X2, X0 |
| 915 | AESENC X1, X0 |
| 916 | SUBL $16, CX |
| 917 | ADDL $16, AX |
| 918 | JMP aesloop |
Keith Randall | ee66972 | 2013-05-15 09:40:14 -0700 | [diff] [blame] | 919 | // 1-16 bytes remaining |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 920 | aesloopend: |
Keith Randall | ee66972 | 2013-05-15 09:40:14 -0700 | [diff] [blame] | 921 | // This load may overlap with the previous load above. |
| 922 | // We'll hash some bytes twice, but that's ok. |
| 923 | MOVOU -16(AX)(CX*1), X1 |
| 924 | JMP partial |
| 925 | // 0-15 bytes |
| 926 | aessmall: |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 927 | TESTL CX, CX |
Keith Randall | ee66972 | 2013-05-15 09:40:14 -0700 | [diff] [blame] | 928 | JE finalize // 0 bytes |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 929 | |
Keith Randall | ee66972 | 2013-05-15 09:40:14 -0700 | [diff] [blame] | 930 | CMPB AX, $0xf0 |
| 931 | JA highpartial |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 932 | |
Keith Randall | ee66972 | 2013-05-15 09:40:14 -0700 | [diff] [blame] | 933 | // 16 bytes loaded at this address won't cross |
| 934 | // a page boundary, so we can load it directly. |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 935 | MOVOU (AX), X1 |
| 936 | ADDL CX, CX |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 937 | PAND masks<>(SB)(CX*8), X1 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 938 | JMP partial |
| 939 | highpartial: |
Keith Randall | ee66972 | 2013-05-15 09:40:14 -0700 | [diff] [blame] | 940 | // address ends in 1111xxxx. Might be up against |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 941 | // a page boundary, so load ending at last byte. |
| 942 | // Then shift bytes down using pshufb. |
| 943 | MOVOU -16(AX)(CX*1), X1 |
| 944 | ADDL CX, CX |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 945 | PSHUFB shifts<>(SB)(CX*8), X1 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 946 | partial: |
| 947 | // incorporate partial block into hash |
| 948 | AESENC X3, X0 |
| 949 | AESENC X1, X0 |
| 950 | finalize: |
| 951 | // finalize hash |
| 952 | AESENC X2, X0 |
| 953 | AESENC X3, X0 |
| 954 | AESENC X2, X0 |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 955 | MOVL X0, ret+12(FP) |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 956 | RET |
| 957 | |
Keith Randall | a2a9768 | 2014-07-31 15:07:05 -0700 | [diff] [blame] | 958 | TEXT runtime·aeshash32(SB),NOSPLIT,$0-16 |
| 959 | MOVL p+0(FP), AX // ptr to data |
| 960 | // s+4(FP) is ignored, it is always sizeof(int32) |
| 961 | MOVL h+8(FP), X0 // seed |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 962 | PINSRD $1, (AX), X0 // data |
Keith Randall | db53d97 | 2013-03-20 14:34:26 -0700 | [diff] [blame] | 963 | AESENC runtime·aeskeysched+0(SB), X0 |
| 964 | AESENC runtime·aeskeysched+16(SB), X0 |
| 965 | AESENC runtime·aeskeysched+0(SB), X0 |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 966 | MOVL X0, ret+12(FP) |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 967 | RET |
| 968 | |
Keith Randall | a2a9768 | 2014-07-31 15:07:05 -0700 | [diff] [blame] | 969 | TEXT runtime·aeshash64(SB),NOSPLIT,$0-16 |
| 970 | MOVL p+0(FP), AX // ptr to data |
| 971 | // s+4(FP) is ignored, it is always sizeof(int64) |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 972 | MOVQ (AX), X0 // data |
Keith Randall | a2a9768 | 2014-07-31 15:07:05 -0700 | [diff] [blame] | 973 | PINSRD $2, h+8(FP), X0 // seed |
Keith Randall | db53d97 | 2013-03-20 14:34:26 -0700 | [diff] [blame] | 974 | AESENC runtime·aeskeysched+0(SB), X0 |
| 975 | AESENC runtime·aeskeysched+16(SB), X0 |
| 976 | AESENC runtime·aeskeysched+0(SB), X0 |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 977 | MOVL X0, ret+12(FP) |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 978 | RET |
| 979 | |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 980 | // simple mask to get rid of data in the high part of the register. |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 981 | DATA masks<>+0x00(SB)/4, $0x00000000 |
| 982 | DATA masks<>+0x04(SB)/4, $0x00000000 |
| 983 | DATA masks<>+0x08(SB)/4, $0x00000000 |
| 984 | DATA masks<>+0x0c(SB)/4, $0x00000000 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 985 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 986 | DATA masks<>+0x10(SB)/4, $0x000000ff |
| 987 | DATA masks<>+0x14(SB)/4, $0x00000000 |
| 988 | DATA masks<>+0x18(SB)/4, $0x00000000 |
| 989 | DATA masks<>+0x1c(SB)/4, $0x00000000 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 990 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 991 | DATA masks<>+0x20(SB)/4, $0x0000ffff |
| 992 | DATA masks<>+0x24(SB)/4, $0x00000000 |
| 993 | DATA masks<>+0x28(SB)/4, $0x00000000 |
| 994 | DATA masks<>+0x2c(SB)/4, $0x00000000 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 995 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 996 | DATA masks<>+0x30(SB)/4, $0x00ffffff |
| 997 | DATA masks<>+0x34(SB)/4, $0x00000000 |
| 998 | DATA masks<>+0x38(SB)/4, $0x00000000 |
| 999 | DATA masks<>+0x3c(SB)/4, $0x00000000 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 1000 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 1001 | DATA masks<>+0x40(SB)/4, $0xffffffff |
| 1002 | DATA masks<>+0x44(SB)/4, $0x00000000 |
| 1003 | DATA masks<>+0x48(SB)/4, $0x00000000 |
| 1004 | DATA masks<>+0x4c(SB)/4, $0x00000000 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 1005 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 1006 | DATA masks<>+0x50(SB)/4, $0xffffffff |
| 1007 | DATA masks<>+0x54(SB)/4, $0x000000ff |
| 1008 | DATA masks<>+0x58(SB)/4, $0x00000000 |
| 1009 | DATA masks<>+0x5c(SB)/4, $0x00000000 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 1010 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 1011 | DATA masks<>+0x60(SB)/4, $0xffffffff |
| 1012 | DATA masks<>+0x64(SB)/4, $0x0000ffff |
| 1013 | DATA masks<>+0x68(SB)/4, $0x00000000 |
| 1014 | DATA masks<>+0x6c(SB)/4, $0x00000000 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 1015 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 1016 | DATA masks<>+0x70(SB)/4, $0xffffffff |
| 1017 | DATA masks<>+0x74(SB)/4, $0x00ffffff |
| 1018 | DATA masks<>+0x78(SB)/4, $0x00000000 |
| 1019 | DATA masks<>+0x7c(SB)/4, $0x00000000 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 1020 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 1021 | DATA masks<>+0x80(SB)/4, $0xffffffff |
| 1022 | DATA masks<>+0x84(SB)/4, $0xffffffff |
| 1023 | DATA masks<>+0x88(SB)/4, $0x00000000 |
| 1024 | DATA masks<>+0x8c(SB)/4, $0x00000000 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 1025 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 1026 | DATA masks<>+0x90(SB)/4, $0xffffffff |
| 1027 | DATA masks<>+0x94(SB)/4, $0xffffffff |
| 1028 | DATA masks<>+0x98(SB)/4, $0x000000ff |
| 1029 | DATA masks<>+0x9c(SB)/4, $0x00000000 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 1030 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 1031 | DATA masks<>+0xa0(SB)/4, $0xffffffff |
| 1032 | DATA masks<>+0xa4(SB)/4, $0xffffffff |
| 1033 | DATA masks<>+0xa8(SB)/4, $0x0000ffff |
| 1034 | DATA masks<>+0xac(SB)/4, $0x00000000 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 1035 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 1036 | DATA masks<>+0xb0(SB)/4, $0xffffffff |
| 1037 | DATA masks<>+0xb4(SB)/4, $0xffffffff |
| 1038 | DATA masks<>+0xb8(SB)/4, $0x00ffffff |
| 1039 | DATA masks<>+0xbc(SB)/4, $0x00000000 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 1040 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 1041 | DATA masks<>+0xc0(SB)/4, $0xffffffff |
| 1042 | DATA masks<>+0xc4(SB)/4, $0xffffffff |
| 1043 | DATA masks<>+0xc8(SB)/4, $0xffffffff |
| 1044 | DATA masks<>+0xcc(SB)/4, $0x00000000 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 1045 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 1046 | DATA masks<>+0xd0(SB)/4, $0xffffffff |
| 1047 | DATA masks<>+0xd4(SB)/4, $0xffffffff |
| 1048 | DATA masks<>+0xd8(SB)/4, $0xffffffff |
| 1049 | DATA masks<>+0xdc(SB)/4, $0x000000ff |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 1050 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 1051 | DATA masks<>+0xe0(SB)/4, $0xffffffff |
| 1052 | DATA masks<>+0xe4(SB)/4, $0xffffffff |
| 1053 | DATA masks<>+0xe8(SB)/4, $0xffffffff |
| 1054 | DATA masks<>+0xec(SB)/4, $0x0000ffff |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 1055 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 1056 | DATA masks<>+0xf0(SB)/4, $0xffffffff |
| 1057 | DATA masks<>+0xf4(SB)/4, $0xffffffff |
| 1058 | DATA masks<>+0xf8(SB)/4, $0xffffffff |
| 1059 | DATA masks<>+0xfc(SB)/4, $0x00ffffff |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 1060 | |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 1061 | GLOBL masks<>(SB),RODATA,$256 |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 1062 | |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 1063 | // these are arguments to pshufb. They move data down from |
| 1064 | // the high bytes of the register to the low bytes of the register. |
| 1065 | // index is how many bytes to move. |
| 1066 | DATA shifts<>+0x00(SB)/4, $0x00000000 |
| 1067 | DATA shifts<>+0x04(SB)/4, $0x00000000 |
| 1068 | DATA shifts<>+0x08(SB)/4, $0x00000000 |
| 1069 | DATA shifts<>+0x0c(SB)/4, $0x00000000 |
| 1070 | |
| 1071 | DATA shifts<>+0x10(SB)/4, $0xffffff0f |
| 1072 | DATA shifts<>+0x14(SB)/4, $0xffffffff |
| 1073 | DATA shifts<>+0x18(SB)/4, $0xffffffff |
| 1074 | DATA shifts<>+0x1c(SB)/4, $0xffffffff |
| 1075 | |
| 1076 | DATA shifts<>+0x20(SB)/4, $0xffff0f0e |
| 1077 | DATA shifts<>+0x24(SB)/4, $0xffffffff |
| 1078 | DATA shifts<>+0x28(SB)/4, $0xffffffff |
| 1079 | DATA shifts<>+0x2c(SB)/4, $0xffffffff |
| 1080 | |
| 1081 | DATA shifts<>+0x30(SB)/4, $0xff0f0e0d |
| 1082 | DATA shifts<>+0x34(SB)/4, $0xffffffff |
| 1083 | DATA shifts<>+0x38(SB)/4, $0xffffffff |
| 1084 | DATA shifts<>+0x3c(SB)/4, $0xffffffff |
| 1085 | |
| 1086 | DATA shifts<>+0x40(SB)/4, $0x0f0e0d0c |
| 1087 | DATA shifts<>+0x44(SB)/4, $0xffffffff |
| 1088 | DATA shifts<>+0x48(SB)/4, $0xffffffff |
| 1089 | DATA shifts<>+0x4c(SB)/4, $0xffffffff |
| 1090 | |
| 1091 | DATA shifts<>+0x50(SB)/4, $0x0e0d0c0b |
| 1092 | DATA shifts<>+0x54(SB)/4, $0xffffff0f |
| 1093 | DATA shifts<>+0x58(SB)/4, $0xffffffff |
| 1094 | DATA shifts<>+0x5c(SB)/4, $0xffffffff |
| 1095 | |
| 1096 | DATA shifts<>+0x60(SB)/4, $0x0d0c0b0a |
| 1097 | DATA shifts<>+0x64(SB)/4, $0xffff0f0e |
| 1098 | DATA shifts<>+0x68(SB)/4, $0xffffffff |
| 1099 | DATA shifts<>+0x6c(SB)/4, $0xffffffff |
| 1100 | |
| 1101 | DATA shifts<>+0x70(SB)/4, $0x0c0b0a09 |
| 1102 | DATA shifts<>+0x74(SB)/4, $0xff0f0e0d |
| 1103 | DATA shifts<>+0x78(SB)/4, $0xffffffff |
| 1104 | DATA shifts<>+0x7c(SB)/4, $0xffffffff |
| 1105 | |
| 1106 | DATA shifts<>+0x80(SB)/4, $0x0b0a0908 |
| 1107 | DATA shifts<>+0x84(SB)/4, $0x0f0e0d0c |
| 1108 | DATA shifts<>+0x88(SB)/4, $0xffffffff |
| 1109 | DATA shifts<>+0x8c(SB)/4, $0xffffffff |
| 1110 | |
| 1111 | DATA shifts<>+0x90(SB)/4, $0x0a090807 |
| 1112 | DATA shifts<>+0x94(SB)/4, $0x0e0d0c0b |
| 1113 | DATA shifts<>+0x98(SB)/4, $0xffffff0f |
| 1114 | DATA shifts<>+0x9c(SB)/4, $0xffffffff |
| 1115 | |
| 1116 | DATA shifts<>+0xa0(SB)/4, $0x09080706 |
| 1117 | DATA shifts<>+0xa4(SB)/4, $0x0d0c0b0a |
| 1118 | DATA shifts<>+0xa8(SB)/4, $0xffff0f0e |
| 1119 | DATA shifts<>+0xac(SB)/4, $0xffffffff |
| 1120 | |
| 1121 | DATA shifts<>+0xb0(SB)/4, $0x08070605 |
| 1122 | DATA shifts<>+0xb4(SB)/4, $0x0c0b0a09 |
| 1123 | DATA shifts<>+0xb8(SB)/4, $0xff0f0e0d |
| 1124 | DATA shifts<>+0xbc(SB)/4, $0xffffffff |
| 1125 | |
| 1126 | DATA shifts<>+0xc0(SB)/4, $0x07060504 |
| 1127 | DATA shifts<>+0xc4(SB)/4, $0x0b0a0908 |
| 1128 | DATA shifts<>+0xc8(SB)/4, $0x0f0e0d0c |
| 1129 | DATA shifts<>+0xcc(SB)/4, $0xffffffff |
| 1130 | |
| 1131 | DATA shifts<>+0xd0(SB)/4, $0x06050403 |
| 1132 | DATA shifts<>+0xd4(SB)/4, $0x0a090807 |
| 1133 | DATA shifts<>+0xd8(SB)/4, $0x0e0d0c0b |
| 1134 | DATA shifts<>+0xdc(SB)/4, $0xffffff0f |
| 1135 | |
| 1136 | DATA shifts<>+0xe0(SB)/4, $0x05040302 |
| 1137 | DATA shifts<>+0xe4(SB)/4, $0x09080706 |
| 1138 | DATA shifts<>+0xe8(SB)/4, $0x0d0c0b0a |
| 1139 | DATA shifts<>+0xec(SB)/4, $0xffff0f0e |
| 1140 | |
| 1141 | DATA shifts<>+0xf0(SB)/4, $0x04030201 |
| 1142 | DATA shifts<>+0xf4(SB)/4, $0x08070605 |
| 1143 | DATA shifts<>+0xf8(SB)/4, $0x0c0b0a09 |
| 1144 | DATA shifts<>+0xfc(SB)/4, $0xff0f0e0d |
| 1145 | |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 1146 | GLOBL shifts<>(SB),RODATA,$256 |
Russ Cox | 9ddfb64 | 2013-07-16 16:24:09 -0400 | [diff] [blame] | 1147 | |
Keith Randall | 7aa4e5a | 2014-08-07 14:52:55 -0700 | [diff] [blame] | 1148 | TEXT runtime·memeq(SB),NOSPLIT,$0-13 |
Keith Randall | 0c6b55e | 2014-07-16 14:16:19 -0700 | [diff] [blame] | 1149 | MOVL a+0(FP), SI |
| 1150 | MOVL b+4(FP), DI |
| 1151 | MOVL size+8(FP), BX |
| 1152 | CALL runtime·memeqbody(SB) |
| 1153 | MOVB AX, ret+12(FP) |
| 1154 | RET |
| 1155 | |
Keith Randall | b36ed90 | 2014-06-16 21:00:37 -0700 | [diff] [blame] | 1156 | // eqstring tests whether two strings are equal. |
| 1157 | // See runtime_test.go:eqstring_generic for |
Josh Bleecher Snyder | 339a24d | 2014-08-19 08:50:35 -0700 | [diff] [blame] | 1158 | // equivalent Go code. |
Keith Randall | b36ed90 | 2014-06-16 21:00:37 -0700 | [diff] [blame] | 1159 | TEXT runtime·eqstring(SB),NOSPLIT,$0-17 |
| 1160 | MOVL s1len+4(FP), AX |
| 1161 | MOVL s2len+12(FP), BX |
| 1162 | CMPL AX, BX |
| 1163 | JNE different |
| 1164 | MOVL s1str+0(FP), SI |
| 1165 | MOVL s2str+8(FP), DI |
| 1166 | CMPL SI, DI |
| 1167 | JEQ same |
| 1168 | CALL runtime·memeqbody(SB) |
| 1169 | MOVB AX, v+16(FP) |
| 1170 | RET |
| 1171 | same: |
| 1172 | MOVB $1, v+16(FP) |
| 1173 | RET |
| 1174 | different: |
| 1175 | MOVB $0, v+16(FP) |
| 1176 | RET |
| 1177 | |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 1178 | TEXT bytes·Equal(SB),NOSPLIT,$0-25 |
Keith Randall | 3d5daa2 | 2013-04-02 16:26:15 -0700 | [diff] [blame] | 1179 | MOVL a_len+4(FP), BX |
| 1180 | MOVL b_len+16(FP), CX |
| 1181 | XORL AX, AX |
| 1182 | CMPL BX, CX |
| 1183 | JNE eqret |
| 1184 | MOVL a+0(FP), SI |
| 1185 | MOVL b+12(FP), DI |
| 1186 | CALL runtime·memeqbody(SB) |
| 1187 | eqret: |
| 1188 | MOVB AX, ret+24(FP) |
| 1189 | RET |
| 1190 | |
| 1191 | // a in SI |
| 1192 | // b in DI |
| 1193 | // count in BX |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 1194 | TEXT runtime·memeqbody(SB),NOSPLIT,$0-0 |
Keith Randall | 3d5daa2 | 2013-04-02 16:26:15 -0700 | [diff] [blame] | 1195 | XORL AX, AX |
| 1196 | |
| 1197 | CMPL BX, $4 |
| 1198 | JB small |
| 1199 | |
| 1200 | // 64 bytes at a time using xmm registers |
| 1201 | hugeloop: |
| 1202 | CMPL BX, $64 |
| 1203 | JB bigloop |
| 1204 | TESTL $0x4000000, runtime·cpuid_edx(SB) // check for sse2 |
| 1205 | JE bigloop |
| 1206 | MOVOU (SI), X0 |
| 1207 | MOVOU (DI), X1 |
| 1208 | MOVOU 16(SI), X2 |
| 1209 | MOVOU 16(DI), X3 |
| 1210 | MOVOU 32(SI), X4 |
| 1211 | MOVOU 32(DI), X5 |
| 1212 | MOVOU 48(SI), X6 |
| 1213 | MOVOU 48(DI), X7 |
| 1214 | PCMPEQB X1, X0 |
| 1215 | PCMPEQB X3, X2 |
| 1216 | PCMPEQB X5, X4 |
| 1217 | PCMPEQB X7, X6 |
| 1218 | PAND X2, X0 |
| 1219 | PAND X6, X4 |
| 1220 | PAND X4, X0 |
| 1221 | PMOVMSKB X0, DX |
| 1222 | ADDL $64, SI |
| 1223 | ADDL $64, DI |
| 1224 | SUBL $64, BX |
| 1225 | CMPL DX, $0xffff |
| 1226 | JEQ hugeloop |
| 1227 | RET |
| 1228 | |
| 1229 | // 4 bytes at a time using 32-bit register |
| 1230 | bigloop: |
| 1231 | CMPL BX, $4 |
| 1232 | JBE leftover |
| 1233 | MOVL (SI), CX |
| 1234 | MOVL (DI), DX |
| 1235 | ADDL $4, SI |
| 1236 | ADDL $4, DI |
| 1237 | SUBL $4, BX |
| 1238 | CMPL CX, DX |
| 1239 | JEQ bigloop |
| 1240 | RET |
| 1241 | |
| 1242 | // remaining 0-4 bytes |
| 1243 | leftover: |
| 1244 | MOVL -4(SI)(BX*1), CX |
| 1245 | MOVL -4(DI)(BX*1), DX |
| 1246 | CMPL CX, DX |
| 1247 | SETEQ AX |
| 1248 | RET |
| 1249 | |
| 1250 | small: |
| 1251 | CMPL BX, $0 |
| 1252 | JEQ equal |
| 1253 | |
| 1254 | LEAL 0(BX*8), CX |
| 1255 | NEGL CX |
| 1256 | |
| 1257 | MOVL SI, DX |
| 1258 | CMPB DX, $0xfc |
| 1259 | JA si_high |
| 1260 | |
| 1261 | // load at SI won't cross a page boundary. |
| 1262 | MOVL (SI), SI |
| 1263 | JMP si_finish |
| 1264 | si_high: |
| 1265 | // address ends in 111111xx. Load up to bytes we want, move to correct position. |
| 1266 | MOVL -4(SI)(BX*1), SI |
| 1267 | SHRL CX, SI |
| 1268 | si_finish: |
| 1269 | |
| 1270 | // same for DI. |
| 1271 | MOVL DI, DX |
| 1272 | CMPB DX, $0xfc |
| 1273 | JA di_high |
| 1274 | MOVL (DI), DI |
| 1275 | JMP di_finish |
| 1276 | di_high: |
| 1277 | MOVL -4(DI)(BX*1), DI |
| 1278 | SHRL CX, DI |
| 1279 | di_finish: |
| 1280 | |
| 1281 | SUBL SI, DI |
| 1282 | SHLL CX, DI |
| 1283 | equal: |
| 1284 | SETEQ AX |
| 1285 | RET |
Keith Randall | b3946dc | 2013-05-14 16:05:51 -0700 | [diff] [blame] | 1286 | |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 1287 | TEXT runtime·cmpstring(SB),NOSPLIT,$0-20 |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 1288 | MOVL s1_base+0(FP), SI |
| 1289 | MOVL s1_len+4(FP), BX |
| 1290 | MOVL s2_base+8(FP), DI |
| 1291 | MOVL s2_len+12(FP), DX |
Keith Randall | b3946dc | 2013-05-14 16:05:51 -0700 | [diff] [blame] | 1292 | CALL runtime·cmpbody(SB) |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 1293 | MOVL AX, ret+16(FP) |
Keith Randall | b3946dc | 2013-05-14 16:05:51 -0700 | [diff] [blame] | 1294 | RET |
| 1295 | |
Russ Cox | 6179aca | 2014-08-28 10:46:59 -0400 | [diff] [blame] | 1296 | TEXT runtime·cmpbytes(SB),NOSPLIT,$0-28 |
Keith Randall | b3946dc | 2013-05-14 16:05:51 -0700 | [diff] [blame] | 1297 | MOVL s1+0(FP), SI |
| 1298 | MOVL s1+4(FP), BX |
| 1299 | MOVL s2+12(FP), DI |
| 1300 | MOVL s2+16(FP), DX |
| 1301 | CALL runtime·cmpbody(SB) |
Russ Cox | 25f6b02 | 2014-08-27 11:32:17 -0400 | [diff] [blame] | 1302 | MOVL AX, ret+24(FP) |
Keith Randall | b3946dc | 2013-05-14 16:05:51 -0700 | [diff] [blame] | 1303 | RET |
| 1304 | |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 1305 | TEXT bytes·IndexByte(SB),NOSPLIT,$0 |
Brad Fitzpatrick | e2a1bd6 | 2013-08-01 16:11:19 -0700 | [diff] [blame] | 1306 | MOVL s+0(FP), SI |
| 1307 | MOVL s_len+4(FP), CX |
| 1308 | MOVB c+12(FP), AL |
| 1309 | MOVL SI, DI |
| 1310 | CLD; REPN; SCASB |
| 1311 | JZ 3(PC) |
| 1312 | MOVL $-1, ret+16(FP) |
| 1313 | RET |
| 1314 | SUBL SI, DI |
| 1315 | SUBL $1, DI |
| 1316 | MOVL DI, ret+16(FP) |
| 1317 | RET |
| 1318 | |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 1319 | TEXT strings·IndexByte(SB),NOSPLIT,$0 |
Brad Fitzpatrick | 598c789 | 2013-08-05 15:04:05 -0700 | [diff] [blame] | 1320 | MOVL s+0(FP), SI |
| 1321 | MOVL s_len+4(FP), CX |
| 1322 | MOVB c+8(FP), AL |
| 1323 | MOVL SI, DI |
| 1324 | CLD; REPN; SCASB |
| 1325 | JZ 3(PC) |
| 1326 | MOVL $-1, ret+12(FP) |
| 1327 | RET |
| 1328 | SUBL SI, DI |
| 1329 | SUBL $1, DI |
| 1330 | MOVL DI, ret+12(FP) |
| 1331 | RET |
| 1332 | |
Keith Randall | b3946dc | 2013-05-14 16:05:51 -0700 | [diff] [blame] | 1333 | // input: |
| 1334 | // SI = a |
| 1335 | // DI = b |
| 1336 | // BX = alen |
| 1337 | // DX = blen |
| 1338 | // output: |
| 1339 | // AX = 1/0/-1 |
Keith Randall | 5a54696 | 2013-08-07 10:23:24 -0700 | [diff] [blame] | 1340 | TEXT runtime·cmpbody(SB),NOSPLIT,$0-0 |
Keith Randall | b3946dc | 2013-05-14 16:05:51 -0700 | [diff] [blame] | 1341 | CMPL SI, DI |
| 1342 | JEQ cmp_allsame |
| 1343 | CMPL BX, DX |
| 1344 | MOVL DX, BP |
| 1345 | CMOVLLT BX, BP // BP = min(alen, blen) |
| 1346 | CMPL BP, $4 |
| 1347 | JB cmp_small |
| 1348 | TESTL $0x4000000, runtime·cpuid_edx(SB) // check for sse2 |
| 1349 | JE cmp_mediumloop |
| 1350 | cmp_largeloop: |
| 1351 | CMPL BP, $16 |
| 1352 | JB cmp_mediumloop |
| 1353 | MOVOU (SI), X0 |
| 1354 | MOVOU (DI), X1 |
| 1355 | PCMPEQB X0, X1 |
| 1356 | PMOVMSKB X1, AX |
| 1357 | XORL $0xffff, AX // convert EQ to NE |
| 1358 | JNE cmp_diff16 // branch if at least one byte is not equal |
| 1359 | ADDL $16, SI |
| 1360 | ADDL $16, DI |
| 1361 | SUBL $16, BP |
| 1362 | JMP cmp_largeloop |
| 1363 | |
| 1364 | cmp_diff16: |
| 1365 | BSFL AX, BX // index of first byte that differs |
| 1366 | XORL AX, AX |
| 1367 | MOVB (SI)(BX*1), CX |
| 1368 | CMPB CX, (DI)(BX*1) |
| 1369 | SETHI AX |
| 1370 | LEAL -1(AX*2), AX // convert 1/0 to +1/-1 |
| 1371 | RET |
| 1372 | |
| 1373 | cmp_mediumloop: |
| 1374 | CMPL BP, $4 |
| 1375 | JBE cmp_0through4 |
| 1376 | MOVL (SI), AX |
| 1377 | MOVL (DI), CX |
| 1378 | CMPL AX, CX |
| 1379 | JNE cmp_diff4 |
| 1380 | ADDL $4, SI |
| 1381 | ADDL $4, DI |
| 1382 | SUBL $4, BP |
| 1383 | JMP cmp_mediumloop |
| 1384 | |
| 1385 | cmp_0through4: |
| 1386 | MOVL -4(SI)(BP*1), AX |
| 1387 | MOVL -4(DI)(BP*1), CX |
| 1388 | CMPL AX, CX |
| 1389 | JEQ cmp_allsame |
| 1390 | |
| 1391 | cmp_diff4: |
| 1392 | BSWAPL AX // reverse order of bytes |
| 1393 | BSWAPL CX |
| 1394 | XORL AX, CX // find bit differences |
| 1395 | BSRL CX, CX // index of highest bit difference |
| 1396 | SHRL CX, AX // move a's bit to bottom |
| 1397 | ANDL $1, AX // mask bit |
| 1398 | LEAL -1(AX*2), AX // 1/0 => +1/-1 |
| 1399 | RET |
| 1400 | |
| 1401 | // 0-3 bytes in common |
| 1402 | cmp_small: |
| 1403 | LEAL (BP*8), CX |
| 1404 | NEGL CX |
| 1405 | JEQ cmp_allsame |
| 1406 | |
| 1407 | // load si |
| 1408 | CMPB SI, $0xfc |
| 1409 | JA cmp_si_high |
| 1410 | MOVL (SI), SI |
| 1411 | JMP cmp_si_finish |
| 1412 | cmp_si_high: |
| 1413 | MOVL -4(SI)(BP*1), SI |
| 1414 | SHRL CX, SI |
| 1415 | cmp_si_finish: |
| 1416 | SHLL CX, SI |
| 1417 | |
| 1418 | // same for di |
| 1419 | CMPB DI, $0xfc |
| 1420 | JA cmp_di_high |
| 1421 | MOVL (DI), DI |
| 1422 | JMP cmp_di_finish |
| 1423 | cmp_di_high: |
| 1424 | MOVL -4(DI)(BP*1), DI |
| 1425 | SHRL CX, DI |
| 1426 | cmp_di_finish: |
| 1427 | SHLL CX, DI |
| 1428 | |
| 1429 | BSWAPL SI // reverse order of bytes |
| 1430 | BSWAPL DI |
| 1431 | XORL SI, DI // find bit differences |
| 1432 | JEQ cmp_allsame |
| 1433 | BSRL DI, CX // index of highest bit difference |
| 1434 | SHRL CX, SI // move a's bit to bottom |
| 1435 | ANDL $1, SI // mask bit |
| 1436 | LEAL -1(SI*2), AX // 1/0 => +1/-1 |
| 1437 | RET |
| 1438 | |
| 1439 | // all the bytes in common are the same, so we just need |
| 1440 | // to compare the lengths. |
| 1441 | cmp_allsame: |
| 1442 | XORL AX, AX |
| 1443 | XORL CX, CX |
| 1444 | CMPL BX, DX |
| 1445 | SETGT AX // 1 if alen > blen |
| 1446 | SETEQ CX // 1 if alen == blen |
| 1447 | LEAL -1(CX)(AX*2), AX // 1,0,-1 result |
| 1448 | RET |
Keith Randall | 6c7cbf0 | 2014-04-01 12:51:02 -0700 | [diff] [blame] | 1449 | |
| 1450 | // A Duff's device for zeroing memory. |
| 1451 | // The compiler jumps to computed addresses within |
| 1452 | // this routine to zero chunks of memory. Do not |
| 1453 | // change this code without also changing the code |
| 1454 | // in ../../cmd/8g/ggen.c:clearfat. |
| 1455 | // AX: zero |
| 1456 | // DI: ptr to memory to be zeroed |
| 1457 | // DI is updated as a side effect. |
| 1458 | TEXT runtime·duffzero(SB), NOSPLIT, $0-0 |
| 1459 | STOSL |
| 1460 | STOSL |
| 1461 | STOSL |
| 1462 | STOSL |
| 1463 | STOSL |
| 1464 | STOSL |
| 1465 | STOSL |
| 1466 | STOSL |
| 1467 | STOSL |
| 1468 | STOSL |
| 1469 | STOSL |
| 1470 | STOSL |
| 1471 | STOSL |
| 1472 | STOSL |
| 1473 | STOSL |
| 1474 | STOSL |
| 1475 | STOSL |
| 1476 | STOSL |
| 1477 | STOSL |
| 1478 | STOSL |
| 1479 | STOSL |
| 1480 | STOSL |
| 1481 | STOSL |
| 1482 | STOSL |
| 1483 | STOSL |
| 1484 | STOSL |
| 1485 | STOSL |
| 1486 | STOSL |
| 1487 | STOSL |
| 1488 | STOSL |
| 1489 | STOSL |
| 1490 | STOSL |
| 1491 | STOSL |
| 1492 | STOSL |
| 1493 | STOSL |
| 1494 | STOSL |
| 1495 | STOSL |
| 1496 | STOSL |
| 1497 | STOSL |
| 1498 | STOSL |
| 1499 | STOSL |
| 1500 | STOSL |
| 1501 | STOSL |
| 1502 | STOSL |
| 1503 | STOSL |
| 1504 | STOSL |
| 1505 | STOSL |
| 1506 | STOSL |
| 1507 | STOSL |
| 1508 | STOSL |
| 1509 | STOSL |
| 1510 | STOSL |
| 1511 | STOSL |
| 1512 | STOSL |
| 1513 | STOSL |
| 1514 | STOSL |
| 1515 | STOSL |
| 1516 | STOSL |
| 1517 | STOSL |
| 1518 | STOSL |
| 1519 | STOSL |
| 1520 | STOSL |
| 1521 | STOSL |
| 1522 | STOSL |
| 1523 | STOSL |
| 1524 | STOSL |
| 1525 | STOSL |
| 1526 | STOSL |
| 1527 | STOSL |
| 1528 | STOSL |
| 1529 | STOSL |
| 1530 | STOSL |
| 1531 | STOSL |
| 1532 | STOSL |
| 1533 | STOSL |
| 1534 | STOSL |
| 1535 | STOSL |
| 1536 | STOSL |
| 1537 | STOSL |
| 1538 | STOSL |
| 1539 | STOSL |
| 1540 | STOSL |
| 1541 | STOSL |
| 1542 | STOSL |
| 1543 | STOSL |
| 1544 | STOSL |
| 1545 | STOSL |
| 1546 | STOSL |
| 1547 | STOSL |
| 1548 | STOSL |
| 1549 | STOSL |
| 1550 | STOSL |
| 1551 | STOSL |
| 1552 | STOSL |
| 1553 | STOSL |
| 1554 | STOSL |
| 1555 | STOSL |
| 1556 | STOSL |
| 1557 | STOSL |
| 1558 | STOSL |
| 1559 | STOSL |
| 1560 | STOSL |
| 1561 | STOSL |
| 1562 | STOSL |
| 1563 | STOSL |
| 1564 | STOSL |
| 1565 | STOSL |
| 1566 | STOSL |
| 1567 | STOSL |
| 1568 | STOSL |
| 1569 | STOSL |
| 1570 | STOSL |
| 1571 | STOSL |
| 1572 | STOSL |
| 1573 | STOSL |
| 1574 | STOSL |
| 1575 | STOSL |
| 1576 | STOSL |
| 1577 | STOSL |
| 1578 | STOSL |
| 1579 | STOSL |
| 1580 | STOSL |
| 1581 | STOSL |
| 1582 | STOSL |
| 1583 | STOSL |
| 1584 | STOSL |
| 1585 | STOSL |
| 1586 | STOSL |
| 1587 | RET |
| 1588 | |
| 1589 | // A Duff's device for copying memory. |
| 1590 | // The compiler jumps to computed addresses within |
| 1591 | // this routine to copy chunks of memory. Source |
| 1592 | // and destination must not overlap. Do not |
| 1593 | // change this code without also changing the code |
| 1594 | // in ../../cmd/6g/cgen.c:sgen. |
| 1595 | // SI: ptr to source memory |
| 1596 | // DI: ptr to destination memory |
| 1597 | // SI and DI are updated as a side effect. |
| 1598 | |
| 1599 | // NOTE: this is equivalent to a sequence of MOVSL but |
| 1600 | // for some reason MOVSL is really slow. |
| 1601 | TEXT runtime·duffcopy(SB), NOSPLIT, $0-0 |
| 1602 | MOVL (SI),CX |
| 1603 | ADDL $4,SI |
| 1604 | MOVL CX,(DI) |
| 1605 | ADDL $4,DI |
| 1606 | |
| 1607 | MOVL (SI),CX |
| 1608 | ADDL $4,SI |
| 1609 | MOVL CX,(DI) |
| 1610 | ADDL $4,DI |
| 1611 | |
| 1612 | MOVL (SI),CX |
| 1613 | ADDL $4,SI |
| 1614 | MOVL CX,(DI) |
| 1615 | ADDL $4,DI |
| 1616 | |
| 1617 | MOVL (SI),CX |
| 1618 | ADDL $4,SI |
| 1619 | MOVL CX,(DI) |
| 1620 | ADDL $4,DI |
| 1621 | |
| 1622 | MOVL (SI),CX |
| 1623 | ADDL $4,SI |
| 1624 | MOVL CX,(DI) |
| 1625 | ADDL $4,DI |
| 1626 | |
| 1627 | MOVL (SI),CX |
| 1628 | ADDL $4,SI |
| 1629 | MOVL CX,(DI) |
| 1630 | ADDL $4,DI |
| 1631 | |
| 1632 | MOVL (SI),CX |
| 1633 | ADDL $4,SI |
| 1634 | MOVL CX,(DI) |
| 1635 | ADDL $4,DI |
| 1636 | |
| 1637 | MOVL (SI),CX |
| 1638 | ADDL $4,SI |
| 1639 | MOVL CX,(DI) |
| 1640 | ADDL $4,DI |
| 1641 | |
| 1642 | MOVL (SI),CX |
| 1643 | ADDL $4,SI |
| 1644 | MOVL CX,(DI) |
| 1645 | ADDL $4,DI |
| 1646 | |
| 1647 | MOVL (SI),CX |
| 1648 | ADDL $4,SI |
| 1649 | MOVL CX,(DI) |
| 1650 | ADDL $4,DI |
| 1651 | |
| 1652 | MOVL (SI),CX |
| 1653 | ADDL $4,SI |
| 1654 | MOVL CX,(DI) |
| 1655 | ADDL $4,DI |
| 1656 | |
| 1657 | MOVL (SI),CX |
| 1658 | ADDL $4,SI |
| 1659 | MOVL CX,(DI) |
| 1660 | ADDL $4,DI |
| 1661 | |
| 1662 | MOVL (SI),CX |
| 1663 | ADDL $4,SI |
| 1664 | MOVL CX,(DI) |
| 1665 | ADDL $4,DI |
| 1666 | |
| 1667 | MOVL (SI),CX |
| 1668 | ADDL $4,SI |
| 1669 | MOVL CX,(DI) |
| 1670 | ADDL $4,DI |
| 1671 | |
| 1672 | MOVL (SI),CX |
| 1673 | ADDL $4,SI |
| 1674 | MOVL CX,(DI) |
| 1675 | ADDL $4,DI |
| 1676 | |
| 1677 | MOVL (SI),CX |
| 1678 | ADDL $4,SI |
| 1679 | MOVL CX,(DI) |
| 1680 | ADDL $4,DI |
| 1681 | |
| 1682 | MOVL (SI),CX |
| 1683 | ADDL $4,SI |
| 1684 | MOVL CX,(DI) |
| 1685 | ADDL $4,DI |
| 1686 | |
| 1687 | MOVL (SI),CX |
| 1688 | ADDL $4,SI |
| 1689 | MOVL CX,(DI) |
| 1690 | ADDL $4,DI |
| 1691 | |
| 1692 | MOVL (SI),CX |
| 1693 | ADDL $4,SI |
| 1694 | MOVL CX,(DI) |
| 1695 | ADDL $4,DI |
| 1696 | |
| 1697 | MOVL (SI),CX |
| 1698 | ADDL $4,SI |
| 1699 | MOVL CX,(DI) |
| 1700 | ADDL $4,DI |
| 1701 | |
| 1702 | MOVL (SI),CX |
| 1703 | ADDL $4,SI |
| 1704 | MOVL CX,(DI) |
| 1705 | ADDL $4,DI |
| 1706 | |
| 1707 | MOVL (SI),CX |
| 1708 | ADDL $4,SI |
| 1709 | MOVL CX,(DI) |
| 1710 | ADDL $4,DI |
| 1711 | |
| 1712 | MOVL (SI),CX |
| 1713 | ADDL $4,SI |
| 1714 | MOVL CX,(DI) |
| 1715 | ADDL $4,DI |
| 1716 | |
| 1717 | MOVL (SI),CX |
| 1718 | ADDL $4,SI |
| 1719 | MOVL CX,(DI) |
| 1720 | ADDL $4,DI |
| 1721 | |
| 1722 | MOVL (SI),CX |
| 1723 | ADDL $4,SI |
| 1724 | MOVL CX,(DI) |
| 1725 | ADDL $4,DI |
| 1726 | |
| 1727 | MOVL (SI),CX |
| 1728 | ADDL $4,SI |
| 1729 | MOVL CX,(DI) |
| 1730 | ADDL $4,DI |
| 1731 | |
| 1732 | MOVL (SI),CX |
| 1733 | ADDL $4,SI |
| 1734 | MOVL CX,(DI) |
| 1735 | ADDL $4,DI |
| 1736 | |
| 1737 | MOVL (SI),CX |
| 1738 | ADDL $4,SI |
| 1739 | MOVL CX,(DI) |
| 1740 | ADDL $4,DI |
| 1741 | |
| 1742 | MOVL (SI),CX |
| 1743 | ADDL $4,SI |
| 1744 | MOVL CX,(DI) |
| 1745 | ADDL $4,DI |
| 1746 | |
| 1747 | MOVL (SI),CX |
| 1748 | ADDL $4,SI |
| 1749 | MOVL CX,(DI) |
| 1750 | ADDL $4,DI |
| 1751 | |
| 1752 | MOVL (SI),CX |
| 1753 | ADDL $4,SI |
| 1754 | MOVL CX,(DI) |
| 1755 | ADDL $4,DI |
| 1756 | |
| 1757 | MOVL (SI),CX |
| 1758 | ADDL $4,SI |
| 1759 | MOVL CX,(DI) |
| 1760 | ADDL $4,DI |
| 1761 | |
| 1762 | MOVL (SI),CX |
| 1763 | ADDL $4,SI |
| 1764 | MOVL CX,(DI) |
| 1765 | ADDL $4,DI |
| 1766 | |
| 1767 | MOVL (SI),CX |
| 1768 | ADDL $4,SI |
| 1769 | MOVL CX,(DI) |
| 1770 | ADDL $4,DI |
| 1771 | |
| 1772 | MOVL (SI),CX |
| 1773 | ADDL $4,SI |
| 1774 | MOVL CX,(DI) |
| 1775 | ADDL $4,DI |
| 1776 | |
| 1777 | MOVL (SI),CX |
| 1778 | ADDL $4,SI |
| 1779 | MOVL CX,(DI) |
| 1780 | ADDL $4,DI |
| 1781 | |
| 1782 | MOVL (SI),CX |
| 1783 | ADDL $4,SI |
| 1784 | MOVL CX,(DI) |
| 1785 | ADDL $4,DI |
| 1786 | |
| 1787 | MOVL (SI),CX |
| 1788 | ADDL $4,SI |
| 1789 | MOVL CX,(DI) |
| 1790 | ADDL $4,DI |
| 1791 | |
| 1792 | MOVL (SI),CX |
| 1793 | ADDL $4,SI |
| 1794 | MOVL CX,(DI) |
| 1795 | ADDL $4,DI |
| 1796 | |
| 1797 | MOVL (SI),CX |
| 1798 | ADDL $4,SI |
| 1799 | MOVL CX,(DI) |
| 1800 | ADDL $4,DI |
| 1801 | |
| 1802 | MOVL (SI),CX |
| 1803 | ADDL $4,SI |
| 1804 | MOVL CX,(DI) |
| 1805 | ADDL $4,DI |
| 1806 | |
| 1807 | MOVL (SI),CX |
| 1808 | ADDL $4,SI |
| 1809 | MOVL CX,(DI) |
| 1810 | ADDL $4,DI |
| 1811 | |
| 1812 | MOVL (SI),CX |
| 1813 | ADDL $4,SI |
| 1814 | MOVL CX,(DI) |
| 1815 | ADDL $4,DI |
| 1816 | |
| 1817 | MOVL (SI),CX |
| 1818 | ADDL $4,SI |
| 1819 | MOVL CX,(DI) |
| 1820 | ADDL $4,DI |
| 1821 | |
| 1822 | MOVL (SI),CX |
| 1823 | ADDL $4,SI |
| 1824 | MOVL CX,(DI) |
| 1825 | ADDL $4,DI |
| 1826 | |
| 1827 | MOVL (SI),CX |
| 1828 | ADDL $4,SI |
| 1829 | MOVL CX,(DI) |
| 1830 | ADDL $4,DI |
| 1831 | |
| 1832 | MOVL (SI),CX |
| 1833 | ADDL $4,SI |
| 1834 | MOVL CX,(DI) |
| 1835 | ADDL $4,DI |
| 1836 | |
| 1837 | MOVL (SI),CX |
| 1838 | ADDL $4,SI |
| 1839 | MOVL CX,(DI) |
| 1840 | ADDL $4,DI |
| 1841 | |
| 1842 | MOVL (SI),CX |
| 1843 | ADDL $4,SI |
| 1844 | MOVL CX,(DI) |
| 1845 | ADDL $4,DI |
| 1846 | |
| 1847 | MOVL (SI),CX |
| 1848 | ADDL $4,SI |
| 1849 | MOVL CX,(DI) |
| 1850 | ADDL $4,DI |
| 1851 | |
| 1852 | MOVL (SI),CX |
| 1853 | ADDL $4,SI |
| 1854 | MOVL CX,(DI) |
| 1855 | ADDL $4,DI |
| 1856 | |
| 1857 | MOVL (SI),CX |
| 1858 | ADDL $4,SI |
| 1859 | MOVL CX,(DI) |
| 1860 | ADDL $4,DI |
| 1861 | |
| 1862 | MOVL (SI),CX |
| 1863 | ADDL $4,SI |
| 1864 | MOVL CX,(DI) |
| 1865 | ADDL $4,DI |
| 1866 | |
| 1867 | MOVL (SI),CX |
| 1868 | ADDL $4,SI |
| 1869 | MOVL CX,(DI) |
| 1870 | ADDL $4,DI |
| 1871 | |
| 1872 | MOVL (SI),CX |
| 1873 | ADDL $4,SI |
| 1874 | MOVL CX,(DI) |
| 1875 | ADDL $4,DI |
| 1876 | |
| 1877 | MOVL (SI),CX |
| 1878 | ADDL $4,SI |
| 1879 | MOVL CX,(DI) |
| 1880 | ADDL $4,DI |
| 1881 | |
| 1882 | MOVL (SI),CX |
| 1883 | ADDL $4,SI |
| 1884 | MOVL CX,(DI) |
| 1885 | ADDL $4,DI |
| 1886 | |
| 1887 | MOVL (SI),CX |
| 1888 | ADDL $4,SI |
| 1889 | MOVL CX,(DI) |
| 1890 | ADDL $4,DI |
| 1891 | |
| 1892 | MOVL (SI),CX |
| 1893 | ADDL $4,SI |
| 1894 | MOVL CX,(DI) |
| 1895 | ADDL $4,DI |
| 1896 | |
| 1897 | MOVL (SI),CX |
| 1898 | ADDL $4,SI |
| 1899 | MOVL CX,(DI) |
| 1900 | ADDL $4,DI |
| 1901 | |
| 1902 | MOVL (SI),CX |
| 1903 | ADDL $4,SI |
| 1904 | MOVL CX,(DI) |
| 1905 | ADDL $4,DI |
| 1906 | |
| 1907 | MOVL (SI),CX |
| 1908 | ADDL $4,SI |
| 1909 | MOVL CX,(DI) |
| 1910 | ADDL $4,DI |
| 1911 | |
| 1912 | MOVL (SI),CX |
| 1913 | ADDL $4,SI |
| 1914 | MOVL CX,(DI) |
| 1915 | ADDL $4,DI |
| 1916 | |
| 1917 | MOVL (SI),CX |
| 1918 | ADDL $4,SI |
| 1919 | MOVL CX,(DI) |
| 1920 | ADDL $4,DI |
| 1921 | |
| 1922 | MOVL (SI),CX |
| 1923 | ADDL $4,SI |
| 1924 | MOVL CX,(DI) |
| 1925 | ADDL $4,DI |
| 1926 | |
| 1927 | MOVL (SI),CX |
| 1928 | ADDL $4,SI |
| 1929 | MOVL CX,(DI) |
| 1930 | ADDL $4,DI |
| 1931 | |
| 1932 | MOVL (SI),CX |
| 1933 | ADDL $4,SI |
| 1934 | MOVL CX,(DI) |
| 1935 | ADDL $4,DI |
| 1936 | |
| 1937 | MOVL (SI),CX |
| 1938 | ADDL $4,SI |
| 1939 | MOVL CX,(DI) |
| 1940 | ADDL $4,DI |
| 1941 | |
| 1942 | MOVL (SI),CX |
| 1943 | ADDL $4,SI |
| 1944 | MOVL CX,(DI) |
| 1945 | ADDL $4,DI |
| 1946 | |
| 1947 | MOVL (SI),CX |
| 1948 | ADDL $4,SI |
| 1949 | MOVL CX,(DI) |
| 1950 | ADDL $4,DI |
| 1951 | |
| 1952 | MOVL (SI),CX |
| 1953 | ADDL $4,SI |
| 1954 | MOVL CX,(DI) |
| 1955 | ADDL $4,DI |
| 1956 | |
| 1957 | MOVL (SI),CX |
| 1958 | ADDL $4,SI |
| 1959 | MOVL CX,(DI) |
| 1960 | ADDL $4,DI |
| 1961 | |
| 1962 | MOVL (SI),CX |
| 1963 | ADDL $4,SI |
| 1964 | MOVL CX,(DI) |
| 1965 | ADDL $4,DI |
| 1966 | |
| 1967 | MOVL (SI),CX |
| 1968 | ADDL $4,SI |
| 1969 | MOVL CX,(DI) |
| 1970 | ADDL $4,DI |
| 1971 | |
| 1972 | MOVL (SI),CX |
| 1973 | ADDL $4,SI |
| 1974 | MOVL CX,(DI) |
| 1975 | ADDL $4,DI |
| 1976 | |
| 1977 | MOVL (SI),CX |
| 1978 | ADDL $4,SI |
| 1979 | MOVL CX,(DI) |
| 1980 | ADDL $4,DI |
| 1981 | |
| 1982 | MOVL (SI),CX |
| 1983 | ADDL $4,SI |
| 1984 | MOVL CX,(DI) |
| 1985 | ADDL $4,DI |
| 1986 | |
| 1987 | MOVL (SI),CX |
| 1988 | ADDL $4,SI |
| 1989 | MOVL CX,(DI) |
| 1990 | ADDL $4,DI |
| 1991 | |
| 1992 | MOVL (SI),CX |
| 1993 | ADDL $4,SI |
| 1994 | MOVL CX,(DI) |
| 1995 | ADDL $4,DI |
| 1996 | |
| 1997 | MOVL (SI),CX |
| 1998 | ADDL $4,SI |
| 1999 | MOVL CX,(DI) |
| 2000 | ADDL $4,DI |
| 2001 | |
| 2002 | MOVL (SI),CX |
| 2003 | ADDL $4,SI |
| 2004 | MOVL CX,(DI) |
| 2005 | ADDL $4,DI |
| 2006 | |
| 2007 | MOVL (SI),CX |
| 2008 | ADDL $4,SI |
| 2009 | MOVL CX,(DI) |
| 2010 | ADDL $4,DI |
| 2011 | |
| 2012 | MOVL (SI),CX |
| 2013 | ADDL $4,SI |
| 2014 | MOVL CX,(DI) |
| 2015 | ADDL $4,DI |
| 2016 | |
| 2017 | MOVL (SI),CX |
| 2018 | ADDL $4,SI |
| 2019 | MOVL CX,(DI) |
| 2020 | ADDL $4,DI |
| 2021 | |
| 2022 | MOVL (SI),CX |
| 2023 | ADDL $4,SI |
| 2024 | MOVL CX,(DI) |
| 2025 | ADDL $4,DI |
| 2026 | |
| 2027 | MOVL (SI),CX |
| 2028 | ADDL $4,SI |
| 2029 | MOVL CX,(DI) |
| 2030 | ADDL $4,DI |
| 2031 | |
| 2032 | MOVL (SI),CX |
| 2033 | ADDL $4,SI |
| 2034 | MOVL CX,(DI) |
| 2035 | ADDL $4,DI |
| 2036 | |
| 2037 | MOVL (SI),CX |
| 2038 | ADDL $4,SI |
| 2039 | MOVL CX,(DI) |
| 2040 | ADDL $4,DI |
| 2041 | |
| 2042 | MOVL (SI),CX |
| 2043 | ADDL $4,SI |
| 2044 | MOVL CX,(DI) |
| 2045 | ADDL $4,DI |
| 2046 | |
| 2047 | MOVL (SI),CX |
| 2048 | ADDL $4,SI |
| 2049 | MOVL CX,(DI) |
| 2050 | ADDL $4,DI |
| 2051 | |
| 2052 | MOVL (SI),CX |
| 2053 | ADDL $4,SI |
| 2054 | MOVL CX,(DI) |
| 2055 | ADDL $4,DI |
| 2056 | |
| 2057 | MOVL (SI),CX |
| 2058 | ADDL $4,SI |
| 2059 | MOVL CX,(DI) |
| 2060 | ADDL $4,DI |
| 2061 | |
| 2062 | MOVL (SI),CX |
| 2063 | ADDL $4,SI |
| 2064 | MOVL CX,(DI) |
| 2065 | ADDL $4,DI |
| 2066 | |
| 2067 | MOVL (SI),CX |
| 2068 | ADDL $4,SI |
| 2069 | MOVL CX,(DI) |
| 2070 | ADDL $4,DI |
| 2071 | |
| 2072 | MOVL (SI),CX |
| 2073 | ADDL $4,SI |
| 2074 | MOVL CX,(DI) |
| 2075 | ADDL $4,DI |
| 2076 | |
| 2077 | MOVL (SI),CX |
| 2078 | ADDL $4,SI |
| 2079 | MOVL CX,(DI) |
| 2080 | ADDL $4,DI |
| 2081 | |
| 2082 | MOVL (SI),CX |
| 2083 | ADDL $4,SI |
| 2084 | MOVL CX,(DI) |
| 2085 | ADDL $4,DI |
| 2086 | |
| 2087 | MOVL (SI),CX |
| 2088 | ADDL $4,SI |
| 2089 | MOVL CX,(DI) |
| 2090 | ADDL $4,DI |
| 2091 | |
| 2092 | MOVL (SI),CX |
| 2093 | ADDL $4,SI |
| 2094 | MOVL CX,(DI) |
| 2095 | ADDL $4,DI |
| 2096 | |
| 2097 | MOVL (SI),CX |
| 2098 | ADDL $4,SI |
| 2099 | MOVL CX,(DI) |
| 2100 | ADDL $4,DI |
| 2101 | |
| 2102 | MOVL (SI),CX |
| 2103 | ADDL $4,SI |
| 2104 | MOVL CX,(DI) |
| 2105 | ADDL $4,DI |
| 2106 | |
| 2107 | MOVL (SI),CX |
| 2108 | ADDL $4,SI |
| 2109 | MOVL CX,(DI) |
| 2110 | ADDL $4,DI |
| 2111 | |
| 2112 | MOVL (SI),CX |
| 2113 | ADDL $4,SI |
| 2114 | MOVL CX,(DI) |
| 2115 | ADDL $4,DI |
| 2116 | |
| 2117 | MOVL (SI),CX |
| 2118 | ADDL $4,SI |
| 2119 | MOVL CX,(DI) |
| 2120 | ADDL $4,DI |
| 2121 | |
| 2122 | MOVL (SI),CX |
| 2123 | ADDL $4,SI |
| 2124 | MOVL CX,(DI) |
| 2125 | ADDL $4,DI |
| 2126 | |
| 2127 | MOVL (SI),CX |
| 2128 | ADDL $4,SI |
| 2129 | MOVL CX,(DI) |
| 2130 | ADDL $4,DI |
| 2131 | |
| 2132 | MOVL (SI),CX |
| 2133 | ADDL $4,SI |
| 2134 | MOVL CX,(DI) |
| 2135 | ADDL $4,DI |
| 2136 | |
| 2137 | MOVL (SI),CX |
| 2138 | ADDL $4,SI |
| 2139 | MOVL CX,(DI) |
| 2140 | ADDL $4,DI |
| 2141 | |
| 2142 | MOVL (SI),CX |
| 2143 | ADDL $4,SI |
| 2144 | MOVL CX,(DI) |
| 2145 | ADDL $4,DI |
| 2146 | |
| 2147 | MOVL (SI),CX |
| 2148 | ADDL $4,SI |
| 2149 | MOVL CX,(DI) |
| 2150 | ADDL $4,DI |
| 2151 | |
| 2152 | MOVL (SI),CX |
| 2153 | ADDL $4,SI |
| 2154 | MOVL CX,(DI) |
| 2155 | ADDL $4,DI |
| 2156 | |
| 2157 | MOVL (SI),CX |
| 2158 | ADDL $4,SI |
| 2159 | MOVL CX,(DI) |
| 2160 | ADDL $4,DI |
| 2161 | |
| 2162 | MOVL (SI),CX |
| 2163 | ADDL $4,SI |
| 2164 | MOVL CX,(DI) |
| 2165 | ADDL $4,DI |
| 2166 | |
| 2167 | MOVL (SI),CX |
| 2168 | ADDL $4,SI |
| 2169 | MOVL CX,(DI) |
| 2170 | ADDL $4,DI |
| 2171 | |
| 2172 | MOVL (SI),CX |
| 2173 | ADDL $4,SI |
| 2174 | MOVL CX,(DI) |
| 2175 | ADDL $4,DI |
| 2176 | |
| 2177 | MOVL (SI),CX |
| 2178 | ADDL $4,SI |
| 2179 | MOVL CX,(DI) |
| 2180 | ADDL $4,DI |
| 2181 | |
| 2182 | MOVL (SI),CX |
| 2183 | ADDL $4,SI |
| 2184 | MOVL CX,(DI) |
| 2185 | ADDL $4,DI |
| 2186 | |
| 2187 | MOVL (SI),CX |
| 2188 | ADDL $4,SI |
| 2189 | MOVL CX,(DI) |
| 2190 | ADDL $4,DI |
| 2191 | |
| 2192 | MOVL (SI),CX |
| 2193 | ADDL $4,SI |
| 2194 | MOVL CX,(DI) |
| 2195 | ADDL $4,DI |
| 2196 | |
| 2197 | MOVL (SI),CX |
| 2198 | ADDL $4,SI |
| 2199 | MOVL CX,(DI) |
| 2200 | ADDL $4,DI |
| 2201 | |
| 2202 | MOVL (SI),CX |
| 2203 | ADDL $4,SI |
| 2204 | MOVL CX,(DI) |
| 2205 | ADDL $4,DI |
| 2206 | |
| 2207 | MOVL (SI),CX |
| 2208 | ADDL $4,SI |
| 2209 | MOVL CX,(DI) |
| 2210 | ADDL $4,DI |
| 2211 | |
| 2212 | MOVL (SI),CX |
| 2213 | ADDL $4,SI |
| 2214 | MOVL CX,(DI) |
| 2215 | ADDL $4,DI |
| 2216 | |
| 2217 | MOVL (SI),CX |
| 2218 | ADDL $4,SI |
| 2219 | MOVL CX,(DI) |
| 2220 | ADDL $4,DI |
| 2221 | |
| 2222 | MOVL (SI),CX |
| 2223 | ADDL $4,SI |
| 2224 | MOVL CX,(DI) |
| 2225 | ADDL $4,DI |
| 2226 | |
| 2227 | MOVL (SI),CX |
| 2228 | ADDL $4,SI |
| 2229 | MOVL CX,(DI) |
| 2230 | ADDL $4,DI |
| 2231 | |
| 2232 | MOVL (SI),CX |
| 2233 | ADDL $4,SI |
| 2234 | MOVL CX,(DI) |
| 2235 | ADDL $4,DI |
| 2236 | |
| 2237 | MOVL (SI),CX |
| 2238 | ADDL $4,SI |
| 2239 | MOVL CX,(DI) |
| 2240 | ADDL $4,DI |
| 2241 | |
| 2242 | RET |
Dmitriy Vyukov | 350a8fc | 2014-05-02 17:32:42 +0100 | [diff] [blame] | 2243 | |
| 2244 | TEXT runtime·timenow(SB), NOSPLIT, $0-0 |
| 2245 | JMP time·now(SB) |
Keith Randall | 0c6b55e | 2014-07-16 14:16:19 -0700 | [diff] [blame] | 2246 | |
Keith Randall | 3306d11 | 2014-09-02 14:33:33 -0700 | [diff] [blame] | 2247 | TEXT runtime·fastrand1(SB), NOSPLIT, $0-4 |
Keith Randall | 0c6b55e | 2014-07-16 14:16:19 -0700 | [diff] [blame] | 2248 | get_tls(CX) |
| 2249 | MOVL g(CX), AX |
| 2250 | MOVL g_m(AX), AX |
| 2251 | MOVL m_fastrand(AX), DX |
| 2252 | ADDL DX, DX |
| 2253 | MOVL DX, BX |
| 2254 | XORL $0x88888eef, DX |
| 2255 | CMOVLMI BX, DX |
| 2256 | MOVL DX, m_fastrand(AX) |
| 2257 | MOVL DX, ret+0(FP) |
| 2258 | RET |
Keith Randall | f440737 | 2014-09-03 08:49:43 -0700 | [diff] [blame] | 2259 | |
| 2260 | TEXT runtime·return0(SB), NOSPLIT, $0 |
| 2261 | MOVL $0, AX |
| 2262 | RET |