src/share/vm/c1/c1_GraphBuilder.cpp

changeset 5987
5ccbab1c69f3
parent 5921
ce0cc25bc5e2
child 6000
0d1661d63d70
     1.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp	Mon Oct 21 17:34:27 2013 -0700
     1.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp	Tue Oct 22 09:51:47 2013 +0200
     1.3 @@ -1470,7 +1470,7 @@
     1.4      set_state(state()->caller_state()->copy_for_parsing());
     1.5      if (x != NULL) {
     1.6        state()->push(x->type(), x);
     1.7 -      if (profile_calls() && MethodData::profile_return() && x->type()->is_object_kind()) {
     1.8 +      if (profile_return() && x->type()->is_object_kind()) {
     1.9          ciMethod* caller = state()->scope()->method();
    1.10          ciMethodData* md = caller->method_data_or_null();
    1.11          ciProfileData* data = md->bci_to_data(invoke_bci);
    1.12 @@ -1672,15 +1672,23 @@
    1.13  }
    1.14  
    1.15  // How many arguments do we want to profile?
    1.16 -Values* GraphBuilder::args_list_for_profiling(int& start, bool may_have_receiver) {
    1.17 +Values* GraphBuilder::args_list_for_profiling(ciMethod* target, int& start, bool may_have_receiver) {
    1.18    int n = 0;
    1.19 -  assert(start == 0, "should be initialized");
    1.20 -  if (MethodData::profile_arguments()) {
    1.21 +  bool has_receiver = may_have_receiver && Bytecodes::has_receiver(method()->java_code_at_bci(bci()));
    1.22 +  start = has_receiver ? 1 : 0;
    1.23 +  if (profile_arguments()) {
    1.24      ciProfileData* data = method()->method_data()->bci_to_data(bci());
    1.25      if (data->is_CallTypeData() || data->is_VirtualCallTypeData()) {
    1.26        n = data->is_CallTypeData() ? data->as_CallTypeData()->number_of_arguments() : data->as_VirtualCallTypeData()->number_of_arguments();
    1.27 -      bool has_receiver = may_have_receiver && Bytecodes::has_receiver(method()->java_code_at_bci(bci()));
    1.28 -      start = has_receiver ? 1 : 0;
    1.29 +    }
    1.30 +  }
    1.31 +  // If we are inlining then we need to collect arguments to profile parameters for the target
    1.32 +  if (profile_parameters() && target != NULL) {
    1.33 +    if (target->method_data() != NULL && target->method_data()->parameters_type_data() != NULL) {
    1.34 +      // The receiver is profiled on method entry so it's included in
    1.35 +      // the number of parameters but here we're only interested in
    1.36 +      // actual arguments.
    1.37 +      n = MAX2(n, target->method_data()->parameters_type_data()->number_of_parameters() - start);
    1.38      }
    1.39    }
    1.40    if (n > 0) {
    1.41 @@ -1690,9 +1698,9 @@
    1.42  }
    1.43  
    1.44  // Collect arguments that we want to profile in a list
    1.45 -Values* GraphBuilder::collect_args_for_profiling(Values* args, bool may_have_receiver) {
    1.46 +Values* GraphBuilder::collect_args_for_profiling(Values* args, ciMethod* target, bool may_have_receiver) {
    1.47    int start = 0;
    1.48 -  Values* obj_args = args_list_for_profiling(start, may_have_receiver);
    1.49 +  Values* obj_args = args_list_for_profiling(target, start, may_have_receiver);
    1.50    if (obj_args == NULL) {
    1.51      return NULL;
    1.52    }
    1.53 @@ -2006,7 +2014,7 @@
    1.54        } else if (exact_target != NULL) {
    1.55          target_klass = exact_target->holder();
    1.56        }
    1.57 -      profile_call(target, recv, target_klass, collect_args_for_profiling(args, false), false);
    1.58 +      profile_call(target, recv, target_klass, collect_args_for_profiling(args, NULL, false), false);
    1.59      }
    1.60    }
    1.61  
    1.62 @@ -2021,7 +2029,7 @@
    1.63        push(result_type, result);
    1.64      }
    1.65    }
    1.66 -  if (profile_calls() && MethodData::profile_return() && result_type->is_object_kind()) {
    1.67 +  if (profile_return() && result_type->is_object_kind()) {
    1.68      profile_return_type(result, target);
    1.69    }
    1.70  }
    1.71 @@ -3561,7 +3569,7 @@
    1.72            recv = args->at(0);
    1.73            null_check(recv);
    1.74          }
    1.75 -        profile_call(callee, recv, NULL, collect_args_for_profiling(args, true), true);
    1.76 +        profile_call(callee, recv, NULL, collect_args_for_profiling(args, callee, true), true);
    1.77        }
    1.78      }
    1.79    }
    1.80 @@ -3572,7 +3580,7 @@
    1.81    Value value = append_split(result);
    1.82    if (result_type != voidType) push(result_type, value);
    1.83  
    1.84 -  if (callee != method() && profile_calls() && MethodData::profile_return() && result_type->is_object_kind()) {
    1.85 +  if (callee != method() && profile_return() && result_type->is_object_kind()) {
    1.86      profile_return_type(result, callee);
    1.87    }
    1.88  
    1.89 @@ -3820,7 +3828,7 @@
    1.90  
    1.91      if (profile_calls()) {
    1.92        int start = 0;
    1.93 -      Values* obj_args = args_list_for_profiling(start, has_receiver);
    1.94 +      Values* obj_args = args_list_for_profiling(callee, start, has_receiver);
    1.95        if (obj_args != NULL) {
    1.96          int s = obj_args->size();
    1.97          // if called through method handle invoke, some arguments may have been popped

mercurial