2011-09-05 08:02:30 -04:00
|
|
|
|
/** ##skip -*- mode:c; style:ruby; coding: utf-8 -*-
|
2007-01-16 03:52:22 -05:00
|
|
|
|
insns.def - YARV instruction definitions
|
|
|
|
|
|
|
|
|
|
$Author: $
|
|
|
|
|
created at: 04/01/01 01:17:55 JST
|
|
|
|
|
|
* blockinlining.c, compile.c, compile.h, debug.c, debug.h,
id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
copyright year.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-13 17:13:04 -05:00
|
|
|
|
Copyright (C) 2004-2007 Koichi Sasada
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** ##skip
|
|
|
|
|
instruction comment
|
|
|
|
|
@c: category
|
|
|
|
|
@e: english description
|
|
|
|
|
@j: japanese description
|
|
|
|
|
|
|
|
|
|
instruction form:
|
|
|
|
|
DEFINE_INSN
|
2010-08-02 11:53:48 -04:00
|
|
|
|
instruction_name
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(instruction_operands, ..)
|
|
|
|
|
(pop_values, ..)
|
|
|
|
|
(return value)
|
|
|
|
|
{
|
|
|
|
|
.. // insn body
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c nop
|
|
|
|
|
@e nop
|
|
|
|
|
@j nop
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
nop
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
/* none */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with variables */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 07:30:51 -04:00
|
|
|
|
@e Get value of local variable (pointed to by idx).
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j idx で指定されたローカル変数をスタックに置く。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getlocal
|
|
|
|
|
(lindex_t idx)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
val = *(GET_LFP() - idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 07:30:51 -04:00
|
|
|
|
@e Set value of local variable (pointed to by idx) to val.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j idx で指定されたローカル変数を val に設定する。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setlocal
|
|
|
|
|
(lindex_t idx)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
(*(GET_LFP() - idx)) = val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 07:30:51 -04:00
|
|
|
|
@e Get value of special local variable ($~, $_, ..).
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 特殊なローカル変数($~, $_, ...)の値を得る。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getspecial
|
2007-07-10 04:04:52 -04:00
|
|
|
|
(VALUE key, rb_num_t type)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2007-08-06 07:36:30 -04:00
|
|
|
|
val = vm_getspecial(th, GET_LFP(), key, type);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 07:30:51 -04:00
|
|
|
|
@e Set value of special local variable ($~, $_, ...) to obj.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 特別なローカル変数($~, $_, ...)の値を設定する。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setspecial
|
2007-07-10 04:04:52 -04:00
|
|
|
|
(VALUE key)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE obj)
|
|
|
|
|
()
|
|
|
|
|
{
|
2007-07-10 04:04:52 -04:00
|
|
|
|
lfp_svar_set(th, GET_LFP(), key, obj);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 07:30:51 -04:00
|
|
|
|
@e Get value of block local variable (pointed to by idx and level).
|
|
|
|
|
'level' indicates the nesting depth from the current block.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j level, idx で指定されたブロックローカル変数の値をスタックに置く。
|
|
|
|
|
level はブロックのネストレベルで、何段上かを示す。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getdynamic
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(dindex_t idx, rb_num_t level)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2009-06-30 03:46:44 -04:00
|
|
|
|
rb_num_t i;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
VALUE *dfp2 = GET_DFP();
|
|
|
|
|
for (i = 0; i < level; i++) {
|
|
|
|
|
dfp2 = GET_PREV_DFP(dfp2);
|
|
|
|
|
}
|
|
|
|
|
val = *(dfp2 - idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 07:30:51 -04:00
|
|
|
|
@e Set block local variable (pointed to by 'idx') as val.
|
|
|
|
|
'level' indicates the nesting depth from the current block.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j level, idx で指定されたブロックローカル変数の値を val にする。
|
|
|
|
|
level はブロックのネストレベルで、何段上かを示す。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setdynamic
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(dindex_t idx, rb_num_t level)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
2009-06-30 03:46:44 -04:00
|
|
|
|
rb_num_t i;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
VALUE *dfp2 = GET_DFP();
|
|
|
|
|
for (i = 0; i < level; i++) {
|
|
|
|
|
dfp2 = GET_PREV_DFP(dfp2);
|
|
|
|
|
}
|
|
|
|
|
*(dfp2 - idx) = val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 07:30:51 -04:00
|
|
|
|
@e Get value of instance variable id of self.
|
|
|
|
|
If is_local is not 0, get value of class local variable.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j self のインスタンス変数 id の値を得る。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getinstancevariable
|
2009-07-13 00:44:20 -04:00
|
|
|
|
(ID id, IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2009-07-13 00:44:20 -04:00
|
|
|
|
val = vm_getivar(GET_SELF(), id, ic);
|
2007-02-04 14:17:33 -05:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 07:30:51 -04:00
|
|
|
|
@e Set value of instance variable id of self to val.
|
|
|
|
|
If is_local is not 0, set value of class local variable.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j self のインスタンス変数 id を val にする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setinstancevariable
|
2009-09-06 03:40:24 -04:00
|
|
|
|
(ID id, IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
2009-09-06 03:40:24 -04:00
|
|
|
|
vm_setivar(GET_SELF(), id, val, ic);
|
2007-02-04 14:17:33 -05:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 07:30:51 -04:00
|
|
|
|
@e Get value of class variable id of klass as val.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 現在のスコープのクラス変数 id の値を得る。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getclassvariable
|
|
|
|
|
(ID id)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2008-05-21 11:18:15 -04:00
|
|
|
|
NODE * const cref = vm_get_cref(GET_ISEQ(), GET_LFP(), GET_DFP());
|
* vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
VM value stack frame of block contains cref information.
(dfp[-1] points CREF)
* compile.c, eval_intern.h, eval_method.c, load.c, proc.c,
vm_dump.h, vm_core.h: ditto.
* include/ruby/ruby.h, gc.c: remove T_VALUES because of above
changes.
* bootstraptest/test_eval.rb, test_knownbug.rb: move solved test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-18 23:08:50 -04:00
|
|
|
|
val = rb_cvar_get(vm_get_cvar_base(cref), id);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 07:30:51 -04:00
|
|
|
|
@e Set value of class variable id of klass as val.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j klass のクラス変数 id を val にする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setclassvariable
|
2007-02-04 14:15:38 -05:00
|
|
|
|
(ID id)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
2008-05-21 11:18:15 -04:00
|
|
|
|
NODE * const cref = vm_get_cref(GET_ISEQ(), GET_LFP(), GET_DFP());
|
* vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
VM value stack frame of block contains cref information.
(dfp[-1] points CREF)
* compile.c, eval_intern.h, eval_method.c, load.c, proc.c,
vm_dump.h, vm_core.h: ditto.
* include/ruby/ruby.h, gc.c: remove T_VALUES because of above
changes.
* bootstraptest/test_eval.rb, test_knownbug.rb: move solved test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-18 23:08:50 -04:00
|
|
|
|
rb_cvar_set(vm_get_cvar_base(cref), id, val);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
|
|
|
|
@e
|
2011-11-05 07:30:51 -04:00
|
|
|
|
Get constant variable id. If klass is Qnil, constants
|
|
|
|
|
are searched in the current scope. If klass is Qfalse, constants
|
|
|
|
|
are searched as top level constants. Otherwise, get constant under klass
|
2007-01-16 03:52:22 -05:00
|
|
|
|
class or module.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 定数 id の値を得る。
|
|
|
|
|
klass が Qnil なら、そのスコープで得られる定数の値を得る。
|
|
|
|
|
Qfalse なら、トップレベルスコープを得る。
|
|
|
|
|
それ以外なら、klass クラスの下の定数を得る。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getconstant
|
|
|
|
|
(ID id)
|
|
|
|
|
(VALUE klass)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
* vm.c: some refactoring.
* rename th_* to vm_*.
* remove unused variables functions.
* add prototypes.
* blockinlining.c, compile.c, cont.c, eval.c, eval_intern.h,
eval_jump.h, eval_load.c, inits.c, insns.def, iseq.c, parse.y,
proc.c, process.c, signal.c, thread.c, vm.c, vm_dump.c,
vm_evalbody.ci, yarvcore.c, yarvcore.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-24 11:42:41 -04:00
|
|
|
|
val = vm_get_ev_const(th, GET_ISEQ(), klass, id, 0);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
|
|
|
|
@e
|
2011-11-05 07:30:51 -04:00
|
|
|
|
Set constant variable id. If klass is Qfalse, constant
|
2007-01-16 03:52:22 -05:00
|
|
|
|
is able to access in this scope. if klass is Qnil, set
|
|
|
|
|
top level constant. otherwise, set constant under klass
|
|
|
|
|
class or module.
|
|
|
|
|
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 定数 id の値を val にする。
|
|
|
|
|
klass が Qfalse なら、そのスコープで得られる定数 id の値を設定する。
|
|
|
|
|
Qnil なら、トップレベルスコープの値を設定する。
|
|
|
|
|
それ以外なら、klass クラスの下の定数を設定する。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setconstant
|
|
|
|
|
(ID id)
|
2008-05-13 22:31:28 -04:00
|
|
|
|
(VALUE val, VALUE cbase)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
()
|
|
|
|
|
{
|
2008-05-13 22:31:28 -04:00
|
|
|
|
vm_check_if_namespace(cbase);
|
|
|
|
|
rb_const_set(cbase, id, val);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
INC_VM_STATE_VERSION();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
|
|
|
|
@e get global variable id.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j グローバル変数 id の値を得る。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getglobal
|
|
|
|
|
(GENTRY entry)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2010-10-12 10:35:40 -04:00
|
|
|
|
val = GET_GLOBAL((VALUE)entry);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
|
|
|
|
@e set global variable id as val.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j グローバル変数 id の値を設定する。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setglobal
|
|
|
|
|
(GENTRY entry)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
2010-10-12 10:35:40 -04:00
|
|
|
|
SET_GLOBAL((VALUE)entry, val);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with values */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
* blockinlining.c, compile.c, compile.h, debug.c, debug.h,
id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
copyright year.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-13 17:13:04 -05:00
|
|
|
|
@e put nil to stack.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j スタックに nil をプッシュする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
putnil
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
val = Qnil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e put self.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j スタックに self をプッシュする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
putself
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
val = GET_SELF();
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-13 22:31:28 -04:00
|
|
|
|
/**
|
|
|
|
|
@c put
|
2008-06-30 23:05:58 -04:00
|
|
|
|
@e put some object.
|
|
|
|
|
i.e. Fixnum, true, false, nil, and so on.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j オブジェクト val をスタックにプッシュする。
|
2008-06-30 23:05:58 -04:00
|
|
|
|
i.e. Fixnum, true, false, nil, and so on.
|
2008-05-13 22:31:28 -04:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
2008-06-30 23:05:58 -04:00
|
|
|
|
putobject
|
|
|
|
|
(VALUE val)
|
2008-05-13 22:31:28 -04:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2008-06-30 23:05:58 -04:00
|
|
|
|
/* */
|
2008-05-13 22:31:28 -04:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/**
|
|
|
|
|
@c put
|
2008-06-30 23:05:58 -04:00
|
|
|
|
@e put special object. "value_type" is for expansion.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 特別なオブジェクト val をスタックにプッシュする。
|
|
|
|
|
オブジェクトの種類は value_type による.
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
2008-06-30 23:05:58 -04:00
|
|
|
|
putspecialobject
|
|
|
|
|
(rb_num_t value_type)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2010-10-31 09:11:02 -04:00
|
|
|
|
enum vm_special_object_type type = (enum vm_special_object_type)value_type;
|
2010-10-30 21:42:54 -04:00
|
|
|
|
|
|
|
|
|
switch (type) {
|
2008-06-30 23:05:58 -04:00
|
|
|
|
case VM_SPECIAL_OBJECT_VMCORE:
|
|
|
|
|
val = rb_mRubyVMFrozenCore;
|
|
|
|
|
break;
|
|
|
|
|
case VM_SPECIAL_OBJECT_CBASE:
|
|
|
|
|
val = vm_get_cbase(GET_ISEQ(), GET_LFP(), GET_DFP());
|
|
|
|
|
break;
|
2009-12-03 13:25:57 -05:00
|
|
|
|
case VM_SPECIAL_OBJECT_CONST_BASE:
|
|
|
|
|
val = vm_get_const_base(GET_ISEQ(), GET_LFP(), GET_DFP());
|
|
|
|
|
break;
|
2008-06-30 23:05:58 -04:00
|
|
|
|
default:
|
|
|
|
|
rb_bug("putspecialobject insn: unknown value_type");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e put iseq value.
|
|
|
|
|
@j put iseq value.
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
putiseq
|
|
|
|
|
(ISEQ iseq)
|
|
|
|
|
()
|
|
|
|
|
(VALUE ret)
|
|
|
|
|
{
|
|
|
|
|
ret = iseq->self;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e put string val. string will be copied.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 文字列をコピーしてスタックにプッシュする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
putstring
|
2007-07-02 08:49:35 -04:00
|
|
|
|
(VALUE str)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2009-02-18 00:33:36 -05:00
|
|
|
|
val = rb_str_resurrect(str);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e put concatenate strings
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j スタックトップの文字列を n 個連結し,結果をスタックにプッシュする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
concatstrings
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(rb_num_t num)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += 1 - num;
|
|
|
|
|
{
|
2011-07-31 23:10:02 -04:00
|
|
|
|
rb_num_t i = num - 1;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
|
2011-07-31 23:10:02 -04:00
|
|
|
|
val = rb_str_resurrect(TOPN(i));
|
2009-06-30 03:46:44 -04:00
|
|
|
|
while (i-- > 0) {
|
2008-05-21 11:18:15 -04:00
|
|
|
|
const VALUE v = TOPN(i);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
rb_str_append(val, v);
|
|
|
|
|
}
|
|
|
|
|
POPN(num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e to_str
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j to_str の結果をスタックにプッシュする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
tostring
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
val = rb_obj_as_string(val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e to Regexp
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 文字列 str を正規表現にコンパイルしてスタックにプッシュする。
|
|
|
|
|
コンパイル時,opt を正規表現のオプションとする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
toregexp
|
2008-01-29 03:03:51 -05:00
|
|
|
|
(rb_num_t opt, rb_num_t cnt)
|
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += 1 - cnt;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
{
|
2008-01-29 03:03:51 -05:00
|
|
|
|
VALUE rb_reg_new_ary(VALUE ary, int options);
|
2009-06-30 03:46:44 -04:00
|
|
|
|
rb_num_t i;
|
2009-02-11 00:46:17 -05:00
|
|
|
|
const VALUE ary = rb_ary_tmp_new(cnt);
|
2008-01-29 03:03:51 -05:00
|
|
|
|
for (i = 0; i < cnt; i++) {
|
|
|
|
|
rb_ary_store(ary, cnt-i-1, TOPN(i));
|
|
|
|
|
}
|
|
|
|
|
POPN(cnt);
|
2009-06-30 03:46:44 -04:00
|
|
|
|
val = rb_reg_new_ary(ary, (int)opt);
|
2009-02-11 00:46:17 -05:00
|
|
|
|
rb_ary_clear(ary);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e put new array.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 新しい配列をスタック上の num 個の値で初期化して生成しプッシュする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
newarray
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(rb_num_t num)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += 1 - num;
|
|
|
|
|
{
|
|
|
|
|
val = rb_ary_new4((long)num, STACK_ADDR_FROM_TOP(num));
|
|
|
|
|
POPN(num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e dup array
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 配列 ary を dup してスタックにプッシュする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
duparray
|
|
|
|
|
(VALUE ary)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2009-02-18 00:33:36 -05:00
|
|
|
|
val = rb_ary_resurrect(ary);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e expand array to num objects.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j スタックトップのオブジェクトが配列であれば、それを展開する。
|
|
|
|
|
配列オブジェクトの要素数が num以下ならば、代わりに nil を積む。num以上なら、
|
|
|
|
|
num以上の要素は切り捨てる。
|
|
|
|
|
配列オブジェクトでなければ、num - 1 個の nil を積む。
|
|
|
|
|
もし flag が真なら、残り要素の配列を積む
|
|
|
|
|
flag: 0x01 - 最後を配列に
|
|
|
|
|
flag: 0x02 - postarg 用
|
2007-08-23 03:10:56 -04:00
|
|
|
|
flag: 0x04 - reverse?
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
expandarray
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(rb_num_t num, rb_num_t flag)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(..., VALUE ary)
|
2008-01-23 12:17:23 -05:00
|
|
|
|
(...) // inc += num - 1 + (flag & 1 ? 1 : 0);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
{
|
2009-06-30 03:46:44 -04:00
|
|
|
|
vm_expandarray(GET_CFP(), ary, num, (int)flag);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e concat two arrays
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 二つの配列 ary1, ary2 を連結しスタックへプッシュする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
concatarray
|
|
|
|
|
()
|
|
|
|
|
(VALUE ary1, VALUE ary2st)
|
|
|
|
|
(VALUE ary)
|
|
|
|
|
{
|
2008-05-21 11:18:15 -04:00
|
|
|
|
const VALUE ary2 = ary2st;
|
2007-12-01 00:20:06 -05:00
|
|
|
|
VALUE tmp1 = rb_check_convert_type(ary1, T_ARRAY, "Array", "to_a");
|
|
|
|
|
VALUE tmp2 = rb_check_convert_type(ary2, T_ARRAY, "Array", "to_a");
|
2007-01-16 03:52:22 -05:00
|
|
|
|
|
2007-07-05 13:11:45 -04:00
|
|
|
|
if (NIL_P(tmp1)) {
|
|
|
|
|
tmp1 = rb_ary_new3(1, ary1);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
2007-07-05 13:11:45 -04:00
|
|
|
|
if (NIL_P(tmp2)) {
|
|
|
|
|
tmp2 = rb_ary_new3(1, ary2);
|
|
|
|
|
}
|
2007-01-16 03:52:22 -05:00
|
|
|
|
|
2007-07-05 13:11:45 -04:00
|
|
|
|
if (tmp1 == ary1) {
|
|
|
|
|
tmp1 = rb_ary_dup(ary1);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
2007-07-05 13:11:45 -04:00
|
|
|
|
ary = rb_ary_concat(tmp1, tmp2);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e splat array
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 配列 ary に対して to_a を呼び出す。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
splatarray
|
|
|
|
|
(VALUE flag)
|
|
|
|
|
(VALUE ary)
|
|
|
|
|
(VALUE obj)
|
|
|
|
|
{
|
2007-12-01 00:20:06 -05:00
|
|
|
|
VALUE tmp = rb_check_convert_type(ary, T_ARRAY, "Array", "to_a");
|
2007-01-16 03:52:22 -05:00
|
|
|
|
if (NIL_P(tmp)) {
|
|
|
|
|
tmp = rb_ary_new3(1, ary);
|
|
|
|
|
}
|
|
|
|
|
obj = tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e check value is included in ary
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 配列 ary に要素 obj が入っているかどうかチェック。case/when で利用する。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
checkincludearray
|
|
|
|
|
(VALUE flag)
|
|
|
|
|
(VALUE obj, VALUE ary)
|
|
|
|
|
(VALUE obj, VALUE result)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
result = Qfalse;
|
|
|
|
|
|
|
|
|
|
if (TYPE(ary) != T_ARRAY) {
|
|
|
|
|
ary = rb_Array(ary);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flag == Qtrue) {
|
|
|
|
|
/* NODE_CASE */
|
|
|
|
|
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 11:26:04 -05:00
|
|
|
|
/* TODO: fix me (use another method dispatch) */
|
2007-01-16 03:52:22 -05:00
|
|
|
|
if (RTEST(rb_funcall2(RARRAY_PTR(ary)[i], idEqq, 1, &obj))) {
|
|
|
|
|
result = Qtrue;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
obj = Qfalse;
|
|
|
|
|
/* NODE_WHEN */
|
|
|
|
|
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
|
|
|
|
if (RTEST(RARRAY_PTR(ary)[i])) {
|
|
|
|
|
obj = result = Qtrue;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e put new Hash.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 新しいハッシュをスタックトップの n 個を初期値として生成する。
|
|
|
|
|
n はキーと値のペアなので 2 の倍数でなければならない。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
newhash
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(rb_num_t num)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += 1 - num;
|
|
|
|
|
{
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-21 16:58:26 -04:00
|
|
|
|
rb_num_t i;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
val = rb_hash_new();
|
|
|
|
|
|
|
|
|
|
for (i = num; i > 0; i -= 2) {
|
2008-05-21 11:18:15 -04:00
|
|
|
|
const VALUE v = TOPN(i - 2);
|
2008-05-21 23:52:22 -04:00
|
|
|
|
const VALUE k = TOPN(i - 1);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
rb_hash_aset(val, k, v);
|
|
|
|
|
}
|
|
|
|
|
POPN(num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e put new Range object.(Range.new(low, high, flag))
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j Range.new(low, high, flag) のようなオブジェクトを生成しスタックにプッシュする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
newrange
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(rb_num_t flag)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE low, VALUE high)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2009-06-30 03:46:44 -04:00
|
|
|
|
val = rb_range_new(low, high, (int)flag);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with stack operation */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
|
|
|
|
@e pop from stack.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j スタックから一つポップする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
pop
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
2011-11-27 03:24:19 -05:00
|
|
|
|
(void)val;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/* none */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
|
|
|
|
@e duplicate stack top.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j スタックトップをコピーしてスタックにプッシュする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
dup
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
(VALUE val1, VALUE val2)
|
|
|
|
|
{
|
|
|
|
|
val1 = val2 = val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
|
|
|
|
@e duplicate stack top n elements
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j スタックトップの n 個をコピーしてスタックにプッシュする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
dupn
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(rb_num_t n)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(...)
|
|
|
|
|
(...) // inc += n;
|
|
|
|
|
{
|
2009-06-30 03:46:44 -04:00
|
|
|
|
rb_num_t i;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
VALUE *sp = STACK_ADDR_FROM_TOP(n);
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
|
GET_SP()[i] = sp[i];
|
|
|
|
|
}
|
|
|
|
|
INC_SP(n);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
|
|
|
|
@e swap top 2 vals
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j スタックトップの 2 つの値を交換する。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
swap
|
|
|
|
|
()
|
|
|
|
|
(VALUE val, VALUE obj)
|
|
|
|
|
(VALUE obj, VALUE val)
|
|
|
|
|
{
|
|
|
|
|
/* none */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
* blockinlining.c, compile.c, compile.h, debug.c, debug.h,
id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
copyright year.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-13 17:13:04 -05:00
|
|
|
|
@e for stack caching.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j スタックキャッシングの状態を調整するために必要な命令。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
reput
|
|
|
|
|
()
|
|
|
|
|
(..., VALUE val)
|
|
|
|
|
(VALUE val) // inc += 0;
|
|
|
|
|
{
|
|
|
|
|
/* none */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
|
|
|
|
@e get nth stack value from stack top
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j スタックトップから n 個目をスタックにプッシュする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
topn
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(rb_num_t n)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += 1;
|
|
|
|
|
{
|
|
|
|
|
val = TOPN(n);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
|
|
|
|
@e set Nth stack entry to stack top
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j スタックトップの値を n 個目のスタックにコピー
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setn
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(rb_num_t n)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(..., VALUE val)
|
|
|
|
|
(VALUE val) // inc += 0
|
|
|
|
|
{
|
2007-06-01 00:05:46 -04:00
|
|
|
|
TOPN(n-1) = val;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
|
|
|
|
@e empt current stack
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j current stack を空にする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
2008-01-25 13:02:01 -05:00
|
|
|
|
adjuststack
|
|
|
|
|
(rb_num_t n)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(...)
|
2008-01-25 13:02:01 -05:00
|
|
|
|
(...) // inc -= n
|
2007-01-16 03:52:22 -05:00
|
|
|
|
{
|
2008-02-05 10:54:33 -05:00
|
|
|
|
DEC_SP(n);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with setting */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c setting
|
|
|
|
|
@e defined?
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j defined? を行う。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
defined
|
2010-10-30 21:42:54 -04:00
|
|
|
|
(rb_num_t op_type, VALUE obj, VALUE needstr)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE v)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
VALUE klass;
|
2008-05-31 05:28:20 -04:00
|
|
|
|
const char *expr_type = 0;
|
2010-10-31 09:11:02 -04:00
|
|
|
|
enum defined_type type = (enum defined_type)op_type;
|
2010-10-30 21:42:54 -04:00
|
|
|
|
|
2007-01-16 03:52:22 -05:00
|
|
|
|
val = Qnil;
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
case DEFINED_IVAR:
|
|
|
|
|
if (rb_ivar_defined(GET_SELF(), SYM2ID(obj))) {
|
|
|
|
|
expr_type = "instance-variable";
|
2007-02-04 14:17:33 -05:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DEFINED_IVAR2:
|
* vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
VM value stack frame of block contains cref information.
(dfp[-1] points CREF)
* compile.c, eval_intern.h, eval_method.c, load.c, proc.c,
vm_dump.h, vm_core.h: ditto.
* include/ruby/ruby.h, gc.c: remove T_VALUES because of above
changes.
* bootstraptest/test_eval.rb, test_knownbug.rb: move solved test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-18 23:08:50 -04:00
|
|
|
|
klass = vm_get_cbase(GET_ISEQ(), GET_LFP(), GET_DFP());
|
2007-01-16 03:52:22 -05:00
|
|
|
|
break;
|
|
|
|
|
case DEFINED_GVAR:
|
2010-03-09 14:21:37 -05:00
|
|
|
|
if (rb_gvar_defined(rb_global_entry(SYM2ID(obj)))) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
expr_type = "global-variable";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DEFINED_CVAR:
|
2011-08-23 20:52:04 -04:00
|
|
|
|
{
|
|
|
|
|
NODE *cref = vm_get_cref(GET_ISEQ(), GET_LFP(), GET_DFP());
|
|
|
|
|
klass = vm_get_cvar_base(cref);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
if (rb_cvar_defined(klass, SYM2ID(obj))) {
|
|
|
|
|
expr_type = "class variable";
|
|
|
|
|
}
|
|
|
|
|
break;
|
2011-08-23 20:52:04 -04:00
|
|
|
|
}
|
2007-01-16 03:52:22 -05:00
|
|
|
|
case DEFINED_CONST:
|
|
|
|
|
klass = v;
|
* vm.c: some refactoring.
* rename th_* to vm_*.
* remove unused variables functions.
* add prototypes.
* blockinlining.c, compile.c, cont.c, eval.c, eval_intern.h,
eval_jump.h, eval_load.c, inits.c, insns.def, iseq.c, parse.y,
proc.c, process.c, signal.c, thread.c, vm.c, vm_dump.c,
vm_evalbody.ci, yarvcore.c, yarvcore.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-24 11:42:41 -04:00
|
|
|
|
if (vm_get_ev_const(th, GET_ISEQ(), klass, SYM2ID(obj), 1)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
expr_type = "constant";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DEFINED_FUNC:
|
|
|
|
|
klass = CLASS_OF(v);
|
|
|
|
|
if (rb_method_boundp(klass, SYM2ID(obj), 0)) {
|
|
|
|
|
expr_type = "method";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DEFINED_METHOD:{
|
2009-12-04 03:34:16 -05:00
|
|
|
|
VALUE klass = CLASS_OF(v);
|
|
|
|
|
const rb_method_entry_t *me = rb_method_entry(klass, SYM2ID(obj));
|
|
|
|
|
|
|
|
|
|
if (me) {
|
|
|
|
|
if (!(me->flag & NOEX_PRIVATE)) {
|
|
|
|
|
if (!((me->flag & NOEX_PROTECTED) &&
|
|
|
|
|
!rb_obj_is_kind_of(GET_SELF(),
|
|
|
|
|
rb_class_real(klass)))) {
|
|
|
|
|
expr_type = "method";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-30 13:20:15 -04:00
|
|
|
|
{
|
|
|
|
|
VALUE args[2];
|
|
|
|
|
VALUE r;
|
|
|
|
|
|
|
|
|
|
args[0] = obj; args[1] = Qfalse;
|
|
|
|
|
r = rb_check_funcall(v, rb_intern("respond_to_missing?"), 2, args);
|
|
|
|
|
if (r != Qundef && RTEST(r))
|
|
|
|
|
expr_type = "method";
|
|
|
|
|
}
|
2009-12-04 03:34:16 -05:00
|
|
|
|
break;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
case DEFINED_YIELD:
|
|
|
|
|
if (GET_BLOCK_PTR()) {
|
|
|
|
|
expr_type = "yield";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DEFINED_ZSUPER:{
|
2010-10-14 09:19:30 -04:00
|
|
|
|
rb_iseq_t *iseq = GET_ISEQ();
|
|
|
|
|
while (iseq) {
|
|
|
|
|
if (iseq->defined_method_id) {
|
2009-12-04 03:34:16 -05:00
|
|
|
|
break;
|
|
|
|
|
}
|
2010-10-14 09:19:30 -04:00
|
|
|
|
iseq = iseq->parent_iseq;
|
2009-12-04 03:34:16 -05:00
|
|
|
|
}
|
2010-10-14 09:19:30 -04:00
|
|
|
|
if (iseq) {
|
|
|
|
|
VALUE klass = vm_search_normal_superclass(iseq->klass, GET_SELF());
|
|
|
|
|
if (rb_method_boundp(klass, iseq->defined_method_id, 0)) {
|
2009-12-04 03:34:16 -05:00
|
|
|
|
expr_type = "super";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
case DEFINED_REF:{
|
2009-12-04 03:34:16 -05:00
|
|
|
|
val = vm_getspecial(th, GET_LFP(), Qfalse, FIX2INT(obj));
|
|
|
|
|
if (val != Qnil) {
|
|
|
|
|
expr_type = "global-variable";
|
|
|
|
|
}
|
|
|
|
|
break;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
rb_bug("unimplemented defined? type (VM)");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (expr_type != 0) {
|
|
|
|
|
if (needstr != Qfalse) {
|
|
|
|
|
val = rb_str_new2(expr_type);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
val = Qtrue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c setting
|
|
|
|
|
@e trace
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j trace 用の命令。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
trace
|
2008-07-01 14:13:22 -04:00
|
|
|
|
(rb_num_t nf)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
{
|
2009-06-30 03:46:44 -04:00
|
|
|
|
rb_event_flag_t flag = (rb_event_flag_t)nf;
|
2008-07-01 14:13:22 -04:00
|
|
|
|
|
2008-07-03 08:55:12 -04:00
|
|
|
|
EXEC_EVENT_HOOK(th, flag, GET_SELF(), 0, 0 /* TODO: id, klass */);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with control flow 1: class/module */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c class/module
|
|
|
|
|
@e
|
|
|
|
|
enter class definition scope. if super is Qfalse, and clsas
|
|
|
|
|
"klass" is defined, it's redefine. otherwise, define "klass" class.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j クラス定義スコープへ移行する。
|
|
|
|
|
もし super が Qfalse で klassクラスが定義されていれば再定義である。
|
|
|
|
|
そうでなければ、klass クラスを定義する。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
defineclass
|
2007-11-21 20:17:52 -05:00
|
|
|
|
(ID id, ISEQ class_iseq, rb_num_t define_type)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE cbase, VALUE super)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
VALUE klass;
|
|
|
|
|
|
2007-07-01 22:59:37 -04:00
|
|
|
|
switch ((int)define_type) {
|
2011-01-28 12:57:34 -05:00
|
|
|
|
case 0: /* scoped: class Foo::Bar */
|
|
|
|
|
case 3: /* no scope: class Bar */
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/* val is dummy. classdef returns class scope value */
|
|
|
|
|
|
|
|
|
|
if (super == Qnil) {
|
|
|
|
|
super = rb_cObject;
|
|
|
|
|
}
|
2007-02-25 11:29:26 -05:00
|
|
|
|
|
2008-04-03 06:59:44 -04:00
|
|
|
|
vm_check_if_namespace(cbase);
|
|
|
|
|
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/* find klass */
|
2009-02-12 10:48:44 -05:00
|
|
|
|
rb_autoload_load(cbase, id);
|
2011-09-02 01:36:49 -04:00
|
|
|
|
if ((klass = vm_search_const_defined_class(cbase, id)) != 0) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/* already exist */
|
2011-09-02 01:36:49 -04:00
|
|
|
|
klass = define_type == 0 ? rb_public_const_get_at(klass, id) : rb_const_get_at(klass, id);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
if (TYPE(klass) != T_CLASS) {
|
|
|
|
|
rb_raise(rb_eTypeError, "%s is not a class", rb_id2name(id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (super != rb_cObject) {
|
|
|
|
|
VALUE tmp;
|
2007-09-28 02:21:46 -04:00
|
|
|
|
tmp = rb_class_real(RCLASS_SUPER(klass));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
|
|
|
|
|
if (tmp != super) {
|
|
|
|
|
rb_raise(rb_eTypeError, "superclass mismatch for class %s",
|
|
|
|
|
rb_id2name(id));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* new class declaration */
|
|
|
|
|
klass = rb_define_class_id(id, super);
|
2009-07-30 03:45:42 -04:00
|
|
|
|
rb_set_class_path_string(klass, cbase, rb_id2str(id));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
rb_const_set(cbase, id, klass);
|
|
|
|
|
rb_class_inherited(super, klass);
|
|
|
|
|
}
|
2007-07-01 22:59:37 -04:00
|
|
|
|
break;
|
|
|
|
|
case 1:
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/* val is dummy. classdef returns class scope value */
|
|
|
|
|
/* super is dummy */
|
|
|
|
|
klass = rb_singleton_class(cbase);
|
2007-07-01 22:59:37 -04:00
|
|
|
|
break;
|
2011-01-28 12:57:34 -05:00
|
|
|
|
case 2: /* scoped: module Foo::Bar or module ::Bar */
|
|
|
|
|
case 5: /* no scope: module Bar */
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/* val is dummy. classdef returns class scope value */
|
|
|
|
|
/* super is dummy */
|
|
|
|
|
|
2008-04-03 06:59:44 -04:00
|
|
|
|
vm_check_if_namespace(cbase);
|
|
|
|
|
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/* find klass */
|
2011-09-02 01:36:49 -04:00
|
|
|
|
if ((klass = vm_search_const_defined_class(cbase, id)) != 0) {
|
|
|
|
|
klass = define_type == 2 ? rb_public_const_get_at(klass, id) : rb_const_get_at(klass, id);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/* already exist */
|
|
|
|
|
if (TYPE(klass) != T_MODULE) {
|
|
|
|
|
rb_raise(rb_eTypeError, "%s is not a module", rb_id2name(id));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* new module declaration */
|
|
|
|
|
klass = rb_define_module_id(id);
|
2009-07-30 03:45:42 -04:00
|
|
|
|
rb_set_class_path_string(klass, cbase, rb_id2str(id));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
rb_const_set(cbase, id, klass);
|
|
|
|
|
}
|
2007-07-01 22:59:37 -04:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
rb_bug("unknown defineclass type: %d", (int)define_type);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
2007-08-12 15:09:15 -04:00
|
|
|
|
|
2009-12-03 13:25:57 -05:00
|
|
|
|
COPY_CREF(class_iseq->cref_stack, vm_cref_push(th, klass, NOEX_PUBLIC, NULL));
|
2007-08-12 15:09:15 -04:00
|
|
|
|
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/* enter scope */
|
2007-11-21 20:17:52 -05:00
|
|
|
|
vm_push_frame(th, class_iseq,
|
2010-05-09 14:21:39 -04:00
|
|
|
|
VM_FRAME_MAGIC_CLASS, klass, (VALUE) GET_BLOCK_PTR(),
|
2007-11-21 20:17:52 -05:00
|
|
|
|
class_iseq->iseq_encoded, GET_SP(), 0,
|
|
|
|
|
class_iseq->local_size);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
RESTORE_REGS();
|
|
|
|
|
|
|
|
|
|
INC_VM_STATE_VERSION();
|
|
|
|
|
NEXT_INSN();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with control flow 2: method/iterator */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c method/iterator
|
|
|
|
|
@e obj.send(id, args..) # args.size => num
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j メソッド呼び出しを行う。
|
* blockinlining.c, compile.c, compile.h, debug.c, debug.h,
id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
copyright year.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-13 17:13:04 -05:00
|
|
|
|
obj.send(id, args..) # args.size => num
|
|
|
|
|
flag & VM_CALL_ARGS_SPLAT_BIT != 0 -> splat last arg
|
|
|
|
|
flag & VM_CALL_ARGS_BLOCKARG_BIT != 0 -> Proc as Block
|
|
|
|
|
flag & VM_CALL_FCALL_BIT != 0 -> FCALL ( func() )
|
|
|
|
|
flag & VM_CALL_VCALL_BIT != 0 -> VCALL ( func )
|
|
|
|
|
...
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
send
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(ID op_id, rb_num_t op_argc, ISEQ blockiseq, rb_num_t op_flag, IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(...)
|
2009-03-10 01:43:14 -04:00
|
|
|
|
(VALUE val) // inc += - (int)(op_argc + ((op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? 1 : 0));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
{
|
2009-07-15 10:59:41 -04:00
|
|
|
|
const rb_method_entry_t *me;
|
* vm.c: some refactoring.
* rename th_* to vm_*.
* remove unused variables functions.
* add prototypes.
* blockinlining.c, compile.c, cont.c, eval.c, eval_intern.h,
eval_jump.h, eval_load.c, inits.c, insns.def, iseq.c, parse.y,
proc.c, process.c, signal.c, thread.c, vm.c, vm_dump.c,
vm_evalbody.ci, yarvcore.c, yarvcore.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-24 11:42:41 -04:00
|
|
|
|
VALUE recv, klass;
|
2007-06-24 09:05:51 -04:00
|
|
|
|
rb_block_t *blockptr = 0;
|
2010-10-30 21:42:54 -04:00
|
|
|
|
VALUE flag = op_flag;
|
|
|
|
|
int num = caller_setup_args(th, GET_CFP(), flag, (int)op_argc,
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-21 16:58:26 -04:00
|
|
|
|
(rb_iseq_t *)blockiseq, &blockptr);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
ID id = op_id;
|
|
|
|
|
|
|
|
|
|
/* get receiver */
|
2007-08-06 07:36:30 -04:00
|
|
|
|
recv = (flag & VM_CALL_FCALL_BIT) ? GET_SELF() : TOPN(num);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
klass = CLASS_OF(recv);
|
2009-07-15 10:59:41 -04:00
|
|
|
|
me = vm_method_search(id, klass, ic);
|
|
|
|
|
CALL_METHOD(num, blockptr, flag, id, me, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c method/iterator
|
|
|
|
|
@e super(args) # args.size => num
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j super を実行する。
|
* blockinlining.c, compile.c, compile.h, debug.c, debug.h,
id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
copyright year.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-13 17:13:04 -05:00
|
|
|
|
super(args) # args.size => num
|
2011-09-04 08:22:46 -04:00
|
|
|
|
flag 等オペランドの意味は send と同じ。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
invokesuper
|
2007-06-24 09:05:51 -04:00
|
|
|
|
(rb_num_t op_argc, ISEQ blockiseq, rb_num_t op_flag)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(...)
|
2009-03-10 01:43:14 -04:00
|
|
|
|
(VALUE val) // inc += - (int)(op_argc + ((op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? 1 : 0));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
{
|
2007-08-06 07:36:30 -04:00
|
|
|
|
rb_block_t *blockptr = !(op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? GET_BLOCK_PTR() : 0;
|
2010-10-30 21:42:54 -04:00
|
|
|
|
VALUE flag = op_flag;
|
|
|
|
|
int num = caller_setup_args(th, GET_CFP(), flag,
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-21 16:58:26 -04:00
|
|
|
|
(int)op_argc, blockiseq, &blockptr);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
VALUE recv, klass;
|
2007-08-06 07:36:30 -04:00
|
|
|
|
ID id;
|
2009-07-15 10:59:41 -04:00
|
|
|
|
const rb_method_entry_t *me;
|
2007-06-24 09:05:51 -04:00
|
|
|
|
|
2010-10-30 21:42:54 -04:00
|
|
|
|
flag = VM_CALL_SUPER_BIT | VM_CALL_FCALL_BIT;
|
|
|
|
|
|
2007-06-24 09:05:51 -04:00
|
|
|
|
recv = GET_SELF();
|
2007-11-21 20:17:52 -05:00
|
|
|
|
vm_search_superclass(GET_CFP(), GET_ISEQ(), recv, TOPN(num), &id, &klass);
|
2010-05-27 11:39:34 -04:00
|
|
|
|
|
|
|
|
|
/* temporary measure for [Bug #2402] [Bug #2502] [Bug #3136] */
|
|
|
|
|
if (!rb_obj_is_kind_of(recv, klass)) {
|
|
|
|
|
rb_raise(rb_eNotImpError, "super from singleton method that is defined to multiple classes is not supported; this will be fixed in 1.9.3 or later");
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-15 10:59:41 -04:00
|
|
|
|
me = rb_method_entry(klass, id);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
|
2009-07-15 10:59:41 -04:00
|
|
|
|
CALL_METHOD(num, blockptr, flag, id, me, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c method/iterator
|
|
|
|
|
@e yield(args) # args.size => num, flag shows expand argument or not
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j yield を実行する。
|
* blockinlining.c, compile.c, compile.h, debug.c, debug.h,
id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
copyright year.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-13 17:13:04 -05:00
|
|
|
|
yield(args) # args.size => num
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
invokeblock
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(rb_num_t num, rb_num_t flag)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += 1 - num;
|
|
|
|
|
{
|
2007-08-06 07:36:30 -04:00
|
|
|
|
val = vm_invoke_block(th, GET_CFP(), num, flag);
|
|
|
|
|
if (val == Qundef) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
RESTORE_REGS();
|
|
|
|
|
NEXT_INSN();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c method/iterator
|
|
|
|
|
@e return from this scope.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j このスコープから抜ける。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
leave
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (OPT_CHECKED_RUN) {
|
|
|
|
|
if (reg_cfp->sp != reg_cfp->bp) {
|
2008-07-12 09:17:29 -04:00
|
|
|
|
rb_bug("Stack consistency error (sp: %"PRIdPTRDIFF", bp: %"PRIdPTRDIFF")",
|
2007-06-27 04:21:21 -04:00
|
|
|
|
VM_SP_CNT(th, reg_cfp->sp), VM_SP_CNT(th, reg_cfp->bp));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
|
RUBY_VM_CHECK_INTS();
|
* vm.c: some refactoring.
* rename th_* to vm_*.
* remove unused variables functions.
* add prototypes.
* blockinlining.c, compile.c, cont.c, eval.c, eval_intern.h,
eval_jump.h, eval_load.c, inits.c, insns.def, iseq.c, parse.y,
proc.c, process.c, signal.c, thread.c, vm.c, vm_dump.c,
vm_evalbody.ci, yarvcore.c, yarvcore.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-24 11:42:41 -04:00
|
|
|
|
vm_pop_frame(th);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
RESTORE_REGS();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c method/iterator
|
|
|
|
|
@e return from this vm loop
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j VM loop から抜ける。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
finish
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2007-06-27 04:21:21 -04:00
|
|
|
|
#if OPT_CALL_THREADED_CODE
|
|
|
|
|
rb_bug("unused instruction on OPT_CALL_THREADED_CODE");
|
|
|
|
|
#else
|
2007-01-16 03:52:22 -05:00
|
|
|
|
th->cfp++;
|
|
|
|
|
return val;
|
2007-06-27 04:21:21 -04:00
|
|
|
|
#endif
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with control flow 3: exception */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c exception
|
|
|
|
|
@e longjump
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 大域ジャンプを行う。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
throw
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(rb_num_t throw_state)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE throwobj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2007-08-16 12:24:18 -04:00
|
|
|
|
RUBY_VM_CHECK_INTS();
|
2007-08-06 07:36:30 -04:00
|
|
|
|
val = vm_throw(th, GET_CFP(), throw_state, throwobj);
|
|
|
|
|
THROW_EXCEPTION(val);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/* unreachable */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with control flow 4: local jump */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c jump
|
|
|
|
|
@e set PC to (PC + dst).
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j PC を (PC + dst) にする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
jump
|
|
|
|
|
(OFFSET dst)
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
{
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
|
RUBY_VM_CHECK_INTS();
|
2007-01-16 03:52:22 -05:00
|
|
|
|
JUMP(dst);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c jump
|
|
|
|
|
@e if val is not false or nil, set PC to (PC + dst).
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j もし val が false か nil でなければ、PC を (PC + dst) にする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
branchif
|
|
|
|
|
(OFFSET dst)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
if (RTEST(val)) {
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
|
RUBY_VM_CHECK_INTS();
|
2007-01-16 03:52:22 -05:00
|
|
|
|
JUMP(dst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c jump
|
|
|
|
|
@e if val is false or nil, set PC to (PC + dst).
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j もし val が false か nil ならば、PC を (PC + dst) にする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
branchunless
|
|
|
|
|
(OFFSET dst)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
if (!RTEST(val)) {
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
|
RUBY_VM_CHECK_INTS();
|
2007-01-16 03:52:22 -05:00
|
|
|
|
JUMP(dst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* for optimize */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e inline cache
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j インラインキャッシュが有効なら、値をスタックにプッシュして dst へジャンプする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getinlinecache
|
2009-07-13 00:44:20 -04:00
|
|
|
|
(OFFSET dst, IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (ic->ic_vmstat == GET_VM_STATE_VERSION()) {
|
2009-09-12 13:16:27 -04:00
|
|
|
|
val = ic->ic_value.value;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
JUMP(dst);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* none */
|
|
|
|
|
val = Qnil;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e inline cache (once)
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j once を実現する。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
onceinlinecache
|
2009-07-13 00:44:20 -04:00
|
|
|
|
(OFFSET dst, IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2010-04-27 10:06:16 -04:00
|
|
|
|
retry:
|
2007-01-16 03:52:22 -05:00
|
|
|
|
if (ic->ic_vmstat) {
|
2009-09-12 13:16:27 -04:00
|
|
|
|
val = ic->ic_value.value;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
JUMP(dst);
|
|
|
|
|
}
|
2010-04-27 10:06:16 -04:00
|
|
|
|
else if (ic->ic_value.value == Qundef)
|
|
|
|
|
{
|
|
|
|
|
RUBY_VM_CHECK_INTS();
|
|
|
|
|
rb_thread_schedule();
|
|
|
|
|
goto retry;
|
|
|
|
|
}
|
2007-01-16 03:52:22 -05:00
|
|
|
|
else {
|
|
|
|
|
/* none */
|
2009-09-12 13:16:27 -04:00
|
|
|
|
ic->ic_value.value = Qundef;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
val = Qnil;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e set inline cache
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j インラインキャッシュの値を設定する。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setinlinecache
|
2010-02-24 12:06:15 -05:00
|
|
|
|
(IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE val)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2009-09-12 13:16:27 -04:00
|
|
|
|
if (ic->ic_value.value == Qundef) {
|
2009-09-07 22:57:39 -04:00
|
|
|
|
rb_ary_push(GET_ISEQ()->mark_ary, val);
|
|
|
|
|
}
|
2009-09-12 13:16:27 -04:00
|
|
|
|
ic->ic_value.value = val;
|
2009-01-15 10:31:43 -05:00
|
|
|
|
ic->ic_vmstat = GET_VM_STATE_VERSION() - ruby_vm_const_missing_count;
|
|
|
|
|
ruby_vm_const_missing_count = 0;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e case dispatcher
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j case 文で、可能なら表引きでジャンプする。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_case_dispatch
|
|
|
|
|
(CDHASH hash, OFFSET else_offset)
|
|
|
|
|
(..., VALUE key)
|
|
|
|
|
() // inc += -1;
|
|
|
|
|
{
|
2010-09-09 09:40:14 -04:00
|
|
|
|
switch(TYPE(key)) {
|
|
|
|
|
case T_FLOAT: {
|
|
|
|
|
double ival;
|
|
|
|
|
if (modf(RFLOAT_VALUE(key), &ival) == 0.0) {
|
|
|
|
|
key = FIXABLE(ival) ? LONG2FIX((long)ival) : rb_dbl2big(ival);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
2010-09-09 09:40:14 -04:00
|
|
|
|
}
|
|
|
|
|
case T_SYMBOL: /* fall through */
|
|
|
|
|
case T_FIXNUM:
|
|
|
|
|
case T_BIGNUM:
|
|
|
|
|
case T_STRING:
|
2011-08-24 18:02:03 -04:00
|
|
|
|
if (BASIC_OP_UNREDEFINED_P(BOP_EQQ,
|
|
|
|
|
SYMBOL_REDEFINED_OP_FLAG |
|
|
|
|
|
FIXNUM_REDEFINED_OP_FLAG |
|
|
|
|
|
BIGNUM_REDEFINED_OP_FLAG |
|
|
|
|
|
STRING_REDEFINED_OP_FLAG)) {
|
2010-10-13 09:51:20 -04:00
|
|
|
|
st_data_t val;
|
2010-09-09 09:40:14 -04:00
|
|
|
|
if (st_lookup(RHASH_TBL(hash), key, &val)) {
|
2010-10-13 09:51:20 -04:00
|
|
|
|
JUMP(FIX2INT((VALUE)val));
|
2010-09-09 09:40:14 -04:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
JUMP(else_offset);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
2010-09-27 10:47:30 -04:00
|
|
|
|
default:
|
|
|
|
|
break;
|
2009-08-12 01:55:06 -04:00
|
|
|
|
}
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e check environment
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 将来の拡張用。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_checkenv
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
if (GET_CFP()->bp != GET_DFP() + 1) {
|
|
|
|
|
VALUE *new_dfp = GET_CFP()->bp - 1;
|
|
|
|
|
/* TODO: copy env and clean stack at creating env? */
|
|
|
|
|
*new_dfp = *GET_DFP();
|
|
|
|
|
SET_DFP(new_dfp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** simple functions */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X+Y.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された X+Y。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_plus
|
2009-09-06 16:42:50 -04:00
|
|
|
|
(IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (0) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#if 1
|
|
|
|
|
else if (FIXNUM_2_P(recv, obj) &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_PLUS,FIXNUM_REDEFINED_OP_FLAG)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/* fixnum + fixnum */
|
2007-06-26 02:23:34 -04:00
|
|
|
|
#ifndef LONG_LONG_VALUE
|
2007-01-16 03:52:22 -05:00
|
|
|
|
val = (recv + (obj & (~1)));
|
|
|
|
|
if ((~(recv ^ obj) & (recv ^ val)) &
|
|
|
|
|
((VALUE)0x01 << ((sizeof(VALUE) * CHAR_BIT) - 1))) {
|
2007-07-12 05:52:48 -04:00
|
|
|
|
val = rb_big_plus(rb_int2big(FIX2LONG(recv)),
|
|
|
|
|
rb_int2big(FIX2LONG(obj)));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
2007-06-26 02:23:34 -04:00
|
|
|
|
#else
|
|
|
|
|
long a, b, c;
|
|
|
|
|
a = FIX2LONG(recv);
|
|
|
|
|
b = FIX2LONG(obj);
|
|
|
|
|
c = a + b;
|
|
|
|
|
if (FIXABLE(c)) {
|
|
|
|
|
val = LONG2FIX(c);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
val = rb_big_plus(rb_int2big(a), rb_int2big(b));
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
|
|
|
|
if (0) {
|
|
|
|
|
}
|
|
|
|
|
#if 1
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cFloat &&
|
|
|
|
|
HEAP_CLASS_OF(obj) == rb_cFloat &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_PLUS, FLOAT_REDEFINED_OP_FLAG)) {
|
2008-09-05 14:24:21 -04:00
|
|
|
|
val = DBL2NUM(RFLOAT_VALUE(recv) + RFLOAT_VALUE(obj));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cString &&
|
|
|
|
|
HEAP_CLASS_OF(obj) == rb_cString &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_PLUS, STRING_REDEFINED_OP_FLAG)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
val = rb_str_plus(recv, obj);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cArray &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_PLUS, ARRAY_REDEFINED_OP_FLAG)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
val = rb_ary_plus(recv, obj);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
else {
|
|
|
|
|
goto INSN_LABEL(normal_dispatch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
INSN_LABEL(normal_dispatch):
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
CALL_SIMPLE_METHOD(1, idPLUS, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X-Y.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された X-Y。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_minus
|
2009-09-06 16:42:50 -04:00
|
|
|
|
(IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (FIXNUM_2_P(recv, obj) &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_MINUS, FIXNUM_REDEFINED_OP_FLAG)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
long a, b, c;
|
|
|
|
|
|
|
|
|
|
a = FIX2LONG(recv);
|
|
|
|
|
b = FIX2LONG(obj);
|
|
|
|
|
c = a - b;
|
|
|
|
|
|
2007-06-26 02:23:34 -04:00
|
|
|
|
if (FIXABLE(c)) {
|
|
|
|
|
val = LONG2FIX(c);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
val = rb_big_minus(rb_int2big(a), rb_int2big(b));
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-02-23 11:12:38 -05:00
|
|
|
|
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
|
|
|
|
if (0) {
|
|
|
|
|
}
|
|
|
|
|
#if 1
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cFloat &&
|
|
|
|
|
HEAP_CLASS_OF(obj) == rb_cFloat &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_MINUS, FLOAT_REDEFINED_OP_FLAG)) {
|
2009-02-23 11:12:38 -05:00
|
|
|
|
val = DBL2NUM(RFLOAT_VALUE(recv) - RFLOAT_VALUE(obj));
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
else {
|
|
|
|
|
goto INSN_LABEL(normal_dispatch);
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-01-16 03:52:22 -05:00
|
|
|
|
else {
|
|
|
|
|
/* other */
|
2009-02-23 11:12:38 -05:00
|
|
|
|
INSN_LABEL(normal_dispatch):
|
2007-01-16 03:52:22 -05:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
CALL_SIMPLE_METHOD(1, idMINUS, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X*Y.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された X*Y。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_mult
|
2009-09-06 16:42:50 -04:00
|
|
|
|
(IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (FIXNUM_2_P(recv, obj) &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_MULT, FIXNUM_REDEFINED_OP_FLAG)) {
|
2011-05-30 02:53:21 -04:00
|
|
|
|
long a, b;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
|
|
|
|
|
a = FIX2LONG(recv);
|
|
|
|
|
if (a == 0) {
|
|
|
|
|
val = recv;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2011-05-30 03:28:30 -04:00
|
|
|
|
volatile long c;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
b = FIX2LONG(obj);
|
2011-05-30 03:28:30 -04:00
|
|
|
|
c = a * b;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
|
2007-06-26 02:23:34 -04:00
|
|
|
|
if (FIXABLE(c) && c / a == b) {
|
|
|
|
|
val = LONG2FIX(c);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
val = rb_big_mul(rb_int2big(a), rb_int2big(b));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
|
|
|
|
if (0) {
|
|
|
|
|
}
|
|
|
|
|
#if 1
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cFloat &&
|
|
|
|
|
HEAP_CLASS_OF(obj) == rb_cFloat &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_MULT, FLOAT_REDEFINED_OP_FLAG)) {
|
2008-09-05 14:24:21 -04:00
|
|
|
|
val = DBL2NUM(RFLOAT_VALUE(recv) * RFLOAT_VALUE(obj));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
else {
|
|
|
|
|
goto INSN_LABEL(normal_dispatch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
INSN_LABEL(normal_dispatch):
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
CALL_SIMPLE_METHOD(1, idMULT, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X/Y.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された X/Y。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_div
|
2009-09-06 16:42:50 -04:00
|
|
|
|
(IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (FIXNUM_2_P(recv, obj) &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_DIV, FIXNUM_REDEFINED_OP_FLAG)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
long x, y, div;
|
|
|
|
|
|
|
|
|
|
x = FIX2LONG(recv);
|
|
|
|
|
y = FIX2LONG(obj);
|
|
|
|
|
{
|
|
|
|
|
/* copied from numeric.c#fixdivmod */
|
|
|
|
|
long mod;
|
|
|
|
|
if (y == 0)
|
2008-02-18 21:14:14 -05:00
|
|
|
|
goto INSN_LABEL(normal_dispatch);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
if (y < 0) {
|
|
|
|
|
if (x < 0)
|
|
|
|
|
div = -x / -y;
|
|
|
|
|
else
|
|
|
|
|
div = -(x / -y);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (x < 0)
|
|
|
|
|
div = -(-x / y);
|
|
|
|
|
else
|
|
|
|
|
div = x / y;
|
|
|
|
|
}
|
|
|
|
|
mod = x - div * y;
|
|
|
|
|
if ((mod < 0 && y > 0) || (mod > 0 && y < 0)) {
|
|
|
|
|
mod += y;
|
|
|
|
|
div -= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-07-13 13:08:12 -04:00
|
|
|
|
val = LONG2NUM(div);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
|
|
|
|
if (0) {
|
|
|
|
|
}
|
|
|
|
|
#if 1
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cFloat &&
|
|
|
|
|
HEAP_CLASS_OF(obj) == rb_cFloat &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_DIV, FLOAT_REDEFINED_OP_FLAG)) {
|
2008-09-05 14:24:21 -04:00
|
|
|
|
val = DBL2NUM(RFLOAT_VALUE(recv) / RFLOAT_VALUE(obj));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
else {
|
|
|
|
|
goto INSN_LABEL(normal_dispatch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
INSN_LABEL(normal_dispatch):
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
CALL_SIMPLE_METHOD(1, idDIV, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X%Y.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された X%Y。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_mod
|
2009-09-06 16:42:50 -04:00
|
|
|
|
(IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (FIXNUM_2_P(recv, obj) &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_MOD, FIXNUM_REDEFINED_OP_FLAG )) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
long x, y, mod;
|
|
|
|
|
|
|
|
|
|
x = FIX2LONG(recv);
|
|
|
|
|
y = FIX2LONG(obj);
|
|
|
|
|
{
|
|
|
|
|
/* copied from numeric.c#fixdivmod */
|
|
|
|
|
long div;
|
|
|
|
|
|
|
|
|
|
if (y == 0)
|
|
|
|
|
rb_num_zerodiv();
|
|
|
|
|
if (y < 0) {
|
|
|
|
|
if (x < 0)
|
|
|
|
|
div = -x / -y;
|
|
|
|
|
else
|
|
|
|
|
div = -(x / -y);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (x < 0)
|
|
|
|
|
div = -(-x / y);
|
|
|
|
|
else
|
|
|
|
|
div = x / y;
|
|
|
|
|
}
|
|
|
|
|
mod = x - div * y;
|
|
|
|
|
if ((mod < 0 && y > 0) || (mod > 0 && y < 0)) {
|
|
|
|
|
mod += y;
|
|
|
|
|
div -= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
val = LONG2FIX(mod);
|
|
|
|
|
}
|
|
|
|
|
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
|
|
|
|
if (0) {
|
|
|
|
|
}
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cFloat &&
|
|
|
|
|
HEAP_CLASS_OF(obj) == rb_cFloat &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_MOD, FLOAT_REDEFINED_OP_FLAG)) {
|
* include/ruby/ruby.h: introduce 2 macros:
RFLOAT_VALUE(v), DOUBLE2NUM(dbl).
Rename RFloat#value -> RFloat#double_value.
Do not touch RFloat#double_value directly.
* bignum.c, insns.def, marshal.c, math.c, numeric.c, object.c,
pack.c, parse.y, process.c, random.c, sprintf.c, string.c,
time.c: apply above changes.
* ext/dl/mkcallback.rb, ext/json/ext/generator/generator.c:
ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-13 11:00:53 -05:00
|
|
|
|
double x = RFLOAT_VALUE(recv);
|
|
|
|
|
double y = RFLOAT_VALUE(obj);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
double div, mod;
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
double z;
|
|
|
|
|
|
|
|
|
|
modf(x / y, &z);
|
|
|
|
|
mod = x - z * y;
|
|
|
|
|
}
|
2007-08-06 07:36:30 -04:00
|
|
|
|
|
2007-01-16 03:52:22 -05:00
|
|
|
|
div = (x - mod) / y;
|
|
|
|
|
if (y * mod < 0) {
|
|
|
|
|
mod += y;
|
|
|
|
|
div -= 1.0;
|
|
|
|
|
}
|
2008-09-05 14:24:21 -04:00
|
|
|
|
val = DBL2NUM(mod);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
goto INSN_LABEL(normal_dispatch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
INSN_LABEL(normal_dispatch):
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
CALL_SIMPLE_METHOD(1, idMOD, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X==Y.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された X==Y。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_eq
|
2007-12-18 07:07:51 -05:00
|
|
|
|
(IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2007-12-18 07:07:51 -05:00
|
|
|
|
val = opt_eq_func(recv, obj, ic);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
|
2007-12-18 07:07:51 -05:00
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
|
|
|
|
CALL_SIMPLE_METHOD(1, idEq, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
2007-12-18 07:07:51 -05:00
|
|
|
|
}
|
2007-01-16 03:52:22 -05:00
|
|
|
|
|
2007-12-18 07:07:51 -05:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X!=Y.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された X!=Y。
|
2007-12-18 07:07:51 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_neq
|
2009-09-06 16:42:50 -04:00
|
|
|
|
(IC ic, IC ic_eq)
|
2007-12-18 07:07:51 -05:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
extern VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2);
|
2009-09-06 16:42:50 -04:00
|
|
|
|
const rb_method_entry_t *me = vm_method_search(idNeq, CLASS_OF(recv), ic);
|
2007-12-18 07:07:51 -05:00
|
|
|
|
val = Qundef;
|
|
|
|
|
|
2009-07-15 10:59:41 -04:00
|
|
|
|
if (check_cfunc(me, rb_obj_not_equal)) {
|
2009-09-06 16:42:50 -04:00
|
|
|
|
val = opt_eq_func(recv, obj, ic_eq);
|
2007-12-18 07:07:51 -05:00
|
|
|
|
|
|
|
|
|
if (val != Qundef) {
|
|
|
|
|
val = RTEST(val) ? Qfalse : Qtrue;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
2007-12-18 07:07:51 -05:00
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/* other */
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
2007-12-18 07:07:51 -05:00
|
|
|
|
CALL_SIMPLE_METHOD(1, idNeq, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X<Y.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された X<Y。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_lt
|
2009-09-06 16:42:50 -04:00
|
|
|
|
(IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (FIXNUM_2_P(recv, obj) &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LT, FIXNUM_REDEFINED_OP_FLAG)) {
|
2008-05-22 13:31:15 -04:00
|
|
|
|
SIGNED_VALUE a = recv, b = obj;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
|
|
|
|
|
if (a < b) {
|
|
|
|
|
val = Qtrue;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
val = Qfalse;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-02-23 11:12:38 -05:00
|
|
|
|
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
|
|
|
|
if (0) {
|
|
|
|
|
}
|
|
|
|
|
#if 1
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cFloat &&
|
|
|
|
|
HEAP_CLASS_OF(obj) == rb_cFloat &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LT, FLOAT_REDEFINED_OP_FLAG)) {
|
2009-02-27 00:42:06 -05:00
|
|
|
|
double a = RFLOAT_VALUE(recv);
|
|
|
|
|
double b = RFLOAT_VALUE(obj);
|
|
|
|
|
#if defined(_MSC_VER) && _MSC_VER < 1300
|
|
|
|
|
if (isnan(a) || isnan(b)) val = Qfalse;
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
val = a < b ? Qtrue : Qfalse;
|
2009-02-23 11:12:38 -05:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
else {
|
|
|
|
|
goto INSN_LABEL(normal_dispatch);
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-01-16 03:52:22 -05:00
|
|
|
|
else {
|
2009-02-23 11:12:38 -05:00
|
|
|
|
INSN_LABEL(normal_dispatch):
|
2007-01-16 03:52:22 -05:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
CALL_SIMPLE_METHOD(1, idLT, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X<=Y.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された X<=Y。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_le
|
2009-09-06 16:42:50 -04:00
|
|
|
|
(IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (FIXNUM_2_P(recv, obj) &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LE, FIXNUM_REDEFINED_OP_FLAG)) {
|
2008-05-22 13:31:15 -04:00
|
|
|
|
SIGNED_VALUE a = recv, b = obj;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
|
|
|
|
|
if (a <= b) {
|
|
|
|
|
val = Qtrue;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
val = Qfalse;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* other */
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
CALL_SIMPLE_METHOD(1, idLE, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-21 00:46:51 -04:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X>Y.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された X>Y。
|
2007-05-21 00:46:51 -04:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_gt
|
2009-09-06 16:42:50 -04:00
|
|
|
|
(IC ic)
|
2007-05-21 00:46:51 -04:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (FIXNUM_2_P(recv, obj) &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_GT, FIXNUM_REDEFINED_OP_FLAG)) {
|
2008-05-22 13:31:15 -04:00
|
|
|
|
SIGNED_VALUE a = recv, b = obj;
|
2007-05-21 00:46:51 -04:00
|
|
|
|
|
|
|
|
|
if (a > b) {
|
|
|
|
|
val = Qtrue;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
val = Qfalse;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-02-23 11:12:38 -05:00
|
|
|
|
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
|
|
|
|
if (0) {
|
|
|
|
|
}
|
|
|
|
|
#if 1
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cFloat &&
|
|
|
|
|
HEAP_CLASS_OF(obj) == rb_cFloat &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_GT, FLOAT_REDEFINED_OP_FLAG)) {
|
2009-02-27 00:42:06 -05:00
|
|
|
|
double a = RFLOAT_VALUE(recv);
|
|
|
|
|
double b = RFLOAT_VALUE(obj);
|
|
|
|
|
#if defined(_MSC_VER) && _MSC_VER < 1300
|
|
|
|
|
if (isnan(a) || isnan(b)) val = Qfalse;
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
val = a > b ? Qtrue : Qfalse;
|
2009-02-23 11:12:38 -05:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
else {
|
|
|
|
|
goto INSN_LABEL(normal_dispatch);
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-05-21 00:46:51 -04:00
|
|
|
|
else {
|
2009-02-23 11:12:38 -05:00
|
|
|
|
INSN_LABEL(normal_dispatch):
|
2007-05-21 00:46:51 -04:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
CALL_SIMPLE_METHOD(1, idGT, recv);
|
2007-05-21 00:46:51 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X>=Y.
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された X>=Y。
|
2007-05-21 00:46:51 -04:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_ge
|
2009-09-06 16:42:50 -04:00
|
|
|
|
(IC ic)
|
2007-05-21 00:46:51 -04:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (FIXNUM_2_P(recv, obj) &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_GE, FIXNUM_REDEFINED_OP_FLAG)) {
|
2008-05-22 13:31:15 -04:00
|
|
|
|
SIGNED_VALUE a = recv, b = obj;
|
2007-05-21 00:46:51 -04:00
|
|
|
|
|
|
|
|
|
if (a >= b) {
|
|
|
|
|
val = Qtrue;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
val = Qfalse;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
CALL_SIMPLE_METHOD(1, idGE, recv);
|
2007-05-21 00:46:51 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e <<
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された X<<Y。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_ltlt
|
2009-09-06 16:42:50 -04:00
|
|
|
|
(IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (!SPECIAL_CONST_P(recv)) {
|
|
|
|
|
if (0) {
|
|
|
|
|
}
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cString &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LTLT, STRING_REDEFINED_OP_FLAG)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
val = rb_str_concat(recv, obj);
|
|
|
|
|
}
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cArray &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LTLT, ARRAY_REDEFINED_OP_FLAG)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
val = rb_ary_push(recv, obj);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
goto INSN_LABEL(normal_dispatch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
INSN_LABEL(normal_dispatch):
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
CALL_SIMPLE_METHOD(1, idLTLT, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e []
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された recv[obj]。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_aref
|
2009-09-06 16:42:50 -04:00
|
|
|
|
(IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2011-08-24 18:02:03 -04:00
|
|
|
|
if (!SPECIAL_CONST_P(recv)) {
|
|
|
|
|
if (HEAP_CLASS_OF(recv) == rb_cArray && BASIC_OP_UNREDEFINED_P(BOP_AREF, ARRAY_REDEFINED_OP_FLAG) && FIXNUM_P(obj)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
val = rb_ary_entry(recv, FIX2LONG(obj));
|
|
|
|
|
}
|
2011-08-24 18:02:03 -04:00
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cHash && BASIC_OP_UNREDEFINED_P(BOP_AREF, HASH_REDEFINED_OP_FLAG)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
val = rb_hash_aref(recv, obj);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
goto INSN_LABEL(normal_dispatch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
INSN_LABEL(normal_dispatch):
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
CALL_SIMPLE_METHOD(1, idAREF, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e recv[obj] = set
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された recv[obj] = set。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_aset
|
2009-09-06 16:42:50 -04:00
|
|
|
|
(IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE recv, VALUE obj, VALUE set)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2011-08-24 18:02:03 -04:00
|
|
|
|
if (!SPECIAL_CONST_P(recv)) {
|
|
|
|
|
if (HEAP_CLASS_OF(recv) == rb_cArray && BASIC_OP_UNREDEFINED_P(BOP_ASET, ARRAY_REDEFINED_OP_FLAG) && FIXNUM_P(obj)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
rb_ary_store(recv, FIX2LONG(obj), set);
|
|
|
|
|
val = set;
|
|
|
|
|
}
|
2011-08-24 18:02:03 -04:00
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cHash && BASIC_OP_UNREDEFINED_P(BOP_ASET, HASH_REDEFINED_OP_FLAG)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
rb_hash_aset(recv, obj, set);
|
|
|
|
|
val = set;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
goto INSN_LABEL(normal_dispatch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
INSN_LABEL(normal_dispatch):
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
|
|
|
|
PUSH(set);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
CALL_SIMPLE_METHOD(2, idASET, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized length
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された recv.length()。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_length
|
2009-09-06 05:16:23 -04:00
|
|
|
|
(IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE recv)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2011-08-24 18:02:03 -04:00
|
|
|
|
if (!SPECIAL_CONST_P(recv)) {
|
|
|
|
|
if (HEAP_CLASS_OF(recv) == rb_cString &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LENGTH, STRING_REDEFINED_OP_FLAG)) {
|
2007-08-25 04:54:29 -04:00
|
|
|
|
val = rb_str_length(recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
2011-08-24 18:02:03 -04:00
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cArray &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LENGTH, ARRAY_REDEFINED_OP_FLAG)) {
|
2007-08-25 04:54:29 -04:00
|
|
|
|
val = LONG2NUM(RARRAY_LEN(recv));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
2011-08-24 18:02:03 -04:00
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cHash &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LENGTH, HASH_REDEFINED_OP_FLAG)) {
|
2007-08-29 19:12:21 -04:00
|
|
|
|
val = INT2FIX(RHASH_SIZE(recv));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
goto INSN_LABEL(normal_dispatch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
INSN_LABEL(normal_dispatch):
|
2007-06-24 09:05:51 -04:00
|
|
|
|
PUSH(recv);
|
2009-09-06 16:42:50 -04:00
|
|
|
|
CALL_SIMPLE_METHOD(0, idLength, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-06 04:39:57 -04:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized size
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された recv.size()。
|
2009-09-06 04:39:57 -04:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_size
|
2009-09-06 05:16:23 -04:00
|
|
|
|
(IC ic)
|
2009-09-06 04:39:57 -04:00
|
|
|
|
(VALUE recv)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2011-08-24 18:02:03 -04:00
|
|
|
|
if (!SPECIAL_CONST_P(recv)) {
|
|
|
|
|
if (HEAP_CLASS_OF(recv) == rb_cString &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_SIZE, STRING_REDEFINED_OP_FLAG)) {
|
2009-09-06 04:39:57 -04:00
|
|
|
|
val = rb_str_length(recv);
|
|
|
|
|
}
|
2011-08-24 18:02:03 -04:00
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cArray &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_SIZE, ARRAY_REDEFINED_OP_FLAG)) {
|
2009-09-06 04:39:57 -04:00
|
|
|
|
val = LONG2NUM(RARRAY_LEN(recv));
|
|
|
|
|
}
|
2011-08-24 18:02:03 -04:00
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cHash &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_SIZE, HASH_REDEFINED_OP_FLAG)) {
|
2009-09-06 04:39:57 -04:00
|
|
|
|
val = INT2FIX(RHASH_SIZE(recv));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
goto INSN_LABEL(normal_dispatch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
INSN_LABEL(normal_dispatch):
|
|
|
|
|
PUSH(recv);
|
2009-09-06 16:42:50 -04:00
|
|
|
|
CALL_SIMPLE_METHOD(0, idSize, recv);
|
2009-09-06 04:39:57 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized succ
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された recv.succ()。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_succ
|
2009-09-06 16:42:50 -04:00
|
|
|
|
(IC ic)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE recv)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (SPECIAL_CONST_P(recv)) {
|
|
|
|
|
if (FIXNUM_P(recv) &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_SUCC, FIXNUM_REDEFINED_OP_FLAG)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
const VALUE obj = INT2FIX(1);
|
|
|
|
|
/* fixnum + INT2FIX(1) */
|
|
|
|
|
val = (recv + (obj & (~1)));
|
2007-07-13 04:42:27 -04:00
|
|
|
|
if ((~(recv ^ obj) & (recv ^ val)) & ((unsigned long)LONG_MAX + 1)) {
|
2007-07-12 05:52:48 -04:00
|
|
|
|
val = rb_big_plus(rb_int2big(FIX2LONG(recv)),
|
|
|
|
|
rb_int2big(FIX2LONG(obj)));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
goto INSN_LABEL(normal_dispatch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (HEAP_CLASS_OF(recv) == rb_cString &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_SUCC, STRING_REDEFINED_OP_FLAG)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
val = rb_str_succ(recv);
|
|
|
|
|
}
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cTime &&
|
2011-08-24 18:02:03 -04:00
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_SUCC, TIME_REDEFINED_OP_FLAG)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
val = rb_time_succ(recv);
|
|
|
|
|
}
|
2007-12-18 07:07:51 -05:00
|
|
|
|
else
|
|
|
|
|
{
|
2007-01-16 03:52:22 -05:00
|
|
|
|
goto INSN_LABEL(normal_dispatch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (0) {
|
|
|
|
|
INSN_LABEL(normal_dispatch):
|
2007-06-24 09:05:51 -04:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
CALL_SIMPLE_METHOD(0, idSucc, recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-18 07:07:51 -05:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized not
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された recv.!()。
|
2007-12-18 07:07:51 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_not
|
|
|
|
|
(IC ic)
|
|
|
|
|
(VALUE recv)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
extern VALUE rb_obj_not(VALUE obj);
|
2009-07-15 10:59:41 -04:00
|
|
|
|
const rb_method_entry_t *me = vm_method_search(idNot, CLASS_OF(recv), ic);
|
2007-12-18 07:07:51 -05:00
|
|
|
|
|
2009-07-15 10:59:41 -04:00
|
|
|
|
if (check_cfunc(me, rb_obj_not)) {
|
2007-12-18 07:07:51 -05:00
|
|
|
|
val = RTEST(recv) ? Qfalse : Qtrue;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
CALL_SIMPLE_METHOD(0, idNot, recv);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-01-16 03:52:22 -05:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized regexp match
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された正規表現マッチ。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_regexpmatch1
|
|
|
|
|
(VALUE r)
|
|
|
|
|
(VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
val = rb_reg_match(r, obj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized regexp match 2
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 最適化された正規表現マッチ 2
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_regexpmatch2
|
|
|
|
|
()
|
|
|
|
|
(VALUE obj2, VALUE obj1)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE(obj2) == T_STRING) {
|
|
|
|
|
val = rb_reg_match(obj1, obj2);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
val = rb_funcall(obj2, idEqTilde, 1, obj1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e call native compiled method
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j ネイティブコンパイルしたメソッドを起動。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
2007-06-30 14:02:24 -04:00
|
|
|
|
opt_call_c_function
|
2007-08-12 15:09:15 -04:00
|
|
|
|
(rb_insn_func_t funcptr)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
{
|
2007-06-30 14:02:24 -04:00
|
|
|
|
reg_cfp = (funcptr)(th, reg_cfp);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
|
2007-06-30 14:02:24 -04:00
|
|
|
|
if (reg_cfp == 0) {
|
|
|
|
|
VALUE err = th->errinfo;
|
|
|
|
|
th->errinfo = Qnil;
|
2007-07-01 22:59:37 -04:00
|
|
|
|
THROW_EXCEPTION(err);
|
2007-06-30 14:02:24 -04:00
|
|
|
|
}
|
|
|
|
|
|
2007-07-02 08:49:35 -04:00
|
|
|
|
RESTORE_REGS();
|
2007-06-30 14:02:24 -04:00
|
|
|
|
NEXT_INSN();
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c joke
|
|
|
|
|
@e BLT
|
|
|
|
|
@j BLT
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
bitblt
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
(VALUE ret)
|
|
|
|
|
{
|
|
|
|
|
ret = rb_str_new2("a bit of bacon, lettuce and tomato");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c joke
|
|
|
|
|
@e The Answer to Life, the Universe, and Everything
|
2011-09-04 08:22:46 -04:00
|
|
|
|
@j 人生、宇宙、すべての答え。
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
answer
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
(VALUE ret)
|
|
|
|
|
{
|
|
|
|
|
ret = INT2FIX(42);
|
|
|
|
|
}
|
|
|
|
|
|