From 8519afcb41f13dd03eeaf503493b3ca90bff961b Mon Sep 17 00:00:00 2001 From: suke Date: Wed, 2 Jul 2008 15:18:44 +0000 Subject: [PATCH] * gc.c: add rb_during_gc(). based on a patch from arton at [ruby-dev:35313]. * include/ruby/intern.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ gc.c | 17 +++++++++++++++++ include/ruby/intern.h | 1 + 3 files changed, 25 insertions(+) diff --git a/ChangeLog b/ChangeLog index 65ce1d464e..e4702d3d3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Jul 3 00:09:31 2008 Masaki Suketa + + * gc.c: add rb_during_gc(). based on a patch from arton at [ruby-dev:35313]. + + * include/ruby/intern.h: ditto. + Wed Jul 2 09:49:10 2008 Narihiro Nakamura * gc.c (gc_lazy_sweep) : use lazy sweep algorithm for response performance gain. diff --git a/gc.c b/gc.c index ff20011ff9..a915df8516 100644 --- a/gc.c +++ b/gc.c @@ -723,6 +723,23 @@ rb_fill_value_cache(rb_thread_t *th) } #endif +int +rb_during_gc(void) +{ +#if USE_VALUE_CACHE + rb_thread_t *th = GET_THREAD(); + VALUE v = *th->value_cache_ptr; +#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE + rb_objspace_t *objspace = th->vm->objspace; +#else + rb_objspace_t *objspace = &rb_objspace; +#endif +#else + rb_objspace_t *objspace = &rb_objspace; +#endif + return during_gc; +} + VALUE rb_newobj(void) { diff --git a/include/ruby/intern.h b/include/ruby/intern.h index f9d4469f69..f1d47f654e 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -329,6 +329,7 @@ void ruby_set_stack_size(size_t); NORETURN(void rb_memerror(void)); int ruby_stack_check(void); int ruby_stack_length(VALUE**); +int rb_during_gc(void); void rb_gc_mark_locations(VALUE*, VALUE*); void rb_mark_tbl(struct st_table*); void rb_mark_set(struct st_table*);