2011-09-05 16:02:30 +04:00
|
|
|
|
/** ##skip -*- mode:c; style:ruby; coding: utf-8 -*-
|
2007-01-16 11:52:22 +03:00
|
|
|
|
insns.def - YARV instruction definitions
|
|
|
|
|
|
|
|
|
|
$Author: $
|
|
|
|
|
created at: 04/01/01 01:17:55 JST
|
|
|
|
|
|
* blockinlining.c, compile.c, compile.h, debug.c, debug.h,
id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
copyright year.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-14 01:13:04 +03:00
|
|
|
|
Copyright (C) 2004-2007 Koichi Sasada
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** ##skip
|
|
|
|
|
instruction comment
|
|
|
|
|
@c: category
|
|
|
|
|
@e: english description
|
|
|
|
|
@j: japanese description
|
|
|
|
|
|
|
|
|
|
instruction form:
|
|
|
|
|
DEFINE_INSN
|
2010-08-02 19:53:48 +04:00
|
|
|
|
instruction_name
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(instruction_operands, ..)
|
|
|
|
|
(pop_values, ..)
|
|
|
|
|
(return value)
|
|
|
|
|
{
|
|
|
|
|
.. // insn body
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c nop
|
|
|
|
|
@e nop
|
|
|
|
|
@j nop
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
nop
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
/* none */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with variables */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2012-10-04 17:52:20 +04:00
|
|
|
|
@e Get local variable (pointed by `idx' and `level').
|
|
|
|
|
'level' indicates the nesting depth from the current block.
|
|
|
|
|
@j level, idx で指定されたローカル変数の値をスタックに置く。
|
|
|
|
|
level はブロックのネストレベルで、何段上かを示す。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getlocal
|
2012-10-04 17:52:20 +04:00
|
|
|
|
(lindex_t idx, rb_num_t level)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = *(vm_get_ep(GET_EP(), level) - idx);
|
2017-05-31 09:46:57 +03:00
|
|
|
|
RB_DEBUG_COUNTER_INC(lvar_get);
|
|
|
|
|
(void)RB_DEBUG_COUNTER_INC_IF(lvar_get_dynamic, level > 0);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2012-10-04 17:52:20 +04:00
|
|
|
|
@e Set a local variable (pointed to by 'idx') as val.
|
|
|
|
|
'level' indicates the nesting depth from the current block.
|
|
|
|
|
@j level, idx で指定されたローカル変数の値を val にする。
|
|
|
|
|
level はブロックのネストレベルで、何段上かを示す。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setlocal
|
2012-10-04 17:52:20 +04:00
|
|
|
|
(lindex_t idx, rb_num_t level)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
vm_env_write(vm_get_ep(GET_EP(), level), -(int)idx, val);
|
2017-05-31 09:46:57 +03:00
|
|
|
|
RB_DEBUG_COUNTER_INC(lvar_set);
|
|
|
|
|
(void)RB_DEBUG_COUNTER_INC_IF(lvar_set_dynamic, level > 0);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-24 14:13:49 +03:00
|
|
|
|
/**
|
|
|
|
|
@c variable
|
|
|
|
|
@e Get a block parameter.
|
|
|
|
|
@j ブロックパラメータを取得する。
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getblockparam
|
|
|
|
|
(lindex_t idx, rb_num_t level)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
const VALUE *ep = vm_get_ep(GET_EP(), level);
|
|
|
|
|
VM_ASSERT(VM_ENV_LOCAL_P(ep));
|
|
|
|
|
|
|
|
|
|
if (!VM_ENV_FLAGS(ep, VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM)) {
|
2017-10-27 09:21:50 +03:00
|
|
|
|
val = rb_vm_bh_to_procval(ec, VM_ENV_BLOCK_HANDLER(ep));
|
2017-10-24 14:13:49 +03:00
|
|
|
|
vm_env_write(ep, -(int)idx, val);
|
|
|
|
|
VM_ENV_FLAGS_SET(ep, VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
val = *(ep - idx);
|
|
|
|
|
RB_DEBUG_COUNTER_INC(lvar_get);
|
|
|
|
|
(void)RB_DEBUG_COUNTER_INC_IF(lvar_get_dynamic, level > 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
|
|
|
|
@e Set block parameter.
|
|
|
|
|
@j ブロックパラメータを設定する。
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setblockparam
|
|
|
|
|
(lindex_t idx, rb_num_t level)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
const VALUE *ep = vm_get_ep(GET_EP(), level);
|
|
|
|
|
VM_ASSERT(VM_ENV_LOCAL_P(ep));
|
|
|
|
|
|
|
|
|
|
vm_env_write(ep, -(int)idx, val);
|
|
|
|
|
RB_DEBUG_COUNTER_INC(lvar_set);
|
|
|
|
|
(void)RB_DEBUG_COUNTER_INC_IF(lvar_set_dynamic, level > 0);
|
|
|
|
|
|
|
|
|
|
VM_ENV_FLAGS_SET(ep, VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM);
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 15:30:51 +04:00
|
|
|
|
@e Get value of special local variable ($~, $_, ..).
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 特殊なローカル変数($~, $_, ...)の値を得る。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getspecial
|
2012-12-10 10:11:16 +04:00
|
|
|
|
(rb_num_t key, rb_num_t type)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2017-10-27 09:21:50 +03:00
|
|
|
|
val = vm_getspecial(ec, GET_LEP(), key, type);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 15:30:51 +04:00
|
|
|
|
@e Set value of special local variable ($~, $_, ...) to obj.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 特別なローカル変数($~, $_, ...)の値を設定する。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setspecial
|
2012-12-10 10:11:16 +04:00
|
|
|
|
(rb_num_t key)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE obj)
|
|
|
|
|
()
|
|
|
|
|
{
|
2017-10-27 09:21:50 +03:00
|
|
|
|
lep_svar_set(ec, GET_LEP(), key, obj);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 15:30:51 +04:00
|
|
|
|
@e Get value of instance variable id of self.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j self のインスタンス変数 id の値を得る。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getinstancevariable
|
2009-07-13 08:44:20 +04:00
|
|
|
|
(ID id, IC ic)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2012-10-16 21:07:23 +04:00
|
|
|
|
val = vm_getinstancevariable(GET_SELF(), id, ic);
|
2007-02-04 22:17:33 +03:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 15:30:51 +04:00
|
|
|
|
@e Set value of instance variable id of self to val.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j self のインスタンス変数 id を val にする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setinstancevariable
|
2009-09-06 11:40:24 +04:00
|
|
|
|
(ID id, IC ic)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
2012-10-16 21:07:23 +04:00
|
|
|
|
vm_setinstancevariable(GET_SELF(), id, val, ic);
|
2007-02-04 22:17:33 +03:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 15:30:51 +04:00
|
|
|
|
@e Get value of class variable id of klass as val.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 現在のスコープのクラス変数 id の値を得る。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getclassvariable
|
|
|
|
|
(ID id)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2015-03-09 00:22:43 +03:00
|
|
|
|
val = rb_cvar_get(vm_get_cvar_base(rb_vm_get_cref(GET_EP()), GET_CFP()), id);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
2011-11-05 15:30:51 +04:00
|
|
|
|
@e Set value of class variable id of klass as val.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j klass のクラス変数 id を val にする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setclassvariable
|
2007-02-04 22:15:38 +03:00
|
|
|
|
(ID id)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
2016-09-08 07:44:51 +03:00
|
|
|
|
vm_ensure_not_refinement_module(GET_SELF());
|
2015-03-09 00:22:43 +03:00
|
|
|
|
rb_cvar_set(vm_get_cvar_base(rb_vm_get_cref(GET_EP()), GET_CFP()), id, val);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
|
|
|
|
@e
|
2011-11-05 15:30:51 +04:00
|
|
|
|
Get constant variable id. If klass is Qnil, constants
|
|
|
|
|
are searched in the current scope. If klass is Qfalse, constants
|
|
|
|
|
are searched as top level constants. Otherwise, get constant under klass
|
2007-01-16 11:52:22 +03:00
|
|
|
|
class or module.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 定数 id の値を得る。
|
|
|
|
|
klass が Qnil なら、そのスコープで得られる定数の値を得る。
|
|
|
|
|
Qfalse なら、トップレベルスコープを得る。
|
|
|
|
|
それ以外なら、klass クラスの下の定数を得る。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getconstant
|
|
|
|
|
(ID id)
|
|
|
|
|
(VALUE klass)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2017-10-27 09:21:50 +03:00
|
|
|
|
val = vm_get_ev_const(ec, klass, id, 0);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
|
|
|
|
@e
|
2011-11-05 15:30:51 +04:00
|
|
|
|
Set constant variable id. If klass is Qfalse, constant
|
2007-01-16 11:52:22 +03:00
|
|
|
|
is able to access in this scope. if klass is Qnil, set
|
|
|
|
|
top level constant. otherwise, set constant under klass
|
|
|
|
|
class or module.
|
|
|
|
|
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 定数 id の値を val にする。
|
|
|
|
|
klass が Qfalse なら、そのスコープで得られる定数 id の値を設定する。
|
|
|
|
|
Qnil なら、トップレベルスコープの値を設定する。
|
|
|
|
|
それ以外なら、klass クラスの下の定数を設定する。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setconstant
|
|
|
|
|
(ID id)
|
2008-05-14 06:31:28 +04:00
|
|
|
|
(VALUE val, VALUE cbase)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
()
|
|
|
|
|
{
|
2008-05-14 06:31:28 +04:00
|
|
|
|
vm_check_if_namespace(cbase);
|
2016-09-08 07:44:51 +03:00
|
|
|
|
vm_ensure_not_refinement_module(GET_SELF());
|
2008-05-14 06:31:28 +04:00
|
|
|
|
rb_const_set(cbase, id, val);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
|
|
|
|
@e get global variable id.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j グローバル変数 id の値を得る。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getglobal
|
|
|
|
|
(GENTRY entry)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2010-10-12 18:35:40 +04:00
|
|
|
|
val = GET_GLOBAL((VALUE)entry);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c variable
|
|
|
|
|
@e set global variable id as val.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j グローバル変数 id の値を設定する。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setglobal
|
|
|
|
|
(GENTRY entry)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
2010-10-12 18:35:40 +04:00
|
|
|
|
SET_GLOBAL((VALUE)entry, val);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with values */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
* blockinlining.c, compile.c, compile.h, debug.c, debug.h,
id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
copyright year.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-14 01:13:04 +03:00
|
|
|
|
@e put nil to stack.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j スタックに nil をプッシュする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
putnil
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
val = Qnil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e put self.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j スタックに self をプッシュする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
putself
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
val = GET_SELF();
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-14 06:31:28 +04:00
|
|
|
|
/**
|
|
|
|
|
@c put
|
2008-07-01 07:05:58 +04:00
|
|
|
|
@e put some object.
|
|
|
|
|
i.e. Fixnum, true, false, nil, and so on.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j オブジェクト val をスタックにプッシュする。
|
2008-07-01 07:05:58 +04:00
|
|
|
|
i.e. Fixnum, true, false, nil, and so on.
|
2008-05-14 06:31:28 +04:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
2008-07-01 07:05:58 +04:00
|
|
|
|
putobject
|
|
|
|
|
(VALUE val)
|
2008-05-14 06:31:28 +04:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2008-07-01 07:05:58 +04:00
|
|
|
|
/* */
|
2008-05-14 06:31:28 +04:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/**
|
|
|
|
|
@c put
|
2008-07-01 07:05:58 +04:00
|
|
|
|
@e put special object. "value_type" is for expansion.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 特別なオブジェクト val をスタックにプッシュする。
|
|
|
|
|
オブジェクトの種類は value_type による.
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
2008-07-01 07:05:58 +04:00
|
|
|
|
putspecialobject
|
|
|
|
|
(rb_num_t value_type)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
enum vm_special_object_type type;
|
|
|
|
|
|
|
|
|
|
type = (enum vm_special_object_type)value_type;
|
|
|
|
|
val = vm_get_special_object(GET_EP(), type);
|
2008-07-01 07:05:58 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e put iseq value.
|
2016-01-10 05:07:00 +03:00
|
|
|
|
@j iseq をスタックにプッシュする。
|
2008-07-01 07:05:58 +04:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
putiseq
|
|
|
|
|
(ISEQ iseq)
|
|
|
|
|
()
|
|
|
|
|
(VALUE ret)
|
|
|
|
|
{
|
2015-07-22 01:52:59 +03:00
|
|
|
|
ret = (VALUE)iseq;
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e put string val. string will be copied.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 文字列をコピーしてスタックにプッシュする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
putstring
|
2007-07-02 16:49:35 +04:00
|
|
|
|
(VALUE str)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2009-02-18 08:33:36 +03:00
|
|
|
|
val = rb_str_resurrect(str);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e put concatenate strings
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j スタックトップの文字列を n 個連結し,結果をスタックにプッシュする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
concatstrings
|
2007-05-03 13:09:14 +04:00
|
|
|
|
(rb_num_t num)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += 1 - num;
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = rb_str_concat_literals(num, STACK_ADDR_FROM_TOP(num));
|
2007-01-16 11:52:22 +03:00
|
|
|
|
POPN(num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
2017-05-25 14:41:45 +03:00
|
|
|
|
@e push the result of to_s.
|
|
|
|
|
@j to_s の結果をスタックにプッシュする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
tostring
|
|
|
|
|
()
|
2017-09-18 05:27:13 +03:00
|
|
|
|
(VALUE val, VALUE str)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2017-09-18 05:27:13 +03:00
|
|
|
|
VALUE rb_obj_as_string_result(VALUE str, VALUE obj);
|
|
|
|
|
val = rb_obj_as_string_result(str, val);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-21 02:49:31 +03:00
|
|
|
|
/**
|
|
|
|
|
@c put
|
2016-01-10 05:07:00 +03:00
|
|
|
|
@e Freeze (dynamically) created strings. if debug_info is given, set it.
|
2015-11-21 02:49:31 +03:00
|
|
|
|
@j (埋め込み)文字列を freeze する。もし、debug_info が与えられていれば、それを設定する。
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
freezestring
|
|
|
|
|
(VALUE debug_info)
|
|
|
|
|
(VALUE str)
|
|
|
|
|
(VALUE str)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
vm_freezestring(str, debug_info);
|
2015-11-21 02:49:31 +03:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/**
|
|
|
|
|
@c put
|
2016-01-10 05:07:00 +03:00
|
|
|
|
@e compile str to Regexp and push it.
|
|
|
|
|
opt is the option for the Regexp.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 文字列 str を正規表現にコンパイルしてスタックにプッシュする。
|
|
|
|
|
コンパイル時,opt を正規表現のオプションとする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
toregexp
|
2008-01-29 11:03:51 +03:00
|
|
|
|
(rb_num_t opt, rb_num_t cnt)
|
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += 1 - cnt;
|
2007-01-16 11:52:22 +03:00
|
|
|
|
{
|
2008-01-29 11:03:51 +03:00
|
|
|
|
VALUE rb_reg_new_ary(VALUE ary, int options);
|
2017-04-20 13:32:08 +03:00
|
|
|
|
VALUE rb_ary_tmp_new_from_values(VALUE, long, const VALUE *);
|
|
|
|
|
const VALUE ary = rb_ary_tmp_new_from_values(0, cnt, STACK_ADDR_FROM_TOP(cnt));
|
2008-01-29 11:03:51 +03:00
|
|
|
|
POPN(cnt);
|
2009-06-30 11:46:44 +04:00
|
|
|
|
val = rb_reg_new_ary(ary, (int)opt);
|
2009-02-11 08:46:17 +03:00
|
|
|
|
rb_ary_clear(ary);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-18 08:16:37 +03:00
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e intern str to Symbol and push it.
|
|
|
|
|
@j 文字列 str をシンボルに変換してスタックにプッシュする。
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
intern
|
|
|
|
|
()
|
|
|
|
|
(VALUE str)
|
|
|
|
|
(VALUE sym)
|
|
|
|
|
{
|
|
|
|
|
sym = rb_str_intern(str);
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/**
|
|
|
|
|
@c put
|
2016-01-10 05:07:00 +03:00
|
|
|
|
@e put new array initialized with num values on the stack.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 新しい配列をスタック上の num 個の値で初期化して生成しプッシュする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
newarray
|
2007-05-03 13:09:14 +04:00
|
|
|
|
(rb_num_t num)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += 1 - num;
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = rb_ary_new4(num, STACK_ADDR_FROM_TOP(num));
|
2007-01-16 11:52:22 +03:00
|
|
|
|
POPN(num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e dup array
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 配列 ary を dup してスタックにプッシュする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
duparray
|
|
|
|
|
(VALUE ary)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2009-02-18 08:33:36 +03:00
|
|
|
|
val = rb_ary_resurrect(ary);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
2016-01-10 05:07:00 +03:00
|
|
|
|
@e if TOS is an array expand, expand it to num objects.
|
|
|
|
|
if the number of the array is less than num, push nils to fill.
|
|
|
|
|
if it is greater than num, exceeding elements are dropped.
|
|
|
|
|
unless TOS is an array, push num - 1 nils.
|
|
|
|
|
if flags is non-zero, push the array of the rest elements.
|
|
|
|
|
flag: 0x01 - rest args array
|
|
|
|
|
flag: 0x02 - for postarg
|
|
|
|
|
flag: 0x04 - reverse?
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j スタックトップのオブジェクトが配列であれば、それを展開する。
|
|
|
|
|
配列オブジェクトの要素数が num以下ならば、代わりに nil を積む。num以上なら、
|
|
|
|
|
num以上の要素は切り捨てる。
|
|
|
|
|
配列オブジェクトでなければ、num - 1 個の nil を積む。
|
|
|
|
|
もし flag が真なら、残り要素の配列を積む
|
|
|
|
|
flag: 0x01 - 最後を配列に
|
|
|
|
|
flag: 0x02 - postarg 用
|
2007-08-23 11:10:56 +04:00
|
|
|
|
flag: 0x04 - reverse?
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
expandarray
|
2007-05-03 13:09:14 +04:00
|
|
|
|
(rb_num_t num, rb_num_t flag)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(..., VALUE ary)
|
2008-01-23 20:17:23 +03:00
|
|
|
|
(...) // inc += num - 1 + (flag & 1 ? 1 : 0);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
{
|
2009-06-30 11:46:44 +04:00
|
|
|
|
vm_expandarray(GET_CFP(), ary, num, (int)flag);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e concat two arrays
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 二つの配列 ary1, ary2 を連結しスタックへプッシュする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
concatarray
|
|
|
|
|
()
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
(VALUE ary1, VALUE ary2)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE ary)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
ary = vm_concat_array(ary1, ary2);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
2016-01-10 05:07:00 +03:00
|
|
|
|
@e call to_a on array ary to splat
|
|
|
|
|
@j splat のために配列 ary に対して to_a を呼び出す。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
splatarray
|
|
|
|
|
(VALUE flag)
|
|
|
|
|
(VALUE ary)
|
|
|
|
|
(VALUE obj)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
obj = vm_splat_array(flag, ary);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
2016-01-10 05:07:00 +03:00
|
|
|
|
@e put new Hash from n elements. n must be an even number.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 新しいハッシュをスタックトップの n 個を初期値として生成する。
|
|
|
|
|
n はキーと値のペアなので 2 の倍数でなければならない。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
newhash
|
2007-05-03 13:09:14 +04:00
|
|
|
|
(rb_num_t num)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += 1 - num;
|
|
|
|
|
{
|
2015-10-29 08:32:57 +03:00
|
|
|
|
RUBY_DTRACE_CREATE_HOOK(HASH, num);
|
* probes.d: add DTrace probe declarations. [ruby-core:27448]
* array.c (empty_ary_alloc, ary_new): added array create DTrace probe.
* compile.c (rb_insns_name): allowing DTrace probes to access
instruction sequence name.
* Makefile.in: translate probes.d file to appropriate header file.
* common.mk: declare dependencies on the DTrace header.
* configure.in: add a test for existence of DTrace.
* eval.c (setup_exception): add a probe for when an exception is
raised.
* gc.c: Add DTrace probes for mark begin and end, and sweep begin and
end.
* hash.c (empty_hash_alloc): Add a probe for hash allocation.
* insns.def: Add probes for function entry and return.
* internal.h: function declaration for compile.c change.
* load.c (rb_f_load): add probes for `load` entry and exit, require
entry and exit, and wrapping search_required for load path search.
* object.c (rb_obj_alloc): added a probe for general object creation.
* parse.y (yycompile0): added a probe around parse and compile phase.
* string.c (empty_str_alloc, str_new): DTrace probes for string
allocation.
* test/dtrace/*: tests for DTrace probes.
* vm.c (vm_invoke_proc): add probes for function return on exception
raise, hash create, and instruction sequence execution.
* vm_core.h: add probe declarations for function entry and exit.
* vm_dump.c: add probes header file.
* vm_eval.c (vm_call0_cfunc, vm_call0_cfunc_with_frame): add probe on
function entry and return.
* vm_exec.c: expose instruction number to instruction name function.
* vm_insnshelper.c: add function entry and exit probes for cfunc
methods.
* vm_insnhelper.h: vm usage information is always collected, so
uncomment the functions.
12 19:14:50 2012 Akinori MUSHA <knu@iDaemons.org>
* configure.in (isinf, isnan): isinf() and isnan() are macros on
DragonFly which cannot be found by AC_REPLACE_FUNCS(). This
workaround enforces the fact that they exist on DragonFly.
12 15:59:38 2012 Shugo Maeda <shugo@ruby-lang.org>
* vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo),
vm_insnhelper.c (vm_search_method): revert r37616 because it's too
slow. [ruby-dev:46477]
* test/ruby/test_refinement.rb (test_inline_method_cache): skip
the test until the bug is fixed efficiently.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-13 01:52:12 +04:00
|
|
|
|
|
2017-09-05 07:48:19 +03:00
|
|
|
|
val = rb_hash_new_with_size(num / 2);
|
2017-04-24 04:40:51 +03:00
|
|
|
|
|
2017-04-27 07:21:04 +03:00
|
|
|
|
if (num) {
|
|
|
|
|
rb_hash_bulk_insert(num, STACK_ADDR_FROM_TOP(num), val);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
POPN(num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c put
|
|
|
|
|
@e put new Range object.(Range.new(low, high, flag))
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j Range.new(low, high, flag) のようなオブジェクトを生成しスタックにプッシュする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
newrange
|
2007-05-03 13:09:14 +04:00
|
|
|
|
(rb_num_t flag)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE low, VALUE high)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2009-06-30 11:46:44 +04:00
|
|
|
|
val = rb_range_new(low, high, (int)flag);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with stack operation */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
|
|
|
|
@e pop from stack.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j スタックから一つポップする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
pop
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
2011-11-27 12:24:19 +04:00
|
|
|
|
(void)val;
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/* none */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
|
|
|
|
@e duplicate stack top.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j スタックトップをコピーしてスタックにプッシュする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
dup
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
(VALUE val1, VALUE val2)
|
|
|
|
|
{
|
|
|
|
|
val1 = val2 = val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
|
|
|
|
@e duplicate stack top n elements
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j スタックトップの n 個をコピーしてスタックにプッシュする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
dupn
|
2007-05-03 13:09:14 +04:00
|
|
|
|
(rb_num_t n)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(...)
|
|
|
|
|
(...) // inc += n;
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
void *dst = GET_SP();
|
|
|
|
|
void *src = STACK_ADDR_FROM_TOP(n);
|
|
|
|
|
|
|
|
|
|
INC_SP(n); /* alloca */
|
|
|
|
|
MEMCPY(dst, src, VALUE, n);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
|
|
|
|
@e swap top 2 vals
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j スタックトップの 2 つの値を交換する。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
swap
|
|
|
|
|
()
|
|
|
|
|
(VALUE val, VALUE obj)
|
|
|
|
|
(VALUE obj, VALUE val)
|
|
|
|
|
{
|
|
|
|
|
/* none */
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-25 03:20:39 +03:00
|
|
|
|
/**
|
|
|
|
|
@c stack
|
|
|
|
|
@e reverse stack top N order.
|
|
|
|
|
@j スタックトップの n 個の値を逆転する。
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
reverse
|
|
|
|
|
(rb_num_t n)
|
|
|
|
|
(...)
|
|
|
|
|
(...) // inc += 0;
|
|
|
|
|
{
|
|
|
|
|
rb_num_t i;
|
|
|
|
|
VALUE *sp = STACK_ADDR_FROM_TOP(n);
|
|
|
|
|
|
|
|
|
|
for (i=0; i<n/2; i++) {
|
|
|
|
|
VALUE v0 = sp[i];
|
|
|
|
|
VALUE v1 = TOPN(i);
|
|
|
|
|
sp[i] = v1;
|
|
|
|
|
TOPN(i) = v0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/**
|
|
|
|
|
@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-14 01:13:04 +03:00
|
|
|
|
@e for stack caching.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j スタックキャッシングの状態を調整するために必要な命令。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
reput
|
|
|
|
|
()
|
|
|
|
|
(..., VALUE val)
|
|
|
|
|
(VALUE val) // inc += 0;
|
|
|
|
|
{
|
|
|
|
|
/* none */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
|
|
|
|
@e get nth stack value from stack top
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j スタックトップから n 個目をスタックにプッシュする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
topn
|
2007-05-03 13:09:14 +04:00
|
|
|
|
(rb_num_t n)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += 1;
|
|
|
|
|
{
|
|
|
|
|
val = TOPN(n);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
|
|
|
|
@e set Nth stack entry to stack top
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j スタックトップの値を n 個目のスタックにコピー
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setn
|
2007-05-03 13:09:14 +04:00
|
|
|
|
(rb_num_t n)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(..., VALUE val)
|
|
|
|
|
(VALUE val) // inc += 0
|
|
|
|
|
{
|
2007-06-01 08:05:46 +04:00
|
|
|
|
TOPN(n-1) = val;
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c stack
|
2015-02-16 17:44:01 +03:00
|
|
|
|
@e empty current stack
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j current stack を空にする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
2008-01-25 21:02:01 +03:00
|
|
|
|
adjuststack
|
|
|
|
|
(rb_num_t n)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(...)
|
2008-01-25 21:02:01 +03:00
|
|
|
|
(...) // inc -= n
|
2007-01-16 11:52:22 +03:00
|
|
|
|
{
|
2008-02-05 18:54:33 +03:00
|
|
|
|
DEC_SP(n);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with setting */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c setting
|
|
|
|
|
@e defined?
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j defined? を行う。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
defined
|
2010-10-31 04:42:54 +03:00
|
|
|
|
(rb_num_t op_type, VALUE obj, VALUE needstr)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE v)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2017-10-27 09:21:50 +03:00
|
|
|
|
val = vm_defined(ec, GET_CFP(), op_type, obj, needstr, v);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-08 11:52:19 +04:00
|
|
|
|
/**
|
|
|
|
|
@c setting
|
|
|
|
|
@e check `target' matches `pattern'.
|
|
|
|
|
`flag & VM_CHECKMATCH_TYPE_MASK' describe how to check pattern.
|
|
|
|
|
VM_CHECKMATCH_TYPE_WHEN: ignore target and check pattern is truthy.
|
|
|
|
|
VM_CHECKMATCH_TYPE_CASE: check `patten === target'.
|
|
|
|
|
VM_CHECKMATCH_TYPE_RESCUE: check `pattern.kind_op?(Module) && pattern == target'.
|
|
|
|
|
if `flag & VM_CHECKMATCH_ARRAY' is not 0, then `patten' is array of patterns.
|
|
|
|
|
@j see above comments.
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
checkmatch
|
|
|
|
|
(rb_num_t flag)
|
|
|
|
|
(VALUE target, VALUE pattern)
|
|
|
|
|
(VALUE result)
|
|
|
|
|
{
|
2017-11-16 09:10:31 +03:00
|
|
|
|
result = vm_check_match(ec, target, pattern, flag);
|
2012-08-08 11:52:19 +04:00
|
|
|
|
}
|
|
|
|
|
|
* rewrite method/block parameter fitting logic to optimize
keyword arguments/parameters and a splat argument.
[Feature #10440] (Details are described in this ticket)
Most of complex part is moved to vm_args.c.
Now, ISeq#to_a does not catch up new instruction format.
* vm_core.h: change iseq data structures.
* introduce rb_call_info_kw_arg_t to represent keyword arguments.
* add rb_call_info_t::kw_arg.
* rename rb_iseq_t::arg_post_len to rb_iseq_t::arg_post_num.
* rename rb_iseq_t::arg_keywords to arg_keyword_num.
* rename rb_iseq_t::arg_keyword to rb_iseq_t::arg_keyword_bits.
to represent keyword bitmap parameter index.
This bitmap parameter shows that which keyword parameters are given
or not given (0 for given).
It is refered by `checkkeyword' instruction described bellow.
* rename rb_iseq_t::arg_keyword_check to rb_iseq_t::arg_keyword_rest
to represent keyword rest parameter index.
* add rb_iseq_t::arg_keyword_default_values to represent default
keyword values.
* rename VM_CALL_ARGS_SKIP_SETUP to VM_CALL_ARGS_SIMPLE
to represent
(ci->flag & (SPLAT|BLOCKARG)) &&
ci->blockiseq == NULL &&
ci->kw_arg == NULL.
* vm_insnhelper.c, vm_args.c: rewrite with refactoring.
* rewrite splat argument code.
* rewrite keyword arguments/parameters code.
* merge method and block parameter fitting code into one code base.
* vm.c, vm_eval.c: catch up these changes.
* compile.c (new_callinfo): callinfo requires kw_arg parameter.
* compile.c (compile_array_): check the last argument Hash object or
not. If Hash object and all keys are Symbol literals, they are
compiled to keyword arguments.
* insns.def (checkkeyword): add new instruction.
This instruction check the availability of corresponding keyword.
For example, a method "def foo k1: 'v1'; end" is cimpiled to the
following instructions.
0000 checkkeyword 2, 0 # check k1 is given.
0003 branchif 9 # if given, jump to address #9
0005 putstring "v1"
0007 setlocal_OP__WC__0 3 # k1 = 'v1'
0009 trace 8
0011 putnil
0012 trace 16
0014 leave
* insns.def (opt_send_simple): removed and add new instruction
"opt_send_without_block".
* parse.y (new_args_tail_gen): reorder variables.
Before this patch, a method "def foo(k1: 1, kr1:, k2: 2, **krest, &b)"
has parameter variables "k1, kr1, k2, &b, internal_id, krest",
but this patch reorders to "kr1, k1, k2, internal_id, krest, &b".
(locate a block variable at last)
* parse.y (vtable_pop): added.
This function remove latest `n' variables from vtable.
* iseq.c: catch up iseq data changes.
* proc.c: ditto.
* class.c (keyword_error): export as rb_keyword_error().
* common.mk: depend vm_args.c for vm.o.
* hash.c (rb_hash_has_key): export.
* internal.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02 21:02:55 +03:00
|
|
|
|
/**
|
|
|
|
|
@c setting
|
|
|
|
|
@e check keywords are specified or not.
|
|
|
|
|
@j キーワードが指定されているかどうかチェックする
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
checkkeyword
|
2017-12-23 03:51:36 +03:00
|
|
|
|
(lindex_t kw_bits_index, lindex_t keyword_index)
|
* rewrite method/block parameter fitting logic to optimize
keyword arguments/parameters and a splat argument.
[Feature #10440] (Details are described in this ticket)
Most of complex part is moved to vm_args.c.
Now, ISeq#to_a does not catch up new instruction format.
* vm_core.h: change iseq data structures.
* introduce rb_call_info_kw_arg_t to represent keyword arguments.
* add rb_call_info_t::kw_arg.
* rename rb_iseq_t::arg_post_len to rb_iseq_t::arg_post_num.
* rename rb_iseq_t::arg_keywords to arg_keyword_num.
* rename rb_iseq_t::arg_keyword to rb_iseq_t::arg_keyword_bits.
to represent keyword bitmap parameter index.
This bitmap parameter shows that which keyword parameters are given
or not given (0 for given).
It is refered by `checkkeyword' instruction described bellow.
* rename rb_iseq_t::arg_keyword_check to rb_iseq_t::arg_keyword_rest
to represent keyword rest parameter index.
* add rb_iseq_t::arg_keyword_default_values to represent default
keyword values.
* rename VM_CALL_ARGS_SKIP_SETUP to VM_CALL_ARGS_SIMPLE
to represent
(ci->flag & (SPLAT|BLOCKARG)) &&
ci->blockiseq == NULL &&
ci->kw_arg == NULL.
* vm_insnhelper.c, vm_args.c: rewrite with refactoring.
* rewrite splat argument code.
* rewrite keyword arguments/parameters code.
* merge method and block parameter fitting code into one code base.
* vm.c, vm_eval.c: catch up these changes.
* compile.c (new_callinfo): callinfo requires kw_arg parameter.
* compile.c (compile_array_): check the last argument Hash object or
not. If Hash object and all keys are Symbol literals, they are
compiled to keyword arguments.
* insns.def (checkkeyword): add new instruction.
This instruction check the availability of corresponding keyword.
For example, a method "def foo k1: 'v1'; end" is cimpiled to the
following instructions.
0000 checkkeyword 2, 0 # check k1 is given.
0003 branchif 9 # if given, jump to address #9
0005 putstring "v1"
0007 setlocal_OP__WC__0 3 # k1 = 'v1'
0009 trace 8
0011 putnil
0012 trace 16
0014 leave
* insns.def (opt_send_simple): removed and add new instruction
"opt_send_without_block".
* parse.y (new_args_tail_gen): reorder variables.
Before this patch, a method "def foo(k1: 1, kr1:, k2: 2, **krest, &b)"
has parameter variables "k1, kr1, k2, &b, internal_id, krest",
but this patch reorders to "kr1, k1, k2, internal_id, krest, &b".
(locate a block variable at last)
* parse.y (vtable_pop): added.
This function remove latest `n' variables from vtable.
* iseq.c: catch up iseq data changes.
* proc.c: ditto.
* class.c (keyword_error): export as rb_keyword_error().
* common.mk: depend vm_args.c for vm.o.
* hash.c (rb_hash_has_key): export.
* internal.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02 21:02:55 +03:00
|
|
|
|
()
|
|
|
|
|
(VALUE ret)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
ret = vm_check_keyword(kw_bits_index, keyword_index, GET_EP());
|
* rewrite method/block parameter fitting logic to optimize
keyword arguments/parameters and a splat argument.
[Feature #10440] (Details are described in this ticket)
Most of complex part is moved to vm_args.c.
Now, ISeq#to_a does not catch up new instruction format.
* vm_core.h: change iseq data structures.
* introduce rb_call_info_kw_arg_t to represent keyword arguments.
* add rb_call_info_t::kw_arg.
* rename rb_iseq_t::arg_post_len to rb_iseq_t::arg_post_num.
* rename rb_iseq_t::arg_keywords to arg_keyword_num.
* rename rb_iseq_t::arg_keyword to rb_iseq_t::arg_keyword_bits.
to represent keyword bitmap parameter index.
This bitmap parameter shows that which keyword parameters are given
or not given (0 for given).
It is refered by `checkkeyword' instruction described bellow.
* rename rb_iseq_t::arg_keyword_check to rb_iseq_t::arg_keyword_rest
to represent keyword rest parameter index.
* add rb_iseq_t::arg_keyword_default_values to represent default
keyword values.
* rename VM_CALL_ARGS_SKIP_SETUP to VM_CALL_ARGS_SIMPLE
to represent
(ci->flag & (SPLAT|BLOCKARG)) &&
ci->blockiseq == NULL &&
ci->kw_arg == NULL.
* vm_insnhelper.c, vm_args.c: rewrite with refactoring.
* rewrite splat argument code.
* rewrite keyword arguments/parameters code.
* merge method and block parameter fitting code into one code base.
* vm.c, vm_eval.c: catch up these changes.
* compile.c (new_callinfo): callinfo requires kw_arg parameter.
* compile.c (compile_array_): check the last argument Hash object or
not. If Hash object and all keys are Symbol literals, they are
compiled to keyword arguments.
* insns.def (checkkeyword): add new instruction.
This instruction check the availability of corresponding keyword.
For example, a method "def foo k1: 'v1'; end" is cimpiled to the
following instructions.
0000 checkkeyword 2, 0 # check k1 is given.
0003 branchif 9 # if given, jump to address #9
0005 putstring "v1"
0007 setlocal_OP__WC__0 3 # k1 = 'v1'
0009 trace 8
0011 putnil
0012 trace 16
0014 leave
* insns.def (opt_send_simple): removed and add new instruction
"opt_send_without_block".
* parse.y (new_args_tail_gen): reorder variables.
Before this patch, a method "def foo(k1: 1, kr1:, k2: 2, **krest, &b)"
has parameter variables "k1, kr1, k2, &b, internal_id, krest",
but this patch reorders to "kr1, k1, k2, internal_id, krest, &b".
(locate a block variable at last)
* parse.y (vtable_pop): added.
This function remove latest `n' variables from vtable.
* iseq.c: catch up iseq data changes.
* proc.c: ditto.
* class.c (keyword_error): export as rb_keyword_error().
* common.mk: depend vm_args.c for vm.o.
* hash.c (rb_hash_has_key): export.
* internal.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02 21:02:55 +03:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-14 04:55:30 +03:00
|
|
|
|
/**
|
|
|
|
|
@c setting
|
2017-12-20 07:24:14 +03:00
|
|
|
|
@e fire a coverage event (currently, this is used for line coverage and branch coverage)
|
|
|
|
|
@j カバレッジイベントを trace する
|
2017-09-14 04:55:30 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
2017-12-20 07:24:14 +03:00
|
|
|
|
tracecoverage
|
2017-09-14 04:55:30 +03:00
|
|
|
|
(rb_num_t nf, VALUE data)
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
rb_event_flag_t flag = (rb_event_flag_t)nf;
|
|
|
|
|
|
2017-11-07 11:19:25 +03:00
|
|
|
|
vm_dtrace(flag, ec);
|
2017-10-29 16:19:14 +03:00
|
|
|
|
EXEC_EVENT_HOOK(ec, flag, GET_SELF(), 0, 0, 0 /* id and klass are resolved at callee */, data);
|
2017-09-14 04:55:30 +03:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with control flow 1: class/module */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c class/module
|
|
|
|
|
@e
|
2014-05-26 19:00:23 +04:00
|
|
|
|
enter class definition scope. if super is Qfalse, and class
|
2007-01-16 11:52:22 +03:00
|
|
|
|
"klass" is defined, it's redefine. otherwise, define "klass" class.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j クラス定義スコープへ移行する。
|
|
|
|
|
もし super が Qfalse で klassクラスが定義されていれば再定義である。
|
|
|
|
|
そうでなければ、klass クラスを定義する。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
defineclass
|
2012-12-20 12:13:53 +04:00
|
|
|
|
(ID id, ISEQ class_iseq, rb_num_t flags)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE cbase, VALUE super)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
VALUE klass = vm_find_or_create_class_by_id(id, flags, cbase, super);
|
2007-08-12 23:09:15 +04:00
|
|
|
|
|
2015-12-08 16:58:50 +03:00
|
|
|
|
rb_iseq_check(class_iseq);
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/* enter scope */
|
2017-10-27 09:21:50 +03:00
|
|
|
|
vm_push_frame(ec, class_iseq, VM_FRAME_MAGIC_CLASS | VM_ENV_FLAG_LOCAL, klass,
|
2016-07-28 14:02:30 +03:00
|
|
|
|
GET_BLOCK_HANDLER(),
|
2017-10-27 09:21:50 +03:00
|
|
|
|
(VALUE)vm_cref_push(ec, klass, NULL, FALSE),
|
2015-07-22 01:52:59 +03:00
|
|
|
|
class_iseq->body->iseq_encoded, GET_SP(),
|
2016-07-28 14:02:30 +03:00
|
|
|
|
class_iseq->body->local_table_size,
|
2015-12-08 16:58:50 +03:00
|
|
|
|
class_iseq->body->stack_max);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
RESTORE_REGS();
|
|
|
|
|
NEXT_INSN();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with control flow 2: method/iterator */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c method/iterator
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
@e invoke method.
|
|
|
|
|
@j メソッド呼び出しを行う。ci に必要な情報が格納されている。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
send
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc, ISEQ blockiseq)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(...)
|
2012-10-15 21:22:57 +04:00
|
|
|
|
(VALUE val) // inc += - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));
|
2007-01-16 11:52:22 +03:00
|
|
|
|
{
|
2015-09-19 20:59:58 +03:00
|
|
|
|
struct rb_calling_info calling;
|
2015-10-01 13:50:49 +03:00
|
|
|
|
|
2017-10-27 09:21:50 +03:00
|
|
|
|
vm_caller_setup_arg_block(ec, reg_cfp, &calling, ci, blockiseq, FALSE);
|
2015-09-19 20:59:58 +03:00
|
|
|
|
vm_search_method(ci, cc, calling.recv = TOPN(calling.argc = ci->orig_argc));
|
|
|
|
|
CALL_METHOD(&calling, ci, cc);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-10 01:17:06 +04:00
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_str_freeze
|
|
|
|
|
(VALUE str)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (BASIC_OP_UNREDEFINED_P(BOP_FREEZE, STRING_REDEFINED_OP_FLAG)) {
|
|
|
|
|
val = str;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
val = rb_funcall(rb_str_resurrect(str), idFreeze, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-27 09:12:37 +03:00
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_str_uminus
|
|
|
|
|
(VALUE str)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (BASIC_OP_UNREDEFINED_P(BOP_UMINUS, STRING_REDEFINED_OP_FLAG)) {
|
|
|
|
|
val = str;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
val = rb_funcall(rb_str_resurrect(str), idUMinus, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-17 15:47:31 +03:00
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_newarray_max
|
|
|
|
|
(rb_num_t num)
|
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += 1 - num;
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_newarray_max(num, STACK_ADDR_FROM_TOP(num));
|
|
|
|
|
POPN(num);
|
2016-03-17 15:47:31 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_newarray_min
|
|
|
|
|
(rb_num_t num)
|
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += 1 - num;
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_newarray_min(num, STACK_ADDR_FROM_TOP(num));
|
|
|
|
|
POPN(num);
|
2016-03-17 15:47:31 +03:00
|
|
|
|
}
|
|
|
|
|
|
2012-10-18 13:44:19 +04:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
* rewrite method/block parameter fitting logic to optimize
keyword arguments/parameters and a splat argument.
[Feature #10440] (Details are described in this ticket)
Most of complex part is moved to vm_args.c.
Now, ISeq#to_a does not catch up new instruction format.
* vm_core.h: change iseq data structures.
* introduce rb_call_info_kw_arg_t to represent keyword arguments.
* add rb_call_info_t::kw_arg.
* rename rb_iseq_t::arg_post_len to rb_iseq_t::arg_post_num.
* rename rb_iseq_t::arg_keywords to arg_keyword_num.
* rename rb_iseq_t::arg_keyword to rb_iseq_t::arg_keyword_bits.
to represent keyword bitmap parameter index.
This bitmap parameter shows that which keyword parameters are given
or not given (0 for given).
It is refered by `checkkeyword' instruction described bellow.
* rename rb_iseq_t::arg_keyword_check to rb_iseq_t::arg_keyword_rest
to represent keyword rest parameter index.
* add rb_iseq_t::arg_keyword_default_values to represent default
keyword values.
* rename VM_CALL_ARGS_SKIP_SETUP to VM_CALL_ARGS_SIMPLE
to represent
(ci->flag & (SPLAT|BLOCKARG)) &&
ci->blockiseq == NULL &&
ci->kw_arg == NULL.
* vm_insnhelper.c, vm_args.c: rewrite with refactoring.
* rewrite splat argument code.
* rewrite keyword arguments/parameters code.
* merge method and block parameter fitting code into one code base.
* vm.c, vm_eval.c: catch up these changes.
* compile.c (new_callinfo): callinfo requires kw_arg parameter.
* compile.c (compile_array_): check the last argument Hash object or
not. If Hash object and all keys are Symbol literals, they are
compiled to keyword arguments.
* insns.def (checkkeyword): add new instruction.
This instruction check the availability of corresponding keyword.
For example, a method "def foo k1: 'v1'; end" is cimpiled to the
following instructions.
0000 checkkeyword 2, 0 # check k1 is given.
0003 branchif 9 # if given, jump to address #9
0005 putstring "v1"
0007 setlocal_OP__WC__0 3 # k1 = 'v1'
0009 trace 8
0011 putnil
0012 trace 16
0014 leave
* insns.def (opt_send_simple): removed and add new instruction
"opt_send_without_block".
* parse.y (new_args_tail_gen): reorder variables.
Before this patch, a method "def foo(k1: 1, kr1:, k2: 2, **krest, &b)"
has parameter variables "k1, kr1, k2, &b, internal_id, krest",
but this patch reorders to "kr1, k1, k2, internal_id, krest, &b".
(locate a block variable at last)
* parse.y (vtable_pop): added.
This function remove latest `n' variables from vtable.
* iseq.c: catch up iseq data changes.
* proc.c: ditto.
* class.c (keyword_error): export as rb_keyword_error().
* common.mk: depend vm_args.c for vm.o.
* hash.c (rb_hash_has_key): export.
* internal.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02 21:02:55 +03:00
|
|
|
|
@e Invoke method without block
|
2017-05-08 16:14:24 +03:00
|
|
|
|
@j ブロックなしでメソッド呼び出しを行う。
|
2012-10-18 13:44:19 +04:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
* rewrite method/block parameter fitting logic to optimize
keyword arguments/parameters and a splat argument.
[Feature #10440] (Details are described in this ticket)
Most of complex part is moved to vm_args.c.
Now, ISeq#to_a does not catch up new instruction format.
* vm_core.h: change iseq data structures.
* introduce rb_call_info_kw_arg_t to represent keyword arguments.
* add rb_call_info_t::kw_arg.
* rename rb_iseq_t::arg_post_len to rb_iseq_t::arg_post_num.
* rename rb_iseq_t::arg_keywords to arg_keyword_num.
* rename rb_iseq_t::arg_keyword to rb_iseq_t::arg_keyword_bits.
to represent keyword bitmap parameter index.
This bitmap parameter shows that which keyword parameters are given
or not given (0 for given).
It is refered by `checkkeyword' instruction described bellow.
* rename rb_iseq_t::arg_keyword_check to rb_iseq_t::arg_keyword_rest
to represent keyword rest parameter index.
* add rb_iseq_t::arg_keyword_default_values to represent default
keyword values.
* rename VM_CALL_ARGS_SKIP_SETUP to VM_CALL_ARGS_SIMPLE
to represent
(ci->flag & (SPLAT|BLOCKARG)) &&
ci->blockiseq == NULL &&
ci->kw_arg == NULL.
* vm_insnhelper.c, vm_args.c: rewrite with refactoring.
* rewrite splat argument code.
* rewrite keyword arguments/parameters code.
* merge method and block parameter fitting code into one code base.
* vm.c, vm_eval.c: catch up these changes.
* compile.c (new_callinfo): callinfo requires kw_arg parameter.
* compile.c (compile_array_): check the last argument Hash object or
not. If Hash object and all keys are Symbol literals, they are
compiled to keyword arguments.
* insns.def (checkkeyword): add new instruction.
This instruction check the availability of corresponding keyword.
For example, a method "def foo k1: 'v1'; end" is cimpiled to the
following instructions.
0000 checkkeyword 2, 0 # check k1 is given.
0003 branchif 9 # if given, jump to address #9
0005 putstring "v1"
0007 setlocal_OP__WC__0 3 # k1 = 'v1'
0009 trace 8
0011 putnil
0012 trace 16
0014 leave
* insns.def (opt_send_simple): removed and add new instruction
"opt_send_without_block".
* parse.y (new_args_tail_gen): reorder variables.
Before this patch, a method "def foo(k1: 1, kr1:, k2: 2, **krest, &b)"
has parameter variables "k1, kr1, k2, &b, internal_id, krest",
but this patch reorders to "kr1, k1, k2, internal_id, krest, &b".
(locate a block variable at last)
* parse.y (vtable_pop): added.
This function remove latest `n' variables from vtable.
* iseq.c: catch up iseq data changes.
* proc.c: ditto.
* class.c (keyword_error): export as rb_keyword_error().
* common.mk: depend vm_args.c for vm.o.
* hash.c (rb_hash_has_key): export.
* internal.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02 21:02:55 +03:00
|
|
|
|
opt_send_without_block
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2012-10-18 13:44:19 +04:00
|
|
|
|
(...)
|
|
|
|
|
(VALUE val) // inc += -ci->orig_argc;
|
|
|
|
|
{
|
2015-09-19 20:59:58 +03:00
|
|
|
|
struct rb_calling_info calling;
|
2016-07-28 14:02:30 +03:00
|
|
|
|
calling.block_handler = VM_BLOCK_HANDLER_NONE;
|
2015-09-19 20:59:58 +03:00
|
|
|
|
vm_search_method(ci, cc, calling.recv = TOPN(calling.argc = ci->orig_argc));
|
|
|
|
|
CALL_METHOD(&calling, ci, cc);
|
2012-10-18 13:44:19 +04:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/**
|
|
|
|
|
@c method/iterator
|
|
|
|
|
@e super(args) # args.size => num
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
@j super を実行する。ci に必要な情報が格納されている。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
invokesuper
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc, ISEQ blockiseq)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(...)
|
2012-10-15 21:22:57 +04:00
|
|
|
|
(VALUE val) // inc += - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));
|
2007-01-16 11:52:22 +03:00
|
|
|
|
{
|
2015-09-19 20:59:58 +03:00
|
|
|
|
struct rb_calling_info calling;
|
|
|
|
|
calling.argc = ci->orig_argc;
|
|
|
|
|
|
2017-10-27 09:21:50 +03:00
|
|
|
|
vm_caller_setup_arg_block(ec, reg_cfp, &calling, ci, blockiseq, TRUE);
|
2015-09-19 20:59:58 +03:00
|
|
|
|
calling.recv = GET_SELF();
|
2017-10-27 09:21:50 +03:00
|
|
|
|
vm_search_super_method(ec, GET_CFP(), &calling, ci, cc);
|
2015-09-19 20:59:58 +03:00
|
|
|
|
CALL_METHOD(&calling, ci, cc);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c method/iterator
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
@e yield(args)
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j yield を実行する。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
invokeblock
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
(CALL_INFO ci)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(...)
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
(VALUE val) // inc += 1 - ci->orig_argc;
|
2007-01-16 11:52:22 +03:00
|
|
|
|
{
|
2015-09-19 20:59:58 +03:00
|
|
|
|
struct rb_calling_info calling;
|
|
|
|
|
calling.argc = ci->orig_argc;
|
2016-07-28 14:02:30 +03:00
|
|
|
|
calling.block_handler = VM_BLOCK_HANDLER_NONE;
|
2015-09-19 20:59:58 +03:00
|
|
|
|
calling.recv = GET_SELF();
|
|
|
|
|
|
2017-10-27 09:21:50 +03:00
|
|
|
|
val = vm_invoke_block(ec, GET_CFP(), &calling, ci);
|
2007-08-06 15:36:30 +04:00
|
|
|
|
if (val == Qundef) {
|
2007-01-16 11:52:22 +03:00
|
|
|
|
RESTORE_REGS();
|
|
|
|
|
NEXT_INSN();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c method/iterator
|
|
|
|
|
@e return from this scope.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j このスコープから抜ける。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
leave
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
|
|
|
|
if (OPT_CHECKED_RUN) {
|
2015-08-05 08:43:58 +03:00
|
|
|
|
const VALUE *const bp = vm_base_ptr(reg_cfp);
|
|
|
|
|
if (reg_cfp->sp != bp) {
|
2017-10-27 09:21:50 +03:00
|
|
|
|
vm_stack_consistency_error(ec, reg_cfp, bp);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-06 10:44:28 +03:00
|
|
|
|
RUBY_VM_CHECK_INTS(ec);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
|
2017-10-27 09:21:50 +03:00
|
|
|
|
if (vm_pop_frame(ec, GET_CFP(), GET_EP())) {
|
2007-06-27 12:21:21 +04:00
|
|
|
|
#if OPT_CALL_THREADED_CODE
|
2017-10-27 22:16:51 +03:00
|
|
|
|
rb_ec_thread_ptr(ec)->retval = val;
|
2012-08-07 15:13:57 +04:00
|
|
|
|
return 0;
|
2007-06-27 12:21:21 +04:00
|
|
|
|
#else
|
* vm_core.h: remove VM_FRAME_MAGIC_FINISH (finish frame type).
Before this commit:
`finish frame' was place holder which indicates that VM loop
needs to return function.
If a C method calls a Ruby methods (a method written by Ruby),
then VM loop will be (re-)invoked. When the Ruby method returns,
then also VM loop should be escaped. `finish frame' has only
one instruction `finish', which returns VM loop function.
VM loop function executes `finish' instruction, then VM loop
function returns itself.
With such mechanism, `leave' instruction (which returns one
frame from current scope) doesn't need to check that this `leave'
should also return from VM loop function.
Strictly, one branch can be removed from `leave' instructon.
Consideration:
However, pushing the `finish frame' needs costs because
it needs several memory accesses. The number of pushing
`finish frame' is greater than I had assumed. Of course,
pushing `finish frame' consumes additional control frame.
Moreover, recent processors has good branch prediction,
with which we can ignore such trivial checking.
After this commit:
Finally, I decide to remove `finish frame' and `finish'
instruction. Some parts of VM depend on `finish frame',
so the new frame flag VM_FRAME_FLAG_FINISH is introduced.
If this frame should escape from VM function loop, then
the result of VM_FRAME_TYPE_FINISH_P(cfp) is true.
`leave' instruction checks this flag every time.
I measured performance on it. However on my environments,
it improves some benchmarks and slows some benchmarks down.
Maybe it is because of C compiler optimization parameters.
I'll re-visit here if this cause problems.
* insns.def (leave, finish): remove finish instruction.
* vm.c, vm_eval.c, vm_exec.c, vm_backtrace.c, vm_dump.c:
apply above changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-15 14:22:34 +04:00
|
|
|
|
return val;
|
2007-06-27 12:21:21 +04:00
|
|
|
|
#endif
|
* vm_core.h: remove VM_FRAME_MAGIC_FINISH (finish frame type).
Before this commit:
`finish frame' was place holder which indicates that VM loop
needs to return function.
If a C method calls a Ruby methods (a method written by Ruby),
then VM loop will be (re-)invoked. When the Ruby method returns,
then also VM loop should be escaped. `finish frame' has only
one instruction `finish', which returns VM loop function.
VM loop function executes `finish' instruction, then VM loop
function returns itself.
With such mechanism, `leave' instruction (which returns one
frame from current scope) doesn't need to check that this `leave'
should also return from VM loop function.
Strictly, one branch can be removed from `leave' instructon.
Consideration:
However, pushing the `finish frame' needs costs because
it needs several memory accesses. The number of pushing
`finish frame' is greater than I had assumed. Of course,
pushing `finish frame' consumes additional control frame.
Moreover, recent processors has good branch prediction,
with which we can ignore such trivial checking.
After this commit:
Finally, I decide to remove `finish frame' and `finish'
instruction. Some parts of VM depend on `finish frame',
so the new frame flag VM_FRAME_FLAG_FINISH is introduced.
If this frame should escape from VM function loop, then
the result of VM_FRAME_TYPE_FINISH_P(cfp) is true.
`leave' instruction checks this flag every time.
I measured performance on it. However on my environments,
it improves some benchmarks and slows some benchmarks down.
Maybe it is because of C compiler optimization parameters.
I'll re-visit here if this cause problems.
* insns.def (leave, finish): remove finish instruction.
* vm.c, vm_eval.c, vm_exec.c, vm_backtrace.c, vm_dump.c:
apply above changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-15 14:22:34 +04:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
RESTORE_REGS();
|
|
|
|
|
}
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with control flow 3: exception */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c exception
|
|
|
|
|
@e longjump
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 大域ジャンプを行う。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
throw
|
2007-05-03 13:09:14 +04:00
|
|
|
|
(rb_num_t throw_state)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE throwobj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2017-11-06 10:44:28 +03:00
|
|
|
|
RUBY_VM_CHECK_INTS(ec);
|
2017-10-27 09:21:50 +03:00
|
|
|
|
val = vm_throw(ec, GET_CFP(), throw_state, throwobj);
|
2007-08-06 15:36:30 +04:00
|
|
|
|
THROW_EXCEPTION(val);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/* unreachable */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* deal with control flow 4: local jump */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c jump
|
|
|
|
|
@e set PC to (PC + dst).
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j PC を (PC + dst) にする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
jump
|
|
|
|
|
(OFFSET dst)
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
{
|
2017-11-06 10:44:28 +03:00
|
|
|
|
RUBY_VM_CHECK_INTS(ec);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
JUMP(dst);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c jump
|
|
|
|
|
@e if val is not false or nil, set PC to (PC + dst).
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j もし val が false か nil でなければ、PC を (PC + dst) にする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
branchif
|
|
|
|
|
(OFFSET dst)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
if (RTEST(val)) {
|
2017-11-06 10:44:28 +03:00
|
|
|
|
RUBY_VM_CHECK_INTS(ec);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
JUMP(dst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c jump
|
|
|
|
|
@e if val is false or nil, set PC to (PC + dst).
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j もし val が false か nil ならば、PC を (PC + dst) にする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
branchunless
|
|
|
|
|
(OFFSET dst)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
if (!RTEST(val)) {
|
2017-11-06 10:44:28 +03:00
|
|
|
|
RUBY_VM_CHECK_INTS(ec);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
JUMP(dst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-22 09:30:12 +03:00
|
|
|
|
/**
|
|
|
|
|
@c jump
|
|
|
|
|
@e if val is nil, set PC to (PC + dst).
|
|
|
|
|
@j もし val が nil ならば、PC を (PC + dst) にする。
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
branchnil
|
|
|
|
|
(OFFSET dst)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
if (NIL_P(val)) {
|
2017-11-06 10:44:28 +03:00
|
|
|
|
RUBY_VM_CHECK_INTS(ec);
|
2015-10-22 09:30:12 +03:00
|
|
|
|
JUMP(dst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-18 05:27:13 +03:00
|
|
|
|
/**
|
|
|
|
|
@c jump
|
|
|
|
|
@e if val is type, set PC to (PC + dst).
|
|
|
|
|
@j もし val が type ならば、PC を (PC + dst) にする。
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
branchiftype
|
|
|
|
|
(rb_num_t type, OFFSET dst)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
()
|
|
|
|
|
{
|
|
|
|
|
if (TYPE(val) == (int)type) {
|
2017-11-06 10:44:28 +03:00
|
|
|
|
RUBY_VM_CHECK_INTS(ec);
|
2017-09-18 05:27:13 +03:00
|
|
|
|
JUMP(dst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
/* for optimize */
|
|
|
|
|
/**********************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
2013-08-21 10:51:51 +04:00
|
|
|
|
@e push inline-cached value and go to dst if it is valid
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j インラインキャッシュが有効なら、値をスタックにプッシュして dst へジャンプする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
getinlinecache
|
2009-07-13 08:44:20 +04:00
|
|
|
|
(OFFSET dst, IC ic)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_ic_hit_p(ic, GET_EP());
|
|
|
|
|
if (val != Qnil) {
|
2007-01-16 11:52:22 +03:00
|
|
|
|
JUMP(dst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e set inline cache
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j インラインキャッシュの値を設定する。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
setinlinecache
|
2010-02-24 20:06:15 +03:00
|
|
|
|
(IC ic)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE val)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
vm_ic_update(ic, val, GET_EP());
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-20 21:41:13 +04:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
2013-08-21 10:51:51 +04:00
|
|
|
|
@e run iseq only once
|
2013-08-20 21:41:13 +04:00
|
|
|
|
@j once を実現する。
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
once
|
|
|
|
|
(ISEQ iseq, IC ic)
|
|
|
|
|
()
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2017-11-07 09:14:00 +03:00
|
|
|
|
val = vm_once_dispatch(ec, iseq, ic);
|
2013-08-20 21:41:13 +04:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
2013-08-21 10:51:51 +04:00
|
|
|
|
@e case dispatcher, jump by table if possible
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j case 文で、可能なら表引きでジャンプする。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_case_dispatch
|
|
|
|
|
(CDHASH hash, OFFSET else_offset)
|
|
|
|
|
(..., VALUE key)
|
|
|
|
|
() // inc += -1;
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
OFFSET dst = vm_case_dispatch(hash, else_offset, key);
|
|
|
|
|
|
|
|
|
|
if (dst) {
|
|
|
|
|
JUMP(dst);
|
2009-08-12 09:55:06 +04:00
|
|
|
|
}
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** simple functions */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X+Y.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された X+Y。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_plus
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_plus(recv, obj);
|
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2007-01-16 11:52:22 +03:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X-Y.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された X-Y。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_minus
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_minus(recv, obj);
|
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/* other */
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X*Y.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された X*Y。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_mult
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_mult(recv, obj);
|
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2007-01-16 11:52:22 +03:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X/Y.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された X/Y。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_div
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_div(recv, obj);
|
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2007-01-16 11:52:22 +03:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X%Y.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された X%Y。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_mod
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_mod(recv, obj);
|
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2007-01-16 11:52:22 +03:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X==Y.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された X==Y。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_eq
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
2015-09-19 20:59:58 +03:00
|
|
|
|
val = opt_eq_func(recv, obj, ci, cc);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
|
2007-12-18 15:07:51 +03:00
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
2007-12-18 15:07:51 +03:00
|
|
|
|
}
|
2007-01-16 11:52:22 +03:00
|
|
|
|
|
2007-12-18 15:07:51 +03:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X!=Y.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された X!=Y。
|
2007-12-18 15:07:51 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_neq
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc, CALL_INFO ci_eq, CALL_CACHE cc_eq)
|
2007-12-18 15:07:51 +03:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_neq(ci, cc, ci_eq, cc_eq, recv, obj);
|
2007-12-18 15:07:51 +03:00
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/* other */
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X<Y.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された X<Y。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_lt
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_lt(recv, obj);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2007-01-16 11:52:22 +03:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X<=Y.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された X<=Y。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_le
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_le(recv, obj);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
if (val == Qundef) {
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/* other */
|
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-21 08:46:51 +04:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X>Y.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された X>Y。
|
2007-05-21 08:46:51 +04:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_gt
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-05-21 08:46:51 +04:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_gt(recv, obj);
|
2007-05-21 08:46:51 +04:00
|
|
|
|
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2007-05-21 08:46:51 +04:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-05-21 08:46:51 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized X>=Y.
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された X>=Y。
|
2007-05-21 08:46:51 +04:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_ge
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-05-21 08:46:51 +04:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_ge(recv, obj);
|
2007-05-21 08:46:51 +04:00
|
|
|
|
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2007-05-21 08:46:51 +04:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-05-21 08:46:51 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e <<
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された X<<Y。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_ltlt
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_ltlt(recv, obj);
|
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2007-01-16 11:52:22 +03:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e []
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された recv[obj]。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_aref
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE recv, VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_aref(recv, obj);
|
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2007-01-16 11:52:22 +03:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e recv[obj] = set
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された recv[obj] = set。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_aset
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE recv, VALUE obj, VALUE set)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_aset(recv, obj, set);
|
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2007-01-16 11:52:22 +03:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(obj);
|
|
|
|
|
PUSH(set);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-10 08:54:08 +04:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e recv[str] = set
|
|
|
|
|
@j 最適化された recv[str] = set。
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_aset_with
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc, VALUE key)
|
2014-01-10 08:54:08 +04:00
|
|
|
|
(VALUE recv, VALUE val)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
VALUE tmp = vm_opt_aset_with(recv, key, val);
|
|
|
|
|
|
|
|
|
|
if (tmp != Qundef) {
|
2017-04-18 14:06:58 +03:00
|
|
|
|
val = tmp;
|
2014-01-25 07:15:30 +04:00
|
|
|
|
}
|
|
|
|
|
else {
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
/* other */
|
2014-01-10 08:54:08 +04:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(rb_str_resurrect(key));
|
|
|
|
|
PUSH(val);
|
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e recv[str]
|
|
|
|
|
@j 最適化された recv[str]。
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_aref_with
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc, VALUE key)
|
2014-01-10 08:54:08 +04:00
|
|
|
|
(VALUE recv)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_aref_with(recv, key);
|
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2014-01-10 08:54:08 +04:00
|
|
|
|
PUSH(recv);
|
|
|
|
|
PUSH(rb_str_resurrect(key));
|
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized length
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された recv.length()。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_length
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE recv)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_length(recv, BOP_LENGTH);
|
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2007-06-24 17:05:51 +04:00
|
|
|
|
PUSH(recv);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-06 12:39:57 +04:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized size
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された recv.size()。
|
2009-09-06 12:39:57 +04:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_size
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2009-09-06 12:39:57 +04:00
|
|
|
|
(VALUE recv)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_length(recv, BOP_SIZE);
|
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2009-09-06 12:39:57 +04:00
|
|
|
|
PUSH(recv);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2009-09-06 12:39:57 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-26 13:34:46 +04:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized empty?
|
|
|
|
|
@j 最適化された recv.empty?()。
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_empty_p
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2012-09-26 13:34:46 +04:00
|
|
|
|
(VALUE recv)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_empty_p(recv);
|
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2012-09-26 13:34:46 +04:00
|
|
|
|
PUSH(recv);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2012-09-26 13:34:46 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized succ
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された recv.succ()。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_succ
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE recv)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_succ(recv);
|
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2007-06-24 17:05:51 +04:00
|
|
|
|
PUSH(recv);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-18 15:07:51 +03:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized not
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された recv.!()。
|
2007-12-18 15:07:51 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_not
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-12-18 15:07:51 +03:00
|
|
|
|
(VALUE recv)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_not(ci, cc, recv);
|
2015-09-19 20:59:58 +03:00
|
|
|
|
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2007-12-18 15:07:51 +03:00
|
|
|
|
PUSH(recv);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
CALL_SIMPLE_METHOD(recv);
|
2007-12-18 15:07:51 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-01-16 11:52:22 +03:00
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized regexp match
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された正規表現マッチ。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_regexpmatch1
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
(VALUE recv)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE obj)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_regexpmatch1(recv, obj);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e optimized regexp match 2
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 最適化された正規表現マッチ 2
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
opt_regexpmatch2
|
2015-09-19 20:59:58 +03:00
|
|
|
|
(CALL_INFO ci, CALL_CACHE cc)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
(VALUE obj2, VALUE obj1)
|
|
|
|
|
(VALUE val)
|
|
|
|
|
{
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 13:58:49 +03:00
|
|
|
|
val = vm_opt_regexpmatch2(obj2, obj1);
|
|
|
|
|
|
|
|
|
|
if (val == Qundef) {
|
|
|
|
|
/* other */
|
2013-08-31 10:07:21 +04:00
|
|
|
|
PUSH(obj2);
|
|
|
|
|
PUSH(obj1);
|
|
|
|
|
CALL_SIMPLE_METHOD(obj2);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c optimize
|
|
|
|
|
@e call native compiled method
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j ネイティブコンパイルしたメソッドを起動。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
2007-06-30 22:02:24 +04:00
|
|
|
|
opt_call_c_function
|
2007-08-12 23:09:15 +04:00
|
|
|
|
(rb_insn_func_t funcptr)
|
2007-01-16 11:52:22 +03:00
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
{
|
2017-10-27 22:08:31 +03:00
|
|
|
|
reg_cfp = (funcptr)(ec, reg_cfp);
|
2007-01-16 11:52:22 +03:00
|
|
|
|
|
2007-06-30 22:02:24 +04:00
|
|
|
|
if (reg_cfp == 0) {
|
2017-10-27 09:21:50 +03:00
|
|
|
|
VALUE err = ec->errinfo;
|
|
|
|
|
ec->errinfo = Qnil;
|
2007-07-02 06:59:37 +04:00
|
|
|
|
THROW_EXCEPTION(err);
|
2007-06-30 22:02:24 +04:00
|
|
|
|
}
|
|
|
|
|
|
2007-07-02 16:49:35 +04:00
|
|
|
|
RESTORE_REGS();
|
2007-06-30 22:02:24 +04:00
|
|
|
|
NEXT_INSN();
|
2007-01-16 11:52:22 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c joke
|
|
|
|
|
@e BLT
|
|
|
|
|
@j BLT
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
bitblt
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
(VALUE ret)
|
|
|
|
|
{
|
|
|
|
|
ret = rb_str_new2("a bit of bacon, lettuce and tomato");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@c joke
|
|
|
|
|
@e The Answer to Life, the Universe, and Everything
|
2011-09-04 16:22:46 +04:00
|
|
|
|
@j 人生、宇宙、すべての答え。
|
2007-01-16 11:52:22 +03:00
|
|
|
|
*/
|
|
|
|
|
DEFINE_INSN
|
|
|
|
|
answer
|
|
|
|
|
()
|
|
|
|
|
()
|
|
|
|
|
(VALUE ret)
|
|
|
|
|
{
|
|
|
|
|
ret = INT2FIX(42);
|
|
|
|
|
}
|
|
|
|
|
|