Provide restarts when returning undefined functions on x86-64.
[sbcl.git] / src / assembly / x86-64 / tramps.lisp
blob53e964220464b621e26402216d4398ac08d3bc96
1 ;;;; Undefined-function and closure trampoline definitions
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
6 (in-package "SB!VM")
8 (define-assembly-routine
9 (undefined-tramp (:return-style :none))
10 ((:temp rax descriptor-reg rax-offset))
11 (inst pop (make-ea :qword :base rbp-tn :disp n-word-bytes))
12 (emit-error-break nil cerror-trap (error-number-or-lose 'undefined-fun-error) (list rax))
13 (inst push (make-ea :qword :base rbp-tn :disp n-word-bytes))
14 (inst jmp
15 (make-ea :qword :base rax
16 :disp (- (* fdefn-raw-addr-slot
17 n-word-bytes)
18 other-pointer-lowtag))))
20 (define-assembly-routine
21 (undefined-alien-tramp (:return-style :none))
23 (inst pop (make-ea :qword :base rbp-tn :disp n-word-bytes))
24 (error-call nil 'undefined-alien-fun-error rbx-tn))
26 ;;; the closure trampoline - entered when a global function is a closure
27 ;;; and the function is called "by name" (normally, as when it is the
28 ;;; head of a form) via an FDEFN. Register %RAX holds the fdefn address,
29 ;;; but the simple-fun which underlies the closure expects %RAX to be the
30 ;;; closure itself. So we grab the closure out of the fdefn pointed to,
31 ;;; then jump to the simple-fun that the closure points to.
32 (define-assembly-routine
33 (closure-tramp (:return-style :none))
35 (loadw rax-tn rax-tn fdefn-fun-slot other-pointer-lowtag)
36 (inst jmp (make-ea-for-object-slot rax-tn closure-fun-slot fun-pointer-lowtag)))
38 (define-assembly-routine
39 (funcallable-instance-tramp (:return-style :none))
41 (loadw rax-tn rax-tn funcallable-instance-function-slot fun-pointer-lowtag)
42 (inst jmp (make-ea-for-object-slot rax-tn closure-fun-slot fun-pointer-lowtag)))