source: release/1.9/source/lisp-kernel/x86-subprims64.s @ 16083

Last change on this file since 16083 was 14993, checked in by rme, 8 years ago

Remove DARWIN_GS_HACK code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/*   Copyright (C) 2005-2009 Clozure Associates*/
2/*   This file is part of Clozure CL.  */
3
4/*   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public*/
5/*   License , known as the LLGPL and distributed with Clozure CL as the*/
6/*   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,*/
7/*   which is distributed with Clozure CL as the file "LGPL".  Where these*/
8/*   conflict, the preamble takes precedence.  */
9
10/*   Clozure CL is referenced in the preamble as the "LIBRARY."*/
11
12/*   The LLGPL is also available online at*/
13/*   http://opensource.franz.com/preamble.html*/
14
15
16        include(lisp.s)
17        _beginfile
18
19        .globl _SPmkcatch1v
20        .globl _SPnthrow1value
21
22
23/* This is called from a c-style context and calls a lisp function.*/
24/* This does the moral equivalent of*/
25/*   (loop */
26/*      (let* ((fn (%function_on_top_of_lisp_stack)))*/
27/*        (if fn*/
28/*            (catch %toplevel-catch%*/
29/*             (funcall fn))*/
30/*            (return nil))))*/
31
32
33_exportfn(toplevel_loop)
34Xsubprims_start:               
35        __(push %rbp)
36        __(movq %rsp,%rbp)
37        /* Switch to the lisp stack */
38        __(push $0)
39        __(push $0)
40        __(movq %rsp,rcontext(tcr.foreign_sp))
41        __(movq rcontext(tcr.save_vsp),%rsp)
42        __(push $0)
43        __(movq %rsp,%rbp)
44       
45        __(TSP_Alloc_Fixed(0,%temp0))
46        __(movsd %fpzero,tsp_frame.save_rbp(%temp0)) /* sentinel */
47        __(jmp local_label(test))
48local_label(loop):
49        __(ref_nrs_value(toplcatch,%arg_z))
50        __(leaq local_label(back_from_catch)(%rip),%ra0)
51        __(leaq local_label(test)(%rip),%xfn)
52        __(push %ra0)
53        __(jmp _SPmkcatch1v)
54__(tra(local_label(back_from_catch)))
55        __(movq %arg_x,%temp0)
56        __(leaq local_label(back_from_funcall)(%rip),%ra0)
57        __(push %ra0)
58        __(set_nargs(0))
59        __(jmp _SPfuncall)
60__(tra(local_label(back_from_funcall)))
61        __(movl $fixnumone,%imm0_l)
62        __(leaq local_label(test)(%rip),%ra0)
63        __(jmp _SPnthrow1value)
64__(tra(local_label(test)))
65        __(movq 8(%rbp),%arg_x)
66        __(cmpq $nil_value,%arg_x)
67        __(jnz local_label(loop))
68local_label(back_to_c):
69        __(discard_temp_frame(%imm0))
70        __(movq rcontext(tcr.foreign_sp),%rsp)
71        __(addq $dnode_size,%rsp)
72        __(movq %rsp,%rbp)
73        __(leave)
74        __(ret)
75
76/* This is called from C code when a thread (including the initial thread) */
77/* starts execution.  (Historically, it also provided a primitive way of */
78/* "resettting" a thread in the event of catastrophic failure, but this */
79/* hasn't worked in a long time.) */
80/* For compatibility with PPC code, this is called with the first foreign */
81/* argument pointing to the thread's TCR and the second foreign argument */
82/*  being a Boolean which indicates whether the thread should try to */
83/* "reset" itself or start running lisp code.  Both of these arguments */
84/* are currently ignored (the TCR is maintained in a segment register and */
85/*  the reset/panic code doesn't work ...), except on Windows, where we use */
86/* the first arg to set up the TCR register */ 
87   
88_exportfn(C(start_lisp))
89        __(push %rbp)
90        __(movq %rsp,%rbp)
91        __(push %csave0)
92        __(push %csave1)
93        __(push %csave2)
94        __(push %csave3)
95        __(push %csave4)
96        __ifdef(`WINDOWS')
97        __(push %csave5)
98        __(push %csave6)
99        __endif
100        __ifdef(`TCR_IN_GPR')
101        __(movq %carg0,%rcontext_reg)
102        __endif
103        __(sub $8,%rsp) /* %rsp is now 16-byte aligned  */
104        /* Put harmless values in lisp node registers  */
105        __(clr %arg_z)
106        __(clr %arg_y)
107        __(clr %arg_x)
108        __(clr %temp0)
109        __(clr %temp1)
110        __(clr %temp2)
111        __(clr %fn)
112        /*      __(clr %ra0) */ /* %ra0 == %temp2, now zeroed above */
113        __(clr %save0)
114        __(clr %save1)
115        __(clr %save2)
116        __ifndef(`TCR_IN_GPR') /* no %save3, r11 is %rcontext_reg */
117        __(clr %save3)
118        __endif
119        __(pxor %fpzero,%fpzero)        /* fpzero = 0.0`d0' */
120        __(stmxcsr rcontext(tcr.foreign_mxcsr))
121        __(andb $~mxcsr_all_exceptions,rcontext(tcr.foreign_mxcsr))
122        __(ldmxcsr rcontext(tcr.lisp_mxcsr))
123        __(movq $TCR_STATE_LISP,rcontext(tcr.valence))
124        __(call toplevel_loop)
125        __(movq $TCR_STATE_FOREIGN,rcontext(tcr.valence))
126        __(emms)
127        __(addq $8,%rsp)        /* discard alignment word */
128        __ifdef(`WINDOWS')
129        __(pop %csave6)
130        __(pop %csave5)
131        __endif
132        __(pop %csave4)
133        __(pop %csave3)
134        __(pop %csave2)
135        __(pop %csave1)
136        __(pop %csave0)
137        __(ldmxcsr rcontext(tcr.foreign_mxcsr))
138        __(movl $nil_value,%eax)
139        __(leave)
140        __(ret)
141Xsubprims_end:           
142_endfn
143
144        .data
145        .globl C(subprims_start)
146        .globl C(subprims_end)
147C(subprims_start):      .quad Xsubprims_start
148C(subprims_end):        .quad Xsubprims_end
149        .text
150                               
Note: See TracBrowser for help on using the repository browser.