From ffe1cf575ecd5f9215a75728947520e9e668fb8a Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 2 Jul 2001 08:46:28 +0000 Subject: * error.c (exc_exception): clone the receiver exception instead of creating brand new exception object of the receiver. * eval.c (rb_eval_string_wrap): extend new ruby_top_self, not original self. * eval.c (rb_eval_cmd): respect ruby_wrapper if set. * eval.c (eval): do not update ruby_class unless scope is not provided. * eval.c (eval): preserve wrapper information. * eval.c (proc_invoke): ditto. * eval.c (block_pass): ditto. * parse.y (void_expr): too much warnings for void context (e.g. foo[1] that can be mere Proc call). * error.c (rb_name_error): new function to raise NameError with name attribute set. * eval.c (rb_f_missing): set name and args in the exception object. [new] * error.c (name_name): NameError#name - new method. * error.c (nometh_args): NoMethodError#args - new method. * lex.c (rb_reserved_word): lex_state after tRESCUE should be EXPR_MID. * gc.c (add_heap): allocation size of the heap unit is doubled for each allocation. * dir.c (isdelim): space, tab, and newline are no longer delimiters for glob patterns. * eval.c (svalue_to_avalue): new conversion scheme between single value and array values. * eval.c (avalue_to_svalue): ditto. * eval.c (rb_eval): REXPAND now uses avalue_to_svalue(), return and yield too. * eval.c (rb_yield_0): use avalue_to_svalue(). * eval.c (proc_invoke): Proc#call gives avaules, whereas Proc#yield gives mvalues. * eval.c (bmcall): convert given value (svalue) to avalue. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- gc.c | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) (limited to 'gc.c') diff --git a/gc.c b/gc.c index cfe981d7ee..6c9a054db1 100644 --- a/gc.c +++ b/gc.c @@ -258,7 +258,10 @@ static RVALUE **heaps; static int heaps_length = 0; static int heaps_used = 0; -#define HEAP_SLOTS 10000 +#define HEAP_MIN_SLOTS 10000 +static int *heaps_limits; +static int heap_slots = HEAP_MIN_SLOTS; + #define FREE_MIN 4096 static RVALUE *himem, *lomem; @@ -275,13 +278,29 @@ add_heap() (RVALUE**)realloc(heaps, heaps_length*sizeof(RVALUE*)): (RVALUE**)malloc(heaps_length*sizeof(RVALUE*))); if (heaps == 0) mem_error("heaps: can't alloc memory"); + RUBY_CRITICAL(heaps_limits = (heaps_used>0)? + (int*)realloc(heaps_limits, heaps_length*sizeof(int)): + (int*)malloc(heaps_length*sizeof(int))); + if (heaps_limits == 0) mem_error("heaps_limits: can't alloc memory"); } - RUBY_CRITICAL(p = heaps[heaps_used++] = (RVALUE*)malloc(sizeof(RVALUE)*HEAP_SLOTS)); - if (p == 0) mem_error("add_heap: can't alloc memory"); - pend = p + HEAP_SLOTS; + for (;;) { + RUBY_CRITICAL(p = heaps[heaps_used] = (RVALUE*)malloc(sizeof(RVALUE)*heap_slots)); + heaps_limits[heaps_used] = heap_slots; + if (p == 0) { + if (heap_slots == HEAP_MIN_SLOTS) { + mem_error("add_heap: can't alloc memory"); + } + heap_slots = HEAP_MIN_SLOTS; + continue; + } + break; + } + pend = p + heap_slots; if (lomem == 0 || lomem > p) lomem = p; if (himem < pend) himem = pend; + heaps_used++; + heap_slots *= 2; while (p < pend) { p->as.free.flags = 0; @@ -337,8 +356,8 @@ is_pointer_to_heap(ptr) /* check if p looks like a pointer */ for (i=0; i < heaps_used; i++) { heap_org = heaps[i]; - if (heap_org <= p && p < heap_org + HEAP_SLOTS - && ((((char*)p)-((char*)heap_org))%sizeof(RVALUE)) == 0) + if (heap_org <= p && p < heap_org + heaps_limits[i] && + ((((char*)p)-((char*)heap_org))%sizeof(RVALUE)) == 0) return Qtrue; } return Qfalse; @@ -512,6 +531,8 @@ rb_gc_mark(ptr) case NODE_DEFINED: case NODE_MATCH: case NODE_RETURN: + case NODE_BREAK: + case NODE_NEXT: case NODE_YIELD: case NODE_COLON2: case NODE_ARGS: @@ -539,8 +560,6 @@ rb_gc_mark(ptr) case NODE_BACK_REF: case NODE_ALIAS: case NODE_VALIAS: - case NODE_BREAK: - case NODE_NEXT: case NODE_REDO: case NODE_RETRY: case NODE_UNDEF: @@ -676,7 +695,7 @@ gc_sweep() if (ruby_in_compile) { /* should not reclaim nodes during compilation */ for (i = 0; i < used; i++) { - p = heaps[i]; pend = p + HEAP_SLOTS; + p = heaps[i]; pend = p + heaps_limits[i]; while (p < pend) { if (!(p->as.basic.flags&FL_MARK) && BUILTIN_TYPE(p) == T_NODE) rb_gc_mark((VALUE)p); @@ -691,7 +710,7 @@ gc_sweep() for (i = 0; i < used; i++) { int n = 0; - p = heaps[i]; pend = p + HEAP_SLOTS; + p = heaps[i]; pend = p + heaps_limits[i]; while (p < pend) { if (!(p->as.basic.flags & FL_MARK)) { if (p->as.basic.flags) { @@ -1045,7 +1064,7 @@ os_live_obj() for (i = 0; i < heaps_used; i++) { RVALUE *p, *pend; - p = heaps[i]; pend = p + HEAP_SLOTS; + p = heaps[i]; pend = p + heaps_limits[i]; for (;p < pend; p++) { if (p->as.basic.flags) { switch (TYPE(p)) { @@ -1078,7 +1097,7 @@ os_obj_of(of) for (i = 0; i < heaps_used; i++) { RVALUE *p, *pend; - p = heaps[i]; pend = p + HEAP_SLOTS; + p = heaps[i]; pend = p + heaps_limits[i]; for (;p < pend; p++) { if (p->as.basic.flags) { switch (TYPE(p)) { @@ -1245,7 +1264,7 @@ rb_gc_call_finalizer_at_exit() } } for (i = 0; i < heaps_used; i++) { - p = heaps[i]; pend = p + HEAP_SLOTS; + p = heaps[i]; pend = p + heaps_limits[i]; while (p < pend) { if (FL_TEST(p, FL_FINALIZE)) { FL_UNSET(p, FL_FINALIZE); @@ -1258,7 +1277,7 @@ rb_gc_call_finalizer_at_exit() } /* run data object's finaliers */ for (i = 0; i < heaps_used; i++) { - p = heaps[i]; pend = p + HEAP_SLOTS; + p = heaps[i]; pend = p + heaps_limits[i]; while (p < pend) { if (BUILTIN_TYPE(p) == T_DATA && DATA_PTR(p) && RANY(p)->as.data.dfree) { -- cgit v1.2.3