summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorcharliesome <charliesome@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-04 05:25:06 +0000
committercharliesome <charliesome@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-04 05:25:06 +0000
commit2f522b9cc6f3e184404040b12af4486520a73b26 (patch)
tree7e24db4e9d97f1096442eadb272215340865336f /vm.c
parent4142e8301dd618a775f611bc7bf6c049ce6a4bf9 (diff)
* 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
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/vm.c b/vm.c
index 9b7eaad..41e9542 100644
--- a/vm.c
+++ b/vm.c
@@ -71,6 +71,9 @@ static VALUE
vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self, VALUE defined_class,
int argc, const VALUE *argv, const rb_block_t *blockptr);
+static vm_state_version_t ruby_vm_global_state_version = 1;
+static vm_state_version_t ruby_vm_sequence = 1;
+
#include "vm_insnhelper.h"
#include "vm_insnhelper.c"
#include "vm_exec.h"
@@ -84,6 +87,12 @@ vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self, VALUE defined_class
#define BUFSIZE 0x100
#define PROCDEBUG 0
+vm_state_version_t
+rb_next_class_sequence()
+{
+ return NEXT_CLASS_SEQUENCE();
+}
+
VALUE rb_cRubyVM;
VALUE rb_cThread;
VALUE rb_cEnv;
@@ -97,14 +106,6 @@ rb_event_flag_t ruby_vm_event_flags;
static void thread_free(void *ptr);
-void
-rb_vm_change_state(void)
-{
- INC_VM_STATE_VERSION();
-}
-
-static void vm_clear_global_method_cache(void);
-
static void
vm_clear_all_inline_method_cache(void)
{
@@ -117,7 +118,6 @@ vm_clear_all_inline_method_cache(void)
static void
vm_clear_all_cache()
{
- vm_clear_global_method_cache();
vm_clear_all_inline_method_cache();
ruby_vm_global_state_version = 1;
}
@@ -2069,11 +2069,13 @@ vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval,
OBJ_WRITE(miseq->self, &miseq->klass, klass);
miseq->defined_method_id = id;
rb_add_method(klass, id, VM_METHOD_TYPE_ISEQ, miseq, noex);
+ rb_clear_cache_by_class(klass);
if (!is_singleton && noex == NOEX_MODFUNC) {
- rb_add_method(rb_singleton_class(klass), id, VM_METHOD_TYPE_ISEQ, miseq, NOEX_PUBLIC);
+ klass = rb_singleton_class(klass);
+ rb_add_method(klass, id, VM_METHOD_TYPE_ISEQ, miseq, NOEX_PUBLIC);
+ rb_clear_cache_by_class(klass);
}
- INC_VM_STATE_VERSION();
}
#define REWIND_CFP(expr) do { \
@@ -2122,7 +2124,8 @@ m_core_undef_method(VALUE self, VALUE cbase, VALUE sym)
{
REWIND_CFP({
rb_undef(cbase, SYM2ID(sym));
- INC_VM_STATE_VERSION();
+ rb_clear_cache_by_class(cbase);
+ rb_clear_cache_by_class(self);
});
return Qnil;
}