3260 void LIRGenerator::profile_arguments(ProfileCall* x) { |
3260 void LIRGenerator::profile_arguments(ProfileCall* x) { |
3261 if (compilation()->profile_arguments()) { |
3261 if (compilation()->profile_arguments()) { |
3262 int bci = x->bci_of_invoke(); |
3262 int bci = x->bci_of_invoke(); |
3263 ciMethodData* md = x->method()->method_data_or_null(); |
3263 ciMethodData* md = x->method()->method_data_or_null(); |
3264 ciProfileData* data = md->bci_to_data(bci); |
3264 ciProfileData* data = md->bci_to_data(bci); |
3265 if ((data->is_CallTypeData() && data->as_CallTypeData()->has_arguments()) || |
3265 if (data != NULL) { |
3266 (data->is_VirtualCallTypeData() && data->as_VirtualCallTypeData()->has_arguments())) { |
3266 if ((data->is_CallTypeData() && data->as_CallTypeData()->has_arguments()) || |
3267 ByteSize extra = data->is_CallTypeData() ? CallTypeData::args_data_offset() : VirtualCallTypeData::args_data_offset(); |
3267 (data->is_VirtualCallTypeData() && data->as_VirtualCallTypeData()->has_arguments())) { |
3268 int base_offset = md->byte_offset_of_slot(data, extra); |
3268 ByteSize extra = data->is_CallTypeData() ? CallTypeData::args_data_offset() : VirtualCallTypeData::args_data_offset(); |
3269 LIR_Opr mdp = LIR_OprFact::illegalOpr; |
3269 int base_offset = md->byte_offset_of_slot(data, extra); |
3270 ciTypeStackSlotEntries* args = data->is_CallTypeData() ? ((ciCallTypeData*)data)->args() : ((ciVirtualCallTypeData*)data)->args(); |
3270 LIR_Opr mdp = LIR_OprFact::illegalOpr; |
3271 |
3271 ciTypeStackSlotEntries* args = data->is_CallTypeData() ? ((ciCallTypeData*)data)->args() : ((ciVirtualCallTypeData*)data)->args(); |
3272 Bytecodes::Code bc = x->method()->java_code_at_bci(bci); |
3272 |
3273 int start = 0; |
3273 Bytecodes::Code bc = x->method()->java_code_at_bci(bci); |
3274 int stop = data->is_CallTypeData() ? ((ciCallTypeData*)data)->number_of_arguments() : ((ciVirtualCallTypeData*)data)->number_of_arguments(); |
3274 int start = 0; |
3275 if (x->callee()->is_loaded() && x->callee()->is_static() && Bytecodes::has_receiver(bc)) { |
3275 int stop = data->is_CallTypeData() ? ((ciCallTypeData*)data)->number_of_arguments() : ((ciVirtualCallTypeData*)data)->number_of_arguments(); |
3276 // first argument is not profiled at call (method handle invoke) |
3276 if (x->callee()->is_loaded() && x->callee()->is_static() && Bytecodes::has_receiver(bc)) { |
3277 assert(x->method()->raw_code_at_bci(bci) == Bytecodes::_invokehandle, "invokehandle expected"); |
3277 // first argument is not profiled at call (method handle invoke) |
3278 start = 1; |
3278 assert(x->method()->raw_code_at_bci(bci) == Bytecodes::_invokehandle, "invokehandle expected"); |
3279 } |
3279 start = 1; |
3280 ciSignature* callee_signature = x->callee()->signature(); |
|
3281 // method handle call to virtual method |
|
3282 bool has_receiver = x->callee()->is_loaded() && !x->callee()->is_static() && !Bytecodes::has_receiver(bc); |
|
3283 ciSignatureStream callee_signature_stream(callee_signature, has_receiver ? x->callee()->holder() : NULL); |
|
3284 |
|
3285 bool ignored_will_link; |
|
3286 ciSignature* signature_at_call = NULL; |
|
3287 x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call); |
|
3288 ciSignatureStream signature_at_call_stream(signature_at_call); |
|
3289 |
|
3290 // if called through method handle invoke, some arguments may have been popped |
|
3291 for (int i = 0; i < stop && i+start < x->nb_profiled_args(); i++) { |
|
3292 int off = in_bytes(TypeEntriesAtCall::argument_type_offset(i)) - in_bytes(TypeEntriesAtCall::args_data_offset()); |
|
3293 ciKlass* exact = profile_type(md, base_offset, off, |
|
3294 args->type(i), x->profiled_arg_at(i+start), mdp, |
|
3295 !x->arg_needs_null_check(i+start), |
|
3296 signature_at_call_stream.next_klass(), callee_signature_stream.next_klass()); |
|
3297 if (exact != NULL) { |
|
3298 md->set_argument_type(bci, i, exact); |
|
3299 } |
3280 } |
3300 } |
3281 ciSignature* callee_signature = x->callee()->signature(); |
3301 } else { |
3282 // method handle call to virtual method |
|
3283 bool has_receiver = x->callee()->is_loaded() && !x->callee()->is_static() && !Bytecodes::has_receiver(bc); |
|
3284 ciSignatureStream callee_signature_stream(callee_signature, has_receiver ? x->callee()->holder() : NULL); |
|
3285 |
|
3286 bool ignored_will_link; |
|
3287 ciSignature* signature_at_call = NULL; |
|
3288 x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call); |
|
3289 ciSignatureStream signature_at_call_stream(signature_at_call); |
|
3290 |
|
3291 // if called through method handle invoke, some arguments may have been popped |
|
3292 for (int i = 0; i < stop && i+start < x->nb_profiled_args(); i++) { |
|
3293 int off = in_bytes(TypeEntriesAtCall::argument_type_offset(i)) - in_bytes(TypeEntriesAtCall::args_data_offset()); |
|
3294 ciKlass* exact = profile_type(md, base_offset, off, |
|
3295 args->type(i), x->profiled_arg_at(i+start), mdp, |
|
3296 !x->arg_needs_null_check(i+start), |
|
3297 signature_at_call_stream.next_klass(), callee_signature_stream.next_klass()); |
|
3298 if (exact != NULL) { |
|
3299 md->set_argument_type(bci, i, exact); |
|
3300 } |
|
3301 } |
|
3302 } else { |
3302 #ifdef ASSERT |
3303 #ifdef ASSERT |
3303 Bytecodes::Code code = x->method()->raw_code_at_bci(x->bci_of_invoke()); |
3304 Bytecodes::Code code = x->method()->raw_code_at_bci(x->bci_of_invoke()); |
3304 int n = x->nb_profiled_args(); |
3305 int n = x->nb_profiled_args(); |
3305 assert(MethodData::profile_parameters() && (MethodData::profile_arguments_jsr292_only() || |
3306 assert(MethodData::profile_parameters() && (MethodData::profile_arguments_jsr292_only() || |
3306 (x->inlined() && ((code == Bytecodes::_invokedynamic && n <= 1) || (code == Bytecodes::_invokehandle && n <= 2)))), |
3307 (x->inlined() && ((code == Bytecodes::_invokedynamic && n <= 1) || (code == Bytecodes::_invokehandle && n <= 2)))), |
3307 "only at JSR292 bytecodes"); |
3308 "only at JSR292 bytecodes"); |
3308 #endif |
3309 #endif |
|
3310 } |
3309 } |
3311 } |
3310 } |
3312 } |
3311 } |
3313 } |
3312 |
3314 |
3313 // profile parameters on entry to an inlined method |
3315 // profile parameters on entry to an inlined method |
3394 |
3396 |
3395 void LIRGenerator::do_ProfileReturnType(ProfileReturnType* x) { |
3397 void LIRGenerator::do_ProfileReturnType(ProfileReturnType* x) { |
3396 int bci = x->bci_of_invoke(); |
3398 int bci = x->bci_of_invoke(); |
3397 ciMethodData* md = x->method()->method_data_or_null(); |
3399 ciMethodData* md = x->method()->method_data_or_null(); |
3398 ciProfileData* data = md->bci_to_data(bci); |
3400 ciProfileData* data = md->bci_to_data(bci); |
3399 assert(data->is_CallTypeData() || data->is_VirtualCallTypeData(), "wrong profile data type"); |
3401 if (data != NULL) { |
3400 ciReturnTypeEntry* ret = data->is_CallTypeData() ? ((ciCallTypeData*)data)->ret() : ((ciVirtualCallTypeData*)data)->ret(); |
3402 assert(data->is_CallTypeData() || data->is_VirtualCallTypeData(), "wrong profile data type"); |
3401 LIR_Opr mdp = LIR_OprFact::illegalOpr; |
3403 ciReturnTypeEntry* ret = data->is_CallTypeData() ? ((ciCallTypeData*)data)->ret() : ((ciVirtualCallTypeData*)data)->ret(); |
3402 |
3404 LIR_Opr mdp = LIR_OprFact::illegalOpr; |
3403 bool ignored_will_link; |
3405 |
3404 ciSignature* signature_at_call = NULL; |
3406 bool ignored_will_link; |
3405 x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call); |
3407 ciSignature* signature_at_call = NULL; |
3406 |
3408 x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call); |
3407 // The offset within the MDO of the entry to update may be too large |
3409 |
3408 // to be used in load/store instructions on some platforms. So have |
3410 // The offset within the MDO of the entry to update may be too large |
3409 // profile_type() compute the address of the profile in a register. |
3411 // to be used in load/store instructions on some platforms. So have |
3410 ciKlass* exact = profile_type(md, md->byte_offset_of_slot(data, ret->type_offset()), 0, |
3412 // profile_type() compute the address of the profile in a register. |
3411 ret->type(), x->ret(), mdp, |
3413 ciKlass* exact = profile_type(md, md->byte_offset_of_slot(data, ret->type_offset()), 0, |
3412 !x->needs_null_check(), |
3414 ret->type(), x->ret(), mdp, |
3413 signature_at_call->return_type()->as_klass(), |
3415 !x->needs_null_check(), |
3414 x->callee()->signature()->return_type()->as_klass()); |
3416 signature_at_call->return_type()->as_klass(), |
3415 if (exact != NULL) { |
3417 x->callee()->signature()->return_type()->as_klass()); |
3416 md->set_return_type(bci, exact); |
3418 if (exact != NULL) { |
|
3419 md->set_return_type(bci, exact); |
|
3420 } |
3417 } |
3421 } |
3418 } |
3422 } |
3419 |
3423 |
3420 void LIRGenerator::do_ProfileInvoke(ProfileInvoke* x) { |
3424 void LIRGenerator::do_ProfileInvoke(ProfileInvoke* x) { |
3421 // We can safely ignore accessors here, since c2 will inline them anyway, |
3425 // We can safely ignore accessors here, since c2 will inline them anyway, |