@@ -471,6 +471,85 @@ class nmethod : public CodeBlob {
471471 void oops_do_set_strong_done (nmethod* old_head);
472472
473473public:
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+
474553 // create nmethod with entry_bci
475554 static nmethod* new_nmethod (const methodHandle& method,
476555 int compile_id,
@@ -633,8 +712,8 @@ class nmethod : public CodeBlob {
633712 // alive. It is used when an uncommon trap happens. Returns true
634713 // if this thread changed the state of the nmethod or false if
635714 // another thread performed the transition.
636- bool make_not_entrant (const char * reason );
637- bool make_not_used () { return make_not_entrant (" not used " ); }
715+ bool make_not_entrant (ChangeReason change_reason );
716+ bool make_not_used () { return make_not_entrant (ChangeReason::not_used ); }
638717
639718 bool is_marked_for_deoptimization () const { return deoptimization_status () != not_marked; }
640719 bool has_been_deoptimized () const { return deoptimization_status () == deoptimize_done; }
@@ -947,7 +1026,7 @@ class nmethod : public CodeBlob {
9471026 // Logging
9481027 void log_identity (xmlStream* log) const ;
9491028 void log_new_nmethod () const ;
950- void log_state_change (const char * reason ) const ;
1029+ void log_state_change (ChangeReason change_reason ) const ;
9511030
9521031 // Prints block-level comments, including nmethod specific block labels:
9531032 void print_nmethod_labels (outputStream* stream, address block_begin, bool print_section_labels=true ) const ;
0 commit comments