src/share/vm/ci/ciMethod.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/ci

src/share/vm/ci/ciMethod.cpp

Print this page




  75   assert(h_m() != NULL, "no null method");
  76 
  77   if (LogTouchedMethods) {
  78     h_m()->log_touched(Thread::current());
  79   }
  80   // These fields are always filled in in loaded methods.
  81   _flags = ciFlags(h_m()->access_flags());
  82 
  83   // Easy to compute, so fill them in now.
  84   _max_stack          = h_m()->max_stack();
  85   _max_locals         = h_m()->max_locals();
  86   _code_size          = h_m()->code_size();
  87   _intrinsic_id       = h_m()->intrinsic_id();
  88   _handler_count      = h_m()->exception_table_length();
  89   _size_of_parameters = h_m()->size_of_parameters();
  90   _uses_monitors      = h_m()->access_flags().has_monitor_bytecodes();
  91   _balanced_monitors  = !_uses_monitors || h_m()->access_flags().is_monitor_matching();
  92   _is_c1_compilable   = !h_m()->is_not_c1_compilable();
  93   _is_c2_compilable   = !h_m()->is_not_c2_compilable();
  94   _has_reserved_stack_access = h_m()->has_reserved_stack_access();

  95   // Lazy fields, filled in on demand.  Require allocation.
  96   _code               = NULL;
  97   _exception_handlers = NULL;
  98   _liveness           = NULL;
  99   _method_blocks = NULL;
 100 #if defined(COMPILER2) || defined(SHARK)
 101   _flow               = NULL;
 102   _bcea               = NULL;
 103 #endif // COMPILER2 || SHARK
 104 
 105   ciEnv *env = CURRENT_ENV;
 106   if (env->jvmti_can_hotswap_or_post_breakpoint() && can_be_compiled()) {
 107     // 6328518 check hotswap conditions under the right lock.
 108     MutexLocker locker(Compile_lock);
 109     if (Dependencies::check_evol_method(h_m()) != NULL) {
 110       _is_c1_compilable = false;
 111       _is_c2_compilable = false;
 112     }
 113   } else {
 114     CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());


 713     return root_m;
 714   }
 715 
 716   if (actual_recv->is_leaf_type() && actual_recv == root_m->holder()) {
 717     // Easy case.  There is no other place to put a method, so don't bother
 718     // to go through the VM_ENTRY_MARK and all the rest.
 719     return root_m;
 720   }
 721 
 722   // Array methods (clone, hashCode, etc.) are always statically bound.
 723   // If we were to see an array type here, we'd return root_m.
 724   // However, this method processes only ciInstanceKlasses.  (See 4962591.)
 725   // The inline_native_clone intrinsic narrows Object to T[] properly,
 726   // so there is no need to do the same job here.
 727 
 728   if (!UseCHA)  return NULL;
 729 
 730   VM_ENTRY_MARK;
 731 
 732   // Disable CHA for default methods for now
 733   if (root_m->get_Method()->is_default_method()) {
 734     return NULL;
 735   }
 736 
 737   methodHandle target;
 738   {
 739     MutexLocker locker(Compile_lock);
 740     Klass* context = actual_recv->get_Klass();
 741     target = Dependencies::find_unique_concrete_method(context,
 742                                                        root_m->get_Method());
 743     // %%% Should upgrade this ciMethod API to look for 1 or 2 concrete methods.
 744   }
 745 
 746 #ifndef PRODUCT
 747   if (TraceDependencies && target() != NULL && target() != root_m->get_Method()) {
 748     tty->print("found a non-root unique target method");
 749     tty->print_cr("  context = %s", actual_recv->get_Klass()->external_name());
 750     tty->print("  method  = ");
 751     target->print_short_name(tty);
 752     tty->cr();
 753   }
 754 #endif //PRODUCT
 755 
 756   if (target() == NULL) {
 757     return NULL;
 758   }
 759   if (target() == root_m->get_Method()) {
 760     return root_m;
 761   }
 762   if (!root_m->is_public() &&
 763       !root_m->is_protected()) {
 764     // If we are going to reason about inheritance, it's easiest
 765     // if the method in question is public, protected, or private.
 766     // If the answer is not root_m, it is conservatively correct
 767     // to return NULL, even if the CHA encountered irrelevant
 768     // methods in other packages.
 769     // %%% TO DO: Work out logic for package-private methods
 770     // with the same name but different vtable indexes.
 771     return NULL;
 772   }

 773   return CURRENT_THREAD_ENV->get_method(target());
 774 }
 775 
 776 // ------------------------------------------------------------------
 777 // ciMethod::resolve_invoke
 778 //
 779 // Given a known receiver klass, find the target for the call.
 780 // Return NULL if the call has no target or the target is abstract.
 781 ciMethod* ciMethod::resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, bool check_access) {
 782    check_is_loaded();
 783    VM_ENTRY_MARK;
 784 
 785    KlassHandle caller_klass (THREAD, caller->get_Klass());
 786    KlassHandle h_recv       (THREAD, exact_receiver->get_Klass());
 787    KlassHandle h_resolved   (THREAD, holder()->get_Klass());
 788    Symbol* h_name      = name()->get_symbol();
 789    Symbol* h_signature = signature()->get_symbol();
 790 
 791    LinkInfo link_info(h_resolved, h_name, h_signature, caller_klass,
 792                       check_access ? LinkInfo::needs_access_check : LinkInfo::skip_access_check);


 869 
 870 // ------------------------------------------------------------------
 871 // ciMethod::get_field_at_bci
 872 ciField* ciMethod::get_field_at_bci(int bci, bool &will_link) {
 873   ciBytecodeStream iter(this);
 874   iter.reset_to_bci(bci);
 875   iter.next();
 876   return iter.get_field(will_link);
 877 }
 878 
 879 // ------------------------------------------------------------------
 880 // ciMethod::get_method_at_bci
 881 ciMethod* ciMethod::get_method_at_bci(int bci, bool &will_link, ciSignature* *declared_signature) {
 882   ciBytecodeStream iter(this);
 883   iter.reset_to_bci(bci);
 884   iter.next();
 885   return iter.get_method(will_link, declared_signature);
 886 }
 887 
 888 // ------------------------------------------------------------------








 889 // Adjust a CounterData count to be commensurate with
 890 // interpreter_invocation_count.  If the MDO exists for
 891 // only 25% of the time the method exists, then the
 892 // counts in the MDO should be scaled by 4X, so that
 893 // they can be usefully and stably compared against the
 894 // invocation counts in methods.
 895 int ciMethod::scale_count(int count, float prof_factor) {
 896   if (count > 0 && method_data() != NULL) {
 897     int counter_life;
 898     int method_life = interpreter_invocation_count();
 899     if (TieredCompilation) {
 900       // In tiered the MDO's life is measured directly, so just use the snapshotted counters
 901       counter_life = MAX2(method_data()->invocation_count(), method_data()->backedge_count());
 902     } else {
 903       int current_mileage = method_data()->current_mileage();
 904       int creation_mileage = method_data()->creation_mileage();
 905       counter_life = current_mileage - creation_mileage;
 906     }
 907 
 908     // counter_life due to backedge_counter could be > method_life




  75   assert(h_m() != NULL, "no null method");
  76 
  77   if (LogTouchedMethods) {
  78     h_m()->log_touched(Thread::current());
  79   }
  80   // These fields are always filled in in loaded methods.
  81   _flags = ciFlags(h_m()->access_flags());
  82 
  83   // Easy to compute, so fill them in now.
  84   _max_stack          = h_m()->max_stack();
  85   _max_locals         = h_m()->max_locals();
  86   _code_size          = h_m()->code_size();
  87   _intrinsic_id       = h_m()->intrinsic_id();
  88   _handler_count      = h_m()->exception_table_length();
  89   _size_of_parameters = h_m()->size_of_parameters();
  90   _uses_monitors      = h_m()->access_flags().has_monitor_bytecodes();
  91   _balanced_monitors  = !_uses_monitors || h_m()->access_flags().is_monitor_matching();
  92   _is_c1_compilable   = !h_m()->is_not_c1_compilable();
  93   _is_c2_compilable   = !h_m()->is_not_c2_compilable();
  94   _has_reserved_stack_access = h_m()->has_reserved_stack_access();
  95   _is_overpass        = h_m()->is_overpass();
  96   // Lazy fields, filled in on demand.  Require allocation.
  97   _code               = NULL;
  98   _exception_handlers = NULL;
  99   _liveness           = NULL;
 100   _method_blocks = NULL;
 101 #if defined(COMPILER2) || defined(SHARK)
 102   _flow               = NULL;
 103   _bcea               = NULL;
 104 #endif // COMPILER2 || SHARK
 105 
 106   ciEnv *env = CURRENT_ENV;
 107   if (env->jvmti_can_hotswap_or_post_breakpoint() && can_be_compiled()) {
 108     // 6328518 check hotswap conditions under the right lock.
 109     MutexLocker locker(Compile_lock);
 110     if (Dependencies::check_evol_method(h_m()) != NULL) {
 111       _is_c1_compilable = false;
 112       _is_c2_compilable = false;
 113     }
 114   } else {
 115     CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());


 714     return root_m;
 715   }
 716 
 717   if (actual_recv->is_leaf_type() && actual_recv == root_m->holder()) {
 718     // Easy case.  There is no other place to put a method, so don't bother
 719     // to go through the VM_ENTRY_MARK and all the rest.
 720     return root_m;
 721   }
 722 
 723   // Array methods (clone, hashCode, etc.) are always statically bound.
 724   // If we were to see an array type here, we'd return root_m.
 725   // However, this method processes only ciInstanceKlasses.  (See 4962591.)
 726   // The inline_native_clone intrinsic narrows Object to T[] properly,
 727   // so there is no need to do the same job here.
 728 
 729   if (!UseCHA)  return NULL;
 730 
 731   VM_ENTRY_MARK;
 732 
 733   // Disable CHA for default methods for now
 734   if (root_m->is_default_method()) {
 735     return NULL;
 736   }
 737 
 738   methodHandle target;
 739   {
 740     MutexLocker locker(Compile_lock);
 741     Klass* context = actual_recv->get_Klass();
 742     target = Dependencies::find_unique_concrete_method(context,
 743                                                        root_m->get_Method());
 744     // %%% Should upgrade this ciMethod API to look for 1 or 2 concrete methods.
 745   }
 746 
 747 #ifndef PRODUCT
 748   if (TraceDependencies && target() != NULL && target() != root_m->get_Method()) {
 749     tty->print("found a non-root unique target method");
 750     tty->print_cr("  context = %s", actual_recv->get_Klass()->external_name());
 751     tty->print("  method  = ");
 752     target->print_short_name(tty);
 753     tty->cr();
 754   }
 755 #endif //PRODUCT
 756 
 757   if (target() == NULL) {
 758     return NULL;
 759   }
 760   if (target() == root_m->get_Method()) {
 761     return root_m;
 762   }
 763   if (!root_m->is_public() &&
 764       !root_m->is_protected()) {
 765     // If we are going to reason about inheritance, it's easiest
 766     // if the method in question is public, protected, or private.
 767     // If the answer is not root_m, it is conservatively correct
 768     // to return NULL, even if the CHA encountered irrelevant
 769     // methods in other packages.
 770     // %%% TO DO: Work out logic for package-private methods
 771     // with the same name but different vtable indexes.
 772     return NULL;
 773   }
 774   assert(!target()->is_abstract(), "not allowed");
 775   return CURRENT_THREAD_ENV->get_method(target());
 776 }
 777 
 778 // ------------------------------------------------------------------
 779 // ciMethod::resolve_invoke
 780 //
 781 // Given a known receiver klass, find the target for the call.
 782 // Return NULL if the call has no target or the target is abstract.
 783 ciMethod* ciMethod::resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, bool check_access) {
 784    check_is_loaded();
 785    VM_ENTRY_MARK;
 786 
 787    KlassHandle caller_klass (THREAD, caller->get_Klass());
 788    KlassHandle h_recv       (THREAD, exact_receiver->get_Klass());
 789    KlassHandle h_resolved   (THREAD, holder()->get_Klass());
 790    Symbol* h_name      = name()->get_symbol();
 791    Symbol* h_signature = signature()->get_symbol();
 792 
 793    LinkInfo link_info(h_resolved, h_name, h_signature, caller_klass,
 794                       check_access ? LinkInfo::needs_access_check : LinkInfo::skip_access_check);


 871 
 872 // ------------------------------------------------------------------
 873 // ciMethod::get_field_at_bci
 874 ciField* ciMethod::get_field_at_bci(int bci, bool &will_link) {
 875   ciBytecodeStream iter(this);
 876   iter.reset_to_bci(bci);
 877   iter.next();
 878   return iter.get_field(will_link);
 879 }
 880 
 881 // ------------------------------------------------------------------
 882 // ciMethod::get_method_at_bci
 883 ciMethod* ciMethod::get_method_at_bci(int bci, bool &will_link, ciSignature* *declared_signature) {
 884   ciBytecodeStream iter(this);
 885   iter.reset_to_bci(bci);
 886   iter.next();
 887   return iter.get_method(will_link, declared_signature);
 888 }
 889 
 890 // ------------------------------------------------------------------
 891 ciKlass* ciMethod::get_declared_method_holder_at_bci(int bci) {
 892   ciBytecodeStream iter(this);
 893   iter.reset_to_bci(bci);
 894   iter.next();
 895   return iter.get_declared_method_holder();
 896 }
 897 
 898 // ------------------------------------------------------------------
 899 // Adjust a CounterData count to be commensurate with
 900 // interpreter_invocation_count.  If the MDO exists for
 901 // only 25% of the time the method exists, then the
 902 // counts in the MDO should be scaled by 4X, so that
 903 // they can be usefully and stably compared against the
 904 // invocation counts in methods.
 905 int ciMethod::scale_count(int count, float prof_factor) {
 906   if (count > 0 && method_data() != NULL) {
 907     int counter_life;
 908     int method_life = interpreter_invocation_count();
 909     if (TieredCompilation) {
 910       // In tiered the MDO's life is measured directly, so just use the snapshotted counters
 911       counter_life = MAX2(method_data()->invocation_count(), method_data()->backedge_count());
 912     } else {
 913       int current_mileage = method_data()->current_mileage();
 914       int creation_mileage = method_data()->creation_mileage();
 915       counter_life = current_mileage - creation_mileage;
 916     }
 917 
 918     // counter_life due to backedge_counter could be > method_life


src/share/vm/ci/ciMethod.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File