1 // Copyright 2016 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.
10 // _rt0_s390x_lib is common startup code for s390x systems when
11 // using -buildmode=c-archive or -buildmode=c-shared. The linker will
12 // arrange to invoke this function as a global constructor (for
13 // c-archive) or when the shared library is loaded (for c-shared).
14 // We expect argc and argv to be passed in the usual C ABI registers
16 TEXT _rt0_s390x_lib(SB), NOSPLIT|NOFRAME, $0
18 MOVD R2, _rt0_s390x_lib_argc<>(SB)
19 MOVD R3, _rt0_s390x_lib_argv<>(SB)
21 // Save R6-R15 in the register save area of the calling function.
24 // Allocate 80 bytes on the stack.
27 // Save F8-F15 in our stack frame.
37 // Synchronous initialization.
38 MOVD $runtime·libpreinit(SB), R1
41 // Create a new thread to finish Go runtime initialization.
42 MOVD _cgo_sys_thread_create(SB), R1
45 MOVD $_rt0_s390x_lib_go(SB), R2
51 MOVD $0x800000, R1 // stacksize
53 MOVD $_rt0_s390x_lib_go(SB), R1
55 MOVD $runtime·newosproc(SB), R1
59 // Restore F8-F15 from our stack frame.
74 // _rt0_s390x_lib_go initializes the Go runtime.
75 // This is started in a separate thread by _rt0_s390x_lib.
76 TEXT _rt0_s390x_lib_go(SB), NOSPLIT|NOFRAME, $0
77 MOVD _rt0_s390x_lib_argc<>(SB), R2
78 MOVD _rt0_s390x_lib_argv<>(SB), R3
79 MOVD $runtime·rt0_go(SB), R1
82 DATA _rt0_s390x_lib_argc<>(SB)/8, $0
83 GLOBL _rt0_s390x_lib_argc<>(SB), NOPTR, $8
84 DATA _rt0_s90x_lib_argv<>(SB)/8, $0
85 GLOBL _rt0_s390x_lib_argv<>(SB), NOPTR, $8
87 TEXT runtime·rt0_go(SB),NOSPLIT|TOPFRAME,$0
88 // R2 = argc; R3 = argv; R11 = temp; R13 = g; R15 = stack pointer
89 // C TLS base pointer in AR0:AR1
91 // initialize essential registers
95 MOVW R2, 8(R15) // argc
96 MOVD R3, 16(R15) // argv
98 // create istack out of the given (operating system) stack.
99 // _cgo_init may update stackguard.
100 MOVD $runtime·g0(SB), g
103 MOVD R11, g_stackguard0(g)
104 MOVD R11, g_stackguard1(g)
105 MOVD R11, (g_stack+stack_lo)(g)
106 MOVD R15, (g_stack+stack_hi)(g)
108 // if there is a _cgo_init, call it using the gcc ABI.
109 MOVD _cgo_init(SB), R11
110 CMPBEQ R11, $0, nocgo
111 MOVW AR0, R4 // (AR0 << 32 | AR1) is the TLS base pointer; MOVD is translated to EAR
113 MOVW AR1, R4 // arg 2: TLS base pointer
114 MOVD $setg_gcc<>(SB), R3 // arg 1: setg
115 MOVD g, R2 // arg 0: G
116 // C functions expect 160 bytes of space on caller stack frame
117 // and an 8-byte aligned stack pointer
118 MOVD R15, R9 // save current stack (R9 is preserved in the Linux ABI)
119 SUB $160, R15 // reserve 160 bytes
121 AND R6, R15 // 8-byte align
122 BL R11 // this call clobbers volatile registers according to Linux ABI (R0-R5, R14)
123 MOVD R9, R15 // restore stack
124 XOR R0, R0 // zero R0
127 // update stackguard after _cgo_init
128 MOVD (g_stack+stack_lo)(g), R2
129 ADD $const_stackGuard, R2
130 MOVD R2, g_stackguard0(g)
131 MOVD R2, g_stackguard1(g)
133 // set the per-goroutine and per-mach "registers"
134 MOVD $runtime·m0(SB), R2
143 // argc/argv are already prepared on stack
145 BL runtime·osinit(SB)
146 BL runtime·schedinit(SB)
148 // create a new goroutine to start program
149 MOVD $runtime·mainPC(SB), R2 // entry
153 BL runtime·newproc(SB)
157 BL runtime·mstart(SB)
162 DATA runtime·mainPC+0(SB)/8,$runtime·main(SB)
163 GLOBL runtime·mainPC(SB),RODATA,$8
165 TEXT runtime·breakpoint(SB),NOSPLIT|NOFRAME,$0-0
169 TEXT runtime·asminit(SB),NOSPLIT|NOFRAME,$0-0
172 TEXT runtime·mstart(SB),NOSPLIT|TOPFRAME,$0
173 CALL runtime·mstart0(SB)
181 // restore state from Gobuf; longjmp
182 TEXT runtime·gogo(SB), NOSPLIT|NOFRAME, $0-8
185 MOVD 0(R6), R7 // make sure g != nil
188 TEXT gogo<>(SB), NOSPLIT|NOFRAME, $0
190 BL runtime·save_g(SB)
193 MOVD gobuf_sp(R5), R15
194 MOVD gobuf_lr(R5), LR
195 MOVD gobuf_ret(R5), R3
196 MOVD gobuf_ctxt(R5), R12
197 MOVD $0, gobuf_sp(R5)
198 MOVD $0, gobuf_ret(R5)
199 MOVD $0, gobuf_lr(R5)
200 MOVD $0, gobuf_ctxt(R5)
201 CMP R0, R0 // set condition codes for == test, needed by stack split
202 MOVD gobuf_pc(R5), R6
205 // void mcall(fn func(*g))
206 // Switch to m->g0's stack, call fn(g).
207 // Fn must never return. It should gogo(&g->sched)
208 // to keep running g.
209 TEXT runtime·mcall(SB), NOSPLIT, $-8-8
210 // Save caller state in g->sched
211 MOVD R15, (g_sched+gobuf_sp)(g)
212 MOVD LR, (g_sched+gobuf_pc)(g)
213 MOVD $0, (g_sched+gobuf_lr)(g)
215 // Switch to m->g0 & its stack, call fn.
219 BL runtime·save_g(SB)
222 BR runtime·badmcall(SB)
223 MOVD fn+0(FP), R12 // context
224 MOVD 0(R12), R4 // code pointer
225 MOVD (g_sched+gobuf_sp)(g), R15 // sp = m->g0->sched.sp
230 BR runtime·badmcall2(SB)
232 // systemstack_switch is a dummy routine that systemstack leaves at the bottom
233 // of the G stack. We need to distinguish the routine that
234 // lives at the bottom of the G stack from the one that lives
235 // at the top of the system stack because the one at the top of
236 // the system stack terminates the stack walk (see topofstack()).
237 TEXT runtime·systemstack_switch(SB), NOSPLIT, $0-0
239 BL (LR) // make sure this function is not leaf
242 // func systemstack(fn func())
243 TEXT runtime·systemstack(SB), NOSPLIT, $0-8
244 MOVD fn+0(FP), R3 // R3 = fn
245 MOVD R3, R12 // context
246 MOVD g_m(g), R4 // R4 = m
248 MOVD m_gsignal(R4), R5 // R5 = gsignal
249 CMPBEQ g, R5, noswitch
251 MOVD m_g0(R4), R5 // R5 = g0
252 CMPBEQ g, R5, noswitch
257 // Bad: g is not gsignal, not g0, not curg. What is it?
258 // Hide call from linker nosplit analysis.
259 MOVD $runtime·badsystemstack(SB), R3
264 // save our state in g->sched. Pretend to
265 // be systemstack_switch if the G stack is scanned.
266 BL gosave_systemstack_switch<>(SB)
270 BL runtime·save_g(SB)
271 MOVD (g_sched+gobuf_sp)(g), R15
273 // call target function
274 MOVD 0(R12), R3 // code pointer
280 BL runtime·save_g(SB)
281 MOVD (g_sched+gobuf_sp)(g), R15
282 MOVD $0, (g_sched+gobuf_sp)(g)
286 // already on m stack, just call directly
287 // Using a tail call here cleans up tracebacks since we won't stop
288 // at an intermediate systemstack.
289 MOVD 0(R12), R3 // code pointer
290 MOVD 0(R15), LR // restore LR
295 * support for morestack
298 // Called during function prolog when more stack is needed.
299 // Caller has already loaded:
300 // R3: framesize, R4: argsize, R5: LR
302 // The traceback routines see morestack on a g0 as being
303 // the top of a stack (for example, morestack calling newstack
304 // calling the scheduler calling newm calling gc), so we must
305 // record an argument size. For that purpose, it has no arguments.
306 TEXT runtime·morestack(SB),NOSPLIT|NOFRAME,$0-0
307 // Cannot grow scheduler stack (m->g0).
311 BL runtime·badmorestackg0(SB)
314 // Cannot grow signal stack (m->gsignal).
315 MOVD m_gsignal(R7), R8
318 BL runtime·badmorestackgsignal(SB)
322 // Set g->sched to context in f.
323 MOVD R15, (g_sched+gobuf_sp)(g)
325 MOVD R8, (g_sched+gobuf_pc)(g)
326 MOVD R5, (g_sched+gobuf_lr)(g)
327 MOVD R12, (g_sched+gobuf_ctxt)(g)
330 // Set m->morebuf to f's caller.
331 MOVD R5, (m_morebuf+gobuf_pc)(R7) // f's caller's PC
332 MOVD R15, (m_morebuf+gobuf_sp)(R7) // f's caller's SP
333 MOVD g, (m_morebuf+gobuf_g)(R7)
335 // Call newstack on m->g0's stack.
337 BL runtime·save_g(SB)
338 MOVD (g_sched+gobuf_sp)(g), R15
339 // Create a stack frame on g0 to call newstack.
340 MOVD $0, -8(R15) // Zero saved LR in frame
342 BL runtime·newstack(SB)
344 // Not reached, but make sure the return PC from the call to newstack
345 // is still in this function, and not the beginning of the next.
348 TEXT runtime·morestack_noctxt(SB),NOSPLIT|NOFRAME,$0-0
349 // Force SPWRITE. This function doesn't actually write SP,
350 // but it is called with a special calling convention where
351 // the caller doesn't save LR on stack but passes it as a
352 // register (R5), and the unwinder currently doesn't understand.
353 // Make it SPWRITE to stop unwinding. (See issue 54332)
357 BR runtime·morestack(SB)
359 // reflectcall: call a function with the given argument list
360 // func call(stackArgsType *_type, f *FuncVal, stackArgs *byte, stackArgsSize, stackRetOffset, frameSize uint32, regArgs *abi.RegArgs).
361 // we don't have variable-sized frames, so we use a small number
362 // of constant-sized-frame functions to encode a few bits of size in the pc.
363 // Caution: ugly multiline assembly macros in your future!
365 #define DISPATCH(NAME,MAXSIZE) \
369 MOVD $NAME(SB), R5; \
371 // Note: can't just "BR NAME(SB)" - bad inlining results.
373 TEXT ·reflectcall(SB), NOSPLIT, $-8-48
374 MOVWZ frameSize+32(FP), R3
375 DISPATCH(runtime·call16, 16)
376 DISPATCH(runtime·call32, 32)
377 DISPATCH(runtime·call64, 64)
378 DISPATCH(runtime·call128, 128)
379 DISPATCH(runtime·call256, 256)
380 DISPATCH(runtime·call512, 512)
381 DISPATCH(runtime·call1024, 1024)
382 DISPATCH(runtime·call2048, 2048)
383 DISPATCH(runtime·call4096, 4096)
384 DISPATCH(runtime·call8192, 8192)
385 DISPATCH(runtime·call16384, 16384)
386 DISPATCH(runtime·call32768, 32768)
387 DISPATCH(runtime·call65536, 65536)
388 DISPATCH(runtime·call131072, 131072)
389 DISPATCH(runtime·call262144, 262144)
390 DISPATCH(runtime·call524288, 524288)
391 DISPATCH(runtime·call1048576, 1048576)
392 DISPATCH(runtime·call2097152, 2097152)
393 DISPATCH(runtime·call4194304, 4194304)
394 DISPATCH(runtime·call8388608, 8388608)
395 DISPATCH(runtime·call16777216, 16777216)
396 DISPATCH(runtime·call33554432, 33554432)
397 DISPATCH(runtime·call67108864, 67108864)
398 DISPATCH(runtime·call134217728, 134217728)
399 DISPATCH(runtime·call268435456, 268435456)
400 DISPATCH(runtime·call536870912, 536870912)
401 DISPATCH(runtime·call1073741824, 1073741824)
402 MOVD $runtime·badreflectcall(SB), R5
405 #define CALLFN(NAME,MAXSIZE) \
406 TEXT NAME(SB), WRAPPER, $MAXSIZE-48; \
408 /* copy arguments to stack */ \
409 MOVD stackArgs+16(FP), R4; \
410 MOVWZ stackArgsSize+24(FP), R5; \
411 MOVD $stack-MAXSIZE(SP), R6; \
412 loopArgs: /* copy 256 bytes at a time */ \
416 MVC $256, 0(R4), 0(R6); \
420 tailArgs: /* copy remaining bytes */ \
424 EXRL $callfnMVC<>(SB), R5; \
428 PCDATA $PCDATA_StackMapIndex, $0; \
430 /* copy return values back */ \
431 MOVD stackArgsType+0(FP), R7; \
432 MOVD stackArgs+16(FP), R6; \
433 MOVWZ stackArgsSize+24(FP), R5; \
434 MOVD $stack-MAXSIZE(SP), R4; \
435 MOVWZ stackRetOffset+28(FP), R1; \
442 // callRet copies return values back at the end of call*. This is a
443 // separate function so it can allocate stack space for the arguments
444 // to reflectcallmove. It does not follow the Go ABI; it expects its
445 // arguments in registers.
446 TEXT callRet<>(SB), NOSPLIT, $40-0
452 BL runtime·reflectcallmove(SB)
458 CALLFN(·call128, 128)
459 CALLFN(·call256, 256)
460 CALLFN(·call512, 512)
461 CALLFN(·call1024, 1024)
462 CALLFN(·call2048, 2048)
463 CALLFN(·call4096, 4096)
464 CALLFN(·call8192, 8192)
465 CALLFN(·call16384, 16384)
466 CALLFN(·call32768, 32768)
467 CALLFN(·call65536, 65536)
468 CALLFN(·call131072, 131072)
469 CALLFN(·call262144, 262144)
470 CALLFN(·call524288, 524288)
471 CALLFN(·call1048576, 1048576)
472 CALLFN(·call2097152, 2097152)
473 CALLFN(·call4194304, 4194304)
474 CALLFN(·call8388608, 8388608)
475 CALLFN(·call16777216, 16777216)
476 CALLFN(·call33554432, 33554432)
477 CALLFN(·call67108864, 67108864)
478 CALLFN(·call134217728, 134217728)
479 CALLFN(·call268435456, 268435456)
480 CALLFN(·call536870912, 536870912)
481 CALLFN(·call1073741824, 1073741824)
483 // Not a function: target for EXRL (execute relative long) instruction.
484 TEXT callfnMVC<>(SB),NOSPLIT|NOFRAME,$0-0
487 TEXT runtime·procyield(SB),NOSPLIT,$0-0
490 // Save state of caller into g->sched,
491 // but using fake PC from systemstack_switch.
492 // Must only be called from functions with no locals ($0)
493 // or else unwinding from systemstack_switch is incorrect.
495 TEXT gosave_systemstack_switch<>(SB),NOSPLIT|NOFRAME,$0
496 MOVD $runtime·systemstack_switch(SB), R1
497 ADD $16, R1 // get past prologue
498 MOVD R1, (g_sched+gobuf_pc)(g)
499 MOVD R15, (g_sched+gobuf_sp)(g)
500 MOVD $0, (g_sched+gobuf_lr)(g)
501 MOVD $0, (g_sched+gobuf_ret)(g)
502 // Assert ctxt is zero. See func save.
503 MOVD (g_sched+gobuf_ctxt)(g), R1
508 // func asmcgocall(fn, arg unsafe.Pointer) int32
509 // Call fn(arg) on the scheduler stack,
510 // aligned appropriately for the gcc ABI.
511 // See cgocall.go for more details.
512 TEXT ·asmcgocall(SB),NOSPLIT,$0-20
513 // R2 = argc; R3 = argv; R11 = temp; R13 = g; R15 = stack pointer
514 // C TLS base pointer in AR0:AR1
518 MOVD R15, R2 // save original stack pointer
521 // Figure out if we need to switch to m->g0 stack.
522 // We get called to create new OS threads too, and those
523 // come in on the m->g0 stack already. Or we might already
524 // be on the m->gsignal stack.
526 MOVD m_gsignal(R6), R7
530 BL gosave_systemstack_switch<>(SB)
532 BL runtime·save_g(SB)
533 MOVD (g_sched+gobuf_sp)(g), R15
535 // Now on a scheduling stack (a pthread-created stack).
537 // Save room for two of our pointers, plus 160 bytes of callee
538 // save area that lives on the caller stack.
541 AND R6, R15 // 8-byte alignment for gcc ABI
542 MOVD R5, 168(R15) // save old g on stack
543 MOVD (g_stack+stack_hi)(R5), R5
545 MOVD R5, 160(R15) // save depth in old g stack (can't just save SP, as stack might be copied during a callback)
546 MOVD $0, 0(R15) // clear back chain pointer (TODO can we give it real back trace information?)
547 MOVD R4, R2 // arg in R2
548 BL R3 // can clobber: R0-R5, R14, F0-F3, F5, F7-F15
550 XOR R0, R0 // set R0 back to 0.
551 // Restore g, stack pointer.
553 BL runtime·save_g(SB)
554 MOVD (g_stack+stack_hi)(g), R5
562 // cgocallback(fn, frame unsafe.Pointer, ctxt uintptr)
563 // See cgocall.go for more details.
564 TEXT ·cgocallback(SB),NOSPLIT,$24-24
567 // Load m and g from thread-local storage.
568 MOVB runtime·iscgo(SB), R3
570 BL runtime·load_g(SB)
573 // If g is nil, Go did not create the current thread.
574 // Call needm to obtain one for temporary use.
575 // In this case, we're running on the thread stack, so there's
576 // lots of space, but the linker doesn't know. Hide the call from
577 // the linker analysis by using an indirect call.
581 MOVD R8, savedm-8(SP)
585 MOVD g, savedm-8(SP) // g is zero, so is m.
586 MOVD $runtime·needm(SB), R3
589 // Set m->sched.sp = SP, so that if a panic happens
590 // during the function we are about to execute, it will
591 // have a valid SP to run on the g0 stack.
592 // The next few lines (after the havem label)
593 // will save this SP onto the stack and then write
594 // the same SP back to m->sched.sp. That seems redundant,
595 // but if an unrecovered panic happens, unwindm will
596 // restore the g->sched.sp from the stack location
597 // and then systemstack will try to use it. If we don't set it here,
598 // that restored SP will be uninitialized (typically 0) and
599 // will not be usable.
602 MOVD R15, (g_sched+gobuf_sp)(R3)
605 // Now there's a valid m, and we're running on its m->g0.
606 // Save current m->g0->sched.sp on stack and then set it to SP.
607 // Save current sp in m->g0->sched.sp in preparation for
608 // switch back to m->curg stack.
609 // NOTE: unwindm knows that the saved g->sched.sp is at 8(R1) aka savedsp-16(SP).
611 MOVD (g_sched+gobuf_sp)(R3), R4
612 MOVD R4, savedsp-24(SP) // must match frame size
613 MOVD R15, (g_sched+gobuf_sp)(R3)
615 // Switch to m->curg stack and call runtime.cgocallbackg.
616 // Because we are taking over the execution of m->curg
617 // but *not* resuming what had been running, we need to
618 // save that information (m->curg->sched) so we can restore it.
619 // We can restore m->curg->sched.sp easily, because calling
620 // runtime.cgocallbackg leaves SP unchanged upon return.
621 // To save m->curg->sched.pc, we push it onto the curg stack and
622 // open a frame the same size as cgocallback's g0 frame.
623 // Once we switch to the curg stack, the pushed PC will appear
624 // to be the return PC of cgocallback, so that the traceback
625 // will seamlessly trace back into the earlier calls.
627 BL runtime·save_g(SB)
628 MOVD (g_sched+gobuf_sp)(g), R4 // prepare stack as R4
629 MOVD (g_sched+gobuf_pc)(g), R5
630 MOVD R5, -(24+8)(R4) // "saved LR"; must match frame size
631 // Gather our arguments into registers.
635 MOVD $-(24+8)(R4), R15 // switch stack; must match frame size
639 BL runtime·cgocallbackg(SB)
641 // Restore g->sched (== m->curg->sched) from saved values.
643 MOVD R5, (g_sched+gobuf_pc)(g)
644 MOVD $(24+8)(R15), R4 // must match frame size
645 MOVD R4, (g_sched+gobuf_sp)(g)
647 // Switch back to m->g0's stack and restore m->g0->sched.sp.
648 // (Unlike m->curg, the g0 goroutine never uses sched.pc,
649 // so we do not have to restore it.)
652 BL runtime·save_g(SB)
653 MOVD (g_sched+gobuf_sp)(g), R15
654 MOVD savedsp-24(SP), R4 // must match frame size
655 MOVD R4, (g_sched+gobuf_sp)(g)
657 // If the m on entry was nil, we called needm above to borrow an m
658 // for the duration of the call. Since the call is over, return it with dropm.
659 MOVD savedm-8(SP), R6
660 CMPBNE R6, $0, droppedm
661 MOVD $runtime·dropm(SB), R3
668 // void setg(G*); set g. for use by needm.
669 TEXT runtime·setg(SB), NOSPLIT, $0-8
671 // This only happens if iscgo, so jump straight to save_g
672 BL runtime·save_g(SB)
675 // void setg_gcc(G*); set g in C TLS.
676 // Must obey the gcc calling convention.
677 TEXT setg_gcc<>(SB),NOSPLIT|NOFRAME,$0-0
678 // The standard prologue clobbers LR (R14), which is callee-save in
679 // the C ABI, so we have to use NOFRAME and save LR ourselves.
681 // Also save g, R10, and R11 since they're callee-save in C ABI
687 BL runtime·save_g(SB)
695 TEXT runtime·abort(SB),NOSPLIT|NOFRAME,$0-0
699 // int64 runtime·cputicks(void)
700 TEXT runtime·cputicks(SB),NOSPLIT,$0-8
701 // The TOD clock on s390 counts from the year 1900 in ~250ps intervals.
702 // This means that since about 1972 the msb has been set, making the
703 // result of a call to STORE CLOCK (stck) a negative number.
704 // We clear the msb to make it positive.
705 STCK ret+0(FP) // serialises before and after call
706 MOVD ret+0(FP), R3 // R3 will wrap to 0 in the year 2043
712 // AES hashing not implemented for s390x
713 TEXT runtime·memhash(SB),NOSPLIT|NOFRAME,$0-32
714 JMP runtime·memhashFallback(SB)
715 TEXT runtime·strhash(SB),NOSPLIT|NOFRAME,$0-24
716 JMP runtime·strhashFallback(SB)
717 TEXT runtime·memhash32(SB),NOSPLIT|NOFRAME,$0-24
718 JMP runtime·memhash32Fallback(SB)
719 TEXT runtime·memhash64(SB),NOSPLIT|NOFRAME,$0-24
720 JMP runtime·memhash64Fallback(SB)
722 TEXT runtime·return0(SB), NOSPLIT, $0
726 // Called from cgo wrappers, this function returns g->m->curg.stack.hi.
727 // Must obey the gcc calling convention.
728 TEXT _cgo_topofstack(SB),NOSPLIT|NOFRAME,$0
729 // g (R13), R10, R11 and LR (R14) are callee-save in the C ABI, so save them
735 BL runtime·load_g(SB) // clobbers g (R13), R10, R11
738 MOVD (g_stack+stack_hi)(R2), R2
746 // The top-most function running on a goroutine
747 // returns to goexit+PCQuantum.
748 TEXT runtime·goexit(SB),NOSPLIT|NOFRAME|TOPFRAME,$0-0
749 BYTE $0x07; BYTE $0x00; // 2-byte nop
750 BL runtime·goexit1(SB) // does not return
751 // traceback from goexit1 must hit code range of goexit
752 BYTE $0x07; BYTE $0x00; // 2-byte nop
754 TEXT ·publicationBarrier(SB),NOSPLIT|NOFRAME,$0-0
755 // Stores are already ordered on s390x, so this is just a
759 // This is called from .init_array and follows the platform, not Go, ABI.
760 // We are overly conservative. We could only save the registers we use.
761 // However, since this function is only called once per loaded module
762 // performance is unimportant.
763 TEXT runtime·addmoduledata(SB),NOSPLIT|NOFRAME,$0-0
764 // Save R6-R15 in the register save area of the calling function.
765 // Don't bother saving F8-F15 as we aren't doing any calls.
766 STMG R6, R15, 48(R15)
768 // append the argument (passed in R2, as per the ELF ABI) to the
769 // moduledata linked list.
770 MOVD runtime·lastmoduledatap(SB), R1
771 MOVD R2, moduledata_next(R1)
772 MOVD R2, runtime·lastmoduledatap(SB)
778 TEXT ·checkASM(SB),NOSPLIT,$0-1
782 // gcWriteBarrier informs the GC about heap pointer writes.
784 // gcWriteBarrier does NOT follow the Go ABI. It accepts the
785 // number of bytes of buffer needed in R9, and returns a pointer
786 // to the buffer space in R9.
787 // It clobbers R10 (the temp register) and R1 (used by PLT stub).
788 // It does not clobber any other general-purpose registers,
789 // but may clobber others (e.g., floating point registers).
790 TEXT gcWriteBarrier<>(SB),NOSPLIT,$96
791 // Save the registers clobbered by the fast path.
796 // Increment wbBuf.next position.
798 ADD (p_wbBuf+wbBuf_next)(R1), R4
799 // Is the buffer full?
800 MOVD (p_wbBuf+wbBuf_end)(R1), R10
801 CMPUBGT R4, R10, flush
802 // Commit to the larger buffer.
803 MOVD R4, (p_wbBuf+wbBuf_next)(R1)
804 // Make return value (the original next position)
806 // Restore registers.
811 // Save all general purpose registers since these could be
812 // clobbered by wbBufFlush and were not saved by the caller.
817 STMG R5, R12, 32(R15) // save R5 - R12
822 CALL runtime·wbBufFlush(SB)
824 LMG 8(R15), R2, R3 // restore R2 - R3
825 MOVD 24(R15), R0 // restore R0
826 LMG 32(R15), R5, R12 // restore R5 - R12
829 TEXT runtime·gcWriteBarrier1<ABIInternal>(SB),NOSPLIT,$0
831 JMP gcWriteBarrier<>(SB)
832 TEXT runtime·gcWriteBarrier2<ABIInternal>(SB),NOSPLIT,$0
834 JMP gcWriteBarrier<>(SB)
835 TEXT runtime·gcWriteBarrier3<ABIInternal>(SB),NOSPLIT,$0
837 JMP gcWriteBarrier<>(SB)
838 TEXT runtime·gcWriteBarrier4<ABIInternal>(SB),NOSPLIT,$0
840 JMP gcWriteBarrier<>(SB)
841 TEXT runtime·gcWriteBarrier5<ABIInternal>(SB),NOSPLIT,$0
843 JMP gcWriteBarrier<>(SB)
844 TEXT runtime·gcWriteBarrier6<ABIInternal>(SB),NOSPLIT,$0
846 JMP gcWriteBarrier<>(SB)
847 TEXT runtime·gcWriteBarrier7<ABIInternal>(SB),NOSPLIT,$0
849 JMP gcWriteBarrier<>(SB)
850 TEXT runtime·gcWriteBarrier8<ABIInternal>(SB),NOSPLIT,$0
852 JMP gcWriteBarrier<>(SB)
854 // Note: these functions use a special calling convention to save generated code space.
855 // Arguments are passed in registers, but the space for those arguments are allocated
856 // in the caller's stack frame. These stubs write the args into that stack space and
857 // then tail call to the corresponding runtime handler.
858 // The tail call makes these stubs disappear in backtraces.
859 TEXT runtime·panicIndex(SB),NOSPLIT,$0-16
862 JMP runtime·goPanicIndex(SB)
863 TEXT runtime·panicIndexU(SB),NOSPLIT,$0-16
866 JMP runtime·goPanicIndexU(SB)
867 TEXT runtime·panicSliceAlen(SB),NOSPLIT,$0-16
870 JMP runtime·goPanicSliceAlen(SB)
871 TEXT runtime·panicSliceAlenU(SB),NOSPLIT,$0-16
874 JMP runtime·goPanicSliceAlenU(SB)
875 TEXT runtime·panicSliceAcap(SB),NOSPLIT,$0-16
878 JMP runtime·goPanicSliceAcap(SB)
879 TEXT runtime·panicSliceAcapU(SB),NOSPLIT,$0-16
882 JMP runtime·goPanicSliceAcapU(SB)
883 TEXT runtime·panicSliceB(SB),NOSPLIT,$0-16
886 JMP runtime·goPanicSliceB(SB)
887 TEXT runtime·panicSliceBU(SB),NOSPLIT,$0-16
890 JMP runtime·goPanicSliceBU(SB)
891 TEXT runtime·panicSlice3Alen(SB),NOSPLIT,$0-16
894 JMP runtime·goPanicSlice3Alen(SB)
895 TEXT runtime·panicSlice3AlenU(SB),NOSPLIT,$0-16
898 JMP runtime·goPanicSlice3AlenU(SB)
899 TEXT runtime·panicSlice3Acap(SB),NOSPLIT,$0-16
902 JMP runtime·goPanicSlice3Acap(SB)
903 TEXT runtime·panicSlice3AcapU(SB),NOSPLIT,$0-16
906 JMP runtime·goPanicSlice3AcapU(SB)
907 TEXT runtime·panicSlice3B(SB),NOSPLIT,$0-16
910 JMP runtime·goPanicSlice3B(SB)
911 TEXT runtime·panicSlice3BU(SB),NOSPLIT,$0-16
914 JMP runtime·goPanicSlice3BU(SB)
915 TEXT runtime·panicSlice3C(SB),NOSPLIT,$0-16
918 JMP runtime·goPanicSlice3C(SB)
919 TEXT runtime·panicSlice3CU(SB),NOSPLIT,$0-16
922 JMP runtime·goPanicSlice3CU(SB)
923 TEXT runtime·panicSliceConvert(SB),NOSPLIT,$0-16
926 JMP runtime·goPanicSliceConvert(SB)