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

Last change on this file since 11229 was 11229, checked in by gb, 11 years ago

Do initial GC only on initial thread and only when GCDebug is non-zero.

File size: 3.3 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        __(movw tcr.ldt_selector(%ebx), %rcontext_reg)
78        __(movl 8(%ebp),%eax)
79        __(cmpl rcontext(tcr.linear),%eax)
80        __(je 0f)
81        __(hlt)
820:             
83        .if c_stack_16_byte_aligned
84        __(sub $12, %esp)       /* stack now 16-byte aligned */
85        .else
86        __(andl $~15,%esp)
87        .endif
88        __(clr %arg_z)
89        __(clr %arg_y) 
90        __(clr %temp0)
91        __(clr %temp1)
92        __(clr %fn)
93        __(pxor %fpzero, %fpzero)
94        __(stmxcsr rcontext(tcr.foreign_mxcsr))
95        __(andb $~mxcsr_all_exceptions,rcontext(tcr.foreign_mxcsr))
96        __(ldmxcsr rcontext(tcr.lisp_mxcsr))
97        __(movl $TCR_STATE_LISP, rcontext(tcr.valence))
98        __(call toplevel_loop)
99        __(movl $TCR_STATE_FOREIGN, rcontext(tcr.valence))
100        __(emms)
101        __(leal -3*node_size(%ebp),%esp)
102        __(pop %ebx)
103        __(pop %esi)
104        __(pop %edi)
105        __(ldmxcsr rcontext(tcr.foreign_mxcsr))
106        __ifdef([WIN32_ES_HACK])
107         __(push %ds)
108         __(pop %es)
109        __endif
110        __(movl $nil_value, %eax)
111        __(leave)
112        __(ret)
113Xsubprims_end:           
114_endfn
115
116        .data
117        .globl C(subprims_start)
118        .globl C(subprims_end)
119C(subprims_start):      .long Xsubprims_start
120C(subprims_end):        .long Xsubprims_end
121        .text
122
123
Note: See TracBrowser for help on using the repository browser.