зеркало из https://github.com/github/ruby.git
* class.c: unify names of vm state version counters to 'serial'.
This includes renaming 'vm_state_version_t' to 'rb_serial_t', 'method_state' to 'method_serial', 'seq' to 'class_serial', 'vmstat' to 'constant_serial', etc. * insns.def: ditto * internal.h: ditto * vm.c: ditto * vm_core.h: ditto * vm_insnhelper.c: ditto * vm_insnhelper.h: ditto * vm_method.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
5d663cc2d3
Коммит
8b0771b014
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
Sat Nov 9 12:31:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
|
||||
|
||||
* class.c: unify names of vm state version counters to 'serial'.
|
||||
This includes renaming 'vm_state_version_t' to 'rb_serial_t',
|
||||
'method_state' to 'method_serial', 'seq' to 'class_serial',
|
||||
'vmstat' to 'constant_serial', etc.
|
||||
|
||||
* insns.def: ditto
|
||||
* internal.h: ditto
|
||||
* vm.c: ditto
|
||||
* vm_core.h: ditto
|
||||
* vm_insnhelper.c: ditto
|
||||
* vm_insnhelper.h: ditto
|
||||
* vm_method.c: ditto
|
||||
|
||||
Sat Nov 9 09:22:29 2013 Masaya Tarui <tarui@ruby-lang.org>
|
||||
|
||||
* gc.c (gc_page_sweep, rgengc_rememberset_mark): Refactoring.
|
||||
|
|
2
class.c
2
class.c
|
@ -166,7 +166,7 @@ class_alloc(VALUE flags, VALUE klass)
|
|||
RCLASS_EXT(obj)->subclasses = NULL;
|
||||
RCLASS_EXT(obj)->parent_subclasses = NULL;
|
||||
RCLASS_EXT(obj)->module_subclasses = NULL;
|
||||
RCLASS_EXT(obj)->seq = rb_next_class_sequence();
|
||||
RCLASS_EXT(obj)->class_serial = rb_next_class_serial();
|
||||
|
||||
RCLASS_REFINED_CLASS(obj) = Qnil;
|
||||
RCLASS_EXT(obj)->allocator = 0;
|
||||
|
|
|
@ -961,8 +961,8 @@ new_callinfo(rb_iseq_t *iseq, ID mid, int argc, VALUE block, unsigned long flag)
|
|||
ci->flag |= VM_CALL_ARGS_SKIP_SETUP;
|
||||
}
|
||||
}
|
||||
ci->method_state = 0;
|
||||
ci->seq = 0;
|
||||
ci->method_serial = 0;
|
||||
ci->class_serial = 0;
|
||||
ci->blockptr = 0;
|
||||
ci->recv = Qundef;
|
||||
ci->call = 0; /* TODO: should set default function? */
|
||||
|
|
|
@ -1183,7 +1183,7 @@ getinlinecache
|
|||
()
|
||||
(VALUE val)
|
||||
{
|
||||
if (ic->ic_vmstat == GET_CONSTANT_STATE_VERSION()) {
|
||||
if (ic->ic_constant_serial == GET_CONSTANT_SERIAL()) {
|
||||
val = ic->ic_value.value;
|
||||
JUMP(dst);
|
||||
}
|
||||
|
@ -1208,7 +1208,7 @@ setinlinecache
|
|||
rb_iseq_add_mark_object(GET_ISEQ(), val);
|
||||
}
|
||||
ic->ic_value.value = val;
|
||||
ic->ic_vmstat = GET_CONSTANT_STATE_VERSION() - ruby_vm_const_missing_count;
|
||||
ic->ic_constant_serial = GET_CONSTANT_SERIAL() - ruby_vm_const_missing_count;
|
||||
ruby_vm_const_missing_count = 0;
|
||||
}
|
||||
|
||||
|
|
10
internal.h
10
internal.h
|
@ -245,11 +245,11 @@ struct rb_subclass_entry {
|
|||
};
|
||||
|
||||
#if defined(HAVE_LONG_LONG)
|
||||
typedef unsigned LONG_LONG vm_state_version_t;
|
||||
typedef unsigned LONG_LONG rb_serial_t;
|
||||
#elif defined(HAVE_UINT64_T)
|
||||
typedef uint64_t vm_state_version_t;
|
||||
typedef uint64_t rb_serial_t;
|
||||
#else
|
||||
typedef unsigned long vm_state_version_t;
|
||||
typedef unsigned long rb_serial_t;
|
||||
#endif
|
||||
|
||||
struct rb_classext_struct {
|
||||
|
@ -264,7 +264,7 @@ struct rb_classext_struct {
|
|||
* included. Hopefully that makes sense.
|
||||
*/
|
||||
rb_subclass_entry_t **module_subclasses;
|
||||
vm_state_version_t seq;
|
||||
rb_serial_t class_serial;
|
||||
VALUE origin;
|
||||
VALUE refined_class;
|
||||
rb_alloc_func_t allocator;
|
||||
|
@ -701,7 +701,7 @@ void ruby_kill(rb_pid_t pid, int sig);
|
|||
void Init_native_thread(void);
|
||||
|
||||
/* vm_insnhelper.h */
|
||||
vm_state_version_t rb_next_class_sequence(void);
|
||||
rb_serial_t rb_next_class_serial(void);
|
||||
|
||||
/* vm.c */
|
||||
VALUE rb_obj_is_thread(VALUE obj);
|
||||
|
|
12
vm.c
12
vm.c
|
@ -71,9 +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_method_state_version = 1;
|
||||
static vm_state_version_t ruby_vm_constant_state_version = 1;
|
||||
static vm_state_version_t ruby_vm_sequence = 1;
|
||||
static rb_serial_t ruby_vm_method_serial = 1;
|
||||
static rb_serial_t ruby_vm_constant_serial = 1;
|
||||
static rb_serial_t ruby_vm_class_serial = 1;
|
||||
|
||||
#include "vm_insnhelper.h"
|
||||
#include "vm_insnhelper.c"
|
||||
|
@ -88,10 +88,10 @@ static vm_state_version_t ruby_vm_sequence = 1;
|
|||
#define BUFSIZE 0x100
|
||||
#define PROCDEBUG 0
|
||||
|
||||
vm_state_version_t
|
||||
rb_next_class_sequence(void)
|
||||
rb_serial_t
|
||||
rb_next_class_serial(void)
|
||||
{
|
||||
return NEXT_CLASS_SEQUENCE();
|
||||
return NEXT_CLASS_SERIAL();
|
||||
}
|
||||
|
||||
VALUE rb_cRubyVM;
|
||||
|
|
|
@ -131,9 +131,8 @@ typedef struct rb_compile_option_struct rb_compile_option_t;
|
|||
|
||||
|
||||
struct iseq_inline_cache_entry {
|
||||
vm_state_version_t ic_vmstat;
|
||||
vm_state_version_t ic_seq;
|
||||
VALUE ic_class;
|
||||
rb_serial_t ic_constant_serial;
|
||||
rb_serial_t ic_class_serial;
|
||||
union {
|
||||
size_t index;
|
||||
VALUE value;
|
||||
|
@ -162,8 +161,8 @@ typedef struct rb_call_info_struct {
|
|||
rb_iseq_t *blockiseq;
|
||||
|
||||
/* inline cache: keys */
|
||||
vm_state_version_t method_state;
|
||||
vm_state_version_t seq;
|
||||
rb_serial_t method_serial;
|
||||
rb_serial_t class_serial;
|
||||
VALUE klass;
|
||||
|
||||
/* inline cache: values */
|
||||
|
|
|
@ -510,7 +510,7 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_call_info_t *ci, int is_attr)
|
|||
VALUE val = Qundef;
|
||||
VALUE klass = RBASIC(obj)->klass;
|
||||
|
||||
if (LIKELY((!is_attr && ic->ic_seq == RCLASS_EXT(klass)->seq) ||
|
||||
if (LIKELY((!is_attr && ic->ic_class_serial == RCLASS_EXT(klass)->class_serial) ||
|
||||
(is_attr && ci->aux.index > 0))) {
|
||||
long index = !is_attr ? (long)ic->ic_value.index : ci->aux.index - 1;
|
||||
long len = ROBJECT_NUMIV(obj);
|
||||
|
@ -533,7 +533,7 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_call_info_t *ci, int is_attr)
|
|||
}
|
||||
if (!is_attr) {
|
||||
ic->ic_value.index = index;
|
||||
ic->ic_seq = RCLASS_EXT(klass)->seq;
|
||||
ic->ic_class_serial = RCLASS_EXT(klass)->class_serial;
|
||||
}
|
||||
else { /* call_info */
|
||||
ci->aux.index = index + 1;
|
||||
|
@ -565,7 +565,7 @@ vm_setivar(VALUE obj, ID id, VALUE val, IC ic, rb_call_info_t *ci, int is_attr)
|
|||
st_data_t index;
|
||||
|
||||
if (LIKELY(
|
||||
(!is_attr && ic->ic_seq == RCLASS_EXT(klass)->seq) ||
|
||||
(!is_attr && ic->ic_class_serial == RCLASS_EXT(klass)->class_serial) ||
|
||||
(is_attr && ci->aux.index > 0))) {
|
||||
long index = !is_attr ? (long)ic->ic_value.index : ci->aux.index-1;
|
||||
long len = ROBJECT_NUMIV(obj);
|
||||
|
@ -582,7 +582,7 @@ vm_setivar(VALUE obj, ID id, VALUE val, IC ic, rb_call_info_t *ci, int is_attr)
|
|||
if (iv_index_tbl && st_lookup(iv_index_tbl, (st_data_t)id, &index)) {
|
||||
if (!is_attr) {
|
||||
ic->ic_value.index = index;
|
||||
ic->ic_seq = RCLASS_EXT(klass)->seq;
|
||||
ic->ic_class_serial = RCLASS_EXT(klass)->class_serial;
|
||||
}
|
||||
else {
|
||||
ci->aux.index = index + 1;
|
||||
|
@ -846,7 +846,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_STATE_VERSION() == ci->method_state && RCLASS_EXT(klass)->seq == ci->seq)) {
|
||||
if (LIKELY(GET_METHOD_SERIAL() == ci->method_serial && RCLASS_EXT(klass)->class_serial == ci->class_serial)) {
|
||||
/* cache hit! */
|
||||
return;
|
||||
}
|
||||
|
@ -856,8 +856,8 @@ 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_state = GET_METHOD_STATE_VERSION();
|
||||
ci->seq = RCLASS_EXT(klass)->seq;
|
||||
ci->method_serial = GET_METHOD_SERIAL();
|
||||
ci->class_serial = RCLASS_EXT(klass)->class_serial;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -924,7 +924,7 @@ rb_equal_opt(VALUE obj1, VALUE obj2)
|
|||
rb_call_info_t ci;
|
||||
ci.mid = idEq;
|
||||
ci.klass = 0;
|
||||
ci.method_state = 0;
|
||||
ci.method_serial = 0;
|
||||
ci.me = NULL;
|
||||
ci.defined_class = 0;
|
||||
return opt_eq_func(obj1, obj2, &ci);
|
||||
|
|
|
@ -259,11 +259,11 @@ enum vm_regan_acttype {
|
|||
CALL_METHOD(ci); \
|
||||
} while (0)
|
||||
|
||||
#define NEXT_CLASS_SEQUENCE() (++ruby_vm_sequence)
|
||||
#define GET_METHOD_STATE_VERSION() (ruby_vm_method_state_version)
|
||||
#define INC_METHOD_STATE_VERSION() (++ruby_vm_method_state_version)
|
||||
#define GET_CONSTANT_STATE_VERSION() (ruby_vm_constant_state_version)
|
||||
#define INC_CONSTANT_STATE_VERSION() (++ruby_vm_constant_state_version)
|
||||
#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)
|
||||
|
||||
static VALUE make_no_method_exception(VALUE exc, const char *format,
|
||||
VALUE obj, int argc, const VALUE *argv);
|
||||
|
|
22
vm_method.c
22
vm_method.c
|
@ -25,8 +25,8 @@ static void rb_vm_check_redefinition_opt_method(const rb_method_entry_t *me, VAL
|
|||
#define attached id__attached__
|
||||
|
||||
struct cache_entry {
|
||||
vm_state_version_t method_state;
|
||||
vm_state_version_t seq;
|
||||
rb_serial_t method_serial;
|
||||
rb_serial_t class_serial;
|
||||
ID mid;
|
||||
rb_method_entry_t* me;
|
||||
VALUE defined_class;
|
||||
|
@ -39,7 +39,7 @@ static struct cache_entry global_method_cache[GLOBAL_METHOD_CACHE_SIZE];
|
|||
static void
|
||||
rb_class_clear_method_cache(VALUE klass)
|
||||
{
|
||||
RCLASS_EXT(klass)->seq = rb_next_class_sequence();
|
||||
RCLASS_EXT(klass)->class_serial = rb_next_class_serial();
|
||||
rb_class_foreach_subclass(klass, rb_class_clear_method_cache);
|
||||
}
|
||||
|
||||
|
@ -47,14 +47,14 @@ void
|
|||
rb_clear_cache(void)
|
||||
{
|
||||
rb_warning("rb_clear_cache() is deprecated.");
|
||||
INC_METHOD_STATE_VERSION();
|
||||
INC_CONSTANT_STATE_VERSION();
|
||||
INC_METHOD_SERIAL();
|
||||
INC_CONSTANT_SERIAL();
|
||||
}
|
||||
|
||||
void
|
||||
rb_clear_constant_cache(void)
|
||||
{
|
||||
INC_CONSTANT_STATE_VERSION();
|
||||
INC_CONSTANT_SERIAL();
|
||||
}
|
||||
|
||||
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_STATE_VERSION();
|
||||
INC_METHOD_SERIAL();
|
||||
}
|
||||
else {
|
||||
rb_class_clear_method_cache(klass);
|
||||
|
@ -549,8 +549,8 @@ rb_method_entry_get_without_cache(VALUE klass, ID id,
|
|||
if (ruby_running) {
|
||||
struct cache_entry *ent;
|
||||
ent = GLOBAL_METHOD_CACHE(klass, id);
|
||||
ent->seq = RCLASS_EXT(klass)->seq;
|
||||
ent->method_state = GET_METHOD_STATE_VERSION();
|
||||
ent->class_serial = RCLASS_EXT(klass)->class_serial;
|
||||
ent->method_serial = GET_METHOD_SERIAL();
|
||||
ent->defined_class = defined_class;
|
||||
ent->mid = id;
|
||||
|
||||
|
@ -588,8 +588,8 @@ 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_state == GET_METHOD_STATE_VERSION() &&
|
||||
ent->seq == RCLASS_EXT(klass)->seq &&
|
||||
if (ent->method_serial == GET_METHOD_SERIAL() &&
|
||||
ent->class_serial == RCLASS_EXT(klass)->class_serial &&
|
||||
ent->mid == id) {
|
||||
if (defined_class_ptr)
|
||||
*defined_class_ptr = ent->defined_class;
|
||||
|
|
Загрузка…
Ссылка в новой задаче