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

Last change on this file since 16083 was 15429, checked in by gb, 7 years ago

Minor tweaks to compile without warnings with some version of Apple's
clang compiler:

gc.h, image.h, lisp.h: prototypes for some functions that haven't had them.
image.c: remove redundant/inconsistent prototypes.
mach-o-image.c: include "image.h" to pick up those prototypes.
pmcl-kernel.c: change a few function declarations to match prototypes.
x86-constants32.s, x86-subprims32.s, x86-spentry32.s: add copyright notice.

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