1 ! Copyright (C) 2020 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: bootstrap.image.private compiler.codegen.relocation
4 compiler.constants compiler.units cpu.arm.assembler
5 cpu.arm.assembler.opcodes generic.single.private
6 kernel kernel.private layouts locals.backend
7 math math.private memory namespaces sequences slots.private
8 strings.private threads.private vocabs ;
9 IN: bootstrap.assembler.arm
16 ! https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling?view=vs-2019
18 ! x0 Volatile Parameter/scratch register 1, result register
19 ! x1-x7 Volatile Parameter/scratch register 2-8
20 ! x8-x15 Volatile Scratch registers
21 ! x16-x17 Volatile Intra-procedure-call scratch registers
22 ! x18 Non-volatile Platform register: in kernel mode, points to KPCR for the current processor;
23 ! in user mode, points to TEB
24 ! x19-x28 Non-volatile Scratch registers
25 ! x29/fp Non-volatile Frame pointer
26 ! x30/lr Non-volatile Link registers
28 ! varargs https://developer.arm.com/documentation/ihi0055/d/?lang=en
29 : stack-frame-size ( -- n ) 8 bootstrap-cells ;
30 : volatile-regs ( -- seq ) { X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 } ;
31 ! windows arm - X18 is non-volatile https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-160
32 : nv-regs ( -- seq ) { X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 } ;
34 ! callee-save = non-volatile aka call-preserved
36 ! x30 is the link register (used to return from subroutines)
37 ! x29 is the frame register
38 ! x19 to x29 are callee-saved
39 ! x18 is the 'platform register', used for some operating-system-specific special purpose,
40 ! or an additional caller-saved register
41 ! x16 and x17 are the Intra-Procedure-call scratch register
42 ! x9 to x15: used to hold local variables (caller saved)
43 ! x8: used to hold indirect return value address
44 ! x0 to x7: used to hold argument values passed to a subroutine, and also hold
45 ! results returned from a subroutine
48 ! https://en.wikichip.org/wiki/arm/aarch64
49 ! Generally, X0 through X18 (volatile, can corrupt) while X19-X29 must be preserved (non-volatile)
50 ! Volatile registers' content may change over a subroutine call
51 ! non-volatile register is a type of register with contents that must be preserved over subroutine calls
52 ! Register Role Requirement
53 ! X0 - X7 Parameter/result registers Can Corrupt (volatile)
54 ! X8 Indirect result location register (volatile)
55 ! X9 - X15 Temporary registers (volatile)
56 ! X16 - X17 Intra-procedure call temporary (volatile)
57 ! x16 - syscall reg with SVC instructioin
58 ! X18 Platform register, otherwise temporary, DONT USE (volatile)
60 ! X19 - X29 Callee-saved register Must preserve (non-volatile)
61 ! X29 - frame pointer register, must always be valid
62 ! X30 Link Register LR Can Corrupt
63 ! X31 Stack Pointer SP
64 ! 16-byte stack alignment
66 ! stack walking - {fp, lr} pairs if compiled with frame pointers enabled
68 : arg1 ( -- reg ) X0 ;
69 : arg2 ( -- reg ) X1 ;
70 : arg3 ( -- reg ) X2 ;
71 : arg4 ( -- reg ) X3 ;
74 ! windows arm64: 16 bytes https://devblogs.microsoft.com/oldnewthing/20190111-00/?p=100685
75 ! windows arm32: 8 bytes
77 ! Apple arm64: 128 bytes https://developer.apple.com/documentation/xcode/writing_arm64_code_for_apple_platforms?language=objc
78 : red-zone-size ( -- n ) 16 ; ! 16 bytes on windows, or 128 bytes on linux? or 0?
80 ! no red zone on x86/x64 windows
83 ! https://github.com/MicrosoftDocs/cpp-docs/blob/master/docs/build/arm64-windows-abi-conventions.md
85 : shift-arg ( -- reg ) X1 ;
86 : div-arg ( -- reg ) X0 ;
87 : mod-arg ( -- reg ) X2 ;
89 ! caller-saved registers X9-X15
90 ! callee-saved registers X19-X29
91 : temp0 ( -- reg ) X9 ;
92 : temp1 ( -- reg ) X10 ;
93 : temp2 ( -- reg ) X11 ;
94 : temp3 ( -- reg ) X12 ;
97 ! : pic-tail-reg ( -- reg ) RBX ;
98 : return-reg ( -- reg ) X0 ;
99 : stack-reg ( -- reg ) SP ;
100 ! https://developer.arm.com/documentation/dui0801/a/Overview-of-AArch64-state/Link-registers
101 : link-reg ( -- reg ) X30 ; ! LR
102 : stack-frame-reg ( -- reg ) X29 ; ! FP
103 : vm-reg ( -- reg ) X28 ;
104 : ds-reg ( -- reg ) X27 ;
105 : rs-reg ( -- reg ) X26 ;
106 ! : ctx-reg ( -- reg ) R12 ;
107 ! : fixnum>slot@ ( -- ) temp0 1 SAR ;
108 ! : rex-length ( -- n ) 1 ;
110 ! rc-absolute-cell is just CONSTANT: 0
111 : jit-call ( name -- )
113 f rc-absolute-cell rel-dlsym
115 ! RAX 0 MOV f rc-absolute-cell rel-dlsym
118 :: jit-call-1arg ( arg1s name -- )
124 :: jit-call-2arg ( arg1s arg2s name -- )
133 ! pic-tail-reg 5 [RIP+] LEA
134 ! 0 JMP f rc-relative rel-word-pic-tail
135 ] JIT-WORD-JUMP jit-define
138 ! no-op on x86-64. in factor contexts vm-reg always contains the
142 : jit-load-context ( -- ) ;
143 ! ctx-reg vm-reg vm-context-offset [+] MOV ;
145 : jit-save-context ( -- ) ;
147 ! The reason for -8 I think is because we are anticipating a CALL
148 ! instruction. After the call instruction, the contexts frame_top
149 ! will point to the origin jump address.
151 ! ctx-reg context-callstack-top-offset [+] R11 MOV
152 ! ctx-reg context-datastack-offset [+] ds-reg MOV
153 ! ctx-reg context-retainstack-offset [+] rs-reg MOV ;
155 ! ctx-reg must already have been loaded
156 : jit-restore-context ( -- ) ;
157 ! ds-reg ctx-reg context-datastack-offset [+] MOV
158 ! rs-reg ctx-reg context-retainstack-offset [+] MOV ;
163 ! ! ctx-reg is preserved across the call because it is non-volatile
166 ! ! call the primitive
168 ! RAX 0 MOV f f rc-absolute-cell rel-dlsym
170 ! jit-restore-context
171 ] JIT-PRIMITIVE jit-define
174 : jit-jump-quot ( -- )
175 quot-entry-point-offset arg1 ADR
177 ! arg1 quot-entry-point-offset [+] JMP ;
179 : jit-call-quot ( -- )
180 quot-entry-point-offset arg1 ADR
182 ! arg1 quot-entry-point-offset [+] CALL ;
184 : signal-handler-save-regs ( -- regs ) { } ;
185 ! { RAX RCX RDX RBX RBP RSI RDI R8 R9 R10 R11 R12 R13 R14 R15 } ;
189 ! temp2 0 MOV f rc-absolute-cell rel-literal
191 ] PIC-CHECK-TUPLE jit-define
196 1 bootstrap-cells rs-reg rs-reg ADDi64
197 -1 bootstrap-cells ds-reg rs-reg LDR-post ;
200 1 bootstrap-cells ds-reg ds-reg ADDi64
201 -1 bootstrap-cells rs-reg ds-reg LDR-post ;
204 1 bootstrap-cells rs-reg rs-reg ADDi64
205 -1 bootstrap-cells ds-reg rs-reg LDR-post
206 1 bootstrap-cells rs-reg rs-reg ADDi64
207 -1 bootstrap-cells ds-reg rs-reg LDR-post ;
210 1 bootstrap-cells ds-reg ds-reg ADDi64
211 -1 bootstrap-cells rs-reg ds-reg LDR-post
212 1 bootstrap-cells ds-reg ds-reg ADDi64
213 -1 bootstrap-cells rs-reg ds-reg LDR-post ;
216 1 bootstrap-cells rs-reg rs-reg ADDi64
217 -1 bootstrap-cells ds-reg rs-reg LDR-post
218 1 bootstrap-cells rs-reg rs-reg ADDi64
219 -1 bootstrap-cells ds-reg rs-reg LDR-post
220 1 bootstrap-cells rs-reg rs-reg ADDi64
221 -1 bootstrap-cells ds-reg rs-reg LDR-post ;
224 1 bootstrap-cells ds-reg ds-reg ADDi64
225 -1 bootstrap-cells rs-reg ds-reg LDR-post
226 1 bootstrap-cells ds-reg ds-reg ADDi64
227 -1 bootstrap-cells rs-reg ds-reg LDR-post
228 1 bootstrap-cells ds-reg ds-reg ADDi64
229 -1 bootstrap-cells rs-reg ds-reg LDR-post ;
232 : jit-switch-context ( reg -- ) drop ;
233 ! ! Push a bogus return address so the GC can track this frame back
237 ! ! Make the new context the current one
239 ! vm-reg vm-context-offset [+] ctx-reg MOV
241 ! ! Load new stack pointer
242 ! RSP ctx-reg context-callstack-top-offset [+] MOV
244 ! ! Load new ds, rs registers
245 ! jit-restore-context
247 ! ctx-reg jit-update-tib ;
249 : jit-pop-context-and-param ( -- ) ;
251 ! arg1 arg1 alien-offset [+] MOV
252 ! arg2 ds-reg -8 [+] MOV
255 : jit-push-param ( -- ) ;
257 ! ds-reg [] arg2 MOV ;
259 : jit-set-context ( -- ) ;
260 ! jit-pop-context-and-param
262 ! arg1 jit-switch-context
266 : jit-pop-quot-and-param ( -- ) ;
268 ! arg2 ds-reg -8 [+] MOV
271 : jit-start-context ( -- ) ;
272 ! Create the new context in return-reg. Have to save context
273 ! twice, first before calling new_context() which may GC,
274 ! and again after popping the two parameters from the stack.
276 ! vm-reg "new_context" jit-call-1arg
278 ! jit-pop-quot-and-param
280 ! return-reg jit-switch-context
284 : jit-delete-current-context ( -- ) ;
285 ! vm-reg "delete_context" jit-call-1arg ;
289 ! 0 CALL f rc-relative rel-word
297 ! 0 [RIP+] EAX MOV rc-relative rel-safepoint
298 ] JIT-SAFEPOINT jit-define
300 ! # All arm.64 subprimitives
316 ! Rn Rd MOVr64 ! comment
318 vm-reg "begin_callback" jit-call-1arg
320 return-reg arg1 MOVr64 ! arg1 is return
323 vm-reg "end_callback" jit-call-1arg
325 } define-sub-primitives
330 ! { (set-context) [ jit-set-context ] }
331 ! { (set-context-and-delete) [
332 ! jit-delete-current-context
335 ! { (start-context) [ jit-start-context ] }
336 ! { (start-context-and-delete) [ jit-start-context-and-delete ] }
342 ! ! vm-reg "begin_callback" jit-call-1arg
344 ! ! ! call the quotation
345 ! ! arg1 return-reg MOV
348 ! ! vm-reg "end_callback" jit-call-1arg
367 ! ! vm-reg "begin_callback" jit-call-1arg
369 ! ! return-reg arg1 MOVr64 ! arg1 is return
372 ! ! vm-reg "end_callback" jit-call-1arg
377 ! { unwind-native-frames [ ] }
380 ! { fixnum+ [ [ ADD ] "overflow_fixnum_add" jit-overflow ] }
381 ! { fixnum- [ [ SUB ] "overflow_fixnum_subtract" jit-overflow ] }
386 ! RBX ds-reg 8 [+] MOV
387 ! RBX tag-bits get SAR
394 ! arg1 tag-bits get SAR
397 ! "overflow_fixnum_multiply" jit-call
412 ! RSP [] arg1 16-bit-version-of MOV
417 ! ! Load callstack object
419 ! ds-reg bootstrap-cell SUB
420 ! ! Get ctx->callstack_bottom
422 ! arg1 ctx-reg context-callstack-bottom-offset [+] MOV
423 ! ! Get top of callstack object -- 'src' for memcpy
424 ! arg2 arg4 callstack-top-offset [+] LEA
425 ! ! Get callstack length, in bytes --- 'len' for memcpy
426 ! arg3 arg4 callstack-length-offset [+] MOV
427 ! arg3 tag-bits get SHR
428 ! ! Compute new stack pointer -- 'dst' for memcpy
430 ! ! Install new stack pointer
432 ! ! Call memcpy; arguments are now in the correct registers
433 ! ! Create register shadow area for Win64
435 ! "factor_memcpy" jit-call
436 ! ! Tear down register shadow area
438 ! ! Return with new callstack
441 ! } define-sub-primitives
445 ! C to Factor entry point
447 ! ! Optimizing compiler's side of callback accesses
448 ! ! arguments that are on the stack via the frame pointer.
449 ! ! On x86-32 fastcall, and x86-64, some arguments are passed
450 ! ! in registers, and so the only registers that are safe for
451 ! ! use here are frame-reg, nv-reg and vm-reg.
453 ! frame-reg stack-reg MOV
455 ! ! Save all non-volatile registers
456 ! nv-regs [ PUSH ] each
460 ! ! Load VM into vm-reg
461 ! vm-reg 0 MOV 0 rc-absolute-cell rel-vm
464 ! nv-reg vm-reg vm-context-offset [+] MOV
467 ! ! Switch over to the spare context
468 ! nv-reg vm-reg vm-spare-context-offset [+] MOV
469 ! vm-reg vm-context-offset [+] nv-reg MOV
471 ! ! Save C callstack pointer
472 ! nv-reg context-callstack-save-offset [+] stack-reg MOV
474 ! ! Load Factor stack pointers
475 ! stack-reg nv-reg context-callstack-bottom-offset [+] MOV
476 ! nv-reg jit-update-tib
479 ! rs-reg nv-reg context-retainstack-offset [+] MOV
480 ! ds-reg nv-reg context-datastack-offset [+] MOV
482 ! ! Call into Factor code
483 ! link-reg 0 MOV f rc-absolute-cell rel-word
486 ! ! Load VM into vm-reg; only needed on x86-32, but doesn't
488 ! vm-reg 0 MOV 0 rc-absolute-cell rel-vm
490 ! ! Load C callstack pointer
491 ! nv-reg vm-reg vm-context-offset [+] MOV
492 ! stack-reg nv-reg context-callstack-save-offset [+] MOV
496 ! vm-reg vm-context-offset [+] nv-reg MOV
498 ! ! Restore non-volatile registers
501 ! nv-regs <reversed> [ POP ] each
505 ! ! Callbacks which return structs, or use stdcall/fastcall/thiscall,
506 ! ! need a parameter here.
508 ! ! See the comment for M\ x86.32 stack-cleanup in cpu.x86.32
509 ! 0xffff RET f rc-absolute-2 rel-untagged
510 ] CALLBACK-STUB jit-define
514 ! temp0 0 MOV f rc-absolute-cell rel-literal
515 ! ! increment datastack pointer
516 ! ds-reg bootstrap-cell ADD
517 ! ! store literal on datastack
518 ! ds-reg [] temp0 MOV
519 ] JIT-PUSH-LITERAL jit-define
522 ! 0 CALL f rc-relative rel-word-pic
523 ] JIT-WORD-CALL jit-define
525 ! The *-signal-handler subprimitives are special-cased in vm/quotations.cpp
526 ! not to trigger generation of a stack frame, so they can
527 ! peform their own prolog/epilog preserving registers.
529 ! It is important that the total is 192/64 and that it matches the
530 ! constants in vm/cpu-x86.*.hpp
531 : jit-signal-handler-prolog ( -- ) ;
532 ! ! Return address already on stack -> 8/4 bytes.
534 ! ! Push all registers. 15 regs/120 bytes on 64bit, 7 regs/28 bytes
535 ! ! on 32bit -> 128/32 bytes.
536 ! signal-handler-save-regs [ PUSH ] each
538 ! ! Push flags -> 136/36 bytes
541 ! ! Register parameter area 32 bytes, unused on platforms other than
542 ! ! windows 64 bit, but including it doesn't hurt. Plus
543 ! ! alignment. LEA used so we don't dirty flags -> 192/64 bytes.
544 ! stack-reg stack-reg 7 bootstrap-cells neg [+] LEA
548 : jit-signal-handler-epilog ( -- ) ;
549 ! stack-reg stack-reg 7 bootstrap-cells [+] LEA
551 ! signal-handler-save-regs reverse [ POP ] each ;
555 ! temp0 ds-reg [] MOV
557 ! ds-reg bootstrap-cell SUB
558 ! ! compare boolean with f
559 ! temp0 \ f type-number CMP
560 ! ! jump to true branch if not equal
561 ! 0 JNE f rc-relative rel-word
562 ! ! jump to false branch if equal
563 ! 0 JMP f rc-relative rel-word
569 ! 0 CALL f rc-relative rel-word
575 ! 0 CALL f rc-relative rel-word
577 ] JIT-2DIP jit-define
581 ! 0 CALL f rc-relative rel-word
583 ] JIT-3DIP jit-define
587 ! temp0 ds-reg [] MOV
589 ! ds-reg bootstrap-cell SUB
591 ! [ temp0 word-entry-point-offset [+] CALL ]
592 ! [ temp0 word-entry-point-offset [+] JMP ]
593 ! \ (execute) define-combinator-primitive
596 ! temp0 ds-reg [] MOV
597 ! ds-reg bootstrap-cell SUB
598 ! temp0 word-entry-point-offset [+] JMP
599 ] JIT-EXECUTE jit-define
602 ! https://elixir.bootlin.com/linux/latest/source/arch/arm64/kernel/stacktrace.c#L22
604 ! x64 ! stack-reg stack-frame-size bootstrap-cell - SUB
607 ! : link-reg ( -- reg ) X30 ; ! LR
608 ! : stack-frame-reg ( -- reg ) X29 ; ! FP
610 ! ! make room for LR plus magic number of callback, 16byte align
611 stack-frame-size bootstrap-cell 2 * + stack-reg stack-reg SUBi64
612 ! link-reg X29 stack-reg STP
613 -16 SP link-reg X29 STP-pre
614 ] JIT-PROLOG jit-define
617 ! x64 ! stack-reg stack-frame-size bootstrap-cell - ADD
618 -16 SP link-reg X29 LDP-pre
619 stack-frame-size bootstrap-cell 2 * + stack-reg stack-reg ADDi64
620 ] JIT-EPILOG jit-define
624 ] JIT-RETURN jit-define
626 ! ! ! Polymorphic inline caches
628 ! The PIC stubs are not permitted to touch pic-tail-reg.
630 ! Load a value from a stack position
632 ! temp1 ds-reg 0x7f [+] MOV f rc-absolute-1 rel-untagged
633 ] PIC-LOAD jit-define
636 ! temp1/32 tag-mask get AND
641 ! temp1/32 tag-mask get AND
642 ! temp1/32 tuple type-number CMP
644 ! [ temp1 temp0 tuple-class-offset [+] MOV ]
646 ] PIC-TUPLE jit-define
649 ! temp1/32 0x7f CMP f rc-absolute-1 rel-untagged
650 ] PIC-CHECK-TAG jit-define
653 ! 0 JE f rc-relative rel-word
656 ! ! ! Megamorphic caches
661 ! temp1/32 tag-mask get AND
662 ! temp1/32 tag-bits get SHL
663 ! temp1/32 tuple type-number tag-fixnum CMP
665 ! [ temp1 temp0 tuple-class-offset [+] MOV ]
668 ! temp0 0 MOV f rc-absolute-cell rel-literal
669 ! ! key = hashcode(class)
671 ! bootstrap-cell 4 = [ temp2 1 SHR ] when
672 ! ! key &= cache.length - 1
673 ! temp2 mega-cache-size get 1 - bootstrap-cell * AND
674 ! ! cache += array-start-offset
675 ! temp0 array-start-offset ADD
678 ! ! if(get(cache) == class)
682 ! ! megamorphic_cache_hits++
683 ! temp1 0 MOV rc-absolute-cell rel-megamorphic-cache-hits
685 ! ! goto get(cache + bootstrap-cell)
686 ! temp0 temp0 bootstrap-cell [+] MOV
687 ! temp0 word-entry-point-offset [+] JMP
688 ! ! fall-through on miss
690 ] MEGA-LOOKUP jit-define
693 : jit-compare ( insn -- ) drop ;
695 ! temp3 0 MOV t rc-absolute-cell rel-literal
697 ! temp1 \ f type-number MOV
699 ! temp0 ds-reg [] MOV
700 ! ! adjust stack pointer
701 ! ds-reg bootstrap-cell SUB
702 ! ! compare with second value
703 ! ds-reg [] temp0 CMP
705 ! [ temp1 temp3 ] dip execute( dst src -- )
707 ! ds-reg [] temp1 MOV ;
710 : jit-math ( insn -- ) drop ;
711 ! ! load second input
712 ! temp0 ds-reg [] MOV
714 ! ds-reg bootstrap-cell SUB
716 ! [ ds-reg [] temp0 ] dip execute( dst src -- ) ;
718 : jit-fixnum-/mod ( -- ) ;
719 ! ! load second parameter
720 ! temp1 ds-reg [] MOV
721 ! ! load first parameter
722 ! div-arg ds-reg bootstrap-cell neg [+] MOV
724 ! mod-arg div-arg MOV
726 ! mod-arg bootstrap-cell-bits 1 - SAR
730 ! # Rest of arm64 subprimitives
735 ! { fixnum+fast [ \ ADD jit-math ] }
738 ! { fixnum-bitand [ \ AND jit-math ] }
743 ! ds-reg [] tag-mask get XOR
745 ! { fixnum-bitor [ \ OR jit-math ] }
746 ! { fixnum-bitxor [ \ XOR jit-math ] }
747 ! { fixnum-shift-fast [
749 ! shift-arg ds-reg [] MOV
750 ! ! untag shift count
751 ! shift-arg tag-bits get SAR
752 ! ! adjust stack pointer
753 ! ds-reg bootstrap-cell SUB
755 ! temp3 ds-reg [] MOV
758 ! ! compute positive shift value in temp2
761 ! ! compute negative shift value in temp3
763 ! temp3 tag-mask get bitnot AND
765 ! ! if shift count was negative, move temp0 to temp2
768 ! ds-reg [] temp2 MOV
773 ! temp0 ds-reg [] MOV
774 ! ds-reg bootstrap-cell SUB
776 ! temp0 tag-mask get TEST
777 ! temp0 \ f type-number MOV
778 ! temp1 1 tag-fixnum MOV
780 ! ds-reg [] temp0 MOV
782 ! { eq? [ \ CMOVE jit-compare ] }
783 ! { fixnum> [ \ CMOVG jit-compare ] }
784 ! { fixnum>= [ \ CMOVGE jit-compare ] }
785 ! { fixnum< [ \ CMOVL jit-compare ] }
786 ! { fixnum<= [ \ CMOVLE jit-compare ] }
791 ! ! adjust stack pointer
792 ! ds-reg bootstrap-cell SUB
794 ! ds-reg [] mod-arg MOV
798 ! ! adjust stack pointer
799 ! ds-reg bootstrap-cell SUB
801 ! div-arg tag-bits get SHL
803 ! ds-reg [] div-arg MOV
805 ! { fixnum/mod-fast [
808 ! div-arg tag-bits get SHL
810 ! ds-reg [] mod-arg MOV
811 ! ds-reg bootstrap-cell neg [+] div-arg MOV
816 ! ! load second input
817 ! temp0 ds-reg [] MOV
819 ! ds-reg bootstrap-cell SUB
821 ! temp1 ds-reg [] MOV
822 ! ! untag second input
823 ! temp0 tag-bits get SAR
827 ! ds-reg [] temp0 MOV
831 ! { fixnum-fast [ \ SUB jit-math ] }
836 ! temp0 ds-reg [] MOV
837 ! ! adjust stack pointer
838 ! ds-reg bootstrap-cell SUB
839 ! ! turn local number into offset
841 ! ! decrement retain stack pointer
845 ! ! load local number
846 ! temp0 ds-reg [] MOV
847 ! ! turn local number into offset
850 ! temp0 rs-reg temp0 [+] MOV
852 ! ds-reg [] temp0 MOV
854 ! { load-local [ jit->r ] }
859 ! temp0 ds-reg [] MOV
860 ! ! adjust stack pointer
861 ! ds-reg bootstrap-cell SUB
863 ! temp1 ds-reg [] MOV
864 ! ! turn slot number into offset
867 ! temp1 tag-bits get SHR
868 ! temp1 tag-bits get SHL
870 ! temp0 temp1 temp0 [+] MOV
872 ! ds-reg [] temp0 MOV
874 ! { string-nth-fast [
875 ! ! load string index from stack
876 ! temp0 ds-reg bootstrap-cell neg [+] MOV
877 ! temp0 tag-bits get SHR
878 ! ! load string from stack
879 ! temp1 ds-reg [] MOV
881 ! temp0 8-bit-version-of temp0 temp1 string-offset [++] MOV
882 ! temp0 temp0 8-bit-version-of MOVZX
883 ! temp0 tag-bits get SHL
884 ! ! store character to stack
885 ! ds-reg bootstrap-cell SUB
886 ! ds-reg [] temp0 MOV
890 ! temp0 ds-reg [] MOV
892 ! temp0/32 tag-mask get AND
894 ! temp0/32 tag-bits get SHL
896 ! ds-reg [] temp0 MOV
902 ! { drop [ ds-reg bootstrap-cell SUB ] }
903 ! { 2drop [ ds-reg 2 bootstrap-cells SUB ] }
904 ! { 3drop [ ds-reg 3 bootstrap-cells SUB ] }
905 ! { 4drop [ ds-reg 4 bootstrap-cells SUB ] }
909 ! temp0 ds-reg [] MOV
910 ! ds-reg bootstrap-cell ADD
911 ! ds-reg [] temp0 MOV
914 ! temp0 ds-reg [] MOV
915 ! temp1 ds-reg bootstrap-cell neg [+] MOV
916 ! ds-reg 2 bootstrap-cells ADD
917 ! ds-reg [] temp0 MOV
918 ! ds-reg bootstrap-cell neg [+] temp1 MOV
921 ! temp0 ds-reg [] MOV
922 ! temp1 ds-reg -1 bootstrap-cells [+] MOV
923 ! temp3 ds-reg -2 bootstrap-cells [+] MOV
924 ! ds-reg 3 bootstrap-cells ADD
925 ! ds-reg [] temp0 MOV
926 ! ds-reg -1 bootstrap-cells [+] temp1 MOV
927 ! ds-reg -2 bootstrap-cells [+] temp3 MOV
930 ! temp0 ds-reg [] MOV
931 ! temp1 ds-reg -1 bootstrap-cells [+] MOV
932 ! temp2 ds-reg -2 bootstrap-cells [+] MOV
933 ! temp3 ds-reg -3 bootstrap-cells [+] MOV
934 ! ds-reg 4 bootstrap-cells ADD
935 ! ds-reg [] temp0 MOV
936 ! ds-reg -1 bootstrap-cells [+] temp1 MOV
937 ! ds-reg -2 bootstrap-cells [+] temp2 MOV
938 ! ds-reg -3 bootstrap-cells [+] temp3 MOV
941 ! temp0 ds-reg [] MOV
942 ! temp1 ds-reg -1 bootstrap-cells [+] MOV
943 ! ds-reg [] temp1 MOV
944 ! ds-reg bootstrap-cell ADD
945 ! ds-reg [] temp0 MOV
948 ! ! ### Misc shufflers
950 ! temp0 ds-reg -1 bootstrap-cells [+] MOV
951 ! ds-reg bootstrap-cell ADD
952 ! ds-reg [] temp0 MOV
955 ! temp0 ds-reg -2 bootstrap-cells [+] MOV
956 ! ds-reg bootstrap-cell ADD
957 ! ds-reg [] temp0 MOV
962 ! temp0 ds-reg [] MOV
963 ! ds-reg bootstrap-cell SUB
964 ! ds-reg [] temp0 MOV
967 ! temp0 ds-reg [] MOV
968 ! ds-reg 2 bootstrap-cells SUB
969 ! ds-reg [] temp0 MOV
974 ! temp0 ds-reg [] MOV
975 ! temp1 ds-reg -1 bootstrap-cells [+] MOV
976 ! temp3 ds-reg -2 bootstrap-cells [+] MOV
977 ! ds-reg -2 bootstrap-cells [+] temp0 MOV
978 ! ds-reg -1 bootstrap-cells [+] temp3 MOV
979 ! ds-reg [] temp1 MOV
982 ! temp0 ds-reg [] MOV
983 ! temp1 ds-reg -1 bootstrap-cells [+] MOV
984 ! temp3 ds-reg -2 bootstrap-cells [+] MOV
985 ! ds-reg -2 bootstrap-cells [+] temp1 MOV
986 ! ds-reg -1 bootstrap-cells [+] temp0 MOV
987 ! ds-reg [] temp3 MOV
990 ! temp0 ds-reg [] MOV
991 ! temp1 ds-reg bootstrap-cell neg [+] MOV
992 ! ds-reg bootstrap-cell neg [+] temp0 MOV
993 ! ds-reg [] temp1 MOV
996 ! temp0 ds-reg -1 bootstrap-cells [+] MOV
997 ! temp1 ds-reg -2 bootstrap-cells [+] MOV
998 ! ds-reg -2 bootstrap-cells [+] temp0 MOV
999 ! ds-reg -1 bootstrap-cells [+] temp1 MOV
1002 ! ! ## Signal handling
1003 ! { leaf-signal-handler [
1004 ! jit-signal-handler-prolog
1006 ! temp0 vm-reg vm-signal-handler-addr-offset [+] MOV
1008 ! jit-signal-handler-epilog
1009 ! ! Pop the fake leaf frame along with our return address
1010 ! leaf-stack-frame-size bootstrap-cell - RET
1012 ! { signal-handler [
1013 ! jit-signal-handler-prolog
1015 ! temp0 vm-reg vm-signal-handler-addr-offset [+] MOV
1017 ! jit-signal-handler-epilog
1020 } define-sub-primitives
1022 [ "bootstrap.arm.64" forget-vocab ] with-compilation-unit