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 | /* |
xdono@1279 | 2 | * Copyright 1997-2009 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/_stackValue.cpp.incl" |
duke@435 | 27 | |
duke@435 | 28 | StackValue* StackValue::create_stack_value(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv) { |
duke@435 | 29 | if (sv->is_location()) { |
duke@435 | 30 | // Stack or register value |
duke@435 | 31 | Location loc = ((LocationValue *)sv)->location(); |
duke@435 | 32 | |
duke@435 | 33 | #ifdef SPARC |
duke@435 | 34 | // %%%%% Callee-save floats will NOT be working on a Sparc until we |
duke@435 | 35 | // handle the case of a 2 floats in a single double register. |
duke@435 | 36 | assert( !(loc.is_register() && loc.type() == Location::float_in_dbl), "Sparc does not handle callee-save floats yet" ); |
duke@435 | 37 | #endif // SPARC |
duke@435 | 38 | |
duke@435 | 39 | // First find address of value |
duke@435 | 40 | |
duke@435 | 41 | address value_addr = loc.is_register() |
duke@435 | 42 | // Value was in a callee-save register |
duke@435 | 43 | ? reg_map->location(VMRegImpl::as_VMReg(loc.register_number())) |
duke@435 | 44 | // Else value was directly saved on the stack. The frame's original stack pointer, |
duke@435 | 45 | // before any extension by its callee (due to Compiler1 linkage on SPARC), must be used. |
duke@435 | 46 | : ((address)fr->unextended_sp()) + loc.stack_offset(); |
duke@435 | 47 | |
duke@435 | 48 | // Then package it right depending on type |
duke@435 | 49 | // Note: the transfer of the data is thru a union that contains |
duke@435 | 50 | // an intptr_t. This is because an interpreter stack slot is |
duke@435 | 51 | // really an intptr_t. The use of a union containing an intptr_t |
duke@435 | 52 | // ensures that on a 64 bit platform we have proper alignment |
duke@435 | 53 | // and that we store the value where the interpreter will expect |
duke@435 | 54 | // to find it (i.e. proper endian). Similarly on a 32bit platform |
duke@435 | 55 | // using the intptr_t ensures that when a value is larger than |
duke@435 | 56 | // a stack slot (jlong/jdouble) that we capture the proper part |
duke@435 | 57 | // of the value for the stack slot in question. |
duke@435 | 58 | // |
duke@435 | 59 | switch( loc.type() ) { |
duke@435 | 60 | case Location::float_in_dbl: { // Holds a float in a double register? |
duke@435 | 61 | // The callee has no clue whether the register holds a float, |
duke@435 | 62 | // double or is unused. He always saves a double. Here we know |
duke@435 | 63 | // a double was saved, but we only want a float back. Narrow the |
duke@435 | 64 | // saved double to the float that the JVM wants. |
duke@435 | 65 | assert( loc.is_register(), "floats always saved to stack in 1 word" ); |
duke@435 | 66 | union { intptr_t p; jfloat jf; } value; |
duke@435 | 67 | value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
duke@435 | 68 | value.jf = (jfloat) *(jdouble*) value_addr; |
duke@435 | 69 | return new StackValue(value.p); // 64-bit high half is stack junk |
duke@435 | 70 | } |
duke@435 | 71 | case Location::int_in_long: { // Holds an int in a long register? |
duke@435 | 72 | // The callee has no clue whether the register holds an int, |
duke@435 | 73 | // long or is unused. He always saves a long. Here we know |
duke@435 | 74 | // a long was saved, but we only want an int back. Narrow the |
duke@435 | 75 | // saved long to the int that the JVM wants. |
duke@435 | 76 | assert( loc.is_register(), "ints always saved to stack in 1 word" ); |
duke@435 | 77 | union { intptr_t p; jint ji;} value; |
duke@435 | 78 | value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
duke@435 | 79 | value.ji = (jint) *(jlong*) value_addr; |
duke@435 | 80 | return new StackValue(value.p); // 64-bit high half is stack junk |
duke@435 | 81 | } |
duke@435 | 82 | #ifdef _LP64 |
duke@435 | 83 | case Location::dbl: |
duke@435 | 84 | // Double value in an aligned adjacent pair |
duke@435 | 85 | return new StackValue(*(intptr_t*)value_addr); |
duke@435 | 86 | case Location::lng: |
duke@435 | 87 | // Long value in an aligned adjacent pair |
duke@435 | 88 | return new StackValue(*(intptr_t*)value_addr); |
kvn@766 | 89 | case Location::narrowoop: { |
kvn@766 | 90 | union { intptr_t p; narrowOop noop;} value; |
kvn@766 | 91 | value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
kvn@766 | 92 | if (loc.is_register()) { |
kvn@766 | 93 | // The callee has no clue whether the register holds an int, |
kvn@766 | 94 | // long or is unused. He always saves a long. Here we know |
kvn@766 | 95 | // a long was saved, but we only want an int back. Narrow the |
kvn@766 | 96 | // saved long to the int that the JVM wants. |
kvn@766 | 97 | value.noop = (narrowOop) *(julong*) value_addr; |
kvn@766 | 98 | } else { |
kvn@766 | 99 | value.noop = *(narrowOop*) value_addr; |
kvn@766 | 100 | } |
kvn@766 | 101 | // Decode narrowoop and wrap a handle around the oop |
kvn@766 | 102 | Handle h(oopDesc::decode_heap_oop(value.noop)); |
kvn@766 | 103 | return new StackValue(h); |
kvn@766 | 104 | } |
duke@435 | 105 | #endif |
duke@435 | 106 | case Location::oop: { |
kvn@1293 | 107 | oop val = *(oop *)value_addr; |
kvn@1293 | 108 | #ifdef _LP64 |
kvn@1293 | 109 | if (Universe::is_narrow_oop_base(val)) { |
kvn@1293 | 110 | // Compiled code may produce decoded oop = narrow_oop_base |
kvn@1293 | 111 | // when a narrow oop implicit null check is used. |
kvn@1293 | 112 | // The narrow_oop_base could be NULL or be the address |
kvn@1293 | 113 | // of the page below heap. Use NULL value for both cases. |
kvn@1293 | 114 | val = (oop)NULL; |
kvn@1293 | 115 | } |
kvn@1293 | 116 | #endif |
kvn@1293 | 117 | Handle h(val); // Wrap a handle around the oop |
duke@435 | 118 | return new StackValue(h); |
duke@435 | 119 | } |
duke@435 | 120 | case Location::addr: { |
duke@435 | 121 | ShouldNotReachHere(); // both C1 and C2 now inline jsrs |
duke@435 | 122 | } |
duke@435 | 123 | case Location::normal: { |
duke@435 | 124 | // Just copy all other bits straight through |
duke@435 | 125 | union { intptr_t p; jint ji;} value; |
duke@435 | 126 | value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
duke@435 | 127 | value.ji = *(jint*)value_addr; |
duke@435 | 128 | return new StackValue(value.p); |
duke@435 | 129 | } |
duke@435 | 130 | case Location::invalid: |
duke@435 | 131 | return new StackValue(); |
duke@435 | 132 | default: |
duke@435 | 133 | ShouldNotReachHere(); |
duke@435 | 134 | } |
duke@435 | 135 | |
duke@435 | 136 | } else if (sv->is_constant_int()) { |
duke@435 | 137 | // Constant int: treat same as register int. |
duke@435 | 138 | union { intptr_t p; jint ji;} value; |
duke@435 | 139 | value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
duke@435 | 140 | value.ji = (jint)((ConstantIntValue*)sv)->value(); |
duke@435 | 141 | return new StackValue(value.p); |
duke@435 | 142 | } else if (sv->is_constant_oop()) { |
duke@435 | 143 | // constant oop |
duke@435 | 144 | return new StackValue(((ConstantOopReadValue *)sv)->value()); |
duke@435 | 145 | #ifdef _LP64 |
duke@435 | 146 | } else if (sv->is_constant_double()) { |
duke@435 | 147 | // Constant double in a single stack slot |
duke@435 | 148 | union { intptr_t p; double d; } value; |
duke@435 | 149 | value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
duke@435 | 150 | value.d = ((ConstantDoubleValue *)sv)->value(); |
duke@435 | 151 | return new StackValue(value.p); |
duke@435 | 152 | } else if (sv->is_constant_long()) { |
duke@435 | 153 | // Constant long in a single stack slot |
duke@435 | 154 | union { intptr_t p; jlong jl; } value; |
duke@435 | 155 | value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
duke@435 | 156 | value.jl = ((ConstantLongValue *)sv)->value(); |
duke@435 | 157 | return new StackValue(value.p); |
duke@435 | 158 | #endif |
kvn@1253 | 159 | } else if (sv->is_object()) { // Scalar replaced object in compiled frame |
kvn@1253 | 160 | Handle ov = ((ObjectValue *)sv)->value(); |
kvn@1253 | 161 | return new StackValue(ov, (ov.is_null()) ? 1 : 0); |
duke@435 | 162 | } |
duke@435 | 163 | |
duke@435 | 164 | // Unknown ScopeValue type |
duke@435 | 165 | ShouldNotReachHere(); |
duke@435 | 166 | return new StackValue((intptr_t) 0); // dummy |
duke@435 | 167 | } |
duke@435 | 168 | |
duke@435 | 169 | |
duke@435 | 170 | BasicLock* StackValue::resolve_monitor_lock(const frame* fr, Location location) { |
duke@435 | 171 | assert(location.is_stack(), "for now we only look at the stack"); |
duke@435 | 172 | int word_offset = location.stack_offset() / wordSize; |
duke@435 | 173 | // (stack picture) |
duke@435 | 174 | // high: [ ] word_offset + 1 |
duke@435 | 175 | // low [ ] word_offset |
duke@435 | 176 | // |
duke@435 | 177 | // sp-> [ ] 0 |
duke@435 | 178 | // the word_offset is the distance from the stack pointer to the lowest address |
duke@435 | 179 | // The frame's original stack pointer, before any extension by its callee |
duke@435 | 180 | // (due to Compiler1 linkage on SPARC), must be used. |
duke@435 | 181 | return (BasicLock*) (fr->unextended_sp() + word_offset); |
duke@435 | 182 | } |
duke@435 | 183 | |
duke@435 | 184 | |
duke@435 | 185 | #ifndef PRODUCT |
duke@435 | 186 | |
duke@435 | 187 | void StackValue::print_on(outputStream* st) const { |
duke@435 | 188 | switch(_type) { |
duke@435 | 189 | case T_INT: |
duke@435 | 190 | st->print("%d (int) %f (float) %x (hex)", *(int *)&_i, *(float *)&_i, *(int *)&_i); |
duke@435 | 191 | break; |
duke@435 | 192 | |
duke@435 | 193 | case T_OBJECT: |
duke@435 | 194 | _o()->print_value_on(st); |
duke@435 | 195 | st->print(" <" INTPTR_FORMAT ">", (address)_o()); |
duke@435 | 196 | break; |
duke@435 | 197 | |
duke@435 | 198 | case T_CONFLICT: |
duke@435 | 199 | st->print("conflict"); |
duke@435 | 200 | break; |
duke@435 | 201 | |
duke@435 | 202 | default: |
duke@435 | 203 | ShouldNotReachHere(); |
duke@435 | 204 | } |
duke@435 | 205 | } |
duke@435 | 206 | |
duke@435 | 207 | #endif |