1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* gc.c (ruby_gc_stress): moved to rb_objspace_t.

* gc.c (gc_stress_get, gc_stress_set): VM local attribute.

* signal.c (sigsegv): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-06-13 15:09:22 +00:00
parent e0d427e855
commit 4641b80166
4 changed files with 23 additions and 10 deletions

View file

@ -1,3 +1,11 @@
Sat Jun 14 00:09:19 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* gc.c (ruby_gc_stress): moved to rb_objspace_t.
* gc.c (gc_stress_get, gc_stress_set): VM local attribute.
* signal.c (sigsegv): ditto.
Fri Jun 13 21:55:48 2008 Tadayoshi Funaba <tadf@dotrb.org> Fri Jun 13 21:55:48 2008 Tadayoshi Funaba <tadf@dotrb.org>
* rational.c (nurat_equal_p): Rational(0,x) and 0 are equivalent, * rational.c (nurat_equal_p): Rational(0,x) and 0 are equivalent,

13
gc.c
View file

@ -179,6 +179,7 @@ typedef struct rb_objspace {
} markstack; } markstack;
struct gc_list *global_list; struct gc_list *global_list;
unsigned int count; unsigned int count;
int gc_stress;
} rb_objspace_t; } rb_objspace_t;
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
@ -206,6 +207,7 @@ static rb_objspace_t rb_objspace = {{GC_MALLOC_LIMIT}, {HEAP_MIN_SLOTS}};
#define mark_stack_ptr objspace->markstack.ptr #define mark_stack_ptr objspace->markstack.ptr
#define mark_stack_overflow objspace->markstack.overflow #define mark_stack_overflow objspace->markstack.overflow
#define global_List objspace->global_list #define global_List objspace->global_list
#define ruby_gc_stress objspace->gc_stress
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
rb_objspace_t * rb_objspace_t *
@ -243,7 +245,7 @@ VALUE *rb_gc_stack_start = 0;
VALUE *rb_gc_register_stack_start = 0; VALUE *rb_gc_register_stack_start = 0;
#endif #endif
int ruby_gc_stress = 0; int ruby_disable_gc_stress = 0;
#ifdef DJGPP #ifdef DJGPP
@ -289,6 +291,7 @@ rb_memerror(void)
static VALUE static VALUE
gc_stress_get(VALUE self) gc_stress_get(VALUE self)
{ {
rb_objspace_t *objspace = &rb_objspace;
return ruby_gc_stress ? Qtrue : Qfalse; return ruby_gc_stress ? Qtrue : Qfalse;
} }
@ -307,6 +310,7 @@ gc_stress_get(VALUE self)
static VALUE static VALUE
gc_stress_set(VALUE self, VALUE bool) gc_stress_set(VALUE self, VALUE bool)
{ {
rb_objspace_t *objspace = &rb_objspace;
rb_secure(2); rb_secure(2);
ruby_gc_stress = RTEST(bool); ruby_gc_stress = RTEST(bool);
return bool; return bool;
@ -326,7 +330,8 @@ vm_xmalloc(rb_objspace_t *objspace, size_t size)
size += sizeof(size_t); size += sizeof(size_t);
#endif #endif
if (ruby_gc_stress || (malloc_increase+size) > malloc_limit) { if ((ruby_gc_stress && !ruby_disable_gc_stress) ||
(malloc_increase+size) > malloc_limit) {
garbage_collect(objspace); garbage_collect(objspace);
} }
RUBY_CRITICAL(mem = malloc(size)); RUBY_CRITICAL(mem = malloc(size));
@ -360,7 +365,7 @@ vm_xrealloc(rb_objspace_t *objspace, void *ptr, size_t size)
} }
if (!ptr) return ruby_xmalloc(size); if (!ptr) return ruby_xmalloc(size);
if (size == 0) size = 1; if (size == 0) size = 1;
if (ruby_gc_stress) garbage_collect(objspace); if (ruby_gc_stress && !ruby_disable_gc_stress) garbage_collect(objspace);
#if CALC_EXACT_MALLOC_SIZE #if CALC_EXACT_MALLOC_SIZE
size += sizeof(size_t); size += sizeof(size_t);
@ -664,7 +669,7 @@ rb_newobj_from_heap(rb_objspace_t *objspace)
{ {
VALUE obj; VALUE obj;
if (ruby_gc_stress || !freelist) { if ((ruby_gc_stress && !ruby_disable_gc_stress) || !freelist) {
if (!heaps_increment(objspace) && !garbage_collect(objspace)) { if (!heaps_increment(objspace) && !garbage_collect(objspace)) {
rb_memerror(); rb_memerror();
} }

View file

@ -554,12 +554,12 @@ sigsegv(int sig)
{ {
if (segv_received) { if (segv_received) {
fprintf(stderr, "SEGV recieved in SEGV handler\n"); fprintf(stderr, "SEGV recieved in SEGV handler\n");
exit(1); exit(EXIT_FAILURE);
} }
else { else {
extern int ruby_gc_stress; extern int ruby_disable_gc_stress;
segv_received = 1; segv_received = 1;
ruby_gc_stress = 0; ruby_disable_gc_stress = 1;
rb_bug("Segmentation fault"); rb_bug("Segmentation fault");
} }
} }

View file

@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0" #define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2008-06-13" #define RUBY_RELEASE_DATE "2008-06-14"
#define RUBY_VERSION_CODE 190 #define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20080613 #define RUBY_RELEASE_CODE 20080614
#define RUBY_PATCHLEVEL 0 #define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MAJOR 1
@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0 #define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_YEAR 2008
#define RUBY_RELEASE_MONTH 6 #define RUBY_RELEASE_MONTH 6
#define RUBY_RELEASE_DAY 13 #define RUBY_RELEASE_DAY 14
#ifdef RUBY_EXTERN #ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[]; RUBY_EXTERN const char ruby_version[];