[前][次][番号順一覧][スレッド一覧]

ruby-changes:20009

From: ko1 <ko1@a...>
Date: Mon, 13 Jun 2011 20:25:55 +0900 (JST)
Subject: [ruby-changes:20009] ko1:r32056 (trunk): * vm_core.h, vm_insnhelper.h: move decl. of

ko1	2011-06-13 20:25:44 +0900 (Mon, 13 Jun 2011)

  New Revision: 32056

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32056

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/vm.c
    trunk/vm_core.h
    trunk/vm_insnhelper.h
    trunk/vm_method.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 32055)
+++ ChangeLog	(revision 32056)
@@ -1,3 +1,16 @@
+Mon Jun 13 20:18:55 2011  Koichi Sasada  <ko1@a...>
+
+	* 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@i...>
 
 	* lib/cmath.rb: add new methd Object#real?. fix #3137
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 32055)
+++ vm_core.h	(revision 32056)
@@ -586,11 +586,6 @@
 /* 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;
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 32055)
+++ vm_method.c	(revision 32056)
@@ -23,6 +23,19 @@
 #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)
 {
Index: vm.c
===================================================================
--- vm.c	(revision 32055)
+++ vm.c	(revision 32056)
@@ -36,7 +36,6 @@
 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 @@
     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)
 {
Index: vm_insnhelper.h
===================================================================
--- vm_insnhelper.h	(revision 32055)
+++ vm_insnhelper.h	(revision 32056)
@@ -208,4 +208,13 @@
 
 #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 */

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]