< prev index next >

src/hotspot/share/code/nmethod.hpp

Print this page

 454   bool oops_do_try_claim_weak_request();
 455 
 456   // Attempt Unclaimed -> N|SD transition. Returns the current link.
 457   oops_do_mark_link* oops_do_try_claim_strong_done();
 458   // Attempt N|WR -> X|WD transition. Returns nullptr if successful, X otherwise.
 459   nmethod* oops_do_try_add_to_list_as_weak_done();
 460 
 461   // Attempt X|WD -> N|SR transition. Returns the current link.
 462   oops_do_mark_link* oops_do_try_add_strong_request(oops_do_mark_link* next);
 463   // Attempt X|WD -> X|SD transition. Returns true if successful.
 464   bool oops_do_try_claim_weak_done_as_strong_done(oops_do_mark_link* next);
 465 
 466   // Do the N|SD -> X|SD transition.
 467   void oops_do_add_to_list_as_strong_done();
 468 
 469   // Sets this nmethod as strongly claimed (as part of N|SD -> X|SD and N|SR -> X|SD
 470   // transitions).
 471   void oops_do_set_strong_done(nmethod* old_head);
 472 
 473 public:
 474   enum class ChangeReason : u1 {
 475     C1_codepatch,
 476     C1_deoptimize,
 477     C1_deoptimize_for_patching,
 478     C1_predicate_failed_trap,
 479     CI_replay,
 480     JVMCI_invalidate_nmethod,
 481     JVMCI_invalidate_nmethod_mirror,
 482     JVMCI_materialize_virtual_object,
 483     JVMCI_new_installation,
 484     JVMCI_register_method,
 485     JVMCI_replacing_with_new_code,
 486     JVMCI_reprofile,
 487     marked_for_deoptimization,
 488     missing_exception_handler,
 489     not_used,
 490     OSR_invalidation_back_branch,
 491     OSR_invalidation_for_compiling_with_C1,
 492     OSR_invalidation_of_lower_level,
 493     set_native_function,
 494     uncommon_trap,
 495     whitebox_deoptimization,
 496     zombie,



 497   };
 498 
 499 
 500   static const char* change_reason_to_string(ChangeReason change_reason) {
 501     switch (change_reason) {
 502       case ChangeReason::C1_codepatch:
 503         return "C1 code patch";
 504       case ChangeReason::C1_deoptimize:
 505         return "C1 deoptimized";
 506       case ChangeReason::C1_deoptimize_for_patching:
 507         return "C1 deoptimize for patching";
 508       case ChangeReason::C1_predicate_failed_trap:
 509         return "C1 predicate failed trap";
 510       case ChangeReason::CI_replay:
 511         return "CI replay";
 512       case ChangeReason::JVMCI_invalidate_nmethod:
 513         return "JVMCI invalidate nmethod";
 514       case ChangeReason::JVMCI_invalidate_nmethod_mirror:
 515         return "JVMCI invalidate nmethod mirror";
 516       case ChangeReason::JVMCI_materialize_virtual_object:
 517         return "JVMCI materialize virtual object";
 518       case ChangeReason::JVMCI_new_installation:
 519         return "JVMCI new installation";
 520       case ChangeReason::JVMCI_register_method:
 521         return "JVMCI register method";
 522       case ChangeReason::JVMCI_replacing_with_new_code:
 523         return "JVMCI replacing with new code";
 524       case ChangeReason::JVMCI_reprofile:
 525         return "JVMCI reprofile";
 526       case ChangeReason::marked_for_deoptimization:
 527         return "marked for deoptimization";
 528       case ChangeReason::missing_exception_handler:
 529         return "missing exception handler";
 530       case ChangeReason::not_used:
 531         return "not used";
 532       case ChangeReason::OSR_invalidation_back_branch:
 533         return "OSR invalidation back branch";
 534       case ChangeReason::OSR_invalidation_for_compiling_with_C1:
 535         return "OSR invalidation for compiling with C1";
 536       case ChangeReason::OSR_invalidation_of_lower_level:
 537         return "OSR invalidation of lower level";
 538       case ChangeReason::set_native_function:
 539         return "set native function";
 540       case ChangeReason::uncommon_trap:
 541         return "uncommon trap";
 542       case ChangeReason::whitebox_deoptimization:
 543         return "whitebox deoptimization";
 544       case ChangeReason::zombie:
 545         return "zombie";
 546       default: {
 547         assert(false, "Unhandled reason");
 548         return "Unknown";
 549       }
 550     }
 551   }
 552 
 553   // create nmethod with entry_bci
 554   static nmethod* new_nmethod(const methodHandle& method,
 555                               int compile_id,
 556                               int entry_bci,
 557                               CodeOffsets* offsets,
 558                               int orig_pc_offset,
 559                               DebugInformationRecorder* recorder,
 560                               Dependencies* dependencies,
 561                               CodeBuffer *code_buffer,
 562                               int frame_size,
 563                               OopMapSet* oop_maps,
 564                               ExceptionHandlerTable* handler_table,

 695 
 696   // flag accessing and manipulation
 697   bool is_not_installed() const        { return _state == not_installed; }
 698   bool is_in_use() const               { return _state <= in_use; }
 699   bool is_not_entrant() const          { return _state == not_entrant; }
 700   int  get_state() const               { return _state; }
 701 
 702   void clear_unloading_state();
 703   // Heuristically deduce an nmethod isn't worth keeping around
 704   bool is_cold();
 705   bool is_unloading();
 706   void do_unloading(bool unloading_occurred);
 707 
 708   bool make_in_use() {
 709     return try_transition(in_use);
 710   }
 711   // Make the nmethod non entrant. The nmethod will continue to be
 712   // alive.  It is used when an uncommon trap happens.  Returns true
 713   // if this thread changed the state of the nmethod or false if
 714   // another thread performed the transition.
 715   bool  make_not_entrant(ChangeReason change_reason);
 716   bool  make_not_used() { return make_not_entrant(ChangeReason::not_used); }
 717 
 718   bool  is_marked_for_deoptimization() const { return deoptimization_status() != not_marked; }
 719   bool  has_been_deoptimized() const { return deoptimization_status() == deoptimize_done; }
 720   void  set_deoptimized_done();
 721 
 722   bool update_recompile_counts() const {
 723     // Update recompile counts when either the update is explicitly requested (deoptimize)
 724     // or the nmethod is not marked for deoptimization at all (not_marked).
 725     // The latter happens during uncommon traps when deoptimized nmethod is made not entrant.
 726     DeoptimizationStatus status = deoptimization_status();
 727     return status != deoptimize_noupdate && status != deoptimize_done;
 728   }
 729 
 730   // tells whether frames described by this nmethod can be deoptimized
 731   // note: native wrappers cannot be deoptimized.
 732   bool can_be_deoptimized() const { return is_java_method(); }
 733 
 734   bool has_dependencies()                         { return dependencies_size() != 0; }
 735   void print_dependencies_on(outputStream* out) PRODUCT_RETURN;
 736   void flush_dependencies();

1009   void print_recorded_oops();
1010   void print_recorded_metadata();
1011 
1012   void print_oops(outputStream* st);     // oops from the underlying CodeBlob.
1013   void print_metadata(outputStream* st); // metadata in metadata pool.
1014 #else
1015   void print_pcs_on(outputStream* st) { return; }
1016 #endif
1017 
1018   void print_calls(outputStream* st)              PRODUCT_RETURN;
1019   static void print_statistics()                  PRODUCT_RETURN;
1020 
1021   void maybe_print_nmethod(const DirectiveSet* directive);
1022   void print_nmethod(bool print_code);
1023 
1024   void print_on_with_msg(outputStream* st, const char* msg) const;
1025 
1026   // Logging
1027   void log_identity(xmlStream* log) const;
1028   void log_new_nmethod() const;
1029   void log_state_change(ChangeReason change_reason) const;
1030 
1031   // Prints block-level comments, including nmethod specific block labels:
1032   void print_nmethod_labels(outputStream* stream, address block_begin, bool print_section_labels=true) const;
1033   const char* nmethod_section_label(address pos) const;
1034 
1035   // returns whether this nmethod has code comments.
1036   bool has_code_comment(address begin, address end);
1037   // Prints a comment for one native instruction (reloc info, pc desc)
1038   void print_code_comment_on(outputStream* st, int column, address begin, address end);
1039 
1040   // tells if this compiled method is dependent on the given changes,
1041   // and the changes have invalidated it
1042   bool check_dependency_on(DepChange& changes);
1043 
1044   // Fast breakpoint support. Tells if this compiled method is
1045   // dependent on the given method. Returns true if this nmethod
1046   // corresponds to the given method as well.
1047   bool is_dependent_on_method(Method* dependee);
1048 
1049   // JVMTI's GetLocalInstance() support

 454   bool oops_do_try_claim_weak_request();
 455 
 456   // Attempt Unclaimed -> N|SD transition. Returns the current link.
 457   oops_do_mark_link* oops_do_try_claim_strong_done();
 458   // Attempt N|WR -> X|WD transition. Returns nullptr if successful, X otherwise.
 459   nmethod* oops_do_try_add_to_list_as_weak_done();
 460 
 461   // Attempt X|WD -> N|SR transition. Returns the current link.
 462   oops_do_mark_link* oops_do_try_add_strong_request(oops_do_mark_link* next);
 463   // Attempt X|WD -> X|SD transition. Returns true if successful.
 464   bool oops_do_try_claim_weak_done_as_strong_done(oops_do_mark_link* next);
 465 
 466   // Do the N|SD -> X|SD transition.
 467   void oops_do_add_to_list_as_strong_done();
 468 
 469   // Sets this nmethod as strongly claimed (as part of N|SD -> X|SD and N|SR -> X|SD
 470   // transitions).
 471   void oops_do_set_strong_done(nmethod* old_head);
 472 
 473 public:
 474   // If you change anything in this enum please patch
 475   // vmStructs_jvmci.cpp accordingly.
 476   enum class InvalidationReason : s1 {
 477     NOT_INVALIDATED = -1,
 478     C1_CODEPATCH,
 479     C1_DEOPTIMIZE,
 480     C1_DEOPTIMIZE_FOR_PATCHING,
 481     C1_PREDICATE_FAILED_TRAP,
 482     CI_REPLAY,
 483     UNLOADING,
 484     UNLOADING_COLD,
 485     JVMCI_INVALIDATE,
 486     JVMCI_MATERIALIZE_VIRTUAL_OBJECT,
 487     JVMCI_REPLACED_WITH_NEW_CODE,
 488     JVMCI_REPROFILE,
 489     MARKED_FOR_DEOPTIMIZATION,
 490     MISSING_EXCEPTION_HANDLER,
 491     NOT_USED,
 492     OSR_INVALIDATION_BACK_BRANCH,
 493     OSR_INVALIDATION_FOR_COMPILING_WITH_C1,
 494     OSR_INVALIDATION_OF_LOWER_LEVEL,
 495     SET_NATIVE_FUNCTION,
 496     UNCOMMON_TRAP,
 497     WHITEBOX_DEOPTIMIZATION,
 498     ZOMBIE,
 499     INVALIDATION_REASONS_COUNT
 500   };
 501 
 502 
 503   static const char* invalidation_reason_to_string(InvalidationReason invalidation_reason) {
 504     switch (invalidation_reason) {
 505       case InvalidationReason::C1_CODEPATCH:
 506         return "C1 code patch";
 507       case InvalidationReason::C1_DEOPTIMIZE:
 508         return "C1 deoptimized";
 509       case InvalidationReason::C1_DEOPTIMIZE_FOR_PATCHING:
 510         return "C1 deoptimize for patching";
 511       case InvalidationReason::C1_PREDICATE_FAILED_TRAP:
 512         return "C1 predicate failed trap";
 513       case InvalidationReason::CI_REPLAY:
 514         return "CI replay";
 515       case InvalidationReason::JVMCI_INVALIDATE:
 516         return "JVMCI invalidate";
 517       case InvalidationReason::JVMCI_MATERIALIZE_VIRTUAL_OBJECT:


 518         return "JVMCI materialize virtual object";
 519       case InvalidationReason::JVMCI_REPLACED_WITH_NEW_CODE:
 520         return "JVMCI replaced with new code";
 521       case InvalidationReason::JVMCI_REPROFILE:




 522         return "JVMCI reprofile";
 523       case InvalidationReason::MARKED_FOR_DEOPTIMIZATION:
 524         return "marked for deoptimization";
 525       case InvalidationReason::MISSING_EXCEPTION_HANDLER:
 526         return "missing exception handler";
 527       case InvalidationReason::NOT_USED:
 528         return "not used";
 529       case InvalidationReason::OSR_INVALIDATION_BACK_BRANCH:
 530         return "OSR invalidation back branch";
 531       case InvalidationReason::OSR_INVALIDATION_FOR_COMPILING_WITH_C1:
 532         return "OSR invalidation for compiling with C1";
 533       case InvalidationReason::OSR_INVALIDATION_OF_LOWER_LEVEL:
 534         return "OSR invalidation of lower level";
 535       case InvalidationReason::SET_NATIVE_FUNCTION:
 536         return "set native function";
 537       case InvalidationReason::UNCOMMON_TRAP:
 538         return "uncommon trap";
 539       case InvalidationReason::WHITEBOX_DEOPTIMIZATION:
 540         return "whitebox deoptimization";
 541       case InvalidationReason::ZOMBIE:
 542         return "zombie";
 543       default: {
 544         assert(false, "Unhandled reason");
 545         return "Unknown";
 546       }
 547     }
 548   }
 549 
 550   // create nmethod with entry_bci
 551   static nmethod* new_nmethod(const methodHandle& method,
 552                               int compile_id,
 553                               int entry_bci,
 554                               CodeOffsets* offsets,
 555                               int orig_pc_offset,
 556                               DebugInformationRecorder* recorder,
 557                               Dependencies* dependencies,
 558                               CodeBuffer *code_buffer,
 559                               int frame_size,
 560                               OopMapSet* oop_maps,
 561                               ExceptionHandlerTable* handler_table,

 692 
 693   // flag accessing and manipulation
 694   bool is_not_installed() const        { return _state == not_installed; }
 695   bool is_in_use() const               { return _state <= in_use; }
 696   bool is_not_entrant() const          { return _state == not_entrant; }
 697   int  get_state() const               { return _state; }
 698 
 699   void clear_unloading_state();
 700   // Heuristically deduce an nmethod isn't worth keeping around
 701   bool is_cold();
 702   bool is_unloading();
 703   void do_unloading(bool unloading_occurred);
 704 
 705   bool make_in_use() {
 706     return try_transition(in_use);
 707   }
 708   // Make the nmethod non entrant. The nmethod will continue to be
 709   // alive.  It is used when an uncommon trap happens.  Returns true
 710   // if this thread changed the state of the nmethod or false if
 711   // another thread performed the transition.
 712   bool  make_not_entrant(InvalidationReason invalidation_reason);
 713   bool  make_not_used() { return make_not_entrant(InvalidationReason::NOT_USED); }
 714 
 715   bool  is_marked_for_deoptimization() const { return deoptimization_status() != not_marked; }
 716   bool  has_been_deoptimized() const { return deoptimization_status() == deoptimize_done; }
 717   void  set_deoptimized_done();
 718 
 719   bool update_recompile_counts() const {
 720     // Update recompile counts when either the update is explicitly requested (deoptimize)
 721     // or the nmethod is not marked for deoptimization at all (not_marked).
 722     // The latter happens during uncommon traps when deoptimized nmethod is made not entrant.
 723     DeoptimizationStatus status = deoptimization_status();
 724     return status != deoptimize_noupdate && status != deoptimize_done;
 725   }
 726 
 727   // tells whether frames described by this nmethod can be deoptimized
 728   // note: native wrappers cannot be deoptimized.
 729   bool can_be_deoptimized() const { return is_java_method(); }
 730 
 731   bool has_dependencies()                         { return dependencies_size() != 0; }
 732   void print_dependencies_on(outputStream* out) PRODUCT_RETURN;
 733   void flush_dependencies();

1006   void print_recorded_oops();
1007   void print_recorded_metadata();
1008 
1009   void print_oops(outputStream* st);     // oops from the underlying CodeBlob.
1010   void print_metadata(outputStream* st); // metadata in metadata pool.
1011 #else
1012   void print_pcs_on(outputStream* st) { return; }
1013 #endif
1014 
1015   void print_calls(outputStream* st)              PRODUCT_RETURN;
1016   static void print_statistics()                  PRODUCT_RETURN;
1017 
1018   void maybe_print_nmethod(const DirectiveSet* directive);
1019   void print_nmethod(bool print_code);
1020 
1021   void print_on_with_msg(outputStream* st, const char* msg) const;
1022 
1023   // Logging
1024   void log_identity(xmlStream* log) const;
1025   void log_new_nmethod() const;
1026   void log_state_change(InvalidationReason invalidation_reason) const;
1027 
1028   // Prints block-level comments, including nmethod specific block labels:
1029   void print_nmethod_labels(outputStream* stream, address block_begin, bool print_section_labels=true) const;
1030   const char* nmethod_section_label(address pos) const;
1031 
1032   // returns whether this nmethod has code comments.
1033   bool has_code_comment(address begin, address end);
1034   // Prints a comment for one native instruction (reloc info, pc desc)
1035   void print_code_comment_on(outputStream* st, int column, address begin, address end);
1036 
1037   // tells if this compiled method is dependent on the given changes,
1038   // and the changes have invalidated it
1039   bool check_dependency_on(DepChange& changes);
1040 
1041   // Fast breakpoint support. Tells if this compiled method is
1042   // dependent on the given method. Returns true if this nmethod
1043   // corresponds to the given method as well.
1044   bool is_dependent_on_method(Method* dependee);
1045 
1046   // JVMTI's GetLocalInstance() support
< prev index next >