Mon, 04 Jan 2010 14:51:26 -0800
6637203: Classunloading messages go to stdout rather than Xloggc file, causing hangs when stdout is closed
Summary: Decoupled TraceClassUnloading from verbose:gc, JVMTI_VERBOSE_GC and PrintGC[Details], making it settable in a manner identical to TraceClassLoading. Reverted an inadvertent change of TraceClassUnloading output in a previous changeset from gclog back to tty.
Reviewed-by: coleenp, dholmes, jmasa, poonam
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | #include "incls/_precompiled.incl" |
duke@435 | 26 | #include "incls/_icache.cpp.incl" |
duke@435 | 27 | |
duke@435 | 28 | // The flush stub function address |
duke@435 | 29 | AbstractICache::flush_icache_stub_t AbstractICache::_flush_icache_stub = NULL; |
duke@435 | 30 | |
duke@435 | 31 | void AbstractICache::initialize() { |
duke@435 | 32 | // Making this stub must be FIRST use of assembler |
duke@435 | 33 | ResourceMark rm; |
duke@435 | 34 | |
duke@435 | 35 | BufferBlob* b = BufferBlob::create("flush_icache_stub", ICache::stub_size); |
duke@435 | 36 | CodeBuffer c(b->instructions_begin(), b->instructions_size()); |
duke@435 | 37 | |
duke@435 | 38 | ICacheStubGenerator g(&c); |
duke@435 | 39 | g.generate_icache_flush(&_flush_icache_stub); |
duke@435 | 40 | |
duke@435 | 41 | // The first use of flush_icache_stub must apply it to itself. |
duke@435 | 42 | // The StubCodeMark destructor in generate_icache_flush will |
duke@435 | 43 | // call Assembler::flush, which in turn will call invalidate_range, |
duke@435 | 44 | // which will in turn call the flush stub. Thus we don't need an |
duke@435 | 45 | // explicit call to invalidate_range here. This assumption is |
duke@435 | 46 | // checked in invalidate_range. |
duke@435 | 47 | } |
duke@435 | 48 | |
duke@435 | 49 | void AbstractICache::call_flush_stub(address start, int lines) { |
duke@435 | 50 | // The business with the magic number is just a little security. |
duke@435 | 51 | // We cannot call the flush stub when generating the flush stub |
duke@435 | 52 | // because it isn't there yet. So, the stub also returns its third |
duke@435 | 53 | // parameter. This is a cheap check that the stub was really executed. |
duke@435 | 54 | static int magic = 0xbaadbabe; |
duke@435 | 55 | |
duke@435 | 56 | int auto_magic = magic; // Make a local copy to avoid race condition |
duke@435 | 57 | int r = (*_flush_icache_stub)(start, lines, auto_magic); |
duke@435 | 58 | guarantee(r == auto_magic, "flush stub routine did not execute"); |
duke@435 | 59 | ++magic; |
duke@435 | 60 | } |
duke@435 | 61 | |
duke@435 | 62 | void AbstractICache::invalidate_word(address addr) { |
duke@435 | 63 | // Because this is called for instruction patching on the fly, long after |
duke@435 | 64 | // bootstrapping, we execute the stub directly. Account for a 4-byte word |
duke@435 | 65 | // spanning two cache lines by computing a start line address by rounding |
duke@435 | 66 | // addr down to a line_size boundary, and an end line address by adding |
duke@435 | 67 | // the word size - 1 and rounding the result down to a line_size boundary. |
duke@435 | 68 | // If we just added word size, we'd mistakenly flush the next cache line |
duke@435 | 69 | // if the word to be flushed started in the last 4 bytes of the line. |
duke@435 | 70 | // Doing that would segv if the next line weren't mapped. |
duke@435 | 71 | |
duke@435 | 72 | const int word_size_in_bytes = 4; // Always, regardless of platform |
duke@435 | 73 | |
duke@435 | 74 | intptr_t start_line = ((intptr_t)addr + 0) & ~(ICache::line_size - 1); |
duke@435 | 75 | intptr_t end_line = ((intptr_t)addr + word_size_in_bytes - 1) |
duke@435 | 76 | & ~(ICache::line_size - 1); |
duke@435 | 77 | (*_flush_icache_stub)((address)start_line, start_line == end_line ? 1 : 2, 0); |
duke@435 | 78 | } |
duke@435 | 79 | |
duke@435 | 80 | void AbstractICache::invalidate_range(address start, int nbytes) { |
duke@435 | 81 | static bool firstTime = true; |
duke@435 | 82 | if (firstTime) { |
duke@435 | 83 | guarantee(start == CAST_FROM_FN_PTR(address, _flush_icache_stub), |
duke@435 | 84 | "first flush should be for flush stub"); |
duke@435 | 85 | firstTime = false; |
duke@435 | 86 | return; |
duke@435 | 87 | } |
duke@435 | 88 | if (nbytes == 0) { |
duke@435 | 89 | return; |
duke@435 | 90 | } |
duke@435 | 91 | // Align start address to an icache line boundary and transform |
duke@435 | 92 | // nbytes to an icache line count. |
duke@435 | 93 | const uint line_offset = mask_address_bits(start, ICache::line_size-1); |
duke@435 | 94 | if (line_offset != 0) { |
duke@435 | 95 | start -= line_offset; |
duke@435 | 96 | nbytes += line_offset; |
duke@435 | 97 | } |
duke@435 | 98 | call_flush_stub(start, round_to(nbytes, ICache::line_size) >> |
duke@435 | 99 | ICache::log2_line_size); |
duke@435 | 100 | } |
duke@435 | 101 | |
duke@435 | 102 | // For init.cpp |
duke@435 | 103 | void icache_init() { |
duke@435 | 104 | ICache::initialize(); |
duke@435 | 105 | } |