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

* compile.c, insns.def, test/ruby/test_rubyvm.rb, vm.c, vm_core.h,

vm_insnhelper.c, vm_insnhelper.h, vm_method.c: Rename method_serial
  to global_method_state and constant_serial to global_constant_state
  after discussion with ko1.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
charliesome 2013-12-09 10:51:02 +00:00
parent a111923062
commit 7df9798126
9 changed files with 37 additions and 30 deletions

View file

@ -1,3 +1,10 @@
Mon Dec 9 19:50:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
* compile.c, insns.def, test/ruby/test_rubyvm.rb, vm.c, vm_core.h,
vm_insnhelper.c, vm_insnhelper.h, vm_method.c: Rename method_serial
to global_method_state and constant_serial to global_constant_state
after discussion with ko1.
Mon Dec 9 18:50:43 2013 Aman Gupta <ruby@tmm1.net>
* hash.c (rb_hash_replace): fix segv on `{}.replace({})` introduced

View file

@ -960,7 +960,7 @@ new_callinfo(rb_iseq_t *iseq, ID mid, int argc, VALUE block, unsigned long flag)
ci->flag |= VM_CALL_ARGS_SKIP_SETUP;
}
}
ci->method_serial = 0;
ci->method_state = 0;
ci->class_serial = 0;
ci->blockptr = 0;
ci->recv = Qundef;

View file

@ -1197,7 +1197,7 @@ getinlinecache
()
(VALUE val)
{
if (ic->ic_serial == GET_CONSTANT_SERIAL()) {
if (ic->ic_serial == GET_GLOBAL_CONSTANT_STATE()) {
val = ic->ic_value.value;
JUMP(dst);
}
@ -1222,7 +1222,7 @@ setinlinecache
rb_iseq_add_mark_object(GET_ISEQ(), val);
}
ic->ic_value.value = val;
ic->ic_serial = GET_CONSTANT_SERIAL() - ruby_vm_const_missing_count;
ic->ic_serial = GET_GLOBAL_CONSTANT_STATE() - ruby_vm_const_missing_count;
ruby_vm_const_missing_count = 0;
}

View file

@ -3,11 +3,11 @@ require 'test/unit'
class TestRubyVM < Test::Unit::TestCase
def test_stat
assert_kind_of Hash, RubyVM.stat
assert_kind_of Fixnum, RubyVM.stat[:method_serial]
assert_kind_of Fixnum, RubyVM.stat[:global_method_state]
RubyVM.stat(stat = {})
assert_not_empty stat
assert_equal stat[:method_serial], RubyVM.stat(:method_serial)
assert_equal stat[:global_method_state], RubyVM.stat(:global_method_state)
end
def test_stat_unknown

20
vm.c
View file

@ -71,8 +71,8 @@ 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 rb_serial_t ruby_vm_method_serial = 1;
static rb_serial_t ruby_vm_constant_serial = 1;
static rb_serial_t ruby_vm_global_method_state = 1;
static rb_serial_t ruby_vm_global_constant_state = 1;
static rb_serial_t ruby_vm_class_serial = 1;
#include "vm_insnhelper.h"
@ -124,8 +124,8 @@ rb_vm_inc_const_missing_count(void)
* This hash includes information about method/constant cache serials:
*
* {
* :method_serial=>251,
* :constant_serial=>481,
* :global_method_state=>251,
* :global_constant_state=>481,
* :class_serial=>9029
* }
*
@ -138,7 +138,7 @@ rb_vm_inc_const_missing_count(void)
static VALUE
vm_stat(int argc, VALUE *argv, VALUE self)
{
static VALUE sym_method_serial, sym_constant_serial, sym_class_serial;
static VALUE sym_global_method_state, sym_global_constant_state, sym_class_serial;
VALUE arg = Qnil;
VALUE hash = Qnil, key = Qnil;
@ -153,10 +153,10 @@ vm_stat(int argc, VALUE *argv, VALUE self)
hash = rb_hash_new();
}
if (sym_method_serial == 0) {
if (sym_global_method_state == 0) {
#define S(s) sym_##s = ID2SYM(rb_intern_const(#s))
S(method_serial);
S(constant_serial);
S(global_method_state);
S(global_constant_state);
S(class_serial);
#undef S
}
@ -167,8 +167,8 @@ vm_stat(int argc, VALUE *argv, VALUE self)
else if (hash != Qnil) \
rb_hash_aset(hash, sym_##name, SERIALT2NUM(attr));
SET(method_serial, ruby_vm_method_serial);
SET(constant_serial, ruby_vm_constant_serial);
SET(global_method_state, ruby_vm_global_method_state);
SET(global_constant_state, ruby_vm_global_constant_state);
SET(class_serial, ruby_vm_class_serial);
#undef SET

View file

@ -160,7 +160,7 @@ typedef struct rb_call_info_struct {
rb_iseq_t *blockiseq;
/* inline cache: keys */
rb_serial_t method_serial;
rb_serial_t method_state;
rb_serial_t class_serial;
VALUE klass;

View file

@ -823,7 +823,7 @@ vm_search_method(rb_call_info_t *ci, VALUE recv)
VALUE klass = CLASS_OF(recv);
#if OPT_INLINE_METHOD_CACHE
if (LIKELY(GET_METHOD_SERIAL() == ci->method_serial && RCLASS_EXT(klass)->class_serial == ci->class_serial)) {
if (LIKELY(GET_GLOBAL_METHOD_STATE() == ci->method_state && RCLASS_EXT(klass)->class_serial == ci->class_serial)) {
/* cache hit! */
return;
}
@ -833,7 +833,7 @@ vm_search_method(rb_call_info_t *ci, VALUE recv)
ci->klass = klass;
ci->call = vm_call_general;
#if OPT_INLINE_METHOD_CACHE
ci->method_serial = GET_METHOD_SERIAL();
ci->method_state = GET_GLOBAL_METHOD_STATE();
ci->class_serial = RCLASS_EXT(klass)->class_serial;
#endif
}
@ -901,7 +901,7 @@ rb_equal_opt(VALUE obj1, VALUE obj2)
rb_call_info_t ci;
ci.mid = idEq;
ci.klass = 0;
ci.method_serial = 0;
ci.method_state = 0;
ci.me = NULL;
ci.defined_class = 0;
return opt_eq_func(obj1, obj2, &ci);

View file

@ -261,10 +261,10 @@ enum vm_regan_acttype {
} while (0)
#define NEXT_CLASS_SERIAL() (++ruby_vm_class_serial)
#define GET_METHOD_SERIAL() (ruby_vm_method_serial)
#define INC_METHOD_SERIAL() (++ruby_vm_method_serial)
#define GET_CONSTANT_SERIAL() (ruby_vm_constant_serial)
#define INC_CONSTANT_SERIAL() (++ruby_vm_constant_serial)
#define GET_GLOBAL_METHOD_STATE() (ruby_vm_global_method_state)
#define INC_GLOBAL_METHOD_STATE() (++ruby_vm_global_method_state)
#define GET_GLOBAL_CONSTANT_STATE() (ruby_vm_global_constant_state)
#define INC_GLOBAL_CONSTANT_STATE() (++ruby_vm_global_constant_state)
static VALUE make_no_method_exception(VALUE exc, const char *format,
VALUE obj, int argc, const VALUE *argv);

View file

@ -25,7 +25,7 @@ static void rb_vm_check_redefinition_opt_method(const rb_method_entry_t *me, VAL
#define attached id__attached__
struct cache_entry {
rb_serial_t method_serial;
rb_serial_t method_state;
rb_serial_t class_serial;
ID mid;
rb_method_entry_t* me;
@ -47,14 +47,14 @@ void
rb_clear_cache(void)
{
rb_warning("rb_clear_cache() is deprecated.");
INC_METHOD_SERIAL();
INC_CONSTANT_SERIAL();
INC_GLOBAL_METHOD_STATE();
INC_GLOBAL_CONSTANT_STATE();
}
void
rb_clear_constant_cache(void)
{
INC_CONSTANT_SERIAL();
INC_GLOBAL_CONSTANT_STATE();
}
void
@ -62,7 +62,7 @@ rb_clear_method_cache_by_class(VALUE klass)
{
if (klass && klass != Qundef) {
if (klass == rb_cBasicObject || klass == rb_cObject || klass == rb_mKernel) {
INC_METHOD_SERIAL();
INC_GLOBAL_METHOD_STATE();
}
else {
rb_class_clear_method_cache(klass);
@ -550,7 +550,7 @@ rb_method_entry_get_without_cache(VALUE klass, ID id,
struct cache_entry *ent;
ent = GLOBAL_METHOD_CACHE(klass, id);
ent->class_serial = RCLASS_EXT(klass)->class_serial;
ent->method_serial = GET_METHOD_SERIAL();
ent->method_state = GET_GLOBAL_METHOD_STATE();
ent->defined_class = defined_class;
ent->mid = id;
@ -588,7 +588,7 @@ rb_method_entry(VALUE klass, ID id, VALUE *defined_class_ptr)
#if OPT_GLOBAL_METHOD_CACHE
struct cache_entry *ent;
ent = GLOBAL_METHOD_CACHE(klass, id);
if (ent->method_serial == GET_METHOD_SERIAL() &&
if (ent->method_state == GET_GLOBAL_METHOD_STATE() &&
ent->class_serial == RCLASS_EXT(klass)->class_serial &&
ent->mid == id) {
if (defined_class_ptr)