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 ! x64 ! stack-reg stack-frame-size bootstrap-cell - SUB
605 ! : link-reg ( -- reg ) X30 ; ! LR
606 ! : stack-frame-reg ( -- reg ) X29 ; ! FP
608 ! ! make room for LR plus magic number of callback, 16byte align
609 stack-frame-size bootstrap-cell 2 * + stack-reg stack-reg SUBi64
610 ! link-reg X29 stack-reg STP
611 -16 SP link-reg X29 STP-pre
612 ] JIT-PROLOG jit-define
615 ! x64 ! stack-reg stack-frame-size bootstrap-cell - ADD
616 -16 SP link-reg X29 LDP-pre
617 stack-frame-size bootstrap-cell 2 * + stack-reg stack-reg ADDi64
618 ] JIT-EPILOG jit-define
622 ] JIT-RETURN jit-define
624 ! ! ! Polymorphic inline caches
626 ! The PIC stubs are not permitted to touch pic-tail-reg.
628 ! Load a value from a stack position
630 ! temp1 ds-reg 0x7f [+] MOV f rc-absolute-1 rel-untagged
631 ] PIC-LOAD jit-define
634 ! temp1/32 tag-mask get AND
639 ! temp1/32 tag-mask get AND
640 ! temp1/32 tuple type-number CMP
642 ! [ temp1 temp0 tuple-class-offset [+] MOV ]
644 ] PIC-TUPLE jit-define
647 ! temp1/32 0x7f CMP f rc-absolute-1 rel-untagged
648 ] PIC-CHECK-TAG jit-define
651 ! 0 JE f rc-relative rel-word
654 ! ! ! Megamorphic caches
659 ! temp1/32 tag-mask get AND
660 ! temp1/32 tag-bits get SHL
661 ! temp1/32 tuple type-number tag-fixnum CMP
663 ! [ temp1 temp0 tuple-class-offset [+] MOV ]
666 ! temp0 0 MOV f rc-absolute-cell rel-literal
667 ! ! key = hashcode(class)
669 ! bootstrap-cell 4 = [ temp2 1 SHR ] when
670 ! ! key &= cache.length - 1
671 ! temp2 mega-cache-size get 1 - bootstrap-cell * AND
672 ! ! cache += array-start-offset
673 ! temp0 array-start-offset ADD
676 ! ! if(get(cache) == class)
680 ! ! megamorphic_cache_hits++
681 ! temp1 0 MOV rc-absolute-cell rel-megamorphic-cache-hits
683 ! ! goto get(cache + bootstrap-cell)
684 ! temp0 temp0 bootstrap-cell [+] MOV
685 ! temp0 word-entry-point-offset [+] JMP
686 ! ! fall-through on miss
688 ] MEGA-LOOKUP jit-define
691 : jit-compare ( insn -- ) drop ;
693 ! temp3 0 MOV t rc-absolute-cell rel-literal
695 ! temp1 \ f type-number MOV
697 ! temp0 ds-reg [] MOV
698 ! ! adjust stack pointer
699 ! ds-reg bootstrap-cell SUB
700 ! ! compare with second value
701 ! ds-reg [] temp0 CMP
703 ! [ temp1 temp3 ] dip execute( dst src -- )
705 ! ds-reg [] temp1 MOV ;
708 : jit-math ( insn -- ) drop ;
709 ! ! load second input
710 ! temp0 ds-reg [] MOV
712 ! ds-reg bootstrap-cell SUB
714 ! [ ds-reg [] temp0 ] dip execute( dst src -- ) ;
716 : jit-fixnum-/mod ( -- ) ;
717 ! ! load second parameter
718 ! temp1 ds-reg [] MOV
719 ! ! load first parameter
720 ! div-arg ds-reg bootstrap-cell neg [+] MOV
722 ! mod-arg div-arg MOV
724 ! mod-arg bootstrap-cell-bits 1 - SAR
728 ! # Rest of arm64 subprimitives
733 ! { fixnum+fast [ \ ADD jit-math ] }
736 ! { fixnum-bitand [ \ AND jit-math ] }
741 ! ds-reg [] tag-mask get XOR
743 ! { fixnum-bitor [ \ OR jit-math ] }
744 ! { fixnum-bitxor [ \ XOR jit-math ] }
745 ! { fixnum-shift-fast [
747 ! shift-arg ds-reg [] MOV
748 ! ! untag shift count
749 ! shift-arg tag-bits get SAR
750 ! ! adjust stack pointer
751 ! ds-reg bootstrap-cell SUB
753 ! temp3 ds-reg [] MOV
756 ! ! compute positive shift value in temp2
759 ! ! compute negative shift value in temp3
761 ! temp3 tag-mask get bitnot AND
763 ! ! if shift count was negative, move temp0 to temp2
766 ! ds-reg [] temp2 MOV
771 ! temp0 ds-reg [] MOV
772 ! ds-reg bootstrap-cell SUB
774 ! temp0 tag-mask get TEST
775 ! temp0 \ f type-number MOV
776 ! temp1 1 tag-fixnum MOV
778 ! ds-reg [] temp0 MOV
780 ! { eq? [ \ CMOVE jit-compare ] }
781 ! { fixnum> [ \ CMOVG jit-compare ] }
782 ! { fixnum>= [ \ CMOVGE jit-compare ] }
783 ! { fixnum< [ \ CMOVL jit-compare ] }
784 ! { fixnum<= [ \ CMOVLE jit-compare ] }
789 ! ! adjust stack pointer
790 ! ds-reg bootstrap-cell SUB
792 ! ds-reg [] mod-arg MOV
796 ! ! adjust stack pointer
797 ! ds-reg bootstrap-cell SUB
799 ! div-arg tag-bits get SHL
801 ! ds-reg [] div-arg MOV
803 ! { fixnum/mod-fast [
806 ! div-arg tag-bits get SHL
808 ! ds-reg [] mod-arg MOV
809 ! ds-reg bootstrap-cell neg [+] div-arg MOV
814 ! ! load second input
815 ! temp0 ds-reg [] MOV
817 ! ds-reg bootstrap-cell SUB
819 ! temp1 ds-reg [] MOV
820 ! ! untag second input
821 ! temp0 tag-bits get SAR
825 ! ds-reg [] temp0 MOV
829 ! { fixnum-fast [ \ SUB jit-math ] }
834 ! temp0 ds-reg [] MOV
835 ! ! adjust stack pointer
836 ! ds-reg bootstrap-cell SUB
837 ! ! turn local number into offset
839 ! ! decrement retain stack pointer
843 ! ! load local number
844 ! temp0 ds-reg [] MOV
845 ! ! turn local number into offset
848 ! temp0 rs-reg temp0 [+] MOV
850 ! ds-reg [] temp0 MOV
852 ! { load-local [ jit->r ] }
857 ! temp0 ds-reg [] MOV
858 ! ! adjust stack pointer
859 ! ds-reg bootstrap-cell SUB
861 ! temp1 ds-reg [] MOV
862 ! ! turn slot number into offset
865 ! temp1 tag-bits get SHR
866 ! temp1 tag-bits get SHL
868 ! temp0 temp1 temp0 [+] MOV
870 ! ds-reg [] temp0 MOV
872 ! { string-nth-fast [
873 ! ! load string index from stack
874 ! temp0 ds-reg bootstrap-cell neg [+] MOV
875 ! temp0 tag-bits get SHR
876 ! ! load string from stack
877 ! temp1 ds-reg [] MOV
879 ! temp0 8-bit-version-of temp0 temp1 string-offset [++] MOV
880 ! temp0 temp0 8-bit-version-of MOVZX
881 ! temp0 tag-bits get SHL
882 ! ! store character to stack
883 ! ds-reg bootstrap-cell SUB
884 ! ds-reg [] temp0 MOV
888 ! temp0 ds-reg [] MOV
890 ! temp0/32 tag-mask get AND
892 ! temp0/32 tag-bits get SHL
894 ! ds-reg [] temp0 MOV
900 ! { drop [ ds-reg bootstrap-cell SUB ] }
901 ! { 2drop [ ds-reg 2 bootstrap-cells SUB ] }
902 ! { 3drop [ ds-reg 3 bootstrap-cells SUB ] }
903 ! { 4drop [ ds-reg 4 bootstrap-cells SUB ] }
907 ! temp0 ds-reg [] MOV
908 ! ds-reg bootstrap-cell ADD
909 ! ds-reg [] temp0 MOV
912 ! temp0 ds-reg [] MOV
913 ! temp1 ds-reg bootstrap-cell neg [+] MOV
914 ! ds-reg 2 bootstrap-cells ADD
915 ! ds-reg [] temp0 MOV
916 ! ds-reg bootstrap-cell neg [+] temp1 MOV
919 ! temp0 ds-reg [] MOV
920 ! temp1 ds-reg -1 bootstrap-cells [+] MOV
921 ! temp3 ds-reg -2 bootstrap-cells [+] MOV
922 ! ds-reg 3 bootstrap-cells ADD
923 ! ds-reg [] temp0 MOV
924 ! ds-reg -1 bootstrap-cells [+] temp1 MOV
925 ! ds-reg -2 bootstrap-cells [+] temp3 MOV
928 ! temp0 ds-reg [] MOV
929 ! temp1 ds-reg -1 bootstrap-cells [+] MOV
930 ! temp2 ds-reg -2 bootstrap-cells [+] MOV
931 ! temp3 ds-reg -3 bootstrap-cells [+] MOV
932 ! ds-reg 4 bootstrap-cells ADD
933 ! ds-reg [] temp0 MOV
934 ! ds-reg -1 bootstrap-cells [+] temp1 MOV
935 ! ds-reg -2 bootstrap-cells [+] temp2 MOV
936 ! ds-reg -3 bootstrap-cells [+] temp3 MOV
939 ! temp0 ds-reg [] MOV
940 ! temp1 ds-reg -1 bootstrap-cells [+] MOV
941 ! ds-reg [] temp1 MOV
942 ! ds-reg bootstrap-cell ADD
943 ! ds-reg [] temp0 MOV
946 ! ! ### Misc shufflers
948 ! temp0 ds-reg -1 bootstrap-cells [+] MOV
949 ! ds-reg bootstrap-cell ADD
950 ! ds-reg [] temp0 MOV
953 ! temp0 ds-reg -2 bootstrap-cells [+] MOV
954 ! ds-reg bootstrap-cell ADD
955 ! ds-reg [] temp0 MOV
960 ! temp0 ds-reg [] MOV
961 ! ds-reg bootstrap-cell SUB
962 ! ds-reg [] temp0 MOV
965 ! temp0 ds-reg [] MOV
966 ! ds-reg 2 bootstrap-cells SUB
967 ! ds-reg [] temp0 MOV
972 ! temp0 ds-reg [] MOV
973 ! temp1 ds-reg -1 bootstrap-cells [+] MOV
974 ! temp3 ds-reg -2 bootstrap-cells [+] MOV
975 ! ds-reg -2 bootstrap-cells [+] temp0 MOV
976 ! ds-reg -1 bootstrap-cells [+] temp3 MOV
977 ! ds-reg [] temp1 MOV
980 ! temp0 ds-reg [] MOV
981 ! temp1 ds-reg -1 bootstrap-cells [+] MOV
982 ! temp3 ds-reg -2 bootstrap-cells [+] MOV
983 ! ds-reg -2 bootstrap-cells [+] temp1 MOV
984 ! ds-reg -1 bootstrap-cells [+] temp0 MOV
985 ! ds-reg [] temp3 MOV
988 ! temp0 ds-reg [] MOV
989 ! temp1 ds-reg bootstrap-cell neg [+] MOV
990 ! ds-reg bootstrap-cell neg [+] temp0 MOV
991 ! ds-reg [] temp1 MOV
994 ! temp0 ds-reg -1 bootstrap-cells [+] MOV
995 ! temp1 ds-reg -2 bootstrap-cells [+] MOV
996 ! ds-reg -2 bootstrap-cells [+] temp0 MOV
997 ! ds-reg -1 bootstrap-cells [+] temp1 MOV
1000 ! ! ## Signal handling
1001 ! { leaf-signal-handler [
1002 ! jit-signal-handler-prolog
1004 ! temp0 vm-reg vm-signal-handler-addr-offset [+] MOV
1006 ! jit-signal-handler-epilog
1007 ! ! Pop the fake leaf frame along with our return address
1008 ! leaf-stack-frame-size bootstrap-cell - RET
1010 ! { signal-handler [
1011 ! jit-signal-handler-prolog
1013 ! temp0 vm-reg vm-signal-handler-addr-offset [+] MOV
1015 ! jit-signal-handler-epilog
1018 } define-sub-primitives
1020 [ "bootstrap.arm.64" forget-vocab ] with-compilation-unit