Remove remnants of non-interleavable raw slot spport.
[sbcl.git] / src / code / arm64-vm.lisp
blob48006ec39a1f2685a181d43542b91f28ca8bbdae
1 ;;; This file contains the ARM specific runtime stuff.
2 ;;;
3 (in-package "SB!VM")
5 ;;; See x86-vm.lisp for a description of this.
6 ;;; FIXME: Why is this present in every ARCH-vm.lisp with the the same definition. Is there something like common-vm?
7 (define-alien-type os-context-t (struct os-context-t-struct))
8 \f
9 (defun machine-type ()
10 #!+sb-doc
11 "Return a string describing the type of the local machine."
12 "ARM64")
14 ;;;; FIXUP-CODE-OBJECT
16 (defun fixup-code-object (code offset fixup kind)
17 (declare (type index offset))
18 (unless (zerop (rem offset 4))
19 (error "Unaligned instruction? offset=#x~X." offset))
20 (without-gcing
21 (let ((sap (%primitive code-instructions code)))
22 (ecase kind
23 (:absolute
24 (setf (sap-ref-word sap offset) fixup))
25 (:cond-branch
26 (setf (ldb (byte 19 5) (sap-ref-32 sap offset))
27 (ash (- fixup (+ (sap-int sap) offset)) -2)))
28 (:uncond-branch
29 (setf (ldb (byte 26 0) (sap-ref-32 sap offset))
30 (ash (- fixup (+ (sap-int sap) offset)) -2)))))))
32 ;;;; "Sigcontext" access functions, cut & pasted from sparc-vm.lisp,
33 ;;;; then modified for ARM.
34 ;;;;
35 ;;;; See also x86-vm for commentary on signed vs unsigned.
37 (define-alien-routine ("os_context_register_addr" context-register-addr)
38 (* unsigned-long)
39 (context (* os-context-t))
40 (index int))
42 (define-alien-routine ("os_context_pc_addr" context-register-pc-addr)
43 (* unsigned-long)
44 (context (* os-context-t)))
45 (define-alien-routine ("os_context_float_register_addr" context-float-register-addr)
46 (* unsigned) (context (* os-context-t)) (index int))
48 ;;; FIXME: Should this and CONTEXT-PC be INLINE to reduce consing?
49 ;;; (Are they used in anything time-critical, or just the debugger?)
50 (defun context-register (context index)
51 (declare (type (alien (* os-context-t)) context))
52 (deref (context-register-addr context index)))
54 (defun %set-context-register (context index new)
55 (declare (type (alien (* os-context-t)) context))
56 (setf (deref (context-register-addr context index))
57 new))
59 (defun context-float-register (context index format)
60 (let ((sap (alien-sap (context-float-register-addr context index))))
61 (ecase format
62 (single-float
63 (sap-ref-single sap 0))
64 (double-float
65 (sap-ref-double sap 0))
66 (complex-single-float
67 (complex (sap-ref-single sap 0)
68 (sap-ref-single sap 4)))
69 (complex-double-float
70 (complex (sap-ref-double sap 0)
71 (sap-ref-double sap 8))))))
73 (defun %set-context-float-register (context index format value)
74 (let ((sap (alien-sap (context-float-register-addr context index))))
75 (ecase format
76 (single-float
77 (setf (sap-ref-single sap 0) value))
78 (double-float
79 (setf (sap-ref-double sap 0) value))
80 (complex-single-float
81 (locally
82 (declare (type (complex single-float) value))
83 (setf (sap-ref-single sap 0) (realpart value)
84 (sap-ref-single sap 4) (imagpart value))))
85 (complex-double-float
86 (locally
87 (declare (type (complex double-float) value))
88 (setf (sap-ref-double sap 0) (realpart value)
89 (sap-ref-double sap 8) (imagpart value)))))))
91 (defun context-pc (context)
92 (declare (type (alien (* os-context-t)) context))
93 (int-sap (deref (context-register-pc-addr context))))
95 ;;;; INTERNAL-ERROR-ARGS.
97 ;;; Given a (POSIX) signal context, extract the internal error
98 ;;; arguments from the instruction stream.
99 (defun internal-error-args (context)
100 (declare (type (alien (* os-context-t)) context))
101 (let* ((pc (context-pc context))
102 (instruction (sap-ref-32 pc 0))
103 (error-number (ldb (byte 8 13) instruction)))
104 (declare (type system-area-pointer pc))
105 (if (= (ldb (byte 8 5) instruction) invalid-arg-count-trap)
106 (values error-number '(#.arg-count-sc))
107 (let* ((length (sap-ref-8 pc 4))
108 (vector (make-array length :element-type '(unsigned-byte 8)))
109 (index 0))
110 (declare (type (unsigned-byte 8) length)
111 (type (simple-array (unsigned-byte 8) (*)) vector))
112 (copy-ub8-from-system-area pc 5 vector 0 length)
113 (collect ((sc-offsets))
114 (loop
115 (when (>= index length)
116 (return))
117 (sc-offsets (sb!c:read-var-integer vector index)))
118 (values error-number (sc-offsets)))))))