From 27fcdfaa0572d64c2036e32d71b374ca09428d39 Mon Sep 17 00:00:00 2001
From: ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Sat, 19 Sep 2015 17:59:58 +0000
Subject: * vm_core.h: split rb_call_info_t into several structs.   *
 rb_call_info (ci) has compiled fixed information.   * if ci->flag &
 VM_CALL_KWARG, then rb_call_info is     also rb_call_info_with_kwarg. This
 technique reduce one word     for major rb_call_info data.   *
 rb_calling_info has temporary data (argc, blockptr, recv).     for each
 method dispatch. This data is allocated only on     machine stack.   *
 rb_call_cache is for inline method cache.   Before this patch, only
 rb_call_info_t data is passed.   After this patch, above three structs are
 passed.   This patch improves:   * data locarity (rb_call_info is now
 read-only data).   * reduce memory consumption (rb_call_info_with_kwarg,    
 rb_calling_info). * compile.c: use above data. * insns.def: ditto. * iseq.c:
 ditto. * vm_args.c: ditto. * vm_eval.c: ditto. * vm_insnhelper.c: ditto. *
 vm_insnhelper.h: ditto. * iseq.h: add iseq_compile_data::ci_index and  
 iseq_compile_data::ci_kw_indx. * tool/instruction.rb: introduce TS_CALLCACHE
 operand type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
---
 insns.def | 102 +++++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 55 insertions(+), 47 deletions(-)

(limited to 'insns.def')

diff --git a/insns.def b/insns.def
index d27fd1a5b9..7eb322120b 100644
--- a/insns.def
+++ b/insns.def
@@ -936,14 +936,15 @@ defineclass
  */
 DEFINE_INSN
 send
-(CALL_INFO ci, ISEQ iseq)
+(CALL_INFO ci, CALL_CACHE cc, ISEQ blockiseq)
 (...)
 (VALUE val) // inc += - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));
 {
-    ci->argc = ci->orig_argc;
-    vm_caller_setup_arg_block(th, reg_cfp, ci, iseq, FALSE);
-    vm_search_method(ci, ci->recv = TOPN(ci->argc));
-    CALL_METHOD(ci);
+    struct rb_calling_info calling;
+
+    vm_caller_setup_arg_block(th, reg_cfp, &calling, ci, blockiseq, FALSE);
+    vm_search_method(ci, cc, calling.recv = TOPN(calling.argc = ci->orig_argc));
+    CALL_METHOD(&calling, ci, cc);
 }
 
 DEFINE_INSN
@@ -967,13 +968,14 @@ opt_str_freeze
  */
 DEFINE_INSN
 opt_send_without_block
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (...)
 (VALUE val) // inc += -ci->orig_argc;
 {
-    ci->argc = ci->orig_argc;
-    vm_search_method(ci, ci->recv = TOPN(ci->argc));
-    CALL_METHOD(ci);
+    struct rb_calling_info calling;
+    calling.blockptr = NULL;
+    vm_search_method(ci, cc, calling.recv = TOPN(calling.argc = ci->orig_argc));
+    CALL_METHOD(&calling, ci, cc);
 }
 
 /**
@@ -983,15 +985,17 @@ opt_send_without_block
  */
 DEFINE_INSN
 invokesuper
-(CALL_INFO ci, ISEQ iseq)
+(CALL_INFO ci, CALL_CACHE cc, ISEQ blockiseq)
 (...)
 (VALUE val) // inc += - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));
 {
-    ci->argc = ci->orig_argc;
-    vm_caller_setup_arg_block(th, reg_cfp, ci, iseq, TRUE);
-    ci->recv = GET_SELF();
-    vm_search_super_method(th, GET_CFP(), ci);
-    CALL_METHOD(ci);
+    struct rb_calling_info calling;
+    calling.argc = ci->orig_argc;
+
+    vm_caller_setup_arg_block(th, reg_cfp, &calling, ci, blockiseq, TRUE);
+    calling.recv = GET_SELF();
+    vm_search_super_method(th, GET_CFP(), &calling, ci, cc);
+    CALL_METHOD(&calling, ci, cc);
 }
 
 /**
@@ -1005,10 +1009,12 @@ invokeblock
 (...)
 (VALUE val)  // inc += 1 - ci->orig_argc;
 {
-    ci->argc = ci->orig_argc;
-    ci->blockptr = 0;
-    ci->recv = GET_SELF();
-    val = vm_invoke_block(th, GET_CFP(), ci);
+    struct rb_calling_info calling;
+    calling.argc = ci->orig_argc;
+    calling.blockptr = NULL;
+    calling.recv = GET_SELF();
+
+    val = vm_invoke_block(th, GET_CFP(), &calling, ci);
     if (val == Qundef) {
 	RESTORE_REGS();
 	NEXT_INSN();
@@ -1260,7 +1266,7 @@ opt_case_dispatch
  */
 DEFINE_INSN
 opt_plus
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv, VALUE obj)
 (VALUE val)
 {
@@ -1323,7 +1329,7 @@ opt_plus
  */
 DEFINE_INSN
 opt_minus
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv, VALUE obj)
 (VALUE val)
 {
@@ -1371,7 +1377,7 @@ opt_minus
  */
 DEFINE_INSN
 opt_mult
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv, VALUE obj)
 (VALUE val)
 {
@@ -1421,7 +1427,7 @@ opt_mult
  */
 DEFINE_INSN
 opt_div
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv, VALUE obj)
 (VALUE val)
 {
@@ -1484,7 +1490,7 @@ opt_div
  */
 DEFINE_INSN
 opt_mod
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv, VALUE obj)
 (VALUE val)
 {
@@ -1551,11 +1557,11 @@ opt_mod
  */
 DEFINE_INSN
 opt_eq
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv, VALUE obj)
 (VALUE val)
 {
-    val = opt_eq_func(recv, obj, ci);
+    val = opt_eq_func(recv, obj, ci, cc);
 
     if (val == Qundef) {
 	/* other */
@@ -1572,16 +1578,17 @@ opt_eq
  */
 DEFINE_INSN
 opt_neq
-(CALL_INFO ci, CALL_INFO ci_eq)
+(CALL_INFO ci, CALL_CACHE cc, CALL_INFO ci_eq, CALL_CACHE cc_eq)
 (VALUE recv, VALUE obj)
 (VALUE val)
 {
     extern VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2);
-    vm_search_method(ci, recv);
+    vm_search_method(ci, cc, recv);
+
     val = Qundef;
 
-    if (check_cfunc(ci->me, rb_obj_not_equal)) {
-	val = opt_eq_func(recv, obj, ci_eq);
+    if (check_cfunc(cc->me, rb_obj_not_equal)) {
+	val = opt_eq_func(recv, obj, ci_eq, cc_eq);
 
 	if (val != Qundef) {
 	    val = RTEST(val) ? Qfalse : Qtrue;
@@ -1603,7 +1610,7 @@ opt_neq
  */
 DEFINE_INSN
 opt_lt
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv, VALUE obj)
 (VALUE val)
 {
@@ -1647,7 +1654,7 @@ opt_lt
  */
 DEFINE_INSN
 opt_le
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv, VALUE obj)
 (VALUE val)
 {
@@ -1682,7 +1689,7 @@ opt_le
  */
 DEFINE_INSN
 opt_gt
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv, VALUE obj)
 (VALUE val)
 {
@@ -1726,7 +1733,7 @@ opt_gt
  */
 DEFINE_INSN
 opt_ge
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv, VALUE obj)
 (VALUE val)
 {
@@ -1760,7 +1767,7 @@ opt_ge
  */
 DEFINE_INSN
 opt_ltlt
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv, VALUE obj)
 (VALUE val)
 {
@@ -1792,7 +1799,7 @@ opt_ltlt
  */
 DEFINE_INSN
 opt_aref
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv, VALUE obj)
 (VALUE val)
 {
@@ -1822,7 +1829,7 @@ opt_aref
  */
 DEFINE_INSN
 opt_aset
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv, VALUE obj, VALUE set)
 (VALUE val)
 {
@@ -1855,7 +1862,7 @@ opt_aset
  */
 DEFINE_INSN
 opt_aset_with
-(CALL_INFO ci, VALUE key)
+(CALL_INFO ci, CALL_CACHE cc, VALUE key)
 (VALUE recv, VALUE val)
 (VALUE val)
 {
@@ -1877,7 +1884,7 @@ opt_aset_with
  */
 DEFINE_INSN
 opt_aref_with
-(CALL_INFO ci, VALUE key)
+(CALL_INFO ci, CALL_CACHE cc, VALUE key)
 (VALUE recv)
 (VALUE val)
 {
@@ -1898,7 +1905,7 @@ opt_aref_with
  */
 DEFINE_INSN
 opt_length
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv)
 (VALUE val)
 {
@@ -1933,7 +1940,7 @@ opt_length
  */
 DEFINE_INSN
 opt_size
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv)
 (VALUE val)
 {
@@ -1968,7 +1975,7 @@ opt_size
  */
 DEFINE_INSN
 opt_empty_p
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv)
 (VALUE val)
 {
@@ -2006,7 +2013,7 @@ opt_empty_p
  */
 DEFINE_INSN
 opt_succ
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv)
 (VALUE val)
 {
@@ -2049,14 +2056,15 @@ opt_succ
  */
 DEFINE_INSN
 opt_not
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE recv)
 (VALUE val)
 {
     extern VALUE rb_obj_not(VALUE obj);
-    vm_search_method(ci, recv);
 
-    if (check_cfunc(ci->me, rb_obj_not)) {
+    vm_search_method(ci, cc, recv);
+
+    if (check_cfunc(cc->me, rb_obj_not)) {
 	val = RTEST(recv) ? Qfalse : Qtrue;
     }
     else {
@@ -2092,7 +2100,7 @@ opt_regexpmatch1
  */
 DEFINE_INSN
 opt_regexpmatch2
-(CALL_INFO ci)
+(CALL_INFO ci, CALL_CACHE cc)
 (VALUE obj2, VALUE obj1)
 (VALUE val)
 {
-- 
cgit v1.2.3

