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

* 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
This commit is contained in:
ko1 2009-09-06 20:42:50 +00:00
parent cea5aeb795
commit b82db5251c
4 changed files with 45 additions and 23 deletions

View file

@ -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.

View file

@ -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)
{

View file

@ -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

View file

@ -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, vm_method_search(id, klass, ic), recv); \
} while (0)
#else
#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); \
} while (0)
#define CALL_SIMPLE_METHOD_IC(num, id, recv, ic) do { \
VALUE klass = CLASS_OF(recv); \
CALL_METHOD(num, 0, 0, id, vm_method_search(id, klass, ic), recv); \
} while (0)
#endif
#endif /* RUBY_INSNHELPER_H */