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

* vm_core.h, vm_insnhelper.h: move decl. of

ruby_vm_global_state_version and related macros
  from vm_core.h to vm_insnhelper.h.
* vm.c (vm_clear_all_cache): added.  This function is called
  when ruby_vm_global_state_version overflows.
  TODO: vm_clear_all_inline_method_cache() is only place holder.
  We need to implement it ASAP.
* vm_method.c (vm_clear_global_method_cache): added.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2011-06-13 11:25:44 +00:00
parent 0f6794cb23
commit 038ef3f05c
5 changed files with 54 additions and 6 deletions

View file

@ -1,3 +1,16 @@
Mon Jun 13 20:18:55 2011 Koichi Sasada <ko1@atdot.net>
* vm_core.h, vm_insnhelper.h: move decl. of
ruby_vm_global_state_version and related macros
from vm_core.h to vm_insnhelper.h.
* vm.c (vm_clear_all_cache): added. This function is called
when ruby_vm_global_state_version overflows.
TODO: vm_clear_all_inline_method_cache() is only place holder.
We need to implement it ASAP.
* vm_method.c (vm_clear_global_method_cache): added.
Mon Jun 13 19:46:21 2011 Keiju Ishitsuka <keiju@ishitsuka.com>
* lib/cmath.rb: add new methd Object#real?. fix #3137

20
vm.c
View file

@ -36,7 +36,6 @@ VALUE rb_cThread;
VALUE rb_cEnv;
VALUE rb_mRubyVMFrozenCore;
VALUE ruby_vm_global_state_version = 1;
VALUE ruby_vm_const_missing_count = 0;
char ruby_vm_redefined_flag[BOP_LAST_];
@ -58,6 +57,25 @@ 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)
{
/* TODO: Clear all inline cache entries in all iseqs.
How to iterate all iseqs in sweep phase?
rb_objspace_each_objects() doesn't work at sweep phase.
*/
}
static void
vm_clear_all_cache()
{
vm_clear_global_method_cache();
vm_clear_all_inline_method_cache();
ruby_vm_global_state_version = 1;
}
void
rb_vm_inc_const_missing_count(void)
{

View file

@ -586,11 +586,6 @@ enum vm_special_object_type {
/* inline cache */
typedef struct iseq_inline_cache_entry *IC;
extern VALUE ruby_vm_global_state_version;
#define GET_VM_STATE_VERSION() (ruby_vm_global_state_version)
#define INC_VM_STATE_VERSION() \
(ruby_vm_global_state_version = (ruby_vm_global_state_version+1) & 0x8fffffff)
void rb_vm_change_state(void);
typedef VALUE CDHASH;

View file

@ -208,4 +208,13 @@ extern VALUE ruby_vm_const_missing_count;
#endif
static VALUE ruby_vm_global_state_version = 1;
#define GET_VM_STATE_VERSION() (ruby_vm_global_state_version)
#define INC_VM_STATE_VERSION() do { \
ruby_vm_global_state_version = (ruby_vm_global_state_version + 1); \
if (ruby_vm_global_state_version == 0) vm_clear_all_cache(); \
} while (0)
static void vm_clear_all_cache(void);
#endif /* RUBY_INSNHELPER_H */

View file

@ -23,6 +23,19 @@ static struct cache_entry cache[CACHE_SIZE];
#define ruby_running (GET_VM()->running)
/* int ruby_running = 0; */
static void
vm_clear_global_method_cache(void)
{
struct cache_entry *ent, *end;
ent = cache;
end = ent + CACHE_SIZE;
while (ent < end) {
ent->filled_version = 0;
ent++;
}
}
void
rb_clear_cache(void)
{