source: branches/arm/lisp-kernel/x86-subprims64.s @ 13923

Last change on this file since 13923 was 13337, checked in by plkrueger, 10 years ago

Don't change the m4 quoting characters from their defaults (`').
(On the ARM, square brackets are used to denote memory operands, curly
braces surround register lists, and multicharacter quoting delimeters
look funny ...)

Some versions (at least) of m4 are confused by quoting characters in
comments, so try to refrain from using contractions ...

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 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        __ifdef(`DARWIN_GS_HACK')
104         __(set_gs_base())
105        __endif
106        __(sub $8,%rsp) /* %rsp is now 16-byte aligned  */
107        /* Put harmless values in lisp node registers  */
108        __(clr %arg_z)
109        __(clr %arg_y)
110        __(clr %arg_x)
111        __(clr %temp0)
112        __(clr %temp1)
113        __(clr %temp2)
114        __(clr %fn)
115        /*      __(clr %ra0) */ /* %ra0 == %temp2, now zeroed above */
116        __(clr %save0)
117        __(clr %save1)
118        __(clr %save2)
119        __ifndef(`TCR_IN_GPR') /* no %save3, r11 is %rcontext_reg */
120        __(clr %save3)
121        __endif
122        __(pxor %fpzero,%fpzero)        /* fpzero = 0.0`d0' */
123        __(stmxcsr rcontext(tcr.foreign_mxcsr))
124        __(andb $~mxcsr_all_exceptions,rcontext(tcr.foreign_mxcsr))
125        __(ldmxcsr rcontext(tcr.lisp_mxcsr))
126        __(movq $TCR_STATE_LISP,rcontext(tcr.valence))
127        __(call toplevel_loop)
128        __(movq $TCR_STATE_FOREIGN,rcontext(tcr.valence))
129        __(emms)
130        __(addq $8,%rsp)        /* discard alignment word */
131        __ifdef(`WINDOWS')
132        __(pop %csave6)
133        __(pop %csave5)
134        __endif
135        __(pop %csave4)
136        __(pop %csave3)
137        __(pop %csave2)
138        __(pop %csave1)
139        __(pop %csave0)
140        __(ldmxcsr rcontext(tcr.foreign_mxcsr))
141        __ifdef(`DARWIN_GS_HACK')
142         __(set_foreign_gs_base)
143        __endif
144        __(movl $nil_value,%eax)
145        __(leave)
146        __(ret)
147Xsubprims_end:           
148_endfn
149
150        .data
151        .globl C(subprims_start)
152        .globl C(subprims_end)
153C(subprims_start):      .quad Xsubprims_start
154C(subprims_end):        .quad Xsubprims_end
155        .text
156                               
Note: See TracBrowser for help on using the repository browser.