summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-06 20:42:50 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-06 20:42:50 +0000
commitb82db5251c2c39f8a10cd21b595cc1cad8155cdc (patch)
tree9a3e5a4bac2efb8080b4649661b874a007c45cdf
parentcea5aeb795149cead9a9cb151a4754c6ce185d13 (diff)
* insns.def (opt_*): add IC operands.
* vm_insnhelper.h (CALL_SIMPLE_METHOD): add a version which use an inline cache. USE_IC_FOR_SPECIALIZED_METHOD macro switchs the behaviour. This change also removes CALL_SIMPLE_METHOD_IC() macro. * tool/instruction.rb: fix elimination process to ignore variable "ic". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog12
-rw-r--r--insns.def36
-rwxr-xr-xtool/instruction.rb2
-rw-r--r--vm_insnhelper.h16
4 files changed, 44 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 5d54fbe..93255c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Mon Sep 7 05:38:34 2009 Koichi Sasada <ko1@atdot.net>
+
+ * insns.def (opt_*): add IC operands.
+
+ * vm_insnhelper.h (CALL_SIMPLE_METHOD): add a version which
+ use an inline cache. USE_IC_FOR_SPECIALIZED_METHOD macro
+ switchs the behaviour. This change also removes
+ CALL_SIMPLE_METHOD_IC() macro.
+
+ * tool/instruction.rb: fix elimination process to ignore
+ variable "ic".
+
Mon Sep 7 05:21:09 2009 Koichi Sasada <ko1@atdot.net>
* Makefile.in, common.mk: move a id.h generation rule.
diff --git a/insns.def b/insns.def
index 031e0bc..426f101 100644
--- a/insns.def
+++ b/insns.def
@@ -1287,7 +1287,7 @@ opt_checkenv
*/
DEFINE_INSN
opt_plus
-()
+(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
@@ -1363,7 +1363,7 @@ opt_plus
*/
DEFINE_INSN
opt_minus
-()
+(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
@@ -1412,7 +1412,7 @@ opt_minus
*/
DEFINE_INSN
opt_mult
-()
+(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
@@ -1465,7 +1465,7 @@ opt_mult
*/
DEFINE_INSN
opt_div
-()
+(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
@@ -1529,7 +1529,7 @@ opt_div
*/
DEFINE_INSN
opt_mod
-()
+(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
@@ -1629,16 +1629,16 @@ opt_eq
*/
DEFINE_INSN
opt_neq
-(IC ic1, IC ic2)
+(IC ic, IC ic_eq)
(VALUE recv, VALUE obj)
(VALUE val)
{
extern VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2);
- const rb_method_entry_t *me = vm_method_search(idNeq, CLASS_OF(recv), ic1);
+ const rb_method_entry_t *me = vm_method_search(idNeq, CLASS_OF(recv), ic);
val = Qundef;
if (check_cfunc(me, rb_obj_not_equal)) {
- val = opt_eq_func(recv, obj, ic2);
+ val = opt_eq_func(recv, obj, ic_eq);
if (val != Qundef) {
val = RTEST(val) ? Qfalse : Qtrue;
@@ -1660,7 +1660,7 @@ opt_neq
*/
DEFINE_INSN
opt_lt
-()
+(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
@@ -1710,7 +1710,7 @@ opt_lt
*/
DEFINE_INSN
opt_le
-()
+(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
@@ -1740,7 +1740,7 @@ opt_le
*/
DEFINE_INSN
opt_gt
-()
+(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
@@ -1790,7 +1790,7 @@ opt_gt
*/
DEFINE_INSN
opt_ge
-()
+(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
@@ -1819,7 +1819,7 @@ opt_ge
*/
DEFINE_INSN
opt_ltlt
-()
+(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
@@ -1853,7 +1853,7 @@ opt_ltlt
*/
DEFINE_INSN
opt_aref
-()
+(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
@@ -1883,7 +1883,7 @@ opt_aref
*/
DEFINE_INSN
opt_aset
-()
+(IC ic)
(VALUE recv, VALUE obj, VALUE set)
(VALUE val)
{
@@ -1939,7 +1939,7 @@ opt_length
else {
INSN_LABEL(normal_dispatch):
PUSH(recv);
- CALL_SIMPLE_METHOD_IC(0, idLength, recv, ic);
+ CALL_SIMPLE_METHOD(0, idLength, recv);
}
}
@@ -1972,7 +1972,7 @@ opt_size
else {
INSN_LABEL(normal_dispatch):
PUSH(recv);
- CALL_SIMPLE_METHOD_IC(0, idSize, recv, ic);
+ CALL_SIMPLE_METHOD(0, idSize, recv);
}
}
@@ -1983,7 +1983,7 @@ opt_size
*/
DEFINE_INSN
opt_succ
-()
+(IC ic)
(VALUE recv)
(VALUE val)
{
diff --git a/tool/instruction.rb b/tool/instruction.rb
index 1a09ab3..088505d 100755
--- a/tool/instruction.rb
+++ b/tool/instruction.rb
@@ -704,7 +704,7 @@ class RubyVM
end
re = /\b#{var}\b/n
- if re =~ insn.body or re =~ insn.sp_inc or insn.rets.any?{|t, v| re =~ v}
+ if re =~ insn.body or re =~ insn.sp_inc or insn.rets.any?{|t, v| re =~ v} or re =~ 'ic'
ops << " #{type} #{var} = (#{type})GET_OPERAND(#{i+1});"
end
n += 1
diff --git a/vm_insnhelper.h b/vm_insnhelper.h
index d4dd5ae..79eb885 100644
--- a/vm_insnhelper.h
+++ b/vm_insnhelper.h
@@ -184,14 +184,24 @@ extern VALUE ruby_vm_const_missing_count;
#define BASIC_OP_UNREDEFINED_P(op) (LIKELY(ruby_vm_redefined_flag[op] == 0))
#define HEAP_CLASS_OF(obj) RBASIC(obj)->klass
+#ifndef USE_IC_FOR_SPECIALIZED_METHOD
+#define USE_IC_FOR_SPECIALIZED_METHOD 1
+#endif
+
+#if USE_IC_FOR_SPECIALIZED_METHOD
+
#define CALL_SIMPLE_METHOD(num, id, recv) do { \
VALUE klass = CLASS_OF(recv); \
- CALL_METHOD(num, 0, 0, id, rb_method_entry(klass, id), recv); \
+ CALL_METHOD(num, 0, 0, id, vm_method_search(id, klass, ic), recv); \
} while (0)
-#define CALL_SIMPLE_METHOD_IC(num, id, recv, ic) do { \
+#else
+
+#define CALL_SIMPLE_METHOD(num, id, recv) do { \
VALUE klass = CLASS_OF(recv); \
- CALL_METHOD(num, 0, 0, id, vm_method_search(id, klass, ic), recv); \
+ CALL_METHOD(num, 0, 0, id, rb_method_entry(klass, id), recv); \
} while (0)
+#endif
+
#endif /* RUBY_INSNHELPER_H */