--- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java 2016-03-17 12:16:01.940360861 +0100 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java 2016-03-17 12:16:01.848360865 +0100 @@ -249,7 +249,6 @@ // public int age(); // public boolean isMarkedForDeoptimization(); // public boolean isMarkedForUnloading(); - // public boolean isMarkedForReclamation(); // public int level(); // public int version(); --- old/src/share/vm/code/nmethod.cpp 2016-03-17 12:16:02.544360833 +0100 +++ new/src/share/vm/code/nmethod.cpp 2016-03-17 12:16:02.348360842 +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; @@ -1565,8 +1564,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); --- old/src/share/vm/code/nmethod.hpp 2016-03-17 12:16:03.192360803 +0100 +++ new/src/share/vm/code/nmethod.hpp 2016-03-17 12:16:03.004360811 +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; } --- old/src/share/vm/runtime/sweeper.cpp 2016-03-17 12:16:03.940360768 +0100 +++ new/src/share/vm/runtime/sweeper.cpp 2016-03-17 12:16:03.792360775 +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 --- old/src/share/vm/runtime/sweeper.hpp 2016-03-17 12:16:04.612360736 +0100 +++ new/src/share/vm/runtime/sweeper.hpp 2016-03-17 12:16:04.444360744 +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 --- old/src/share/vm/trace/trace.xml 2016-03-17 12:16:05.292360705 +0100 +++ new/src/share/vm/trace/trace.xml 2016-03-17 12:16:05.108360713 +0100 @@ -550,7 +550,6 @@ - --- old/test/compiler/whitebox/ForceNMethodSweepTest.java 2016-03-17 12:16:06.004360672 +0100 +++ new/test/compiler/whitebox/ForceNMethodSweepTest.java 2016-03-17 12:16:05.880360677 +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();