summaryrefslogtreecommitdiff
path: root/insns.def
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-19 13:25:22 (GMT)
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-19 13:25:22 (GMT)
commitc86fc2bba5db7b5fc38714deeec29fd2948cc786 (patch)
treef170a966368c5e9948e10084c7488b199ca64942 /insns.def
parent33f2c8940e3bb044489fd8ec0dec2eb47ffc0b3c (diff)
mjit_compile.c: reduce sp motion on JIT
This retries r62655, which was reverted at r63863 for r63763. tool/ruby_vm/views/_mjit_compile_insn.erb: revert the revert. tool/ruby_vm/views/_mjit_compile_insn_body.erb: ditto. tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb: ditto. tool/ruby_vm/views/_mjit_compile_send.erb: ditto. tool/ruby_vm/views/mjit_compile.inc.erb: ditto. tool/ruby_vm/views/_insn_entry.erb: revert half of r63763. The commit was originally reverted since changing pc motion was bad for tracing, but changing sp motion was totally fine. For JIT, I wanna resurrect the sp motion change in r62051. tool/ruby_vm/models/bare_instructions.rb: ditto. insns.def: ditto. vm_insnhelper.c: ditto. vm_insnhelper.h: ditto. * benchmark $ benchmark-driver benchmark.yml --rbenv 'before;after;before --jit;after --jit' --repeat-count 12 -v before: ruby 2.6.0dev (2018-07-19 trunk 63998) [x86_64-linux] after: ruby 2.6.0dev (2018-07-19 add-sp 63998) [x86_64-linux] last_commit=mjit_compile.c: reduce sp motion on JIT before --jit: ruby 2.6.0dev (2018-07-19 trunk 63998) +JIT [x86_64-linux] after --jit: ruby 2.6.0dev (2018-07-19 add-sp 63998) +JIT [x86_64-linux] last_commit=mjit_compile.c: reduce sp motion on JIT Calculating ------------------------------------- before after before --jit after --jit Optcarrot Lan_Master.nes 51.354 50.238 70.010 72.139 fps Comparison: Optcarrot Lan_Master.nes after --jit: 72.1 fps before --jit: 70.0 fps - 1.03x slower before: 51.4 fps - 1.40x slower after: 50.2 fps - 1.44x slower git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'insns.def')
-rw-r--r--insns.def68
1 files changed, 15 insertions, 53 deletions
diff --git a/insns.def b/insns.def
index f048cac..da5a771 100644
--- a/insns.def
+++ b/insns.def
@@ -43,6 +43,8 @@
* sp_inc: Used to dynamically calculate sp increase in
`insn_stack_increase`.
+ * handles_frame: If it is true, VM deals with sp in the insn.
+
- Attributes can access operands, but not stack (push/pop) variables.
- An instruction's body is a pure C block, copied verbatimly into
@@ -364,7 +366,6 @@ concatstrings
// attr rb_snum_t sp_inc = 1 - num;
{
val = rb_str_concat_literals(num, STACK_ADDR_FROM_TOP(num));
- POPN(num);
}
/* push the result of to_s. */
@@ -400,7 +401,6 @@ toregexp
const VALUE ary = rb_ary_tmp_new_from_values(0, cnt, STACK_ADDR_FROM_TOP(cnt));
val = rb_reg_new_ary(ary, (int)opt);
rb_ary_clear(ary);
- POPN(cnt);
}
/* intern str to Symbol and push it. */
@@ -422,7 +422,6 @@ newarray
// attr rb_snum_t sp_inc = 1 - num;
{
val = rb_ary_new4(num, STACK_ADDR_FROM_TOP(num));
- POPN(num);
}
/* dup array */
@@ -451,7 +450,7 @@ expandarray
(...)
// attr rb_snum_t sp_inc = num - 1 + (flag & 1 ? 1 : 0);
{
- vm_expandarray(GET_CFP(), ary, num, (int)flag);
+ vm_expandarray(GET_SP(), ary, num, (int)flag);
}
/* concat two arrays */
@@ -488,7 +487,6 @@ newhash
if (num) {
rb_hash_bulk_insert(num, STACK_ADDR_FROM_TOP(num), val);
- POPN(num);
}
}
@@ -538,7 +536,6 @@ dupn
void *dst = GET_SP();
void *src = STACK_ADDR_FROM_TOP(n);
- INC_SP(n); /* alloca */
MEMCPY(dst, src, VALUE, n);
}
@@ -601,7 +598,7 @@ setn
(VALUE val)
// attr rb_snum_t sp_inc = 0;
{
- TOPN(n - 1) = val;
+ TOPN(n) = val;
}
/* empty current stack */
@@ -612,7 +609,7 @@ adjuststack
(...)
// attr rb_snum_t sp_inc = -(rb_snum_t)n;
{
- POPN(n);
+ /* none */
}
/**********************************************************/
@@ -690,6 +687,7 @@ defineclass
(ID id, ISEQ class_iseq, rb_num_t flags)
(VALUE cbase, VALUE super)
(VALUE val)
+// attr bool handles_frame = true;
{
VALUE klass = vm_find_or_create_class_by_id(id, flags, cbase, super);
@@ -716,6 +714,7 @@ send
(CALL_INFO ci, CALL_CACHE cc, ISEQ blockiseq)
(...)
(VALUE val)
+// attr bool handles_frame = true;
// attr rb_snum_t sp_inc = - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));
{
struct rb_calling_info calling;
@@ -751,7 +750,6 @@ opt_newarray_max
// attr rb_snum_t sp_inc = 1 - num;
{
val = vm_opt_newarray_max(num, STACK_ADDR_FROM_TOP(num));
- POPN(num);
}
DEFINE_INSN
@@ -762,7 +760,6 @@ opt_newarray_min
// attr rb_snum_t sp_inc = 1 - num;
{
val = vm_opt_newarray_min(num, STACK_ADDR_FROM_TOP(num));
- POPN(num);
}
/* Invoke method without block */
@@ -771,6 +768,7 @@ opt_send_without_block
(CALL_INFO ci, CALL_CACHE cc)
(...)
(VALUE val)
+// attr bool handles_frame = true;
// attr rb_snum_t sp_inc = -ci->orig_argc;
{
struct rb_calling_info calling;
@@ -785,6 +783,7 @@ invokesuper
(CALL_INFO ci, CALL_CACHE cc, ISEQ blockiseq)
(...)
(VALUE val)
+// attr bool handles_frame = true;
// attr rb_snum_t sp_inc = - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));
{
struct rb_calling_info calling;
@@ -802,6 +801,7 @@ invokeblock
(CALL_INFO ci)
(...)
(VALUE val)
+// attr bool handles_frame = true;
// attr rb_snum_t sp_inc = 1 - ci->orig_argc;
{
struct rb_calling_info calling;
@@ -828,6 +828,7 @@ leave
()
(VALUE val)
(VALUE val)
+// attr bool handles_frame = true;
{
if (OPT_CHECKED_RUN) {
const VALUE *const bp = vm_base_ptr(reg_cfp);
@@ -989,8 +990,6 @@ opt_plus
val = vm_opt_plus(recv, obj);
if (val == Qundef) {
- PUSH(recv);
- PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1008,8 +1007,6 @@ opt_minus
val = vm_opt_minus(recv, obj);
if (val == Qundef) {
- PUSH(recv);
- PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1027,8 +1024,6 @@ opt_mult
val = vm_opt_mult(recv, obj);
if (val == Qundef) {
- PUSH(recv);
- PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1046,8 +1041,6 @@ opt_div
val = vm_opt_div(recv, obj);
if (val == Qundef) {
- PUSH(recv);
- PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1065,8 +1058,6 @@ opt_mod
val = vm_opt_mod(recv, obj);
if (val == Qundef) {
- PUSH(recv);
- PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1084,8 +1075,6 @@ opt_eq
val = opt_eq_func(recv, obj, ci, cc);
if (val == Qundef) {
- PUSH(recv);
- PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1103,8 +1092,6 @@ opt_neq
val = vm_opt_neq(ci, cc, ci_eq, cc_eq, recv, obj);
if (val == Qundef) {
- PUSH(recv);
- PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1122,8 +1109,6 @@ opt_lt
val = vm_opt_lt(recv, obj);
if (val == Qundef) {
- PUSH(recv);
- PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1141,8 +1126,6 @@ opt_le
val = vm_opt_le(recv, obj);
if (val == Qundef) {
- PUSH(recv);
- PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1160,8 +1143,6 @@ opt_gt
val = vm_opt_gt(recv, obj);
if (val == Qundef) {
- PUSH(recv);
- PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1179,8 +1160,6 @@ opt_ge
val = vm_opt_ge(recv, obj);
if (val == Qundef) {
- PUSH(recv);
- PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1198,8 +1177,6 @@ opt_ltlt
val = vm_opt_ltlt(recv, obj);
if (val == Qundef) {
- PUSH(recv);
- PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1217,8 +1194,6 @@ opt_aref
val = vm_opt_aref(recv, obj);
if (val == Qundef) {
- PUSH(recv);
- PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1236,9 +1211,6 @@ opt_aset
val = vm_opt_aset(recv, obj, set);
if (val == Qundef) {
- PUSH(recv);
- PUSH(obj);
- PUSH(set);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1259,12 +1231,9 @@ opt_aset_with
val = tmp;
}
else {
- PUSH(recv);
-#ifndef MJIT_HEADER
- PUSH(rb_str_resurrect(key));
-#endif
- PUSH(val);
#ifndef MJIT_HEADER
+ TOPN(0) = rb_str_resurrect(key);
+ PUSH(val);
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@@ -1281,9 +1250,8 @@ opt_aref_with
val = vm_opt_aref_with(recv, key);
if (val == Qundef) {
- PUSH(recv);
#ifndef MJIT_HEADER
- PUSH(rb_str_resurrect(key));
+ PUSH(rb_str_resurrect(key));
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@@ -1300,7 +1268,6 @@ opt_length
val = vm_opt_length(recv, BOP_LENGTH);
if (val == Qundef) {
- PUSH(recv);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1318,7 +1285,6 @@ opt_size
val = vm_opt_length(recv, BOP_SIZE);
if (val == Qundef) {
- PUSH(recv);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1336,7 +1302,6 @@ opt_empty_p
val = vm_opt_empty_p(recv);
if (val == Qundef) {
- PUSH(recv);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1354,7 +1319,6 @@ opt_succ
val = vm_opt_succ(recv);
if (val == Qundef) {
- PUSH(recv);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1372,7 +1336,6 @@ opt_not
val = vm_opt_not(ci, cc, recv);
if (val == Qundef) {
- PUSH(recv);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1400,8 +1363,6 @@ opt_regexpmatch2
val = vm_opt_regexpmatch2(obj2, obj1);
if (val == Qundef) {
- PUSH(obj2);
- PUSH(obj1);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@@ -1415,6 +1376,7 @@ opt_call_c_function
(rb_insn_func_t funcptr)
()
()
+// attr bool handles_frame = true;
{
reg_cfp = (funcptr)(ec, reg_cfp);