@@ -476,6 +476,85 @@ class nmethod : public CodeBlob {
476
476
void oops_do_set_strong_done (nmethod* old_head);
477
477
478
478
public:
479
+ enum class ChangeReason : u1 {
480
+ C1_codepatch,
481
+ C1_deoptimize,
482
+ C1_deoptimize_for_patching,
483
+ C1_predicate_failed_trap,
484
+ CI_replay,
485
+ JVMCI_invalidate_nmethod,
486
+ JVMCI_invalidate_nmethod_mirror,
487
+ JVMCI_materialize_virtual_object,
488
+ JVMCI_new_installation,
489
+ JVMCI_register_method,
490
+ JVMCI_replacing_with_new_code,
491
+ JVMCI_reprofile,
492
+ marked_for_deoptimization,
493
+ missing_exception_handler,
494
+ not_used,
495
+ OSR_invalidation_back_branch,
496
+ OSR_invalidation_for_compiling_with_C1,
497
+ OSR_invalidation_of_lower_level,
498
+ set_native_function,
499
+ uncommon_trap,
500
+ whitebox_deoptimization,
501
+ zombie,
502
+ };
503
+
504
+
505
+ static const char * change_reason_to_string (ChangeReason change_reason) {
506
+ switch (change_reason) {
507
+ case ChangeReason::C1_codepatch:
508
+ return " C1 code patch" ;
509
+ case ChangeReason::C1_deoptimize:
510
+ return " C1 deoptimized" ;
511
+ case ChangeReason::C1_deoptimize_for_patching:
512
+ return " C1 deoptimize for patching" ;
513
+ case ChangeReason::C1_predicate_failed_trap:
514
+ return " C1 predicate failed trap" ;
515
+ case ChangeReason::CI_replay:
516
+ return " CI replay" ;
517
+ case ChangeReason::JVMCI_invalidate_nmethod:
518
+ return " JVMCI invalidate nmethod" ;
519
+ case ChangeReason::JVMCI_invalidate_nmethod_mirror:
520
+ return " JVMCI invalidate nmethod mirror" ;
521
+ case ChangeReason::JVMCI_materialize_virtual_object:
522
+ return " JVMCI materialize virtual object" ;
523
+ case ChangeReason::JVMCI_new_installation:
524
+ return " JVMCI new installation" ;
525
+ case ChangeReason::JVMCI_register_method:
526
+ return " JVMCI register method" ;
527
+ case ChangeReason::JVMCI_replacing_with_new_code:
528
+ return " JVMCI replacing with new code" ;
529
+ case ChangeReason::JVMCI_reprofile:
530
+ return " JVMCI reprofile" ;
531
+ case ChangeReason::marked_for_deoptimization:
532
+ return " marked for deoptimization" ;
533
+ case ChangeReason::missing_exception_handler:
534
+ return " missing exception handler" ;
535
+ case ChangeReason::not_used:
536
+ return " not used" ;
537
+ case ChangeReason::OSR_invalidation_back_branch:
538
+ return " OSR invalidation back branch" ;
539
+ case ChangeReason::OSR_invalidation_for_compiling_with_C1:
540
+ return " OSR invalidation for compiling with C1" ;
541
+ case ChangeReason::OSR_invalidation_of_lower_level:
542
+ return " OSR invalidation of lower level" ;
543
+ case ChangeReason::set_native_function:
544
+ return " set native function" ;
545
+ case ChangeReason::uncommon_trap:
546
+ return " uncommon trap" ;
547
+ case ChangeReason::whitebox_deoptimization:
548
+ return " whitebox deoptimization" ;
549
+ case ChangeReason::zombie:
550
+ return " zombie" ;
551
+ default : {
552
+ assert (false , " Unhandled reason" );
553
+ return " Unknown" ;
554
+ }
555
+ }
556
+ }
557
+
479
558
// create nmethod with entry_bci
480
559
static nmethod* new_nmethod (const methodHandle& method,
481
560
int compile_id,
@@ -641,8 +720,8 @@ class nmethod : public CodeBlob {
641
720
// alive. It is used when an uncommon trap happens. Returns true
642
721
// if this thread changed the state of the nmethod or false if
643
722
// another thread performed the transition.
644
- bool make_not_entrant (const char * reason );
645
- bool make_not_used () { return make_not_entrant (" not used " ); }
723
+ bool make_not_entrant (ChangeReason change_reason );
724
+ bool make_not_used () { return make_not_entrant (ChangeReason::not_used ); }
646
725
647
726
bool is_marked_for_deoptimization () const { return deoptimization_status () != not_marked; }
648
727
bool has_been_deoptimized () const { return deoptimization_status () == deoptimize_done; }
@@ -965,7 +1044,7 @@ class nmethod : public CodeBlob {
965
1044
// Logging
966
1045
void log_identity (xmlStream* log) const ;
967
1046
void log_new_nmethod () const ;
968
- void log_state_change (const char * reason ) const ;
1047
+ void log_state_change (ChangeReason change_reason ) const ;
969
1048
970
1049
// Prints block-level comments, including nmethod specific block labels:
971
1050
void print_nmethod_labels (outputStream* stream, address block_begin, bool print_section_labels=true ) const ;
0 commit comments