63 // This class represents a Method* in the HotSpot virtual
64 // machine.
65
66
67 // ------------------------------------------------------------------
68 // ciMethod::ciMethod
69 //
70 // Loaded method.
71 ciMethod::ciMethod(methodHandle h_m) : ciMetadata(h_m()) {
72 assert(h_m() != NULL, "no null method");
73
74 // These fields are always filled in in loaded methods.
75 _flags = ciFlags(h_m()->access_flags());
76
77 // Easy to compute, so fill them in now.
78 _max_stack = h_m()->max_stack();
79 _max_locals = h_m()->max_locals();
80 _code_size = h_m()->code_size();
81 _intrinsic_id = h_m()->intrinsic_id();
82 _handler_count = h_m()->exception_table_length();
83 _uses_monitors = h_m()->access_flags().has_monitor_bytecodes();
84 _balanced_monitors = !_uses_monitors || h_m()->access_flags().is_monitor_matching();
85 _is_c1_compilable = !h_m()->is_not_c1_compilable();
86 _is_c2_compilable = !h_m()->is_not_c2_compilable();
87 // Lazy fields, filled in on demand. Require allocation.
88 _code = NULL;
89 _exception_handlers = NULL;
90 _liveness = NULL;
91 _method_blocks = NULL;
92 #if defined(COMPILER2) || defined(SHARK)
93 _flow = NULL;
94 _bcea = NULL;
95 #endif // COMPILER2 || SHARK
96
97 ciEnv *env = CURRENT_ENV;
98 if (env->jvmti_can_hotswap_or_post_breakpoint() && can_be_compiled()) {
99 // 6328518 check hotswap conditions under the right lock.
100 MutexLocker locker(Compile_lock);
101 if (Dependencies::check_evol_method(h_m()) != NULL) {
102 _is_c1_compilable = false;
858 }
859 return -1; // unknown
860 }
861
862 // ------------------------------------------------------------------
863 // ciMethod::get_field_at_bci
864 ciField* ciMethod::get_field_at_bci(int bci, bool &will_link) {
865 ciBytecodeStream iter(this);
866 iter.reset_to_bci(bci);
867 iter.next();
868 return iter.get_field(will_link);
869 }
870
871 // ------------------------------------------------------------------
872 // ciMethod::get_method_at_bci
873 ciMethod* ciMethod::get_method_at_bci(int bci, bool &will_link, ciSignature* *declared_signature) {
874 ciBytecodeStream iter(this);
875 iter.reset_to_bci(bci);
876 iter.next();
877 return iter.get_method(will_link, declared_signature);
878 }
879
880 // ------------------------------------------------------------------
881 // Adjust a CounterData count to be commensurate with
882 // interpreter_invocation_count. If the MDO exists for
883 // only 25% of the time the method exists, then the
884 // counts in the MDO should be scaled by 4X, so that
885 // they can be usefully and stably compared against the
886 // invocation counts in methods.
887 int ciMethod::scale_count(int count, float prof_factor) {
888 if (count > 0 && method_data() != NULL) {
889 int counter_life;
890 int method_life = interpreter_invocation_count();
891 if (TieredCompilation) {
892 // In tiered the MDO's life is measured directly, so just use the snapshotted counters
893 counter_life = MAX2(method_data()->invocation_count(), method_data()->backedge_count());
894 } else {
895 int current_mileage = method_data()->current_mileage();
896 int creation_mileage = method_data()->creation_mileage();
897 counter_life = current_mileage - creation_mileage;
|
63 // This class represents a Method* in the HotSpot virtual
64 // machine.
65
66
67 // ------------------------------------------------------------------
68 // ciMethod::ciMethod
69 //
70 // Loaded method.
71 ciMethod::ciMethod(methodHandle h_m) : ciMetadata(h_m()) {
72 assert(h_m() != NULL, "no null method");
73
74 // These fields are always filled in in loaded methods.
75 _flags = ciFlags(h_m()->access_flags());
76
77 // Easy to compute, so fill them in now.
78 _max_stack = h_m()->max_stack();
79 _max_locals = h_m()->max_locals();
80 _code_size = h_m()->code_size();
81 _intrinsic_id = h_m()->intrinsic_id();
82 _handler_count = h_m()->exception_table_length();
83 _size_of_parameters = h_m()->size_of_parameters();
84 _uses_monitors = h_m()->access_flags().has_monitor_bytecodes();
85 _balanced_monitors = !_uses_monitors || h_m()->access_flags().is_monitor_matching();
86 _is_c1_compilable = !h_m()->is_not_c1_compilable();
87 _is_c2_compilable = !h_m()->is_not_c2_compilable();
88 // Lazy fields, filled in on demand. Require allocation.
89 _code = NULL;
90 _exception_handlers = NULL;
91 _liveness = NULL;
92 _method_blocks = NULL;
93 #if defined(COMPILER2) || defined(SHARK)
94 _flow = NULL;
95 _bcea = NULL;
96 #endif // COMPILER2 || SHARK
97
98 ciEnv *env = CURRENT_ENV;
99 if (env->jvmti_can_hotswap_or_post_breakpoint() && can_be_compiled()) {
100 // 6328518 check hotswap conditions under the right lock.
101 MutexLocker locker(Compile_lock);
102 if (Dependencies::check_evol_method(h_m()) != NULL) {
103 _is_c1_compilable = false;
859 }
860 return -1; // unknown
861 }
862
863 // ------------------------------------------------------------------
864 // ciMethod::get_field_at_bci
865 ciField* ciMethod::get_field_at_bci(int bci, bool &will_link) {
866 ciBytecodeStream iter(this);
867 iter.reset_to_bci(bci);
868 iter.next();
869 return iter.get_field(will_link);
870 }
871
872 // ------------------------------------------------------------------
873 // ciMethod::get_method_at_bci
874 ciMethod* ciMethod::get_method_at_bci(int bci, bool &will_link, ciSignature* *declared_signature) {
875 ciBytecodeStream iter(this);
876 iter.reset_to_bci(bci);
877 iter.next();
878 return iter.get_method(will_link, declared_signature);
879 }
880
881 // How much stack slots is this invoke going to add or remove?
882 int ciMethod::get_stack_effect_at_invoke(int bci, Bytecodes::Code code, int& inputs) {
883 assert(Bytecodes::is_invoke(code), "not an invoke");
884 bool ignored_will_link;
885 ciSignature* declared_signature = NULL;
886 ciMethod* ignored_callee = get_method_at_bci(bci, ignored_will_link, &declared_signature);
887 assert(declared_signature != NULL, "cannot be null");
888 inputs = declared_signature->arg_size_for_bc(code);
889 int size = declared_signature->return_type()->size();
890 return size - inputs;
891 }
892
893 int ciMethod::get_stack_effect_if_at_invoke(int bci) {
894 Bytecodes::Code code = java_code_at_bci(bci);
895 if (Bytecodes::is_invoke(code)) {
896 int ignored = 0;
897 return get_stack_effect_at_invoke(bci, code, ignored);
898 }
899 return 0;
900 }
901
902 // ------------------------------------------------------------------
903 // Adjust a CounterData count to be commensurate with
904 // interpreter_invocation_count. If the MDO exists for
905 // only 25% of the time the method exists, then the
906 // counts in the MDO should be scaled by 4X, so that
907 // they can be usefully and stably compared against the
908 // invocation counts in methods.
909 int ciMethod::scale_count(int count, float prof_factor) {
910 if (count > 0 && method_data() != NULL) {
911 int counter_life;
912 int method_life = interpreter_invocation_count();
913 if (TieredCompilation) {
914 // In tiered the MDO's life is measured directly, so just use the snapshotted counters
915 counter_life = MAX2(method_data()->invocation_count(), method_data()->backedge_count());
916 } else {
917 int current_mileage = method_data()->current_mileage();
918 int creation_mileage = method_data()->creation_mileage();
919 counter_life = current_mileage - creation_mileage;
|