source: trunk/source/lisp-kernel/x86-subprims32.s @ 14261

Last change on this file since 14261 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 ...

File size: 3.4 KB
Line 
1        include(lisp.s)
2        _beginfile
3       
4        .globl _SPmkcatch1v
5        .globl _SPnthrow1value
6       
7/* This is called from a c-style context and calls a lisp function.*/
8/* This does the moral equivalent of*/
9/*   (loop */
10/*      (let* ((fn (%function_on_top_of_lisp_stack)))*/
11/*        (if fn*/
12/*            (catch %toplevel-catch%*/
13/*             (funcall fn))*/
14/*            (return nil))))*/
15
16
17_exportfn(toplevel_loop)
18Xsubprims_start:               
19        __(push %ebp)
20        __(movl %esp,%ebp)
21        /* Switch to the lisp stack */
22        __(movl %esp,rcontext(tcr.foreign_sp))
23        __(movl rcontext(tcr.save_vsp),%esp)
24        __(push $0)
25        __(mov %esp,%ebp)
26        __(cmpl $0,C(GCDebug))
27        __(je 1f)
28        __(ref_global(initial_tcr,%imm0))
29        __(cmpl rcontext(tcr.linear),%imm0)
30        __(jne 1f)
31        __(clr %imm0)
32        __(uuo_error_gc_trap)
331:
34        __(jmp local_label(test))
35local_label(loop):
36        __(ref_nrs_value(toplcatch,%arg_z))
37        __(movl `$'local_label(back_from_catch),%ra0)
38        __(movl `$'local_label(test),%xfn)
39        __(push %ra0)
40        __(jmp _SPmkcatch1v)
41__(tra(local_label(back_from_catch)))
42        __(movl %arg_y,%temp0)
43        __(pushl `$'local_label(back_from_funcall))
44        __(set_nargs(0))
45        __(jmp _SPfuncall)
46__(tra(local_label(back_from_funcall)))
47        __(movl $fixnumone,%imm0)
48        __(movl `$'local_label(test),%ra0)
49        __(jmp _SPnthrow1value)
50__(tra(local_label(test)))
51        __(movl 4(%ebp),%arg_y)
52        __(cmpl $nil_value,%arg_y)
53        __(jnz local_label(loop))
54local_label(back_to_c):
55        __(movl rcontext(tcr.foreign_sp),%esp)
56        __(movl %esp,%ebp)
57        __(leave)
58        __(ret)
59
60/* This is called from C code when a thread (including the initial thread) */
61/* starts execution.  (Historically, it also provided a primitive way of */
62/* "resettting" a thread in the event of catastrophic failure, but this */
63/* hasn't worked in a long time.) */
64/* For compatibility with PPC code, this is called with the first foreign */
65/* argument pointing to the thread's TCR and the second foreign argument */
66/*  being a Boolean which indicates whether the thread should try to */
67/* "reset" itself or start running lisp code. */
68/* The reset/panic code doesn't work. */
69
70_exportfn(C(start_lisp))
71        __(push %ebp)
72        __(movl %esp, %ebp)
73        __(push %edi)
74        __(push %esi)
75        __(push %ebx)
76        __(mov 8(%ebp), %ebx)   /* get tcr */
77        __(cmpb $0,C(rcontext_readonly))
78        __(jne 0f)
79        __(movw tcr.ldt_selector(%ebx), %rcontext_reg)
800:             
81        __(movl 8(%ebp),%eax)
82        __(cmpl rcontext(tcr.linear),%eax)
83        __(je 1f)
84        __(hlt)
851:             
86        .if c_stack_16_byte_aligned
87        __(sub $12, %esp)       /* stack now 16-byte aligned */
88        .else
89        __(andl $~15,%esp)
90        .endif
91        __(clr %arg_z)
92        __(clr %arg_y) 
93        __(clr %temp0)
94        __(clr %temp1)
95        __(clr %fn)
96        __(pxor %fpzero, %fpzero)
97        __(stmxcsr rcontext(tcr.foreign_mxcsr))
98        __(andb $~mxcsr_all_exceptions,rcontext(tcr.foreign_mxcsr))
99        __(ldmxcsr rcontext(tcr.lisp_mxcsr))
100        __(movl $TCR_STATE_LISP, rcontext(tcr.valence))
101        __(call toplevel_loop)
102        __(movl $TCR_STATE_FOREIGN, rcontext(tcr.valence))
103        __(emms)
104        __(leal -3*node_size(%ebp),%esp)
105        __(pop %ebx)
106        __(pop %esi)
107        __(pop %edi)
108        __(ldmxcsr rcontext(tcr.foreign_mxcsr))
109        __ifdef(`WIN32_ES_HACK')
110         __(push %ds)
111         __(pop %es)
112        __endif
113        __(movl $nil_value, %eax)
114        __(leave)
115        __(ret)
116Xsubprims_end:           
117_endfn
118
119        .data
120        .globl C(subprims_start)
121        .globl C(subprims_end)
122C(subprims_start):      .long Xsubprims_start
123C(subprims_end):        .long Xsubprims_end
124        .text
125
126
Note: See TracBrowser for help on using the repository browser.