2007-07-01 22:59:37 -04:00
|
|
|
|
/** ##skip -*- mode:c; style:ruby -*-
|
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
|
* 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 get local variable value (which is pointed by idx).
|
2007-01-16 03:52:22 -05:00
|
|
|
|
@j idx <EFBFBD>Ŏw<EFBFBD>肳<EFBFBD>ꂽ<EFBFBD><EFBFBD><EFBFBD>[<EFBFBD>J<EFBFBD><EFBFBD><EFBFBD>ϐ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>ɒu<EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getlocal
|
|
|
|
|
(lindex_t idx)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
val = *(GET_LFP() - idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
* 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 set local variable value (which is pointed by idx) as val.
|
|
|
|
|
@j idx <EFBFBD>Ŏw<EFBFBD>肳<EFBFBD>ꂽ<EFBFBD><EFBFBD><EFBFBD>[<EFBFBD>J<EFBFBD><EFBFBD><EFBFBD>ϐ<EFBFBD><EFBFBD><EFBFBD> val <EFBFBD>ɐݒ肷<EFBFBD><EFBFBD><EFBFBD>B
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setlocal
|
|
|
|
|
(lindex_t idx)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
(*(GET_LFP() - idx)) = val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
* 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 get special local variable ($~, $_, ..) value.
|
|
|
|
|
@j <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȃ<EFBFBD><EFBFBD>[<EFBFBD>J<EFBFBD><EFBFBD><EFBFBD>ϐ<EFBFBD><EFBFBD>i$~, $_, ...<EFBFBD>j<EFBFBD>̒l<EFBFBD><EFBFBD><EFBFBD>B
|
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
|
* 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 set special local variable ($~, $_, ...) value as obj.
|
2009-02-11 00:46:17 -05:00
|
|
|
|
@j <EFBFBD><EFBFBD><EFBFBD>ʂȃ<EFBFBD><EFBFBD>[<EFBFBD>J<EFBFBD><EFBFBD><EFBFBD>ϐ<EFBFBD><EFBFBD>i$~, $_, ...<EFBFBD>j<EFBFBD>̒l<EFBFBD><EFBFBD><EFBFBD>ݒ肷<EFBFBD><EFBFBD><EFBFBD>B
|
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
|
|
|
|
|
@e get block local variable(which is pointed by idx and level).
|
|
|
|
|
level means nest level of block, and specify how above this variable.
|
|
|
|
|
@j level, idx <EFBFBD>Ŏw<EFBFBD>肳<EFBFBD>ꂽ<EFBFBD>u<EFBFBD><EFBFBD><EFBFBD>b<EFBFBD>N<EFBFBD><EFBFBD><EFBFBD>[<EFBFBD>J<EFBFBD><EFBFBD><EFBFBD>ϐ<EFBFBD><EFBFBD>̒l<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>ɒu<EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
level <EFBFBD>̓u<EFBFBD><EFBFBD><EFBFBD>b<EFBFBD>N<EFBFBD>̃l<EFBFBD>X<EFBFBD>g<EFBFBD><EFBFBD><EFBFBD>x<EFBFBD><EFBFBD><EFBFBD>ŁA<EFBFBD><EFBFBD><EFBFBD>i<EFBFBD>ォ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
@e set block local variable(which is pointed by 'idx') as val.
|
|
|
|
|
level means nest level of block, and specify how above this variable.
|
|
|
|
|
@j level, idx <EFBFBD>Ŏw<EFBFBD>肳<EFBFBD>ꂽ<EFBFBD>u<EFBFBD><EFBFBD><EFBFBD>b<EFBFBD>N<EFBFBD><EFBFBD><EFBFBD>[<EFBFBD>J<EFBFBD><EFBFBD><EFBFBD>ϐ<EFBFBD><EFBFBD>̒l<EFBFBD><EFBFBD> val <EFBFBD>ɂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
level <EFBFBD>̓u<EFBFBD><EFBFBD><EFBFBD>b<EFBFBD>N<EFBFBD>̃l<EFBFBD>X<EFBFBD>g<EFBFBD><EFBFBD><EFBFBD>x<EFBFBD><EFBFBD><EFBFBD>ŁA<EFBFBD><EFBFBD><EFBFBD>i<EFBFBD>ォ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
@e get instance variable id of obj.
|
2007-02-06 00:22:17 -05:00
|
|
|
|
if is_local is not 0, search as class local variable.
|
* 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
|
|
|
|
@j self <EFBFBD>̃C<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>^<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>ϐ<EFBFBD> id <EFBFBD>̒l<EFBFBD><EFBFBD><EFBFBD>B
|
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
|
|
|
|
|
@e set instance variable id of obj as val.
|
2007-02-06 00:22:17 -05:00
|
|
|
|
if is_local is not 0, search as class local variable.
|
* 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
|
|
|
|
@j self <EFBFBD>̃C<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>^<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>ϐ<EFBFBD> id <EFBFBD><EFBFBD> val <EFBFBD>ɂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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
|
|
|
|
|
@e get class variable id of klass as val.
|
* 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
|
|
|
|
@j <EFBFBD><EFBFBD><EFBFBD>݂̃X<EFBFBD>R<EFBFBD>[<EFBFBD>v<EFBFBD>̃N<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>ϐ<EFBFBD> id <EFBFBD>̒l<EFBFBD><EFBFBD><EFBFBD>B
|
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
|
|
|
|
|
@e set class variable id of klass as val.
|
|
|
|
|
@j klass <EFBFBD>̃N<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>ϐ<EFBFBD> id <EFBFBD><EFBFBD> val <EFBFBD>ɂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
get constant variable id. if klass is Qnil, constant
|
|
|
|
|
are searched in current scope. if klass is Qfalse, constant as
|
|
|
|
|
top level constant. otherwise, get constant under klass
|
|
|
|
|
class or module.
|
* 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
|
|
|
|
@j <EFBFBD>萔 id <EFBFBD>̒l<EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
klass <EFBFBD><EFBFBD> Qnil <EFBFBD>Ȃ<EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD>̃X<EFBFBD>R<EFBFBD>[<EFBFBD>v<EFBFBD>œ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>萔<EFBFBD>̒l<EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
Qfalse <EFBFBD>Ȃ<EFBFBD><EFBFBD>A<EFBFBD>g<EFBFBD>b<EFBFBD>v<EFBFBD><EFBFBD><EFBFBD>x<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>R<EFBFBD>[<EFBFBD>v<EFBFBD><EFBFBD><EFBFBD>B
|
2007-01-16 03:52:22 -05:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȊO<EFBFBD>Ȃ<EFBFBD><EFBFBD>Aklass <EFBFBD>N<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>̉<EFBFBD><EFBFBD>̒萔<EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
set constant variable id. if klass is Qfalse, constant
|
|
|
|
|
is able to access in this scope. if klass is Qnil, set
|
|
|
|
|
top level constant. otherwise, set constant under klass
|
|
|
|
|
class or module.
|
|
|
|
|
|
* 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
|
|
|
|
@j <EFBFBD>萔 id <EFBFBD>̒l<EFBFBD><EFBFBD> val <EFBFBD>ɂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
klass <EFBFBD><EFBFBD> Qfalse <EFBFBD>Ȃ<EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD>̃X<EFBFBD>R<EFBFBD>[<EFBFBD>v<EFBFBD>œ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>萔 id <EFBFBD>̒l<EFBFBD><EFBFBD><EFBFBD>ݒ肷<EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
Qnil <EFBFBD>Ȃ<EFBFBD><EFBFBD>A<EFBFBD>g<EFBFBD>b<EFBFBD>v<EFBFBD><EFBFBD><EFBFBD>x<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>R<EFBFBD>[<EFBFBD>v<EFBFBD>̒l<EFBFBD><EFBFBD><EFBFBD>ݒ肷<EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȊO<EFBFBD>Ȃ<EFBFBD><EFBFBD>Aklass <EFBFBD>N<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>̉<EFBFBD><EFBFBD>̒萔<EFBFBD><EFBFBD><EFBFBD>ݒ肷<EFBFBD><EFBFBD><EFBFBD>B
|
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.
|
* 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
|
|
|
|
@j <EFBFBD>O<EFBFBD><EFBFBD><EFBFBD>[<EFBFBD>o<EFBFBD><EFBFBD><EFBFBD>ϐ<EFBFBD> id <EFBFBD>̒l<EFBFBD><EFBFBD><EFBFBD>B
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getglobal
|
|
|
|
|
(GENTRY entry)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
val = GET_GLOBAL(entry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
|
|
|
|
@e set global variable id as val.
|
* 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
|
|
|
|
@j <EFBFBD>O<EFBFBD><EFBFBD><EFBFBD>[<EFBFBD>o<EFBFBD><EFBFBD><EFBFBD>ϐ<EFBFBD> id <EFBFBD>̒l<EFBFBD><EFBFBD><EFBFBD>ݒ肷<EFBFBD><EFBFBD><EFBFBD>B
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setglobal
|
|
|
|
|
(GENTRY entry)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
SET_GLOBAL(entry, val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* 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.
|
|
|
|
|
@j <EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD><EFBFBD> nil <EFBFBD><EFBFBD><EFBFBD>v<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
putnil
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
val = Qnil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e put self.
|
* 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
|
|
|
|
@j <EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD><EFBFBD> self <EFBFBD><EFBFBD><EFBFBD>v<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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.
|
|
|
|
|
@j <EFBFBD>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g val <EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>Ƀv<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
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.
|
|
|
|
|
@j <EFBFBD><EFBFBD><EFBFBD>ʂȃI<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g val <EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>Ƀv<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
<EFBFBD>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD>̎<EFBFBD><EFBFBD>ނ<EFBFBD> value_type <EFBFBD>ɂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>D
|
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)
|
|
|
|
|
{
|
2008-06-30 23:05:58 -04:00
|
|
|
|
switch (value_type) {
|
|
|
|
|
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.
|
2009-02-11 00:46:17 -05:00
|
|
|
|
@j <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>R<EFBFBD>s<EFBFBD>[<EFBFBD><EFBFBD><EFBFBD>ăX<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>Ƀv<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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
|
* 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
|
|
|
|
@j <EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>g<EFBFBD>b<EFBFBD>v<EFBFBD>̕<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> n <EFBFBD>A<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD>ʂ<EFBFBD><EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>Ƀv<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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;
|
|
|
|
|
{
|
2009-06-30 03:46:44 -04:00
|
|
|
|
rb_num_t i = num;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
|
|
|
|
|
val = rb_str_new(0, 0);
|
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
|
* 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
|
|
|
|
@j to_str <EFBFBD>̌<EFBFBD><EFBFBD>ʂ<EFBFBD><EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>Ƀv<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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
|
* 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
|
|
|
|
@j <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> str <EFBFBD>𐳋K<EFBFBD>\<EFBFBD><EFBFBD><EFBFBD>ɃR<EFBFBD><EFBFBD><EFBFBD>p<EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ăX<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>Ƀv<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
<EFBFBD>R<EFBFBD><EFBFBD><EFBFBD>p<EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Copt <EFBFBD>𐳋K<EFBFBD>\<EFBFBD><EFBFBD><EFBFBD>̃I<EFBFBD>v<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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.
|
* 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
|
|
|
|
@j <EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>z<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD><EFBFBD><EFBFBD><EFBFBD> num <EFBFBD>̒l<EFBFBD>ŏ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Đ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>v<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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
|
* 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
|
|
|
|
@j <EFBFBD>z<EFBFBD><EFBFBD> ary <EFBFBD><EFBFBD> dup <EFBFBD><EFBFBD><EFBFBD>ăX<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>Ƀv<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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.
|
|
|
|
|
@j <EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>g<EFBFBD>b<EFBFBD>v<EFBFBD>̃I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD><EFBFBD><EFBFBD>z<EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>W<EFBFBD>J<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
<EFBFBD>z<EFBFBD><EFBFBD><EFBFBD>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD>̗v<EFBFBD>f<EFBFBD><EFBFBD><EFBFBD><EFBFBD> num<EFBFBD>ȉ<EFBFBD><EFBFBD>Ȃ<EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> nil <EFBFBD><EFBFBD><EFBFBD>ςށBnum<EFBFBD>ȏ<EFBFBD><EFBFBD>Ȃ<EFBFBD><EFBFBD>A
|
|
|
|
|
num<EFBFBD>ȏ<EFBFBD><EFBFBD>̗v<EFBFBD>f<EFBFBD>͐<EFBFBD><EFBFBD>̂Ă<EFBFBD><EFBFBD>B
|
|
|
|
|
<EFBFBD>z<EFBFBD><EFBFBD><EFBFBD>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD>łȂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Anum - 1 <EFBFBD><EFBFBD> nil <EFBFBD><EFBFBD><EFBFBD>ςށB
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> flag <EFBFBD><EFBFBD><EFBFBD>^<EFBFBD>Ȃ<EFBFBD><EFBFBD>A<EFBFBD>c<EFBFBD><EFBFBD><EFBFBD>v<EFBFBD>f<EFBFBD>̔z<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ς<EFBFBD>
|
2007-08-23 03:10:56 -04:00
|
|
|
|
flag: 0x01 - <EFBFBD>Ō<EFBFBD><EFBFBD><EFBFBD><EFBFBD>z<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
flag: 0x02 - postarg <EFBFBD>p
|
|
|
|
|
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
|
* 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
|
|
|
|
@j <EFBFBD><EFBFBD><EFBFBD>̔z<EFBFBD><EFBFBD> ary1, ary2 <EFBFBD><EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>փv<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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
|
2007-12-01 00:20:06 -05:00
|
|
|
|
@j <EFBFBD>z<EFBFBD><EFBFBD> ary <EFBFBD>ɑ<EFBFBD><EFBFBD><EFBFBD> to_a <EFBFBD><EFBFBD><EFBFBD>Ăяo<EFBFBD><EFBFBD><EFBFBD>B
|
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
|
* 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
|
|
|
|
@j <EFBFBD>z<EFBFBD><EFBFBD> ary <EFBFBD>ɗv<EFBFBD>f obj <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><EFBFBD>邩<EFBFBD>ǂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>`<EFBFBD>F<EFBFBD>b<EFBFBD>N<EFBFBD>Bcase/when <EFBFBD>ŗ<EFBFBD><EFBFBD>p<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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.
|
* 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
|
|
|
|
@j <EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>n<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>g<EFBFBD>b<EFBFBD>v<EFBFBD><EFBFBD> n <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>l<EFBFBD>Ƃ<EFBFBD><EFBFBD>Đ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
n <EFBFBD>̓L<EFBFBD>[<EFBFBD>ƒl<EFBFBD>̃y<EFBFBD>A<EFBFBD>Ȃ̂<EFBFBD> 2 <EFBFBD>̔{<EFBFBD><EFBFBD><EFBFBD>łȂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȃ<EFBFBD><EFBFBD>Ȃ<EFBFBD><EFBFBD>B
|
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))
|
* 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
|
|
|
|
@j Range.new(low, high, flag) <EFBFBD>̂悤<EFBFBD>ȃI<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>Ƀv<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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.
|
|
|
|
|
@j <EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>|<EFBFBD>b<EFBFBD>v<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
pop
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
val = val;
|
|
|
|
|
/* none */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
|
|
|
|
@e duplicate stack top.
|
* 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
|
|
|
|
@j <EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>g<EFBFBD>b<EFBFBD>v<EFBFBD><EFBFBD><EFBFBD>R<EFBFBD>s<EFBFBD>[<EFBFBD><EFBFBD><EFBFBD>ăX<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>Ƀv<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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
|
* 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
|
|
|
|
@j <EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>g<EFBFBD>b<EFBFBD>v<EFBFBD><EFBFBD> n <EFBFBD><EFBFBD><EFBFBD>R<EFBFBD>s<EFBFBD>[<EFBFBD><EFBFBD><EFBFBD>ăX<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>Ƀv<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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
|
* 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
|
|
|
|
@j <EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>g<EFBFBD>b<EFBFBD>v<EFBFBD><EFBFBD> 2 <EFBFBD>̒l<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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.
|
|
|
|
|
@j <EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>L<EFBFBD><EFBFBD><EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD>O<EFBFBD>̏<EFBFBD><EFBFBD>Ԃ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>邽<EFBFBD>߂ɕK<EFBFBD>v<EFBFBD>Ȗ<EFBFBD><EFBFBD>߁B
|
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
|
* 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
|
|
|
|
@j <EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>g<EFBFBD>b<EFBFBD>v<EFBFBD><EFBFBD><EFBFBD><EFBFBD> n <EFBFBD>ڂ<EFBFBD><EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>Ƀv<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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
|
|
|
|
|
@j <EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>g<EFBFBD>b<EFBFBD>v<EFBFBD>̒l<EFBFBD><EFBFBD> n <EFBFBD>ڂ̃X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>ɃR<EFBFBD>s<EFBFBD>[
|
|
|
|
|
*/
|
|
|
|
|
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
|
* 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
|
|
|
|
@j current stack <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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?
|
* 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
|
|
|
|
@j defined? <EFBFBD><EFBFBD><EFBFBD>s<EFBFBD><EFBFBD><EFBFBD>B
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
defined
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(rb_num_t 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;
|
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:
|
* 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
|
|
|
|
if (rb_cvar_defined(klass, SYM2ID(obj))) {
|
|
|
|
|
expr_type = "class variable";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
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:{
|
2009-12-04 03:34:16 -05:00
|
|
|
|
rb_iseq_t *ip = GET_ISEQ();
|
|
|
|
|
while (ip) {
|
|
|
|
|
if (ip->defined_method_id) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
ip = ip->parent_iseq;
|
|
|
|
|
}
|
|
|
|
|
if (ip) {
|
|
|
|
|
VALUE klass = vm_search_normal_superclass(ip->klass, GET_SELF());
|
|
|
|
|
if (rb_method_boundp(klass, ip->defined_method_id, 0)) {
|
|
|
|
|
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
|
* 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
|
|
|
|
@j trace <EFBFBD>p<EFBFBD>̖<EFBFBD><EFBFBD>߁B
|
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.
|
* 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
|
|
|
|
@j <EFBFBD>N<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD><EFBFBD><EFBFBD>`<EFBFBD>X<EFBFBD>R<EFBFBD>[<EFBFBD>v<EFBFBD>ֈڍs<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> super <EFBFBD><EFBFBD> Qfalse <EFBFBD><EFBFBD> klass<EFBFBD>N<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>`<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ē<EFBFBD><EFBFBD>`<EFBFBD>ł<EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>łȂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Aklass <EFBFBD>N<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>`<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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) {
|
|
|
|
|
case 0:
|
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);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
if (rb_const_defined_at(cbase, id)) {
|
|
|
|
|
/* already exist */
|
|
|
|
|
klass = rb_const_get_at(cbase, id);
|
|
|
|
|
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;
|
|
|
|
|
case 2:
|
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 */
|
|
|
|
|
if (rb_const_defined_at(cbase, id)) {
|
|
|
|
|
klass = rb_const_get_at(cbase, id);
|
|
|
|
|
/* 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
|
* 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
|
|
|
|
@j <EFBFBD><EFBFBD><EFBFBD>\<EFBFBD>b<EFBFBD>h<EFBFBD>Ăяo<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>s<EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
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;
|
* 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 num = caller_setup_args(th, GET_CFP(), op_flag, (int)op_argc,
|
|
|
|
|
(rb_iseq_t *)blockiseq, &blockptr);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
rb_num_t flag = op_flag;
|
|
|
|
|
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
|
* 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
|
|
|
|
@j super <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>s<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
super(args) # args.size => num
|
|
|
|
|
flag <EFBFBD><EFBFBD><EFBFBD>I<EFBFBD>y<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>h<EFBFBD>̈Ӗ<EFBFBD><EFBFBD><EFBFBD> send <EFBFBD>Ɠ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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;
|
* 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 num = caller_setup_args(th, GET_CFP(), op_flag,
|
|
|
|
|
(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
|
|
|
|
VALUE flag = VM_CALL_SUPER_BIT | VM_CALL_FCALL_BIT;
|
|
|
|
|
const rb_method_entry_t *me;
|
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
|
* 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
|
|
|
|
@j yield <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>s<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
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.
|
|
|
|
|
@j <EFBFBD><EFBFBD><EFBFBD>̃X<EFBFBD>R<EFBFBD>[<EFBFBD>v<EFBFBD><EFBFBD><EFBFBD>甲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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
|
* 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
|
|
|
|
@j VM loop <EFBFBD><EFBFBD><EFBFBD>甲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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
|
* 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
|
|
|
|
@j <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>W<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>v<EFBFBD><EFBFBD><EFBFBD>s<EFBFBD><EFBFBD><EFBFBD>B
|
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).
|
|
|
|
|
@j PC <EFBFBD><EFBFBD> (PC + dst) <EFBFBD>ɂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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).
|
|
|
|
|
@j <EFBFBD><EFBFBD><EFBFBD><EFBFBD> val <EFBFBD><EFBFBD> false <EFBFBD><EFBFBD> nil <EFBFBD>łȂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>APC <EFBFBD><EFBFBD> (PC + dst) <EFBFBD>ɂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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).
|
|
|
|
|
@j <EFBFBD><EFBFBD><EFBFBD><EFBFBD> val <EFBFBD><EFBFBD> false <EFBFBD><EFBFBD> nil <EFBFBD>Ȃ<EFBFBD><EFBFBD>APC <EFBFBD><EFBFBD> (PC + dst) <EFBFBD>ɂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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
|
* 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
|
|
|
|
@j <EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD>L<EFBFBD><EFBFBD><EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>L<EFBFBD><EFBFBD><EFBFBD>Ȃ<EFBFBD><EFBFBD>A<EFBFBD>l<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>^<EFBFBD>b<EFBFBD>N<EFBFBD>Ƀv<EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> dst <EFBFBD>փW<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>v<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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)
|
* 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
|
|
|
|
@j once <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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
|
* 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
|
|
|
|
@j <EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD>L<EFBFBD><EFBFBD><EFBFBD>b<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD>̒l<EFBFBD><EFBFBD><EFBFBD>ݒ肷<EFBFBD><EFBFBD><EFBFBD>B
|
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
|
* 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
|
|
|
|
@j case <EFBFBD><EFBFBD><EFBFBD>ŁA<EFBFBD>\<EFBFBD>Ȃ<EFBFBD><EFBFBD>\<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŃW<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>v<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
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:
|
|
|
|
|
if (BASIC_OP_UNREDEFINED_P(BOP_EQQ)) {
|
|
|
|
|
VALUE val;
|
|
|
|
|
if (st_lookup(RHASH_TBL(hash), key, &val)) {
|
|
|
|
|
JUMP(FIX2INT(val));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
JUMP(else_offset);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
2010-09-09 09:40:14 -04:00
|
|
|
|
default: { /* fall through (else) */
|
2009-11-17 02:26:26 -05:00
|
|
|
|
struct opt_case_dispatch_i_arg arg;
|
2009-08-12 01:55:06 -04:00
|
|
|
|
|
2009-11-17 02:26:26 -05:00
|
|
|
|
arg.obj = key;
|
|
|
|
|
arg.label = -1;
|
2009-08-13 03:31:23 -04:00
|
|
|
|
st_foreach(RHASH_TBL(hash), opt_case_dispatch_i, (st_data_t)&arg);
|
2009-08-12 01:55:06 -04:00
|
|
|
|
|
|
|
|
|
if (arg.label != -1) {
|
|
|
|
|
JUMP(arg.label);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
JUMP(else_offset);
|
|
|
|
|
}
|
2010-09-09 09:40:14 -04:00
|
|
|
|
}
|
2009-08-12 01:55:06 -04:00
|
|
|
|
}
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e check environment
|
* 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
|
|
|
|
@j <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̊g<EFBFBD><EFBFBD><EFBFBD>p<EFBFBD>B
|
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.
|
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ X+Y<EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_PLUS)) {
|
|
|
|
|
/* 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 &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_PLUS)) {
|
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 &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_PLUS)) {
|
|
|
|
|
val = rb_str_plus(recv, obj);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cArray &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_PLUS)) {
|
|
|
|
|
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.
|
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ X-Y<EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_MINUS)) {
|
|
|
|
|
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 &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_MINUS)) {
|
|
|
|
|
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.
|
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ X*Y<EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_MULT)) {
|
|
|
|
|
long a, b, c;
|
|
|
|
|
|
|
|
|
|
a = FIX2LONG(recv);
|
|
|
|
|
if (a == 0) {
|
|
|
|
|
val = recv;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
b = FIX2LONG(obj);
|
|
|
|
|
c = a * b;
|
|
|
|
|
|
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 &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_MULT)) {
|
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.
|
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ X/Y<EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_DIV)) {
|
|
|
|
|
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 &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_DIV)) {
|
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.
|
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ X%Y<EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_MOD)) {
|
|
|
|
|
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 &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_MOD)) {
|
* 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.
|
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ X==Y<EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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.
|
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ X!=Y<EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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.
|
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ X<Y<EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LT)) {
|
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 &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LT)) {
|
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.
|
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ X<=Y<EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LE)) {
|
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.
|
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ X>Y<EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_GT)) {
|
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 &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_GT)) {
|
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.
|
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ X>=Y<EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_GE)) {
|
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 <<
|
* 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
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ X<<Y<EFBFBD>B
|
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 &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LTLT)) {
|
|
|
|
|
val = rb_str_concat(recv, obj);
|
|
|
|
|
}
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cArray &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LTLT)) {
|
|
|
|
|
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 []
|
* 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
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ recv[obj]<EFBFBD>B
|
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)
|
|
|
|
|
{
|
|
|
|
|
if (!SPECIAL_CONST_P(recv) && BASIC_OP_UNREDEFINED_P(BOP_AREF)) {
|
|
|
|
|
if (HEAP_CLASS_OF(recv) == rb_cArray && FIXNUM_P(obj)) {
|
|
|
|
|
val = rb_ary_entry(recv, FIX2LONG(obj));
|
|
|
|
|
}
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cHash) {
|
|
|
|
|
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
|
* 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
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ recv[obj] = set<EFBFBD>B
|
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)
|
|
|
|
|
{
|
|
|
|
|
if (!SPECIAL_CONST_P(recv) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_ASET)) {
|
|
|
|
|
if (HEAP_CLASS_OF(recv) == rb_cArray && FIXNUM_P(obj)) {
|
|
|
|
|
rb_ary_store(recv, FIX2LONG(obj), set);
|
|
|
|
|
val = set;
|
|
|
|
|
}
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cHash) {
|
|
|
|
|
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
|
* 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
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ recv.length()<EFBFBD>B
|
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)
|
|
|
|
|
{
|
2009-09-06 04:39:57 -04:00
|
|
|
|
if (LIKELY(!SPECIAL_CONST_P(recv) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LENGTH))) {
|
2007-08-25 04:54:29 -04:00
|
|
|
|
if (HEAP_CLASS_OF(recv) == rb_cString) {
|
|
|
|
|
val = rb_str_length(recv);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
2007-08-25 04:54:29 -04:00
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cArray) {
|
|
|
|
|
val = LONG2NUM(RARRAY_LEN(recv));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cHash) {
|
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
|
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ recv.size()<EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
if (LIKELY(BASIC_OP_UNREDEFINED_P(BOP_SIZE) &&
|
|
|
|
|
!SPECIAL_CONST_P(recv))) {
|
|
|
|
|
if (HEAP_CLASS_OF(recv) == rb_cString) {
|
|
|
|
|
val = rb_str_length(recv);
|
|
|
|
|
}
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cArray) {
|
|
|
|
|
val = LONG2NUM(RARRAY_LEN(recv));
|
|
|
|
|
}
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cHash) {
|
|
|
|
|
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
|
* 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
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ recv.succ()<EFBFBD>B
|
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) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_SUCC)) {
|
|
|
|
|
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 &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_SUCC)) {
|
|
|
|
|
val = rb_str_succ(recv);
|
|
|
|
|
}
|
|
|
|
|
else if (HEAP_CLASS_OF(recv) == rb_cTime &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_SUCC)) {
|
|
|
|
|
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
|
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ recv.!()<EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
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
|
* 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
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ<EFBFBD><EFBFBD><EFBFBD>K<EFBFBD>\<EFBFBD><EFBFBD><EFBFBD>}<EFBFBD>b<EFBFBD>`<EFBFBD>B
|
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
|
|
|
|
|
@j <EFBFBD>œK<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ<EFBFBD><EFBFBD><EFBFBD>K<EFBFBD>\<EFBFBD><EFBFBD><EFBFBD>}<EFBFBD>b<EFBFBD>` 2
|
|
|
|
|
*/
|
|
|
|
|
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
|
* 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
|
|
|
|
@j <EFBFBD>l<EFBFBD>C<EFBFBD>e<EFBFBD>B<EFBFBD>u<EFBFBD>R<EFBFBD><EFBFBD><EFBFBD>p<EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\<EFBFBD>b<EFBFBD>h<EFBFBD><EFBFBD><EFBFBD>N<EFBFBD><EFBFBD><EFBFBD>B
|
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
|
* 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
|
|
|
|
@j <EFBFBD>l<EFBFBD><EFBFBD><EFBFBD>A<EFBFBD>F<EFBFBD><EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD>ׂĂ̓<EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
answer
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
(VALUE ret)
|
|
|
|
|
{
|
|
|
|
|
ret = INT2FIX(42);
|
|
|
|
|
}
|
|
|
|
|
|