[前][次][番号順一覧][スレッド一覧]

ruby-changes:49970

From: shyouhei <ko1@a...>
Date: Mon, 29 Jan 2018 16:04:57 +0900 (JST)
Subject: [ruby-changes:49970] shyouhei:r62088 (trunk): s/CALL_SIMPLE_METHOD/DISPATCH_ORIGINAL_INSN/

shyouhei	2018-01-29 16:04:50 +0900 (Mon, 29 Jan 2018)

  New Revision: 62088

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62088

  Log:
    s/CALL_SIMPLE_METHOD/DISPATCH_ORIGINAL_INSN/
    
    Now that DISPATCH_ORIGINAL_INSN is introduced, we can replace
    CALL_SIMPLE_METHOD with DISPATCH_ORIGINAL_INSN. These two macros
    differ in size very much and results in this big difference in
    compiled binary size. This changeset reduces the size of
    vm_exec_core from 32,352 bytes to 27,008 bytes on my machine.  As
    a result it yields slightly better performance.
    Closes [GH-1779].
    
    -----------------------------------------------------------
    benchmark results:
    minimum results in each 3 measurements.
    Execution time (sec)
    name    before  after
    so_ackermann     0.484  0.454
    so_array         0.837  0.779
    so_binary_trees  5.928  5.801
    so_concatenate   3.473  3.543
    so_count_words   0.201  0.222
    so_exception     0.255  0.252
    so_fannkuch      1.080  1.019
    so_fasta         1.459  1.463
    so_k_nucleotide  1.218  1.180
    so_lists         0.499  0.484
    so_mandelbrot    2.189  2.324
    so_matrix        0.510  0.496
    so_meteor_contest        3.025  2.925
    so_nbody         1.319  1.273
    so_nested_loop   0.941  0.932
    so_nsieve        1.806  1.647
    so_nsieve_bits   2.151  2.078
    so_object        0.632  0.621
    so_partial_sums  1.560  1.632
    so_pidigits      1.190  1.183
    so_random        0.333  0.353
    so_reverse_complement    0.604  0.586
    so_sieve         0.521  0.481
    so_spectralnorm  1.774  1.722
    
    Speedup ratio: compare with the result of `before' (greater is better)
    name    after
    so_ackermann    1.065
    so_array        1.075
    so_binary_trees 1.022
    so_concatenate  0.980
    so_count_words  0.903
    so_exception    1.009
    so_fannkuch     1.059
    so_fasta        0.997
    so_k_nucleotide 1.032
    so_lists        1.032
    so_mandelbrot   0.942
    so_matrix       1.028
    so_meteor_contest       1.034
    so_nbody        1.036
    so_nested_loop  1.009
    so_nsieve       1.097
    so_nsieve_bits  1.035
    so_object       1.018
    so_partial_sums 0.956
    so_pidigits     1.006
    so_random       0.943
    so_reverse_complement   1.032
    so_sieve        1.083
    so_spectralnorm 1.030

  Modified files:
    trunk/insns.def
    trunk/tool/ruby_vm/models/bare_instructions.rb
Index: insns.def
===================================================================
--- insns.def	(revision 62087)
+++ insns.def	(revision 62088)
@@ -709,6 +709,7 @@ send https://github.com/ruby/ruby/blob/trunk/insns.def#L709
 (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;
@@ -772,6 +773,7 @@ opt_send_without_block https://github.com/ruby/ruby/blob/trunk/insns.def#L773
 (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;
@@ -786,6 +788,7 @@ invokesuper https://github.com/ruby/ruby/blob/trunk/insns.def#L788
 (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;
@@ -803,6 +806,7 @@ invokeblock https://github.com/ruby/ruby/blob/trunk/insns.def#L806
 (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;
@@ -1002,10 +1006,7 @@ opt_plus https://github.com/ruby/ruby/blob/trunk/insns.def#L1006
     val = vm_opt_plus(recv, obj);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	PUSH(obj);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1019,10 +1020,7 @@ opt_minus https://github.com/ruby/ruby/blob/trunk/insns.def#L1020
     val = vm_opt_minus(recv, obj);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	PUSH(obj);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1036,10 +1034,7 @@ opt_mult https://github.com/ruby/ruby/blob/trunk/insns.def#L1034
     val = vm_opt_mult(recv, obj);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	PUSH(obj);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1053,10 +1048,7 @@ opt_div https://github.com/ruby/ruby/blob/trunk/insns.def#L1048
     val = vm_opt_div(recv, obj);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	PUSH(obj);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1070,10 +1062,7 @@ opt_mod https://github.com/ruby/ruby/blob/trunk/insns.def#L1062
     val = vm_opt_mod(recv, obj);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	PUSH(obj);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1087,10 +1076,7 @@ opt_eq https://github.com/ruby/ruby/blob/trunk/insns.def#L1076
     val = opt_eq_func(recv, obj, ci, cc);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	PUSH(obj);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1100,6 +1086,7 @@ opt_neq https://github.com/ruby/ruby/blob/trunk/insns.def#L1086
 (CALL_INFO ci, CALL_CACHE cc, CALL_INFO ci_eq, CALL_CACHE cc_eq)
 (VALUE recv, VALUE obj)
 (VALUE val)
+// attr bool handles_frame = true;
 {
     val = vm_opt_neq(ci, cc, ci_eq, cc_eq, recv, obj);
 
@@ -1121,10 +1108,7 @@ opt_lt https://github.com/ruby/ruby/blob/trunk/insns.def#L1108
     val = vm_opt_lt(recv, obj);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	PUSH(obj);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1138,10 +1122,7 @@ opt_le https://github.com/ruby/ruby/blob/trunk/insns.def#L1122
     val = vm_opt_le(recv, obj);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	PUSH(obj);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1155,10 +1136,7 @@ opt_gt https://github.com/ruby/ruby/blob/trunk/insns.def#L1136
     val = vm_opt_gt(recv, obj);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	PUSH(obj);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1172,10 +1150,7 @@ opt_ge https://github.com/ruby/ruby/blob/trunk/insns.def#L1150
     val = vm_opt_ge(recv, obj);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	PUSH(obj);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1189,10 +1164,7 @@ opt_ltlt https://github.com/ruby/ruby/blob/trunk/insns.def#L1164
     val = vm_opt_ltlt(recv, obj);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	PUSH(obj);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1206,10 +1178,7 @@ opt_aref https://github.com/ruby/ruby/blob/trunk/insns.def#L1178
     val = vm_opt_aref(recv, obj);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	PUSH(obj);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1223,11 +1192,7 @@ opt_aset https://github.com/ruby/ruby/blob/trunk/insns.def#L1192
     val = vm_opt_aset(recv, obj, set);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	PUSH(obj);
-	PUSH(set);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1237,6 +1202,7 @@ opt_aset_with https://github.com/ruby/ruby/blob/trunk/insns.def#L1202
 (CALL_INFO ci, CALL_CACHE cc, VALUE key)
 (VALUE recv, VALUE val)
 (VALUE val)
+// attr bool handles_frame = true;
 {
     VALUE tmp = vm_opt_aset_with(recv, key, val);
 
@@ -1258,6 +1224,7 @@ opt_aref_with https://github.com/ruby/ruby/blob/trunk/insns.def#L1224
 (CALL_INFO ci, CALL_CACHE cc, VALUE key)
 (VALUE recv)
 (VALUE val)
+// attr bool handles_frame = true;
 {
     val = vm_opt_aref_with(recv, key);
 
@@ -1279,9 +1246,7 @@ opt_length https://github.com/ruby/ruby/blob/trunk/insns.def#L1246
     val = vm_opt_length(recv, BOP_LENGTH);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1295,9 +1260,7 @@ opt_size https://github.com/ruby/ruby/blob/trunk/insns.def#L1260
     val = vm_opt_length(recv, BOP_SIZE);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1311,9 +1274,7 @@ opt_empty_p https://github.com/ruby/ruby/blob/trunk/insns.def#L1274
     val = vm_opt_empty_p(recv);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1327,9 +1288,7 @@ opt_succ https://github.com/ruby/ruby/blob/trunk/insns.def#L1288
     val = vm_opt_succ(recv);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1343,9 +1302,7 @@ opt_not https://github.com/ruby/ruby/blob/trunk/insns.def#L1302
     val = vm_opt_not(ci, cc, recv);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(recv);
-	CALL_SIMPLE_METHOD(recv);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
@@ -1369,10 +1326,7 @@ opt_regexpmatch2 https://github.com/ruby/ruby/blob/trunk/insns.def#L1326
     val = vm_opt_regexpmatch2(obj2, obj1);
 
     if (val == Qundef) {
-	/* other */
-	PUSH(obj2);
-	PUSH(obj1);
-	CALL_SIMPLE_METHOD(obj2);
+	DISPATCH_ORIGINAL_INSN(opt_send_without_block);
     }
 }
 
Index: tool/ruby_vm/models/bare_instructions.rb
===================================================================
--- tool/ruby_vm/models/bare_instructions.rb	(revision 62087)
+++ tool/ruby_vm/models/bare_instructions.rb	(revision 62088)
@@ -69,9 +69,11 @@ class RubyVM::BareInstructions https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/models/bare_instructions.rb#L69
     return @variables                                        \
       . values                                               \
       . group_by {|h| h[:type] }                             \
+      . sort_by  {|t, v| t }                                 \
       . map      {|t, v| [t, v.map {|i| i[:name] }.sort ] }  \
-      . map      {|t, v| sprintf("%s %s", t, v.join(', ')) } \
-      . sort
+      . map      {|t, v|
+        sprintf("MAYBE_UNUSED(%s) %s", t, v.join(', '))
+      }
   end
 
   def preamble
@@ -127,8 +129,7 @@ class RubyVM::BareInstructions https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/models/bare_instructions.rb#L129
     generate_attribute 'rb_num_t', 'retn', rets.size
     generate_attribute 'rb_num_t', 'width', width
     generate_attribute 'rb_num_t', 'sp_inc', rets.size - pops.size
-    generate_attribute 'bool', 'handles_frame', \
-      opes.any? {|o| /CALL_INFO/ =~ o[:type] }
+    generate_attribute 'bool', 'handles_frame', false
   end
 
   def typesplit a

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]