From 2f522b9cc6f3e184404040b12af4486520a73b26 Mon Sep 17 00:00:00 2001 From: charliesome Date: Wed, 4 Sep 2013 05:25:06 +0000 Subject: * class.c, compile.c, eval.c, gc.h, insns.def, internal.h, method.h, variable.c, vm.c, vm_core.c, vm_insnhelper.c, vm_insnhelper.h, vm_method.c: Implement class hierarchy method cache invalidation. [ruby-core:55053] [Feature #8426] [GH-387] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- variable.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'variable.c') diff --git a/variable.c b/variable.c index af1d23a86b..b3d9b3f6e8 100644 --- a/variable.c +++ b/variable.c @@ -1939,7 +1939,7 @@ rb_const_remove(VALUE mod, ID id) rb_class_name(mod), QUOTE_ID(id)); } - rb_vm_change_state(); + rb_clear_cache(); val = ((rb_const_entry_t*)v)->value; if (val == Qundef) { @@ -2149,7 +2149,8 @@ rb_const_set(VALUE klass, ID id, VALUE val) load = autoload_data(klass, id); /* for autoloading thread, keep the defined value to autoloading storage */ if (load && (ele = check_autoload_data(load)) && (ele->thread == rb_thread_current())) { - rb_vm_change_state(); + rb_clear_cache(); + ele->value = val; /* autoload_i is shady */ return; } @@ -2172,7 +2173,8 @@ rb_const_set(VALUE klass, ID id, VALUE val) } } - rb_vm_change_state(); + rb_clear_cache(); + ce = ALLOC(rb_const_entry_t); MEMZERO(ce, rb_const_entry_t, 1); @@ -2217,8 +2219,10 @@ set_const_visibility(VALUE mod, int argc, VALUE *argv, rb_const_flag_t flag) VALUE val = argv[i]; id = rb_check_id(&val); if (!id) { - if (i > 0) - rb_clear_cache_by_class(mod); + if (i > 0) { + rb_clear_cache(); + } + rb_name_error_str(val, "constant %"PRIsVALUE"::%"PRIsVALUE" not defined", rb_class_name(mod), QUOTE(val)); } @@ -2227,13 +2231,14 @@ set_const_visibility(VALUE mod, int argc, VALUE *argv, rb_const_flag_t flag) ((rb_const_entry_t*)v)->flag = flag; } else { - if (i > 0) - rb_clear_cache_by_class(mod); + if (i > 0) { + rb_clear_cache(); + } rb_name_error(id, "constant %"PRIsVALUE"::%"PRIsVALUE" not defined", rb_class_name(mod), QUOTE_ID(id)); } } - rb_clear_cache_by_class(mod); + rb_clear_cache(); } /* -- cgit v1.2.3