Mercurial > emacs
comparison gc/mach_dep.c @ 51488:5de98dce4bd1
*** empty log message ***
author | Dave Love <fx@gnu.org> |
---|---|
date | Thu, 05 Jun 2003 17:49:22 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
51487:01d68b199093 | 51488:5de98dce4bd1 |
---|---|
1 /* | |
2 * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers | |
3 * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. | |
4 * | |
5 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED | |
6 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. | |
7 * | |
8 * Permission is hereby granted to use or copy this program | |
9 * for any purpose, provided the above notices are retained on all copies. | |
10 * Permission to modify the code and to distribute modified code is granted, | |
11 * provided the above notices are retained, and a notice that the code was | |
12 * modified is included with the above copyright notice. | |
13 */ | |
14 /* Boehm, November 17, 1995 12:13 pm PST */ | |
15 # include "private/gc_priv.h" | |
16 # include <stdio.h> | |
17 # include <setjmp.h> | |
18 # if defined(OS2) || defined(CX_UX) | |
19 # define _setjmp(b) setjmp(b) | |
20 # define _longjmp(b,v) longjmp(b,v) | |
21 # endif | |
22 # ifdef AMIGA | |
23 # ifndef __GNUC__ | |
24 # include <dos.h> | |
25 # else | |
26 # include <machine/reg.h> | |
27 # endif | |
28 # endif | |
29 | |
30 #if defined(__MWERKS__) && !defined(POWERPC) | |
31 | |
32 asm static void PushMacRegisters() | |
33 { | |
34 sub.w #4,sp // reserve space for one parameter. | |
35 move.l a2,(sp) | |
36 jsr GC_push_one | |
37 move.l a3,(sp) | |
38 jsr GC_push_one | |
39 move.l a4,(sp) | |
40 jsr GC_push_one | |
41 # if !__option(a6frames) | |
42 // <pcb> perhaps a6 should be pushed if stack frames are not being used. | |
43 move.l a6,(sp) | |
44 jsr GC_push_one | |
45 # endif | |
46 // skip a5 (globals), a6 (frame pointer), and a7 (stack pointer) | |
47 move.l d2,(sp) | |
48 jsr GC_push_one | |
49 move.l d3,(sp) | |
50 jsr GC_push_one | |
51 move.l d4,(sp) | |
52 jsr GC_push_one | |
53 move.l d5,(sp) | |
54 jsr GC_push_one | |
55 move.l d6,(sp) | |
56 jsr GC_push_one | |
57 move.l d7,(sp) | |
58 jsr GC_push_one | |
59 add.w #4,sp // fix stack. | |
60 rts | |
61 } | |
62 | |
63 #endif /* __MWERKS__ */ | |
64 | |
65 # if defined(SPARC) || defined(IA64) | |
66 /* Value returned from register flushing routine; either sp (SPARC) */ | |
67 /* or ar.bsp (IA64) */ | |
68 word GC_save_regs_ret_val; | |
69 # endif | |
70 | |
71 /* Routine to mark from registers that are preserved by the C compiler. */ | |
72 /* This must be ported to every new architecture. There is a generic */ | |
73 /* version at the end, that is likely, but not guaranteed to work */ | |
74 /* on your architecture. Run the test_setjmp program to see whether */ | |
75 /* there is any chance it will work. */ | |
76 | |
77 #ifndef USE_GENERIC_PUSH_REGS | |
78 void GC_push_regs() | |
79 { | |
80 # ifdef RT | |
81 register long TMP_SP; /* must be bound to r11 */ | |
82 # endif | |
83 | |
84 # ifdef VAX | |
85 /* VAX - generic code below does not work under 4.2 */ | |
86 /* r1 through r5 are caller save, and therefore */ | |
87 /* on the stack or dead. */ | |
88 asm("pushl r11"); asm("calls $1,_GC_push_one"); | |
89 asm("pushl r10"); asm("calls $1,_GC_push_one"); | |
90 asm("pushl r9"); asm("calls $1,_GC_push_one"); | |
91 asm("pushl r8"); asm("calls $1,_GC_push_one"); | |
92 asm("pushl r7"); asm("calls $1,_GC_push_one"); | |
93 asm("pushl r6"); asm("calls $1,_GC_push_one"); | |
94 # endif | |
95 # if defined(M68K) && (defined(SUNOS4) || defined(NEXT)) | |
96 /* M68K SUNOS - could be replaced by generic code */ | |
97 /* a0, a1 and d1 are caller save */ | |
98 /* and therefore are on stack or dead. */ | |
99 | |
100 asm("subqw #0x4,sp"); /* allocate word on top of stack */ | |
101 | |
102 asm("movl a2,sp@"); asm("jbsr _GC_push_one"); | |
103 asm("movl a3,sp@"); asm("jbsr _GC_push_one"); | |
104 asm("movl a4,sp@"); asm("jbsr _GC_push_one"); | |
105 asm("movl a5,sp@"); asm("jbsr _GC_push_one"); | |
106 /* Skip frame pointer and stack pointer */ | |
107 asm("movl d1,sp@"); asm("jbsr _GC_push_one"); | |
108 asm("movl d2,sp@"); asm("jbsr _GC_push_one"); | |
109 asm("movl d3,sp@"); asm("jbsr _GC_push_one"); | |
110 asm("movl d4,sp@"); asm("jbsr _GC_push_one"); | |
111 asm("movl d5,sp@"); asm("jbsr _GC_push_one"); | |
112 asm("movl d6,sp@"); asm("jbsr _GC_push_one"); | |
113 asm("movl d7,sp@"); asm("jbsr _GC_push_one"); | |
114 | |
115 asm("addqw #0x4,sp"); /* put stack back where it was */ | |
116 # endif | |
117 | |
118 # if defined(M68K) && defined(HP) | |
119 /* M68K HP - could be replaced by generic code */ | |
120 /* a0, a1 and d1 are caller save. */ | |
121 | |
122 asm("subq.w &0x4,%sp"); /* allocate word on top of stack */ | |
123 | |
124 asm("mov.l %a2,(%sp)"); asm("jsr _GC_push_one"); | |
125 asm("mov.l %a3,(%sp)"); asm("jsr _GC_push_one"); | |
126 asm("mov.l %a4,(%sp)"); asm("jsr _GC_push_one"); | |
127 asm("mov.l %a5,(%sp)"); asm("jsr _GC_push_one"); | |
128 /* Skip frame pointer and stack pointer */ | |
129 asm("mov.l %d1,(%sp)"); asm("jsr _GC_push_one"); | |
130 asm("mov.l %d2,(%sp)"); asm("jsr _GC_push_one"); | |
131 asm("mov.l %d3,(%sp)"); asm("jsr _GC_push_one"); | |
132 asm("mov.l %d4,(%sp)"); asm("jsr _GC_push_one"); | |
133 asm("mov.l %d5,(%sp)"); asm("jsr _GC_push_one"); | |
134 asm("mov.l %d6,(%sp)"); asm("jsr _GC_push_one"); | |
135 asm("mov.l %d7,(%sp)"); asm("jsr _GC_push_one"); | |
136 | |
137 asm("addq.w &0x4,%sp"); /* put stack back where it was */ | |
138 # endif /* M68K HP */ | |
139 | |
140 # if defined(M68K) && defined(AMIGA) | |
141 /* AMIGA - could be replaced by generic code */ | |
142 /* a0, a1, d0 and d1 are caller save */ | |
143 | |
144 # ifdef __GNUC__ | |
145 asm("subq.w &0x4,%sp"); /* allocate word on top of stack */ | |
146 | |
147 asm("mov.l %a2,(%sp)"); asm("jsr _GC_push_one"); | |
148 asm("mov.l %a3,(%sp)"); asm("jsr _GC_push_one"); | |
149 asm("mov.l %a4,(%sp)"); asm("jsr _GC_push_one"); | |
150 asm("mov.l %a5,(%sp)"); asm("jsr _GC_push_one"); | |
151 asm("mov.l %a6,(%sp)"); asm("jsr _GC_push_one"); | |
152 /* Skip frame pointer and stack pointer */ | |
153 asm("mov.l %d2,(%sp)"); asm("jsr _GC_push_one"); | |
154 asm("mov.l %d3,(%sp)"); asm("jsr _GC_push_one"); | |
155 asm("mov.l %d4,(%sp)"); asm("jsr _GC_push_one"); | |
156 asm("mov.l %d5,(%sp)"); asm("jsr _GC_push_one"); | |
157 asm("mov.l %d6,(%sp)"); asm("jsr _GC_push_one"); | |
158 asm("mov.l %d7,(%sp)"); asm("jsr _GC_push_one"); | |
159 | |
160 asm("addq.w &0x4,%sp"); /* put stack back where it was */ | |
161 # else /* !__GNUC__ */ | |
162 GC_push_one(getreg(REG_A2)); | |
163 GC_push_one(getreg(REG_A3)); | |
164 # ifndef __SASC | |
165 /* Can probably be changed to #if 0 -Kjetil M. (a4=globals)*/ | |
166 GC_push_one(getreg(REG_A4)); | |
167 # endif | |
168 GC_push_one(getreg(REG_A5)); | |
169 GC_push_one(getreg(REG_A6)); | |
170 /* Skip stack pointer */ | |
171 GC_push_one(getreg(REG_D2)); | |
172 GC_push_one(getreg(REG_D3)); | |
173 GC_push_one(getreg(REG_D4)); | |
174 GC_push_one(getreg(REG_D5)); | |
175 GC_push_one(getreg(REG_D6)); | |
176 GC_push_one(getreg(REG_D7)); | |
177 # endif /* !__GNUC__ */ | |
178 # endif /* AMIGA */ | |
179 | |
180 # if defined(M68K) && defined(MACOS) | |
181 # if defined(THINK_C) | |
182 # define PushMacReg(reg) \ | |
183 move.l reg,(sp) \ | |
184 jsr GC_push_one | |
185 asm { | |
186 sub.w #4,sp ; reserve space for one parameter. | |
187 PushMacReg(a2); | |
188 PushMacReg(a3); | |
189 PushMacReg(a4); | |
190 ; skip a5 (globals), a6 (frame pointer), and a7 (stack pointer) | |
191 PushMacReg(d2); | |
192 PushMacReg(d3); | |
193 PushMacReg(d4); | |
194 PushMacReg(d5); | |
195 PushMacReg(d6); | |
196 PushMacReg(d7); | |
197 add.w #4,sp ; fix stack. | |
198 } | |
199 # undef PushMacReg | |
200 # endif /* THINK_C */ | |
201 # if defined(__MWERKS__) | |
202 PushMacRegisters(); | |
203 # endif /* __MWERKS__ */ | |
204 # endif /* MACOS */ | |
205 | |
206 # if defined(I386) &&!defined(OS2) &&!defined(SVR4) \ | |
207 && (defined(__MINGW32__) || !defined(MSWIN32)) \ | |
208 && !defined(SCO) && !defined(SCO_ELF) \ | |
209 && !(defined(LINUX) && defined(__ELF__)) \ | |
210 && !(defined(FREEBSD) && defined(__ELF__)) \ | |
211 && !(defined(NETBSD) && defined(__ELF__)) \ | |
212 && !(defined(OPENBSD) && defined(__ELF__)) \ | |
213 && !(defined(BEOS) && defined(__ELF__)) \ | |
214 && !defined(DOS4GW) && !defined(HURD) | |
215 /* I386 code, generic code does not appear to work */ | |
216 /* It does appear to work under OS2, and asms dont */ | |
217 /* This is used for some 38g UNIX variants and for CYGWIN32 */ | |
218 asm("pushl %eax"); asm("call _GC_push_one"); asm("addl $4,%esp"); | |
219 asm("pushl %ecx"); asm("call _GC_push_one"); asm("addl $4,%esp"); | |
220 asm("pushl %edx"); asm("call _GC_push_one"); asm("addl $4,%esp"); | |
221 asm("pushl %ebp"); asm("call _GC_push_one"); asm("addl $4,%esp"); | |
222 asm("pushl %esi"); asm("call _GC_push_one"); asm("addl $4,%esp"); | |
223 asm("pushl %edi"); asm("call _GC_push_one"); asm("addl $4,%esp"); | |
224 asm("pushl %ebx"); asm("call _GC_push_one"); asm("addl $4,%esp"); | |
225 # endif | |
226 | |
227 # if ( defined(I386) && defined(LINUX) && defined(__ELF__) ) \ | |
228 || ( defined(I386) && defined(FREEBSD) && defined(__ELF__) ) \ | |
229 || ( defined(I386) && defined(NETBSD) && defined(__ELF__) ) \ | |
230 || ( defined(I386) && defined(OPENBSD) && defined(__ELF__) ) \ | |
231 || ( defined(I386) && defined(HURD) && defined(__ELF__) ) \ | |
232 || ( defined(I386) && defined(DGUX) ) | |
233 | |
234 /* This is modified for Linux with ELF (Note: _ELF_ only) */ | |
235 /* This section handles FreeBSD with ELF. */ | |
236 /* Eax is caller-save and dead here. Other caller-save */ | |
237 /* registers could also be skipped. We assume there are no */ | |
238 /* pointers in MMX registers, etc. */ | |
239 /* We combine instructions in a single asm to prevent gcc from */ | |
240 /* inserting code in the middle. */ | |
241 asm("pushl %ecx; call GC_push_one; addl $4,%esp"); | |
242 asm("pushl %edx; call GC_push_one; addl $4,%esp"); | |
243 asm("pushl %ebp; call GC_push_one; addl $4,%esp"); | |
244 asm("pushl %esi; call GC_push_one; addl $4,%esp"); | |
245 asm("pushl %edi; call GC_push_one; addl $4,%esp"); | |
246 asm("pushl %ebx; call GC_push_one; addl $4,%esp"); | |
247 # endif | |
248 | |
249 # if ( defined(I386) && defined(BEOS) && defined(__ELF__) ) | |
250 /* As far as I can understand from */ | |
251 /* http://www.beunited.org/articles/jbq/nasm.shtml, */ | |
252 /* only ebp, esi, edi and ebx are not scratch. How MMX */ | |
253 /* etc. registers should be treated, I have no idea. */ | |
254 asm("pushl %ebp; call GC_push_one; addl $4,%esp"); | |
255 asm("pushl %esi; call GC_push_one; addl $4,%esp"); | |
256 asm("pushl %edi; call GC_push_one; addl $4,%esp"); | |
257 asm("pushl %ebx; call GC_push_one; addl $4,%esp"); | |
258 # endif | |
259 | |
260 # if defined(I386) && defined(MSWIN32) && !defined(__MINGW32__) \ | |
261 && !defined(USE_GENERIC) | |
262 /* I386 code, Microsoft variant */ | |
263 __asm push eax | |
264 __asm call GC_push_one | |
265 __asm add esp,4 | |
266 __asm push ebx | |
267 __asm call GC_push_one | |
268 __asm add esp,4 | |
269 __asm push ecx | |
270 __asm call GC_push_one | |
271 __asm add esp,4 | |
272 __asm push edx | |
273 __asm call GC_push_one | |
274 __asm add esp,4 | |
275 __asm push ebp | |
276 __asm call GC_push_one | |
277 __asm add esp,4 | |
278 __asm push esi | |
279 __asm call GC_push_one | |
280 __asm add esp,4 | |
281 __asm push edi | |
282 __asm call GC_push_one | |
283 __asm add esp,4 | |
284 # endif | |
285 | |
286 # if defined(I386) && (defined(SVR4) || defined(SCO) || defined(SCO_ELF)) | |
287 /* I386 code, SVR4 variant, generic code does not appear to work */ | |
288 asm("pushl %eax"); asm("call GC_push_one"); asm("addl $4,%esp"); | |
289 asm("pushl %ebx"); asm("call GC_push_one"); asm("addl $4,%esp"); | |
290 asm("pushl %ecx"); asm("call GC_push_one"); asm("addl $4,%esp"); | |
291 asm("pushl %edx"); asm("call GC_push_one"); asm("addl $4,%esp"); | |
292 asm("pushl %ebp"); asm("call GC_push_one"); asm("addl $4,%esp"); | |
293 asm("pushl %esi"); asm("call GC_push_one"); asm("addl $4,%esp"); | |
294 asm("pushl %edi"); asm("call GC_push_one"); asm("addl $4,%esp"); | |
295 # endif | |
296 | |
297 # ifdef NS32K | |
298 asm ("movd r3, tos"); asm ("bsr ?_GC_push_one"); asm ("adjspb $-4"); | |
299 asm ("movd r4, tos"); asm ("bsr ?_GC_push_one"); asm ("adjspb $-4"); | |
300 asm ("movd r5, tos"); asm ("bsr ?_GC_push_one"); asm ("adjspb $-4"); | |
301 asm ("movd r6, tos"); asm ("bsr ?_GC_push_one"); asm ("adjspb $-4"); | |
302 asm ("movd r7, tos"); asm ("bsr ?_GC_push_one"); asm ("adjspb $-4"); | |
303 # endif | |
304 | |
305 # if defined(SPARC) | |
306 { | |
307 word GC_save_regs_in_stack(); | |
308 | |
309 GC_save_regs_ret_val = GC_save_regs_in_stack(); | |
310 } | |
311 # endif | |
312 | |
313 # ifdef RT | |
314 GC_push_one(TMP_SP); /* GC_push_one from r11 */ | |
315 | |
316 asm("cas r11, r6, r0"); GC_push_one(TMP_SP); /* r6 */ | |
317 asm("cas r11, r7, r0"); GC_push_one(TMP_SP); /* through */ | |
318 asm("cas r11, r8, r0"); GC_push_one(TMP_SP); /* r10 */ | |
319 asm("cas r11, r9, r0"); GC_push_one(TMP_SP); | |
320 asm("cas r11, r10, r0"); GC_push_one(TMP_SP); | |
321 | |
322 asm("cas r11, r12, r0"); GC_push_one(TMP_SP); /* r12 */ | |
323 asm("cas r11, r13, r0"); GC_push_one(TMP_SP); /* through */ | |
324 asm("cas r11, r14, r0"); GC_push_one(TMP_SP); /* r15 */ | |
325 asm("cas r11, r15, r0"); GC_push_one(TMP_SP); | |
326 # endif | |
327 | |
328 # if defined(M68K) && defined(SYSV) | |
329 /* Once again similar to SUN and HP, though setjmp appears to work. | |
330 --Parag | |
331 */ | |
332 # ifdef __GNUC__ | |
333 asm("subqw #0x4,%sp"); /* allocate word on top of stack */ | |
334 | |
335 asm("movl %a2,%sp@"); asm("jbsr GC_push_one"); | |
336 asm("movl %a3,%sp@"); asm("jbsr GC_push_one"); | |
337 asm("movl %a4,%sp@"); asm("jbsr GC_push_one"); | |
338 asm("movl %a5,%sp@"); asm("jbsr GC_push_one"); | |
339 /* Skip frame pointer and stack pointer */ | |
340 asm("movl %d1,%sp@"); asm("jbsr GC_push_one"); | |
341 asm("movl %d2,%sp@"); asm("jbsr GC_push_one"); | |
342 asm("movl %d3,%sp@"); asm("jbsr GC_push_one"); | |
343 asm("movl %d4,%sp@"); asm("jbsr GC_push_one"); | |
344 asm("movl %d5,%sp@"); asm("jbsr GC_push_one"); | |
345 asm("movl %d6,%sp@"); asm("jbsr GC_push_one"); | |
346 asm("movl %d7,%sp@"); asm("jbsr GC_push_one"); | |
347 | |
348 asm("addqw #0x4,%sp"); /* put stack back where it was */ | |
349 # else /* !__GNUC__*/ | |
350 asm("subq.w &0x4,%sp"); /* allocate word on top of stack */ | |
351 | |
352 asm("mov.l %a2,(%sp)"); asm("jsr GC_push_one"); | |
353 asm("mov.l %a3,(%sp)"); asm("jsr GC_push_one"); | |
354 asm("mov.l %a4,(%sp)"); asm("jsr GC_push_one"); | |
355 asm("mov.l %a5,(%sp)"); asm("jsr GC_push_one"); | |
356 /* Skip frame pointer and stack pointer */ | |
357 asm("mov.l %d1,(%sp)"); asm("jsr GC_push_one"); | |
358 asm("mov.l %d2,(%sp)"); asm("jsr GC_push_one"); | |
359 asm("mov.l %d3,(%sp)"); asm("jsr GC_push_one"); | |
360 asm("mov.l %d4,(%sp)"); asm("jsr GC_push_one"); | |
361 asm("mov.l %d5,(%sp)"); asm("jsr GC_push_one"); | |
362 asm("mov.l %d6,(%sp)"); asm("jsr GC_push_one"); | |
363 asm("mov.l %d7,(%sp)"); asm("jsr GC_push_one"); | |
364 | |
365 asm("addq.w &0x4,%sp"); /* put stack back where it was */ | |
366 # endif /* !__GNUC__ */ | |
367 # endif /* M68K/SYSV */ | |
368 | |
369 # if defined(PJ) | |
370 { | |
371 register int * sp asm ("optop"); | |
372 extern int *__libc_stack_end; | |
373 | |
374 GC_push_all_stack (sp, __libc_stack_end); | |
375 } | |
376 # endif | |
377 | |
378 /* other machines... */ | |
379 # if !defined(M68K) && !defined(VAX) && !defined(RT) | |
380 # if !defined(SPARC) && !defined(I386) && !defined(NS32K) | |
381 # if !defined(POWERPC) && !defined(UTS4) | |
382 # if !defined(PJ) && !(defined(MIPS) && defined(LINUX)) | |
383 --> bad news <-- | |
384 # endif | |
385 # endif | |
386 # endif | |
387 # endif | |
388 } | |
389 #endif /* !USE_GENERIC_PUSH_REGS */ | |
390 | |
391 #if defined(USE_GENERIC_PUSH_REGS) | |
392 void GC_generic_push_regs(cold_gc_frame) | |
393 ptr_t cold_gc_frame; | |
394 { | |
395 { | |
396 # ifdef HAVE_BUILTIN_UNWIND_INIT | |
397 /* This was suggested by Richard Henderson as the way to */ | |
398 /* force callee-save registers and register windows onto */ | |
399 /* the stack. */ | |
400 __builtin_unwind_init(); | |
401 # else /* !HAVE_BUILTIN_UNWIND_INIT */ | |
402 /* Generic code */ | |
403 /* The idea is due to Parag Patel at HP. */ | |
404 /* We're not sure whether he would like */ | |
405 /* to be he acknowledged for it or not. */ | |
406 jmp_buf regs; | |
407 register word * i = (word *) regs; | |
408 register ptr_t lim = (ptr_t)(regs) + (sizeof regs); | |
409 | |
410 /* Setjmp doesn't always clear all of the buffer. */ | |
411 /* That tends to preserve garbage. Clear it. */ | |
412 for (; (char *)i < lim; i++) { | |
413 *i = 0; | |
414 } | |
415 # if defined(POWERPC) || defined(MSWIN32) || defined(MSWINCE) \ | |
416 || defined(UTS4) || defined(LINUX) || defined(EWS4800) | |
417 (void) setjmp(regs); | |
418 # else | |
419 (void) _setjmp(regs); | |
420 # endif | |
421 # endif /* !HAVE_BUILTIN_UNWIND_INIT */ | |
422 # if (defined(SPARC) && !defined(HAVE_BUILTIN_UNWIND_INIT)) \ | |
423 || defined(IA64) | |
424 /* On a register window machine, we need to save register */ | |
425 /* contents on the stack for this to work. The setjmp */ | |
426 /* is probably not needed on SPARC, since pointers are */ | |
427 /* only stored in windowed or scratch registers. It is */ | |
428 /* needed on IA64, since some non-windowed registers are */ | |
429 /* preserved. */ | |
430 { | |
431 word GC_save_regs_in_stack(); | |
432 | |
433 GC_save_regs_ret_val = GC_save_regs_in_stack(); | |
434 /* On IA64 gcc, could use __builtin_ia64_flushrs() and */ | |
435 /* __builtin_ia64_flushrs(). The latter will be done */ | |
436 /* implicitly by __builtin_unwind_init() for gcc3.0.1 */ | |
437 /* and later. */ | |
438 } | |
439 # endif | |
440 GC_push_current_stack(cold_gc_frame); | |
441 } | |
442 } | |
443 #endif /* USE_GENERIC_PUSH_REGS */ | |
444 | |
445 /* On register window machines, we need a way to force registers into */ | |
446 /* the stack. Return sp. */ | |
447 # ifdef SPARC | |
448 asm(" .seg \"text\""); | |
449 # ifdef SVR4 | |
450 asm(" .globl GC_save_regs_in_stack"); | |
451 asm("GC_save_regs_in_stack:"); | |
452 asm(" .type GC_save_regs_in_stack,#function"); | |
453 # else | |
454 asm(" .globl _GC_save_regs_in_stack"); | |
455 asm("_GC_save_regs_in_stack:"); | |
456 # endif | |
457 # if defined(__arch64__) || defined(__sparcv9) | |
458 asm(" save %sp,-128,%sp"); | |
459 asm(" flushw"); | |
460 asm(" ret"); | |
461 asm(" restore %sp,2047+128,%o0"); | |
462 # else | |
463 asm(" ta 0x3 ! ST_FLUSH_WINDOWS"); | |
464 asm(" retl"); | |
465 asm(" mov %sp,%o0"); | |
466 # endif | |
467 # ifdef SVR4 | |
468 asm(" .GC_save_regs_in_stack_end:"); | |
469 asm(" .size GC_save_regs_in_stack,.GC_save_regs_in_stack_end-GC_save_regs_in_stack"); | |
470 # endif | |
471 # ifdef LINT | |
472 word GC_save_regs_in_stack() { return(0 /* sp really */);} | |
473 # endif | |
474 # endif | |
475 | |
476 /* On IA64, we also need to flush register windows. But they end */ | |
477 /* up on the other side of the stack segment. */ | |
478 /* Returns the backing store pointer for the register stack. */ | |
479 /* We now implement this as a separate assembly file, since inline */ | |
480 /* assembly code here doesn't work with either the Intel or HP */ | |
481 /* compilers. */ | |
482 # if 0 | |
483 # ifdef LINUX | |
484 asm(" .text"); | |
485 asm(" .psr abi64"); | |
486 asm(" .psr lsb"); | |
487 asm(" .lsb"); | |
488 asm(""); | |
489 asm(" .text"); | |
490 asm(" .align 16"); | |
491 asm(" .global GC_save_regs_in_stack"); | |
492 asm(" .proc GC_save_regs_in_stack"); | |
493 asm("GC_save_regs_in_stack:"); | |
494 asm(" .body"); | |
495 asm(" flushrs"); | |
496 asm(" ;;"); | |
497 asm(" mov r8=ar.bsp"); | |
498 asm(" br.ret.sptk.few rp"); | |
499 asm(" .endp GC_save_regs_in_stack"); | |
500 # endif /* LINUX */ | |
501 # if 0 /* Other alternatives that don't work on HP/UX */ | |
502 word GC_save_regs_in_stack() { | |
503 # if USE_BUILTINS | |
504 __builtin_ia64_flushrs(); | |
505 return __builtin_ia64_bsp(); | |
506 # else | |
507 # ifdef HPUX | |
508 _asm(" flushrs"); | |
509 _asm(" ;;"); | |
510 _asm(" mov r8=ar.bsp"); | |
511 _asm(" br.ret.sptk.few rp"); | |
512 # else | |
513 asm(" flushrs"); | |
514 asm(" ;;"); | |
515 asm(" mov r8=ar.bsp"); | |
516 asm(" br.ret.sptk.few rp"); | |
517 # endif | |
518 # endif | |
519 } | |
520 # endif | |
521 # endif | |
522 | |
523 /* GC_clear_stack_inner(arg, limit) clears stack area up to limit and */ | |
524 /* returns arg. Stack clearing is crucial on SPARC, so we supply */ | |
525 /* an assembly version that's more careful. Assumes limit is hotter */ | |
526 /* than sp, and limit is 8 byte aligned. */ | |
527 #if defined(ASM_CLEAR_CODE) | |
528 #ifndef SPARC | |
529 --> fix it | |
530 #endif | |
531 # ifdef SUNOS4 | |
532 asm(".globl _GC_clear_stack_inner"); | |
533 asm("_GC_clear_stack_inner:"); | |
534 # else | |
535 asm(".globl GC_clear_stack_inner"); | |
536 asm("GC_clear_stack_inner:"); | |
537 asm(".type GC_save_regs_in_stack,#function"); | |
538 # endif | |
539 #if defined(__arch64__) || defined(__sparcv9) | |
540 asm("mov %sp,%o2"); /* Save sp */ | |
541 asm("add %sp,2047-8,%o3"); /* p = sp+bias-8 */ | |
542 asm("add %o1,-2047-192,%sp"); /* Move sp out of the way, */ | |
543 /* so that traps still work. */ | |
544 /* Includes some extra words */ | |
545 /* so we can be sloppy below. */ | |
546 asm("loop:"); | |
547 asm("stx %g0,[%o3]"); /* *(long *)p = 0 */ | |
548 asm("cmp %o3,%o1"); | |
549 asm("bgu,pt %xcc, loop"); /* if (p > limit) goto loop */ | |
550 asm("add %o3,-8,%o3"); /* p -= 8 (delay slot) */ | |
551 asm("retl"); | |
552 asm("mov %o2,%sp"); /* Restore sp., delay slot */ | |
553 #else | |
554 asm("mov %sp,%o2"); /* Save sp */ | |
555 asm("add %sp,-8,%o3"); /* p = sp-8 */ | |
556 asm("clr %g1"); /* [g0,g1] = 0 */ | |
557 asm("add %o1,-0x60,%sp"); /* Move sp out of the way, */ | |
558 /* so that traps still work. */ | |
559 /* Includes some extra words */ | |
560 /* so we can be sloppy below. */ | |
561 asm("loop:"); | |
562 asm("std %g0,[%o3]"); /* *(long long *)p = 0 */ | |
563 asm("cmp %o3,%o1"); | |
564 asm("bgu loop "); /* if (p > limit) goto loop */ | |
565 asm("add %o3,-8,%o3"); /* p -= 8 (delay slot) */ | |
566 asm("retl"); | |
567 asm("mov %o2,%sp"); /* Restore sp., delay slot */ | |
568 #endif /* old SPARC */ | |
569 /* First argument = %o0 = return value */ | |
570 # ifdef SVR4 | |
571 asm(" .GC_clear_stack_inner_end:"); | |
572 asm(" .size GC_clear_stack_inner,.GC_clear_stack_inner_end-GC_clear_stack_inner"); | |
573 # endif | |
574 | |
575 # ifdef LINT | |
576 /*ARGSUSED*/ | |
577 ptr_t GC_clear_stack_inner(arg, limit) | |
578 ptr_t arg; word limit; | |
579 { return(arg); } | |
580 # endif | |
581 #endif |