Mercurial > hg > truffle
comparison src/share/vm/ci/ciMethod.cpp @ 13086:096c224171c4
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 20 Nov 2013 00:10:38 +0100 |
parents | cefad50507d8 b2ee5dc63353 |
children | d8041d695d19 |
comparison
equal
deleted
inserted
replaced
12782:92b7ec34ddfa | 13086:096c224171c4 |
---|---|
563 _receiver[i] = receiver; | 563 _receiver[i] = receiver; |
564 _receiver_count[i] = receiver_count; | 564 _receiver_count[i] = receiver_count; |
565 if (_limit < MorphismLimit) _limit++; | 565 if (_limit < MorphismLimit) _limit++; |
566 } | 566 } |
567 | 567 |
568 | |
569 void ciMethod::assert_virtual_call_type_ok(int bci) { | |
570 assert(java_code_at_bci(bci) == Bytecodes::_invokevirtual || | |
571 java_code_at_bci(bci) == Bytecodes::_invokeinterface, err_msg("unexpected bytecode %s", Bytecodes::name(java_code_at_bci(bci)))); | |
572 } | |
573 | |
574 void ciMethod::assert_call_type_ok(int bci) { | |
575 assert(java_code_at_bci(bci) == Bytecodes::_invokestatic || | |
576 java_code_at_bci(bci) == Bytecodes::_invokespecial || | |
577 java_code_at_bci(bci) == Bytecodes::_invokedynamic, err_msg("unexpected bytecode %s", Bytecodes::name(java_code_at_bci(bci)))); | |
578 } | |
579 | |
580 /** | |
581 * Check whether profiling provides a type for the argument i to the | |
582 * call at bci bci | |
583 * | |
584 * @param bci bci of the call | |
585 * @param i argument number | |
586 * @return profiled type | |
587 * | |
588 * If the profile reports that the argument may be null, return false | |
589 * at least for now. | |
590 */ | |
591 ciKlass* ciMethod::argument_profiled_type(int bci, int i) { | |
592 if (MethodData::profile_parameters() && method_data() != NULL && method_data()->is_mature()) { | |
593 ciProfileData* data = method_data()->bci_to_data(bci); | |
594 if (data != NULL) { | |
595 if (data->is_VirtualCallTypeData()) { | |
596 assert_virtual_call_type_ok(bci); | |
597 ciVirtualCallTypeData* call = (ciVirtualCallTypeData*)data->as_VirtualCallTypeData(); | |
598 if (i >= call->number_of_arguments()) { | |
599 return NULL; | |
600 } | |
601 ciKlass* type = call->valid_argument_type(i); | |
602 if (type != NULL && !call->argument_maybe_null(i)) { | |
603 return type; | |
604 } | |
605 } else if (data->is_CallTypeData()) { | |
606 assert_call_type_ok(bci); | |
607 ciCallTypeData* call = (ciCallTypeData*)data->as_CallTypeData(); | |
608 if (i >= call->number_of_arguments()) { | |
609 return NULL; | |
610 } | |
611 ciKlass* type = call->valid_argument_type(i); | |
612 if (type != NULL && !call->argument_maybe_null(i)) { | |
613 return type; | |
614 } | |
615 } | |
616 } | |
617 } | |
618 return NULL; | |
619 } | |
620 | |
621 /** | |
622 * Check whether profiling provides a type for the return value from | |
623 * the call at bci bci | |
624 * | |
625 * @param bci bci of the call | |
626 * @return profiled type | |
627 * | |
628 * If the profile reports that the argument may be null, return false | |
629 * at least for now. | |
630 */ | |
631 ciKlass* ciMethod::return_profiled_type(int bci) { | |
632 if (MethodData::profile_return() && method_data() != NULL && method_data()->is_mature()) { | |
633 ciProfileData* data = method_data()->bci_to_data(bci); | |
634 if (data != NULL) { | |
635 if (data->is_VirtualCallTypeData()) { | |
636 assert_virtual_call_type_ok(bci); | |
637 ciVirtualCallTypeData* call = (ciVirtualCallTypeData*)data->as_VirtualCallTypeData(); | |
638 ciKlass* type = call->valid_return_type(); | |
639 if (type != NULL && !call->return_maybe_null()) { | |
640 return type; | |
641 } | |
642 } else if (data->is_CallTypeData()) { | |
643 assert_call_type_ok(bci); | |
644 ciCallTypeData* call = (ciCallTypeData*)data->as_CallTypeData(); | |
645 ciKlass* type = call->valid_return_type(); | |
646 if (type != NULL && !call->return_maybe_null()) { | |
647 return type; | |
648 } | |
649 } | |
650 } | |
651 } | |
652 return NULL; | |
653 } | |
654 | |
655 /** | |
656 * Check whether profiling provides a type for the parameter i | |
657 * | |
658 * @param i parameter number | |
659 * @return profiled type | |
660 * | |
661 * If the profile reports that the argument may be null, return false | |
662 * at least for now. | |
663 */ | |
664 ciKlass* ciMethod::parameter_profiled_type(int i) { | |
665 if (MethodData::profile_parameters() && method_data() != NULL && method_data()->is_mature()) { | |
666 ciParametersTypeData* parameters = method_data()->parameters_type_data(); | |
667 if (parameters != NULL && i < parameters->number_of_parameters()) { | |
668 ciKlass* type = parameters->valid_parameter_type(i); | |
669 if (type != NULL && !parameters->parameter_maybe_null(i)) { | |
670 return type; | |
671 } | |
672 } | |
673 } | |
674 return NULL; | |
675 } | |
676 | |
677 | |
568 // ------------------------------------------------------------------ | 678 // ------------------------------------------------------------------ |
569 // ciMethod::find_monomorphic_target | 679 // ciMethod::find_monomorphic_target |
570 // | 680 // |
571 // Given a certain calling environment, find the monomorphic target | 681 // Given a certain calling environment, find the monomorphic target |
572 // for the call. Return NULL if the call is not monomorphic in | 682 // for the call. Return NULL if the call is not monomorphic in |
844 // | 954 // |
845 // Generate new MethodData* objects at compile time. | 955 // Generate new MethodData* objects at compile time. |
846 // Return true if allocation was successful or no MDO is required. | 956 // Return true if allocation was successful or no MDO is required. |
847 bool ciMethod::ensure_method_data(methodHandle h_m) { | 957 bool ciMethod::ensure_method_data(methodHandle h_m) { |
848 EXCEPTION_CONTEXT; | 958 EXCEPTION_CONTEXT; |
849 if (is_native() || is_abstract() || h_m()->is_accessor()) return true; | 959 if (is_native() || is_abstract() || h_m()->is_accessor()) { |
960 return true; | |
961 } | |
850 if (h_m()->method_data() == NULL) { | 962 if (h_m()->method_data() == NULL) { |
851 Method::build_interpreter_method_data(h_m, THREAD); | 963 Method::build_interpreter_method_data(h_m, THREAD); |
852 if (HAS_PENDING_EXCEPTION) { | 964 if (HAS_PENDING_EXCEPTION) { |
853 CLEAR_PENDING_EXCEPTION; | 965 CLEAR_PENDING_EXCEPTION; |
854 } | 966 } |
901 // ciMethod::method_data_or_null | 1013 // ciMethod::method_data_or_null |
902 // Returns a pointer to ciMethodData if MDO exists on the VM side, | 1014 // Returns a pointer to ciMethodData if MDO exists on the VM side, |
903 // NULL otherwise. | 1015 // NULL otherwise. |
904 ciMethodData* ciMethod::method_data_or_null() { | 1016 ciMethodData* ciMethod::method_data_or_null() { |
905 ciMethodData *md = method_data(); | 1017 ciMethodData *md = method_data(); |
906 if (md->is_empty()) return NULL; | 1018 if (md->is_empty()) { |
1019 return NULL; | |
1020 } | |
907 return md; | 1021 return md; |
908 } | 1022 } |
909 | 1023 |
910 // ------------------------------------------------------------------ | 1024 // ------------------------------------------------------------------ |
911 // ciMethod::ensure_method_counters | 1025 // ciMethod::ensure_method_counters |
912 // | 1026 // |
913 address ciMethod::ensure_method_counters() { | 1027 MethodCounters* ciMethod::ensure_method_counters() { |
914 check_is_loaded(); | 1028 check_is_loaded(); |
915 VM_ENTRY_MARK; | 1029 VM_ENTRY_MARK; |
916 methodHandle mh(THREAD, get_Method()); | 1030 methodHandle mh(THREAD, get_Method()); |
917 MethodCounters *counter = mh->method_counters(); | 1031 MethodCounters* method_counters = mh->get_method_counters(CHECK_NULL); |
918 if (counter == NULL) { | 1032 return method_counters; |
919 counter = Method::build_method_counters(mh(), CHECK_AND_CLEAR_NULL); | |
920 } | |
921 return (address)counter; | |
922 } | 1033 } |
923 | 1034 |
924 // ------------------------------------------------------------------ | 1035 // ------------------------------------------------------------------ |
925 // ciMethod::should_exclude | 1036 // ciMethod::should_exclude |
926 // | 1037 // |
1245 } | 1356 } |
1246 | 1357 |
1247 #undef FETCH_FLAG_FROM_VM | 1358 #undef FETCH_FLAG_FROM_VM |
1248 | 1359 |
1249 void ciMethod::dump_replay_data(outputStream* st) { | 1360 void ciMethod::dump_replay_data(outputStream* st) { |
1250 ASSERT_IN_VM; | |
1251 ResourceMark rm; | 1361 ResourceMark rm; |
1252 Method* method = get_Method(); | 1362 Method* method = get_Method(); |
1253 MethodCounters* mcs = method->method_counters(); | 1363 MethodCounters* mcs = method->method_counters(); |
1254 Klass* holder = method->method_holder(); | 1364 Klass* holder = method->method_holder(); |
1255 st->print_cr("ciMethod %s %s %s %d %d %d %d %d", | 1365 st->print_cr("ciMethod %s %s %s %d %d %d %d %d", |