changeset 10518:1fec7d381d2b

8136458: Remove "marked for reclamation" nmethod state Summary: Removed "marked for reclamation" nmethod state because only sweeper sets nmethods to zombie. Reviewed-by: kvn, neliasso
author thartmann
date Thu, 24 Mar 2016 09:09:52 +0100
parents 4226e949ec95
children c8c4c889fe4c d9cf2220c734
files src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java src/share/vm/code/nmethod.cpp src/share/vm/code/nmethod.hpp src/share/vm/runtime/sweeper.cpp src/share/vm/runtime/sweeper.hpp src/share/vm/trace/trace.xml test/compiler/whitebox/ForceNMethodSweepTest.java
diffstat 7 files changed, 10 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java	Wed Mar 23 15:35:38 2016 -0700
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java	Thu Mar 24 09:09:52 2016 +0100
@@ -249,7 +249,6 @@
   // public int     age();
   // public boolean isMarkedForDeoptimization();
   // public boolean isMarkedForUnloading();
-  // public boolean isMarkedForReclamation();
   // public int     level();
   // public int     version();
 
--- a/src/share/vm/code/nmethod.cpp	Wed Mar 23 15:35:38 2016 -0700
+++ b/src/share/vm/code/nmethod.cpp	Thu Mar 24 09:09:52 2016 +0100
@@ -530,7 +530,6 @@
 void nmethod::init_defaults() {
   _state                      = in_use;
   _unloading_clock            = 0;
-  _marked_for_reclamation     = 0;
   _has_flushed_dependencies   = 0;
   _has_unsafe_access          = 0;
   _has_method_handle_invokes  = 0;
@@ -1564,8 +1563,6 @@
   assert(!is_osr_method() || is_unloaded() || is_zombie(),
          "osr nmethod must be unloaded or zombie before flushing");
   assert(is_zombie() || is_osr_method(), "must be a zombie method");
-  assert(is_marked_for_reclamation() || is_osr_method(), "must be marked for reclamation");
-
   assert (!is_locked_by_vm(), "locked methods shouldn't be flushed");
   assert_locked_or_safepoint(CodeCache_lock);
 
--- a/src/share/vm/code/nmethod.hpp	Wed Mar 23 15:35:38 2016 -0700
+++ b/src/share/vm/code/nmethod.hpp	Thu Mar 24 09:09:52 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -188,8 +188,6 @@
   // protected by CodeCache_lock
   bool _has_flushed_dependencies;            // Used for maintenance of dependencies (CodeCache_lock)
 
-  bool _marked_for_reclamation;              // Used by NMethodSweeper (set only by sweeper)
-
   enum MarkForDeoptimizationStatus {
     not_marked,
     deoptimize,
@@ -503,9 +501,6 @@
     _has_flushed_dependencies = 1;
   }
 
-  bool  is_marked_for_reclamation() const         { return _marked_for_reclamation; }
-  void  mark_for_reclamation()                    { _marked_for_reclamation = 1; }
-
   bool  has_unsafe_access() const                 { return _has_unsafe_access; }
   void  set_has_unsafe_access(bool z)             { _has_unsafe_access = z; }
 
--- a/src/share/vm/runtime/sweeper.cpp	Wed Mar 23 15:35:38 2016 -0700
+++ b/src/share/vm/runtime/sweeper.cpp	Thu Mar 24 09:09:52 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -146,7 +146,6 @@
 volatile int  NMethodSweeper::_bytes_changed           = 0;    // Counts the total nmethod size if the nmethod changed from:
                                                                //   1) alive       -> not_entrant
                                                                //   2) not_entrant -> zombie
-                                                               //   3) zombie      -> marked_for_reclamation
 int    NMethodSweeper::_hotness_counter_reset_val       = 0;
 
 long   NMethodSweeper::_total_nof_methods_reclaimed     = 0;   // Accumulated nof methods flushed
@@ -397,7 +396,6 @@
 
   int flushed_count                = 0;
   int zombified_count              = 0;
-  int marked_for_reclamation_count = 0;
   int flushed_c2_count     = 0;
 
   if (PrintMethodFlushing && Verbose) {
@@ -442,10 +440,6 @@
               ++flushed_c2_count;
             }
             break;
-          case MarkedForReclamation:
-            state_after = "marked for reclamation";
-            ++marked_for_reclamation_count;
-            break;
           case MadeZombie:
             state_after = "made zombie";
             ++zombified_count;
@@ -486,7 +480,6 @@
     event.set_sweepIndex(_traversals);
     event.set_sweptCount(swept_count);
     event.set_flushedCount(flushed_count);
-    event.set_markedCount(marked_for_reclamation_count);
     event.set_zombifiedCount(zombified_count);
     event.commit();
   }
@@ -601,23 +594,12 @@
   }
 
   if (nm->is_zombie()) {
-    // If it is the first time we see nmethod then we mark it. Otherwise,
-    // we reclaim it. When we have seen a zombie method twice, we know that
-    // there are no inline caches that refer to it.
-    if (nm->is_marked_for_reclamation()) {
-      assert(!nm->is_locked_by_vm(), "must not flush locked nmethods");
-      release_nmethod(nm);
-      assert(result == None, "sanity");
-      result = Flushed;
-    } else {
-      nm->mark_for_reclamation();
-      // Keep track of code cache state change
-      _bytes_changed += nm->total_size();
-      SWEEP(nm);
-      assert(result == None, "sanity");
-      result = MarkedForReclamation;
-      assert(nm->is_marked_for_reclamation(), "nmethod must be marked for reclamation");
-    }
+    // All inline caches that referred to this nmethod were cleaned in the
+    // previous sweeper cycle. Now flush the nmethod from the code cache.
+    assert(!nm->is_locked_by_vm(), "must not flush locked nmethods");
+    release_nmethod(nm);
+    assert(result == None, "sanity");
+    result = Flushed;
   } else if (nm->is_not_entrant()) {
     // If there are no current activations of this method on the
     // stack we can safely convert it to a zombie method
--- a/src/share/vm/runtime/sweeper.hpp	Wed Mar 23 15:35:38 2016 -0700
+++ b/src/share/vm/runtime/sweeper.hpp	Thu Mar 24 09:09:52 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,7 +60,6 @@
   enum MethodStateChange {
     None,
     MadeZombie,
-    MarkedForReclamation,
     Flushed
   };
   static long      _traversals;                   // Stack scan count, also sweep ID.
@@ -76,7 +75,6 @@
   static volatile int _bytes_changed;             // Counts the total nmethod size if the nmethod changed from:
                                                   //   1) alive       -> not_entrant
                                                   //   2) not_entrant -> zombie
-                                                  //   3) zombie      -> marked_for_reclamation
   // Stat counters
   static long      _total_nof_methods_reclaimed;    // Accumulated nof methods flushed
   static long      _total_nof_c2_methods_reclaimed; // Accumulated nof C2-compiled methods flushed
--- a/src/share/vm/trace/trace.xml	Wed Mar 23 15:35:38 2016 -0700
+++ b/src/share/vm/trace/trace.xml	Thu Mar 24 09:09:52 2016 +0100
@@ -550,7 +550,6 @@
       <value type="INTEGER" field="sweepIndex" label="Sweep Index" relation="SWEEP_ID"/>
       <value type="UINT" field="sweptCount" label="Methods Swept"/>
       <value type="UINT" field="flushedCount" label="Methods Flushed"/>
-      <value type="UINT" field="markedCount" label="Methods Reclaimed"/>
       <value type="UINT" field="zombifiedCount" label="Methods Zombified"/>
     </event>
 
--- a/test/compiler/whitebox/ForceNMethodSweepTest.java	Wed Mar 23 15:35:38 2016 -0700
+++ b/test/compiler/whitebox/ForceNMethodSweepTest.java	Thu Mar 24 09:09:52 2016 +0100
@@ -90,7 +90,7 @@
         return usage;
     }
     private void guaranteedSweep() {
-        // not entrant -> ++stack_traversal_mark -> zombie -> reclamation -> flushed
+        // not entrant -> ++stack_traversal_mark -> zombie -> flushed
         for (int i = 0; i < 5; ++i) {
             WHITE_BOX.fullGC();
             WHITE_BOX.forceNMethodSweep();