src/share/vm/runtime/stackValue.cpp

Wed, 10 Sep 2008 18:23:32 -0700

author
kvn
date
Wed, 10 Sep 2008 18:23:32 -0700
changeset 766
cecd8eb4e0ca
parent 435
a61af66fc99e
child 1253
b109e761e927
permissions
-rw-r--r--

6706829: Compressed Oops: add debug info for narrow oops
Summary: Add support for narrow oops in debug info to avoid decoding.
Reviewed-by: rasbold, never

duke@435 1 /*
kvn@766 2 * Copyright 1997-2008 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: {
duke@435 107 Handle h(*(oop *)value_addr); // Wrap a handle around the oop
duke@435 108 return new StackValue(h);
duke@435 109 }
duke@435 110 case Location::addr: {
duke@435 111 ShouldNotReachHere(); // both C1 and C2 now inline jsrs
duke@435 112 }
duke@435 113 case Location::normal: {
duke@435 114 // Just copy all other bits straight through
duke@435 115 union { intptr_t p; jint ji;} value;
duke@435 116 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);
duke@435 117 value.ji = *(jint*)value_addr;
duke@435 118 return new StackValue(value.p);
duke@435 119 }
duke@435 120 case Location::invalid:
duke@435 121 return new StackValue();
duke@435 122 default:
duke@435 123 ShouldNotReachHere();
duke@435 124 }
duke@435 125
duke@435 126 } else if (sv->is_constant_int()) {
duke@435 127 // Constant int: treat same as register int.
duke@435 128 union { intptr_t p; jint ji;} value;
duke@435 129 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);
duke@435 130 value.ji = (jint)((ConstantIntValue*)sv)->value();
duke@435 131 return new StackValue(value.p);
duke@435 132 } else if (sv->is_constant_oop()) {
duke@435 133 // constant oop
duke@435 134 return new StackValue(((ConstantOopReadValue *)sv)->value());
duke@435 135 #ifdef _LP64
duke@435 136 } else if (sv->is_constant_double()) {
duke@435 137 // Constant double in a single stack slot
duke@435 138 union { intptr_t p; double d; } value;
duke@435 139 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);
duke@435 140 value.d = ((ConstantDoubleValue *)sv)->value();
duke@435 141 return new StackValue(value.p);
duke@435 142 } else if (sv->is_constant_long()) {
duke@435 143 // Constant long in a single stack slot
duke@435 144 union { intptr_t p; jlong jl; } value;
duke@435 145 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);
duke@435 146 value.jl = ((ConstantLongValue *)sv)->value();
duke@435 147 return new StackValue(value.p);
duke@435 148 #endif
duke@435 149 } else if (sv->is_object()) {
duke@435 150 return new StackValue(((ObjectValue *)sv)->value());
duke@435 151 }
duke@435 152
duke@435 153 // Unknown ScopeValue type
duke@435 154 ShouldNotReachHere();
duke@435 155 return new StackValue((intptr_t) 0); // dummy
duke@435 156 }
duke@435 157
duke@435 158
duke@435 159 BasicLock* StackValue::resolve_monitor_lock(const frame* fr, Location location) {
duke@435 160 assert(location.is_stack(), "for now we only look at the stack");
duke@435 161 int word_offset = location.stack_offset() / wordSize;
duke@435 162 // (stack picture)
duke@435 163 // high: [ ] word_offset + 1
duke@435 164 // low [ ] word_offset
duke@435 165 //
duke@435 166 // sp-> [ ] 0
duke@435 167 // the word_offset is the distance from the stack pointer to the lowest address
duke@435 168 // The frame's original stack pointer, before any extension by its callee
duke@435 169 // (due to Compiler1 linkage on SPARC), must be used.
duke@435 170 return (BasicLock*) (fr->unextended_sp() + word_offset);
duke@435 171 }
duke@435 172
duke@435 173
duke@435 174 #ifndef PRODUCT
duke@435 175
duke@435 176 void StackValue::print_on(outputStream* st) const {
duke@435 177 switch(_type) {
duke@435 178 case T_INT:
duke@435 179 st->print("%d (int) %f (float) %x (hex)", *(int *)&_i, *(float *)&_i, *(int *)&_i);
duke@435 180 break;
duke@435 181
duke@435 182 case T_OBJECT:
duke@435 183 _o()->print_value_on(st);
duke@435 184 st->print(" <" INTPTR_FORMAT ">", (address)_o());
duke@435 185 break;
duke@435 186
duke@435 187 case T_CONFLICT:
duke@435 188 st->print("conflict");
duke@435 189 break;
duke@435 190
duke@435 191 default:
duke@435 192 ShouldNotReachHere();
duke@435 193 }
duke@435 194 }
duke@435 195
duke@435 196 #endif

mercurial