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: $
|
|
|
|
|
$Date: $
|
|
|
|
|
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
|
|
|
|
|
instrunction_name
|
|
|
|
|
(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.
|
|
|
|
|
@j <EFBFBD><EFBFBD><EFBFBD>ʂȃ<EFBFBD><EFBFBD>[<EFBFBD>J<EFBFBD><EFBFBD><EFBFBD>ϐ<EFBFBD><EFBFBD>i$~, $_, ...<EFBFBD>j<EFBFBD>̒l<EFBFBD><EFBFBD><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)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
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)
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
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
|
* parse.y, compile.c, gc.c, insns.def, intern.h, iseq.c, node.h,
object.c, string.c, variable.c, vm_macro.def: revert private
instance variable feature, which is postponed until next major
release.
* marshal.c: TYPE_SYMBOL2 removed; MARSHAL_MINOR reverted back to
8th version.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-22 21:49:41 -05:00
|
|
|
|
(ID id)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2007-02-04 14:17:33 -05:00
|
|
|
|
val = rb_ivar_get(GET_SELF(), id);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
* parse.y, compile.c, gc.c, insns.def, intern.h, iseq.c, node.h,
object.c, string.c, variable.c, vm_macro.def: revert private
instance variable feature, which is postponed until next major
release.
* marshal.c: TYPE_SYMBOL2 removed; MARSHAL_MINOR reverted back to
8th version.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-22 21:49:41 -05:00
|
|
|
|
(ID id)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
2007-02-04 14:17:33 -05:00
|
|
|
|
rb_ivar_set(GET_SELF(), id, val);
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2007-11-25 20:31:20 -05:00
|
|
|
|
val = rb_cvar_get(vm_get_cvar_base(th, GET_ISEQ()), 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)
|
|
|
|
|
()
|
|
|
|
|
{
|
* 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
|
|
|
|
rb_cvar_set(vm_get_cvar_base(th, GET_ISEQ()), 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)
|
|
|
|
|
(VALUE val, VALUE klass)
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
if (klass == Qnil) {
|
* 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
|
|
|
|
klass = vm_get_cbase(th);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
if (NIL_P(klass)) {
|
|
|
|
|
rb_raise(rb_eTypeError, "no class/module to define constant");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (TYPE(klass)) {
|
2007-07-01 22:59:37 -04:00
|
|
|
|
case T_CLASS:
|
|
|
|
|
case T_MODULE:
|
2007-01-16 03:52:22 -05:00
|
|
|
|
break;
|
2007-07-01 22:59:37 -04:00
|
|
|
|
default: {
|
2007-06-15 02:55:36 -04:00
|
|
|
|
volatile VALUE tmp = rb_obj_as_string(klass);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
rb_raise(rb_eTypeError, "%s is not a class/module",
|
2007-06-15 02:55:36 -04:00
|
|
|
|
RSTRING_PTR(tmp));
|
2007-07-01 22:59:37 -04:00
|
|
|
|
}
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rb_const_set(klass, id, val);
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e put some object.
|
|
|
|
|
i.e. Fixnum, true, false, nil, and so on.
|
* 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>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.
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
putobject
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
/* */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e put string val. string will be copied.
|
* 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><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)
|
|
|
|
|
{
|
2007-07-02 08:49:35 -04:00
|
|
|
|
val = rb_str_new3(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;
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
VALUE v;
|
|
|
|
|
|
|
|
|
|
val = rb_str_new(0, 0);
|
|
|
|
|
for (i = num - 1; i >= 0; i--) {
|
|
|
|
|
v = TOPN(i);
|
|
|
|
|
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
|
* 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
|
|
|
|
(rb_num_t opt)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE str)
|
|
|
|
|
(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
|
|
|
|
volatile VALUE tmp = str; /* for GC */
|
* 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
|
|
|
|
val = rb_reg_new(str, opt);
|
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)
|
|
|
|
|
{
|
|
|
|
|
val = rb_ary_dup(ary);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@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)
|
2007-08-23 03:10:56 -04:00
|
|
|
|
(...) // inc += flag == 0x02 ? num : ((num > 0) ? num - 1 + (flag ? 1 : 0) : num + 1 - (flag ? 1 : 0));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
{
|
2007-08-23 03:10:56 -04:00
|
|
|
|
vm_expandarray(GET_CFP(), ary, num, 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)
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
VALUE k, v;
|
|
|
|
|
val = rb_hash_new();
|
|
|
|
|
|
|
|
|
|
for (i = num; i > 0; i -= 2) {
|
|
|
|
|
v = TOPN(i - 2);
|
|
|
|
|
k = TOPN(i - 1);
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
val = rb_range_new(low, high, flag);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* 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;
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
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
|
|
|
|
|
emptstack
|
|
|
|
|
()
|
|
|
|
|
(...)
|
|
|
|
|
(...) // inc = 0; depth = 0;
|
|
|
|
|
{
|
|
|
|
|
SET_SP(GET_CFP()->bp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with setting */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c setting
|
|
|
|
|
@e define (singleton) method id as body
|
* 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>i<EFBFBD><EFBFBD><EFBFBD>فj<EFBFBD><EFBFBD><EFBFBD>\<EFBFBD>b<EFBFBD>h id <EFBFBD><EFBFBD> body <EFBFBD>Ƃ<EFBFBD><EFBFBD>Ē<EFBFBD><EFBFBD>`<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
definemethod
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(ID id, ISEQ body, rb_num_t is_singleton)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
(VALUE obj)
|
|
|
|
|
()
|
|
|
|
|
{
|
* 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_define_method(th, obj, id, body, is_singleton,
|
|
|
|
|
get_cref(GET_ISEQ(), GET_LFP()));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c setting
|
|
|
|
|
@e make alias (if v_p is Qtrue, make valias)
|
* 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 alias <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B<EFBFBD><EFBFBD><EFBFBD><EFBFBD> v_p <EFBFBD><EFBFBD> Qtrue <EFBFBD>Ȃ<EFBFBD><EFBFBD>Avalias (global variable) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
alias
|
2007-11-26 20:02:30 -05:00
|
|
|
|
(VALUE v_p)
|
|
|
|
|
(VALUE sym1, VALUE sym2)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
VALUE klass;
|
|
|
|
|
|
|
|
|
|
if (v_p == Qtrue) {
|
2007-11-26 21:56:15 -05:00
|
|
|
|
rb_alias_variable(SYM2ID(sym1), SYM2ID(sym2));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
|
2007-11-26 20:02:30 -05:00
|
|
|
|
rb_alias(klass, SYM2ID(sym1), SYM2ID(sym2));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c setting
|
|
|
|
|
@e undef
|
* 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 undef <EFBFBD><EFBFBD><EFBFBD>s<EFBFBD><EFBFBD><EFBFBD>B
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
undef
|
|
|
|
|
()
|
2007-11-26 20:02:30 -05:00
|
|
|
|
(VALUE sym)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
VALUE klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
|
2007-11-26 20:02:30 -05:00
|
|
|
|
rb_undef(klass, SYM2ID(sym));
|
2007-01-16 03:52:22 -05:00
|
|
|
|
INC_VM_STATE_VERSION();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@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;
|
|
|
|
|
char *expr_type = 0;
|
|
|
|
|
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:
|
|
|
|
|
klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
break;
|
|
|
|
|
case DEFINED_GVAR:
|
|
|
|
|
if (rb_gvar_defined((struct global_entry *)(obj & ~1))) {
|
|
|
|
|
expr_type = "global-variable";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DEFINED_CVAR:
|
|
|
|
|
klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
|
|
|
|
|
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:{
|
|
|
|
|
VALUE klass = CLASS_OF(v);
|
|
|
|
|
NODE *method = (NODE *) rb_method_node(klass, SYM2ID(obj));
|
|
|
|
|
|
|
|
|
|
if (method) {
|
|
|
|
|
if (!(method->nd_noex & NOEX_PRIVATE)) {
|
|
|
|
|
if (!((method->nd_noex & NOEX_PROTECTED) &&
|
|
|
|
|
!rb_obj_is_kind_of(GET_SELF(),
|
|
|
|
|
rb_class_real(klass)))) {
|
|
|
|
|
expr_type = "method";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case DEFINED_YIELD:
|
|
|
|
|
if (GET_BLOCK_PTR()) {
|
|
|
|
|
expr_type = "yield";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DEFINED_ZSUPER:{
|
* 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
|
|
|
|
rb_iseq_t *ip = GET_ISEQ();
|
2007-01-16 03:52:22 -05:00
|
|
|
|
while (ip) {
|
|
|
|
|
if (ip->defined_method_id) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
ip = ip->parent_iseq;
|
|
|
|
|
}
|
|
|
|
|
if (ip) {
|
2007-11-21 20:17:52 -05:00
|
|
|
|
VALUE klass = vm_search_normal_superclass(ip->klass, GET_SELF());
|
2007-01-16 03:52:22 -05:00
|
|
|
|
if (rb_method_boundp(klass, ip->defined_method_id, 0)) {
|
|
|
|
|
expr_type = "super";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case DEFINED_REF:{
|
2007-11-26 23:43:54 -05:00
|
|
|
|
val = vm_getspecial(th, GET_LFP(), Qfalse, FIX2INT(obj));
|
|
|
|
|
if (val != Qnil) {
|
|
|
|
|
expr_type = "global-variable";
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
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 END{}
|
* 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 END{} <EFBFBD>ɑΉ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>邽<EFBFBD>߂Ƀu<EFBFBD><EFBFBD><EFBFBD>b<EFBFBD>N<EFBFBD><EFBFBD><EFBFBD>o<EFBFBD>^<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
2007-01-16 03:52:22 -05:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
postexe
|
|
|
|
|
(ISEQ blockiseq)
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
{
|
* 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
|
|
|
|
rb_block_t *blockptr;
|
2007-01-16 03:52:22 -05:00
|
|
|
|
VALUE proc;
|
|
|
|
|
|
* 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
|
|
|
|
blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(GET_CFP());
|
2007-01-16 03:52:22 -05:00
|
|
|
|
blockptr->iseq = blockiseq;
|
|
|
|
|
blockptr->proc = 0;
|
|
|
|
|
|
* 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
|
|
|
|
proc = vm_make_proc(th, GET_CFP(), blockptr);
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 00:25:46 -04:00
|
|
|
|
rb_set_end_proc(call_end_proc, proc);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@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
|
2007-05-03 05:09:14 -04:00
|
|
|
|
(rb_num_t nf)
|
2007-01-16 03:52:22 -05:00
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
{
|
2007-04-19 06:37:08 -04:00
|
|
|
|
rb_event_flag_t flag = nf;
|
|
|
|
|
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
|
|
|
|
|
2007-01-16 03:52:22 -05:00
|
|
|
|
if (cbase == Qnil) {
|
* 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
|
|
|
|
cbase = vm_get_cbase(th);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* find klass */
|
|
|
|
|
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);
|
|
|
|
|
rb_set_class_path(klass, cbase, rb_id2name(id));
|
|
|
|
|
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 */
|
|
|
|
|
if (cbase == Qnil) {
|
* 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
|
|
|
|
cbase = vm_get_cbase(th);
|
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);
|
|
|
|
|
rb_set_class_path(klass, cbase, rb_id2name(id));
|
|
|
|
|
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
|
|
|
|
|
2007-11-21 20:17:52 -05:00
|
|
|
|
COPY_CREF(class_iseq->cref_stack, vm_cref_push(th, klass, NOEX_PUBLIC));
|
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,
|
* 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
|
|
|
|
FRAME_MAGIC_CLASS, klass, (VALUE) GET_DFP() | 0x02,
|
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
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += - (op_argc + ((op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? 1 : 0));
|
|
|
|
|
{
|
2007-06-24 09:05:51 -04:00
|
|
|
|
NODE *mn;
|
* 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;
|
* 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
|
|
|
|
rb_num_t num = caller_setup_args(th, GET_CFP(), op_flag, 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);
|
* 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
|
|
|
|
mn = vm_method_search(id, klass, ic);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
|
|
|
|
|
/* send/funcall optimization */
|
2007-08-06 07:36:30 -04:00
|
|
|
|
if (flag & VM_CALL_SEND_BIT) {
|
|
|
|
|
vm_send_optimize(GET_CFP(), &mn, &flag, &num, &id, klass);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CALL_METHOD(num, blockptr, flag, id, mn, recv, klass);
|
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
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += - op_argc;
|
|
|
|
|
{
|
2007-08-06 07:36:30 -04:00
|
|
|
|
rb_block_t *blockptr = !(op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? GET_BLOCK_PTR() : 0;
|
|
|
|
|
int num = caller_setup_args(th, GET_CFP(), op_flag, op_argc, blockiseq, &blockptr);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
VALUE recv, klass;
|
|
|
|
|
NODE *mn;
|
2007-08-06 07:36:30 -04:00
|
|
|
|
ID id;
|
|
|
|
|
const VALUE flag = VM_CALL_SUPER_BIT | VM_CALL_FCALL_BIT;
|
2007-06-24 09:05:51 -04:00
|
|
|
|
|
|
|
|
|
recv = GET_SELF();
|
2007-11-21 20:17:52 -05:00
|
|
|
|
vm_search_superclass(GET_CFP(), GET_ISEQ(), recv, TOPN(num), &id, &klass);
|
2007-06-24 09:05:51 -04:00
|
|
|
|
mn = rb_method_node(klass, id);
|
|
|
|
|
|
|
|
|
|
CALL_METHOD(num, blockptr, flag, id, mn, recv, klass);
|
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) {
|
2007-06-27 04:21:21 -04:00
|
|
|
|
rb_bug("Stack consistency error (sp: %d, bp: %d)",
|
|
|
|
|
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
|
|
|
|
|
(IC ic, OFFSET dst)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (ic->ic_vmstat == GET_VM_STATE_VERSION()) {
|
|
|
|
|
val = ic->ic_value;
|
|
|
|
|
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
|
|
|
|
|
(IC ic, OFFSET dst)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (ic->ic_vmstat) {
|
|
|
|
|
val = ic->ic_value;
|
|
|
|
|
JUMP(dst);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* none */
|
|
|
|
|
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
|
|
|
|
|
(OFFSET dst)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2007-07-01 14:16:02 -04:00
|
|
|
|
IC ic = GET_CONST_INLINE_CACHE(dst);
|
2007-01-16 03:52:22 -05:00
|
|
|
|
|
|
|
|
|
ic->ic_value = val;
|
|
|
|
|
ic->ic_vmstat = GET_VM_STATE_VERSION();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@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;
|
|
|
|
|
{
|
|
|
|
|
if (0) {
|
* 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
|
|
|
|
/* TODO: if some === method is overrided */
|
2007-01-16 03:52:22 -05:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
VALUE val;
|
2007-08-29 19:12:21 -04:00
|
|
|
|
if (st_lookup(RHASH_TBL(hash), key, &val)) {
|
2007-01-16 03:52:22 -05:00
|
|
|
|
JUMP(FIX2INT(val));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
JUMP(else_offset);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@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
|
|
|
|
|
()
|
|
|
|
|
(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)) {
|
* 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
|
|
|
|
val = DOUBLE2NUM(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
|
|
|
|
|
()
|
|
|
|
|
(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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* other */
|
|
|
|
|
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
|
|
|
|
|
()
|
|
|
|
|
(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)) {
|
* 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
|
|
|
|
val = DOUBLE2NUM(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
|
|
|
|
|
()
|
|
|
|
|
(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)
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
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)) {
|
* 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
|
|
|
|
val = DOUBLE2NUM(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
|
|
|
|
|
()
|
|
|
|
|
(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;
|
|
|
|
|
}
|
* 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
|
|
|
|
val = DOUBLE2NUM(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
|
|
|
|
|
(IC ic1, IC ic2)
|
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
extern VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2);
|
|
|
|
|
NODE *mn = vm_method_search(idNeq, CLASS_OF(recv), ic1);
|
|
|
|
|
val = Qundef;
|
|
|
|
|
|
|
|
|
|
if (check_cfunc(mn, rb_obj_not_equal)) {
|
|
|
|
|
val = opt_eq_func(recv, obj, ic2);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
()
|
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (FIXNUM_2_P(recv, obj) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LT)) {
|
|
|
|
|
long a = FIX2LONG(recv), b = FIX2LONG(obj);
|
|
|
|
|
|
|
|
|
|
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, 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
|
|
|
|
|
()
|
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (FIXNUM_2_P(recv, obj) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_LE)) {
|
|
|
|
|
long a = FIX2LONG(recv), b = FIX2LONG(obj);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
()
|
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (FIXNUM_2_P(recv, obj) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_GT)) {
|
|
|
|
|
long a = FIX2LONG(recv), b = FIX2LONG(obj);
|
|
|
|
|
|
|
|
|
|
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, 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
|
|
|
|
|
()
|
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (FIXNUM_2_P(recv, obj) &&
|
|
|
|
|
BASIC_OP_UNREDEFINED_P(BOP_GE)) {
|
|
|
|
|
long a = FIX2LONG(recv), b = FIX2LONG(obj);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
()
|
|
|
|
|
(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
|
|
|
|
|
()
|
|
|
|
|
(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
|
|
|
|
|
()
|
|
|
|
|
(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
|
|
|
|
|
()
|
|
|
|
|
(VALUE recv)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (!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);
|
|
|
|
|
CALL_SIMPLE_METHOD(0, idLength, recv);
|
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
|
|
|
|
|
()
|
|
|
|
|
(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);
|
|
|
|
|
NODE *mn = vm_method_search(idNot, CLASS_OF(recv), ic);
|
|
|
|
|
|
|
|
|
|
if (check_cfunc(mn, rb_obj_not)) {
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|