Skip to content

Commit

Permalink
* insns.def (opt_*): add IC operands.
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ko1 committed Sep 6, 2009
1 parent cea5aeb commit b82db52
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 22 deletions.
12 changes: 12 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Mon Sep 7 05:38:34 2009 Koichi Sasada <[email protected]>

* 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 <[email protected]>

* Makefile.in, common.mk: move a id.h generation rule.
Expand Down
36 changes: 18 additions & 18 deletions insns.def
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ opt_checkenv
*/
DEFINE_INSN
opt_plus
()
(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
Expand Down Expand Up @@ -1363,7 +1363,7 @@ opt_plus
*/
DEFINE_INSN
opt_minus
()
(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
Expand Down Expand Up @@ -1412,7 +1412,7 @@ opt_minus
*/
DEFINE_INSN
opt_mult
()
(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
Expand Down Expand Up @@ -1465,7 +1465,7 @@ opt_mult
*/
DEFINE_INSN
opt_div
()
(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
Expand Down Expand Up @@ -1529,7 +1529,7 @@ opt_div
*/
DEFINE_INSN
opt_mod
()
(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
Expand Down Expand Up @@ -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;
Expand All @@ -1660,7 +1660,7 @@ opt_neq
*/
DEFINE_INSN
opt_lt
()
(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
Expand Down Expand Up @@ -1710,7 +1710,7 @@ opt_lt
*/
DEFINE_INSN
opt_le
()
(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
Expand Down Expand Up @@ -1740,7 +1740,7 @@ opt_le
*/
DEFINE_INSN
opt_gt
()
(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
Expand Down Expand Up @@ -1790,7 +1790,7 @@ opt_gt
*/
DEFINE_INSN
opt_ge
()
(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
Expand Down Expand Up @@ -1819,7 +1819,7 @@ opt_ge
*/
DEFINE_INSN
opt_ltlt
()
(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
Expand Down Expand Up @@ -1853,7 +1853,7 @@ opt_ltlt
*/
DEFINE_INSN
opt_aref
()
(IC ic)
(VALUE recv, VALUE obj)
(VALUE val)
{
Expand Down Expand Up @@ -1883,7 +1883,7 @@ opt_aref
*/
DEFINE_INSN
opt_aset
()
(IC ic)
(VALUE recv, VALUE obj, VALUE set)
(VALUE val)
{
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand All @@ -1983,7 +1983,7 @@ opt_size
*/
DEFINE_INSN
opt_succ
()
(IC ic)
(VALUE recv)
(VALUE val)
{
Expand Down
2 changes: 1 addition & 1 deletion tool/instruction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ def make_header_operands insn
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
Expand Down
16 changes: 13 additions & 3 deletions vm_insnhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit b82db52

Please sign in to comment.