annotate src/share/vm/runtime/sweeper.hpp @ 2481:f52ed367b66d

6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify Reviewed-by: kvn, iveresov
author never
date Mon, 16 May 2011 22:16:44 -0700
parents f95d63e2154a
children bb74dc5ddf07
rev   line source
duke@0 1 /*
never@1564 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1879 25 #ifndef SHARE_VM_RUNTIME_SWEEPER_HPP
stefank@1879 26 #define SHARE_VM_RUNTIME_SWEEPER_HPP
stefank@1879 27
duke@0 28 // An NmethodSweeper is an incremental cleaner for:
duke@0 29 // - cleanup inline caches
duke@0 30 // - reclamation of unreferences zombie nmethods
duke@0 31 //
duke@0 32
duke@0 33 class NMethodSweeper : public AllStatic {
duke@0 34 static long _traversals; // Stack traversal count
never@1535 35 static nmethod* _current; // Current nmethod
duke@0 36 static int _seen; // Nof. nmethod we have currently processed in current pass of CodeCache
never@1564 37
never@1564 38 static volatile int _invocations; // No. of invocations left until we are completed with this pass
never@1564 39 static volatile int _sweep_started; // Flag to control conc sweeper
duke@0 40
duke@0 41 static bool _rescan; // Indicates that we should do a full rescan of the
duke@0 42 // of the code cache looking for work to do.
never@1458 43 static bool _do_sweep; // Flag to skip the conc sweep if no stack scan happened
duke@0 44 static int _locked_seen; // Number of locked nmethods encountered during the scan
duke@0 45 static int _not_entrant_seen_on_stack; // Number of not entrant nmethod were are still on stack
duke@0 46
kvn@1202 47 static bool _was_full; // remember if we did emergency unloading
kvn@1202 48 static jint _advise_to_sweep; // flag to indicate code cache getting full
kvn@1202 49 static jlong _last_was_full; // timestamp of last emergency unloading
kvn@1202 50 static uint _highest_marked; // highest compile id dumped at last emergency unloading
kvn@1202 51 static long _was_full_traversal; // trav number at last emergency unloading
duke@0 52
duke@0 53 static void process_nmethod(nmethod *nm);
never@1564 54
never@1564 55 static void log_sweep(const char* msg, const char* format = NULL, ...);
never@1564 56
duke@0 57 public:
duke@0 58 static long traversal_count() { return _traversals; }
duke@0 59
never@2481 60 #ifdef ASSERT
never@2481 61 // Keep track of sweeper activity in the ring buffer
never@2481 62 static void record_sweep(nmethod* nm, int line);
never@2481 63 static void report_events(int id, address entry);
never@2481 64 static void report_events();
never@2481 65 #endif
never@2481 66
never@1458 67 static void scan_stacks(); // Invoked at the end of each safepoint
never@1458 68 static void sweep_code_cache(); // Concurrent part of sweep job
never@1458 69 static void possibly_sweep(); // Compiler threads call this to sweep
duke@0 70
duke@0 71 static void notify(nmethod* nm) {
duke@0 72 // Perform a full scan of the code cache from the beginning. No
duke@0 73 // need to synchronize the setting of this flag since it only
duke@0 74 // changes to false at safepoint so we can never overwrite it with false.
duke@0 75 _rescan = true;
duke@0 76 }
kvn@1202 77
kvn@1202 78 static void handle_full_code_cache(bool is_full); // Called by compilers who fail to allocate
kvn@1202 79 static void speculative_disconnect_nmethods(bool was_full); // Called by vm op to deal with alloc failure
kvn@1202 80
kvn@1202 81 static void set_was_full(bool state) { _was_full = state; }
kvn@1202 82 static bool was_full() { return _was_full; }
duke@0 83 };
stefank@1879 84
stefank@1879 85 #endif // SHARE_VM_RUNTIME_SWEEPER_HPP