Skip to content

Instantly share code, notes, and snippets.

@stassats
Created January 28, 2019 12:29
Show Gist options
  • Save stassats/9fb06c6260939b3e605f43fe74025ba4 to your computer and use it in GitHub Desktop.
Save stassats/9fb06c6260939b3e605f43fe74025ba4 to your computer and use it in GitHub Desktop.
diff --git a/src/assembly/master.lisp b/src/assembly/master.lisp
index 24393760f..b5d3186f8 100644
--- a/src/assembly/master.lisp
+++ b/src/assembly/master.lisp
@@ -4,6 +4,7 @@
(make-pathname :type "lisp"))
:verbose nil :print nil))
'("src/assembly/target/tramps"
+ "src/assembly/target/runtime-rtns"
"src/assembly/target/assem-rtns"
"src/assembly/target/array"
"src/assembly/target/arith"
diff --git a/src/assembly/x86-64/runtime-rtns.lisp b/src/assembly/x86-64/runtime-rtns.lisp
new file mode 100644
index 000000000..446b10cf0
--- /dev/null
+++ b/src/assembly/x86-64/runtime-rtns.lisp
@@ -0,0 +1,15 @@
+;;;; This software is part of the SBCL system. See the README file for
+;;;; more information.
+;;;;
+;;;; This software is derived from the CMU CL system, which was
+;;;; written at Carnegie Mellon University and released into the
+;;;; public domain. The software is in the public domain and is
+;;;; provided with absolutely no warranty. See the COPYING and CREDITS
+;;;; files for more information.
+
+(in-package "SB-VM")
+
+(define-assembly-routine
+ (call-into-lisp (:return-style :none))
+ ()
+ (inst break halt-trap))
diff --git a/src/compiler/generic/genesis.lisp b/src/compiler/generic/genesis.lisp
index 74ebd1ed3..c7a391042 100644
--- a/src/compiler/generic/genesis.lisp
+++ b/src/compiler/generic/genesis.lisp
@@ -3272,6 +3272,11 @@ core and return a descriptor to it."
(sb-vm:pad-data-block sb-vm:symbol-size))
(* index (sb-vm:pad-data-block sb-vm:fdefn-size)))))))
+(defun init-runtime-routines ()
+ (dolist (symbol sb-vm::+runtime-routines+)
+ (let* ((des (cold-intern symbol :gspace *static*)))
+ (cold-set des (make-descriptor (lookup-assembler-reference symbol))))))
+
(defun write-sc+offset-coding (stream)
(flet ((write-array (name bytes)
(format stream "static struct sc_and_offset_byte ~A[] = {~@
@@ -3649,7 +3654,8 @@ III. initially undefined function references (alphabetically):
(cold-cons z z (ecase (gspace-name
(descriptor-gspace *cold-assembler-obj*))
(:read-only *static*)
- (:immobile-varyobj *dynamic*))))))
+ (:immobile-varyobj *dynamic*)))))
+ (init-runtime-routines))
;; Initialize the *COLD-SYMBOLS* system with the information
;; from common-lisp-exports.lisp-expr.
diff --git a/src/compiler/x86-64/parms.lisp b/src/compiler/x86-64/parms.lisp
index 93de71574..7acfb3d49 100644
--- a/src/compiler/x86-64/parms.lisp
+++ b/src/compiler/x86-64/parms.lisp
@@ -172,6 +172,9 @@
;;; Note these spaces grow from low to high addresses.
(defvar *binding-stack-pointer*)
+(defconstant-eqx +runtime-routines+
+ '(sb-vm::call-into-lisp))
+
(defconstant-eqx +static-symbols+
`#(,@+common-static-symbols+
#!+(and immobile-space (not sb-thread)) function-layout
@@ -179,7 +182,8 @@
;; interrupt handling
#!-sb-thread *pseudo-atomic-bits* ; ditto
#!-sb-thread *binding-stack-pointer* ; ditto
- *cpuid-fn1-ecx*)
+ *cpuid-fn1-ecx*
+ ,@+runtime-routines+)
#'equalp)
;;; FIXME: with #!+immobile-space, this should be the empty list,
diff --git a/src/runtime/thread.c b/src/runtime/thread.c
index eb36d7dd5..bd812ffe0 100644
--- a/src/runtime/thread.c
+++ b/src/runtime/thread.c
@@ -220,6 +220,8 @@ initial_thread_trampoline(struct thread *th)
set_thread_stack(th->control_stack_end);
#endif
+ ((lispobj(*)(lispobj))SYMBOL(CALL_INTO_LISP)->value)(function);
+
/* WIN32 has a special stack arrangement, calling
* call_into_lisp_first_time will put the new stack in the middle
* of the current stack */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment