summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-12 03:28:49 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-12 03:28:49 +0000
commit7215c9af95eb2375eebef478502a7a824ddd16d5 (patch)
treeb05f36681843290d9165b54ad98af61e36aabd90
parentc809aaa5e1453cf74cf7e22f2468f671c2d687ec (diff)
* vm.c, vm_insnhelper.h (ruby_vm_redefined_flag): apply optimization
patch proposed by Paul Brannan. [ruby-core:19171] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--vm.c6
-rw-r--r--vm_insnhelper.h45
3 files changed, 32 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index 5e538482ea..ff21609e72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Oct 12 12:03:38 2008 Koichi Sasada <ko1@atdot.net>
+
+ * vm.c, vm_insnhelper.h (ruby_vm_redefined_flag): apply optimization
+ patch proposed by Paul Brannan. [ruby-core:19171]
+
Sun Oct 12 09:46:36 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* strftime.c (rb_strftime): suppressed warnings on cygwin.
diff --git a/vm.c b/vm.c
index a805c80526..5bf684237e 100644
--- a/vm.c
+++ b/vm.c
@@ -34,7 +34,7 @@ VALUE rb_cEnv;
VALUE rb_mRubyVMFrozenCore;
VALUE ruby_vm_global_state_version = 1;
-VALUE ruby_vm_redefined_flag = 0;
+char ruby_vm_redefined_flag[BOP_LAST_];
rb_thread_t *ruby_current_thread = 0;
rb_vm_t *ruby_current_vm = 0;
@@ -877,7 +877,7 @@ rb_vm_check_redefinition_opt_method(const NODE *node)
VALUE bop;
if (st_lookup(vm_opt_method_table, (st_data_t)node, &bop)) {
- ruby_vm_redefined_flag |= bop;
+ ruby_vm_redefined_flag[bop] = 1;
}
}
@@ -902,7 +902,7 @@ vm_init_redefined_flag(void)
vm_opt_method_table = st_init_numtable();
-#define OP(mid_, bop_) (mid = id##mid_, bop = BOP_##bop_)
+#define OP(mid_, bop_) (mid = id##mid_, bop = BOP_##bop_, ruby_vm_redefined_flag[bop] = 0)
#define C(k) add_opt_method(rb_c##k, mid, bop)
OP(PLUS, PLUS), (C(Fixnum), C(Float), C(String), C(Array));
OP(MINUS, MINUS), (C(Fixnum));
diff --git a/vm_insnhelper.h b/vm_insnhelper.h
index 1d2bdafdad..83efeda4ba 100644
--- a/vm_insnhelper.h
+++ b/vm_insnhelper.h
@@ -34,32 +34,35 @@
#define VMDEBUG 3
#endif
-/* VM state version */
-
+enum {
+ BOP_PLUS,
+ BOP_MINUS,
+ BOP_MULT,
+ BOP_DIV,
+ BOP_MOD,
+ BOP_EQ,
+ BOP_LT,
+ BOP_LE,
+ BOP_LTLT,
+ BOP_AREF,
+ BOP_ASET,
+ BOP_LENGTH,
+ BOP_SUCC,
+ BOP_GT,
+ BOP_GE,
+ BOP_NOT,
+ BOP_NEQ,
+
+ BOP_LAST_,
+};
+
+extern char ruby_vm_redefined_flag[BOP_LAST_];
extern VALUE ruby_vm_global_state_version;
-extern VALUE ruby_vm_redefined_flag;
#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)
-#define BOP_PLUS 0x01
-#define BOP_MINUS 0x02
-#define BOP_MULT 0x04
-#define BOP_DIV 0x08
-#define BOP_MOD 0x10
-#define BOP_EQ 0x20
-#define BOP_LT 0x40
-#define BOP_LE 0x80
-#define BOP_LTLT 0x100
-#define BOP_AREF 0x200
-#define BOP_ASET 0x400
-#define BOP_LENGTH 0x800
-#define BOP_SUCC 0x1000
-#define BOP_GT 0x2000
-#define BOP_GE 0x4000
-#define BOP_NOT 0x8000
-#define BOP_NEQ 0x10000
/**********************************************************/
/* deal with stack */
@@ -180,7 +183,7 @@ extern VALUE ruby_vm_redefined_flag;
/* optimize insn */
#define FIXNUM_2_P(a, b) ((a) & (b) & 1)
-#define BASIC_OP_UNREDEFINED_P(op) (LIKELY((ruby_vm_redefined_flag & (op)) == 0))
+#define BASIC_OP_UNREDEFINED_P(op) (LIKELY(ruby_vm_redefined_flag[op] == 0))
#define HEAP_CLASS_OF(obj) RBASIC(obj)->klass
#define CALL_SIMPLE_METHOD(num, id, recv) do { \