0.9.17.8:
[sbcl.git] / src / runtime / mips-assem.S
index d18699a..ca4cfd0 100644 (file)
@@ -1,8 +1,24 @@
+/*
+ * very-low-level utilities for runtime support
+ */
+
+/*
+ * 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.
+ */
+\f
 #include "sbcl.h"
 #include "lispregs.h"
 #include "globals.h"
 #include "genesis/fdefn.h"
 #include "genesis/closure.h"
+#include "genesis/funcallable-instance.h"
 #include "genesis/return-pc.h"
 #include "genesis/simple-fun.h"
 #include "genesis/static-symbols.h"
@@ -122,9 +138,6 @@ symbol:
        li      reg_ALLOC, 1
         .set    reorder
 
-       /* Mark us as in Lisp land. */
-       sw      zero, foreign_function_call_active
-
        /* Load the allocation pointer, preserving the low-bit of alloc */
        lw      reg_BSP, dynamic_space_free_pointer
        addu    reg_ALLOC, reg_BSP
@@ -158,8 +171,12 @@ symbol:
        /* Indirect closure */
        lw      reg_CODE, CLOSURE_FUN_OFFSET(reg_LEXENV)
 
-       /* Jump into lisp land. */
        addu    reg_LIP, reg_CODE, SIMPLE_FUN_CODE_OFFSET
+
+       /* Mark us as in Lisp land. */
+       sw      zero, foreign_function_call_active
+
+       /* Jump into lisp land. */
        jr      reg_LIP
 
        .align  3
@@ -180,6 +197,9 @@ lra:        .word   RETURN_PC_HEADER_WIDETAG
        addu    reg_ALLOC, 1
        .set    reorder
 
+       /* Mark us as in C land. */
+       sw      reg_CSP, foreign_function_call_active
+
        /* Save LISP state. */
        subu    reg_NL0, reg_ALLOC, 1
        sw      reg_NL0, dynamic_space_free_pointer
@@ -187,9 +207,6 @@ lra:        .word   RETURN_PC_HEADER_WIDETAG
        sw      reg_CSP, current_control_stack_pointer
        sw      reg_CFP, current_control_frame_pointer
 
-       /* Mark us as in C land. */
-       sw      reg_CSP, foreign_function_call_active
-
        /* Check for interrupt */
        .set    noreorder
        bgez    reg_NL4, 1f
@@ -251,6 +268,9 @@ lra:        .word   RETURN_PC_HEADER_WIDETAG
        addu    reg_ALLOC, 1
        .set    reorder
 
+       /* Mark us as in C land. */
+       sw      reg_CSP, foreign_function_call_active
+
        /* Convert the return address to an offset and save it on the stack. */
        subu    reg_NFP, reg_LIP, reg_CODE
        addu    reg_NFP, OTHER_POINTER_LOWTAG
@@ -265,9 +285,6 @@ lra:        .word   RETURN_PC_HEADER_WIDETAG
        sw      reg_CSP, current_control_stack_pointer
        sw      reg_CFP, current_control_frame_pointer
 
-       /* Mark us as in C land. */
-       sw      reg_CSP, foreign_function_call_active
-
        /* Check for interrupt */
        .set    noreorder
        bgez    reg_NL4, 1f
@@ -314,9 +331,6 @@ lra:        .word   RETURN_PC_HEADER_WIDETAG
        li      reg_ALLOC, 1
        .set    reorder
 
-       /* Mark us as in Lisp land. */
-       sw      zero, foreign_function_call_active
-
        /* Load the allocation pointer, preserving the low-bit of alloc */
        lw      reg_BSP, dynamic_space_free_pointer
        addu    reg_ALLOC, reg_BSP
@@ -341,6 +355,9 @@ lra:        .word   RETURN_PC_HEADER_WIDETAG
        move    reg_CSP, reg_CFP
        move    reg_CFP, reg_OCFP
 
+       /* Mark us as in Lisp land. */
+       sw      zero, foreign_function_call_active
+
        /* Return to LISP. */
        jr      reg_LIP
        END(call_into_c)
@@ -404,6 +421,25 @@ lra:       .word   RETURN_PC_HEADER_WIDETAG
        END(closure_tramp)
 
 /*
+ * The trampoline for funcallable instances
+ */
+       .globl funcallable_instance_tramp
+       .align  3
+       .word   SIMPLE_FUN_HEADER_WIDETAG
+funcallable_instance_tramp = . + 1
+       .word   funcallable_instance_tramp
+       .word   NIL
+       .word   NIL
+       .word   NIL
+       .word   NIL
+
+       lw      reg_LEXENV, FUNCALLABLE_INSTANCE_FUNCTION_OFFSET(reg_LEXENV)
+       lw      reg_CODE, CLOSURE_FUN_OFFSET(reg_LEXENV)
+       addu    reg_LIP, reg_CODE, SIMPLE_FUN_CODE_OFFSET
+       jr      reg_LIP
+       nop
+
+/*
  * Function-end breakpoint magic. This is truely magic, the code is
  * copied and has to be relocatable. It also needs a properly aligned
  * header tag after the fun_end_breakpoint_guts symbol.