Mercurial > emacs
comparison src/alloc.c @ 112138:3d3d7ef762fd
Merge from mainline.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 06 Jan 2011 21:16:15 -0800 |
parents | 4dbda0e7c8bf |
children | ef719132ddfa 7df2e30d72ec |
comparison
equal
deleted
inserted
replaced
112120:aa1843c74710 | 112138:3d3d7ef762fd |
---|---|
1 /* Storage allocation and gc for GNU Emacs Lisp interpreter. | 1 /* Storage allocation and gc for GNU Emacs Lisp interpreter. |
2 Copyright (C) 1985, 1986, 1988, 1993, 1994, 1995, 1997, 1998, 1999, | 2 Copyright (C) 1985, 1986, 1988, 1993, 1994, 1995, 1997, 1998, 1999, |
3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 | 3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
4 Free Software Foundation, Inc. | 4 Free Software Foundation, Inc. |
5 | 5 |
6 This file is part of GNU Emacs. | 6 This file is part of GNU Emacs. |
7 | 7 |
8 GNU Emacs is free software: you can redistribute it and/or modify | 8 GNU Emacs is free software: you can redistribute it and/or modify |
4220 succeeds, this is _not_ a proof that setjmp is sufficient for | 4220 succeeds, this is _not_ a proof that setjmp is sufficient for |
4221 conservative stack marking. Only the sources or a disassembly | 4221 conservative stack marking. Only the sources or a disassembly |
4222 can prove that. */ | 4222 can prove that. */ |
4223 | 4223 |
4224 static void | 4224 static void |
4225 test_setjmp () | 4225 test_setjmp (void) |
4226 { | 4226 { |
4227 char buf[10]; | 4227 char buf[10]; |
4228 register int x; | 4228 register int x; |
4229 jmp_buf jbuf; | 4229 jmp_buf jbuf; |
4230 int result = 0; | 4230 int result = 0; |
4268 #if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS | 4268 #if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS |
4269 | 4269 |
4270 /* Abort if anything GCPRO'd doesn't survive the GC. */ | 4270 /* Abort if anything GCPRO'd doesn't survive the GC. */ |
4271 | 4271 |
4272 static void | 4272 static void |
4273 check_gcpros () | 4273 check_gcpros (void) |
4274 { | 4274 { |
4275 struct gcpro *p; | 4275 struct gcpro *p; |
4276 int i; | 4276 int i; |
4277 | 4277 |
4278 for (p = gcprolist; p; p = p->next) | 4278 for (p = gcprolist; p; p = p->next) |
4284 } | 4284 } |
4285 | 4285 |
4286 #elif GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES | 4286 #elif GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
4287 | 4287 |
4288 static void | 4288 static void |
4289 dump_zombies () | 4289 dump_zombies (void) |
4290 { | 4290 { |
4291 int i; | 4291 int i; |
4292 | 4292 |
4293 fprintf (stderr, "\nZombies kept alive = %d:\n", nzombies); | 4293 fprintf (stderr, "\nZombies kept alive = %d:\n", nzombies); |
4294 for (i = 0; i < min (MAX_ZOMBIES, nzombies); ++i) | 4294 for (i = 0; i < min (MAX_ZOMBIES, nzombies); ++i) |
4318 If GC_SAVE_REGISTERS_ON_STACK is not defined, the current | 4318 If GC_SAVE_REGISTERS_ON_STACK is not defined, the current |
4319 implementation assumes that calling setjmp saves registers we need | 4319 implementation assumes that calling setjmp saves registers we need |
4320 to see in a jmp_buf which itself lies on the stack. This doesn't | 4320 to see in a jmp_buf which itself lies on the stack. This doesn't |
4321 have to be true! It must be verified for each system, possibly | 4321 have to be true! It must be verified for each system, possibly |
4322 by taking a look at the source code of setjmp. | 4322 by taking a look at the source code of setjmp. |
4323 | |
4324 If __builtin_unwind_init is available (defined by GCC >= 2.8) we | |
4325 can use it as a machine independent method to store all registers | |
4326 to the stack. In this case the macros described in the previous | |
4327 two paragraphs are not used. | |
4323 | 4328 |
4324 Stack Layout | 4329 Stack Layout |
4325 | 4330 |
4326 Architectures differ in the way their processor stack is organized. | 4331 Architectures differ in the way their processor stack is organized. |
4327 For example, the stack might look like this | 4332 For example, the stack might look like this |
4357 jmp_buf j; | 4362 jmp_buf j; |
4358 } j; | 4363 } j; |
4359 volatile int stack_grows_down_p = (char *) &j > (char *) stack_base; | 4364 volatile int stack_grows_down_p = (char *) &j > (char *) stack_base; |
4360 void *end; | 4365 void *end; |
4361 | 4366 |
4367 #ifdef HAVE___BUILTIN_UNWIND_INIT | |
4368 /* Force callee-saved registers and register windows onto the stack. | |
4369 This is the preferred method if available, obviating the need for | |
4370 machine dependent methods. */ | |
4371 __builtin_unwind_init (); | |
4372 end = &end; | |
4373 #else /* not HAVE___BUILTIN_UNWIND_INIT */ | |
4362 /* This trick flushes the register windows so that all the state of | 4374 /* This trick flushes the register windows so that all the state of |
4363 the process is contained in the stack. */ | 4375 the process is contained in the stack. */ |
4364 /* Fixme: Code in the Boehm GC suggests flushing (with `flushrs') is | 4376 /* Fixme: Code in the Boehm GC suggests flushing (with `flushrs') is |
4365 needed on ia64 too. See mach_dep.c, where it also says inline | 4377 needed on ia64 too. See mach_dep.c, where it also says inline |
4366 assembler doesn't work with relevant proprietary compilers. */ | 4378 assembler doesn't work with relevant proprietary compilers. */ |
4392 #endif /* GC_SETJMP_WORKS */ | 4404 #endif /* GC_SETJMP_WORKS */ |
4393 | 4405 |
4394 setjmp (j.j); | 4406 setjmp (j.j); |
4395 end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j; | 4407 end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j; |
4396 #endif /* not GC_SAVE_REGISTERS_ON_STACK */ | 4408 #endif /* not GC_SAVE_REGISTERS_ON_STACK */ |
4409 #endif /* not HAVE___BUILTIN_UNWIND_INIT */ | |
4397 | 4410 |
4398 /* This assumes that the stack is a contiguous region in memory. If | 4411 /* This assumes that the stack is a contiguous region in memory. If |
4399 that's not the case, something has to be done here to iterate | 4412 that's not the case, something has to be done here to iterate |
4400 over the stack segments. */ | 4413 over the stack segments. */ |
4401 #ifndef GC_LISP_OBJECT_ALIGNMENT | 4414 #ifndef GC_LISP_OBJECT_ALIGNMENT |