Mercurial > hg > graal-jvmci-8
annotate src/share/vm/runtime/stackValue.cpp @ 1937:4853c5cad3aa
More deoptmization tracing.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Thu, 23 Dec 2010 22:14:31 +0100 |
parents | c18cbe5936b8 |
children | 1aa5b22a7716 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
866
diff
changeset
|
2 * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
866
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
866
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
866
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_stackValue.cpp.incl" | |
27 | |
28 StackValue* StackValue::create_stack_value(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv) { | |
29 if (sv->is_location()) { | |
30 // Stack or register value | |
31 Location loc = ((LocationValue *)sv)->location(); | |
32 | |
33 #ifdef SPARC | |
34 // %%%%% Callee-save floats will NOT be working on a Sparc until we | |
35 // handle the case of a 2 floats in a single double register. | |
36 assert( !(loc.is_register() && loc.type() == Location::float_in_dbl), "Sparc does not handle callee-save floats yet" ); | |
37 #endif // SPARC | |
38 | |
39 // First find address of value | |
40 | |
41 address value_addr = loc.is_register() | |
42 // Value was in a callee-save register | |
43 ? reg_map->location(VMRegImpl::as_VMReg(loc.register_number())) | |
44 // Else value was directly saved on the stack. The frame's original stack pointer, | |
45 // before any extension by its callee (due to Compiler1 linkage on SPARC), must be used. | |
46 : ((address)fr->unextended_sp()) + loc.stack_offset(); | |
47 | |
48 // Then package it right depending on type | |
49 // Note: the transfer of the data is thru a union that contains | |
50 // an intptr_t. This is because an interpreter stack slot is | |
51 // really an intptr_t. The use of a union containing an intptr_t | |
52 // ensures that on a 64 bit platform we have proper alignment | |
53 // and that we store the value where the interpreter will expect | |
54 // to find it (i.e. proper endian). Similarly on a 32bit platform | |
55 // using the intptr_t ensures that when a value is larger than | |
56 // a stack slot (jlong/jdouble) that we capture the proper part | |
57 // of the value for the stack slot in question. | |
58 // | |
59 switch( loc.type() ) { | |
60 case Location::float_in_dbl: { // Holds a float in a double register? | |
61 // The callee has no clue whether the register holds a float, | |
62 // double or is unused. He always saves a double. Here we know | |
63 // a double was saved, but we only want a float back. Narrow the | |
64 // saved double to the float that the JVM wants. | |
65 assert( loc.is_register(), "floats always saved to stack in 1 word" ); | |
66 union { intptr_t p; jfloat jf; } value; | |
67 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); | |
68 value.jf = (jfloat) *(jdouble*) value_addr; | |
69 return new StackValue(value.p); // 64-bit high half is stack junk | |
70 } | |
71 case Location::int_in_long: { // Holds an int in a long register? | |
72 // The callee has no clue whether the register holds an int, | |
73 // long or is unused. He always saves a long. Here we know | |
74 // a long was saved, but we only want an int back. Narrow the | |
75 // saved long to the int that the JVM wants. | |
76 assert( loc.is_register(), "ints always saved to stack in 1 word" ); | |
77 union { intptr_t p; jint ji;} value; | |
78 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); | |
79 value.ji = (jint) *(jlong*) value_addr; | |
80 return new StackValue(value.p); // 64-bit high half is stack junk | |
81 } | |
82 #ifdef _LP64 | |
83 case Location::dbl: | |
84 // Double value in an aligned adjacent pair | |
85 return new StackValue(*(intptr_t*)value_addr); | |
86 case Location::lng: | |
87 // Long value in an aligned adjacent pair | |
88 return new StackValue(*(intptr_t*)value_addr); | |
331 | 89 case Location::narrowoop: { |
90 union { intptr_t p; narrowOop noop;} value; | |
91 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); | |
92 if (loc.is_register()) { | |
93 // The callee has no clue whether the register holds an int, | |
94 // long or is unused. He always saves a long. Here we know | |
95 // a long was saved, but we only want an int back. Narrow the | |
96 // saved long to the int that the JVM wants. | |
97 value.noop = (narrowOop) *(julong*) value_addr; | |
98 } else { | |
99 value.noop = *(narrowOop*) value_addr; | |
100 } | |
101 // Decode narrowoop and wrap a handle around the oop | |
102 Handle h(oopDesc::decode_heap_oop(value.noop)); | |
103 return new StackValue(h); | |
104 } | |
0 | 105 #endif |
106 case Location::oop: { | |
858 | 107 oop val = *(oop *)value_addr; |
108 #ifdef _LP64 | |
109 if (Universe::is_narrow_oop_base(val)) { | |
110 // Compiled code may produce decoded oop = narrow_oop_base | |
111 // when a narrow oop implicit null check is used. | |
112 // The narrow_oop_base could be NULL or be the address | |
113 // of the page below heap. Use NULL value for both cases. | |
114 val = (oop)NULL; | |
115 } | |
116 #endif | |
1937
4853c5cad3aa
More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1552
diff
changeset
|
117 #ifndef PRODUCT |
4853c5cad3aa
More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1552
diff
changeset
|
118 if (!val->is_oop()) { |
4853c5cad3aa
More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1552
diff
changeset
|
119 tty->print_cr("found wrong oop %x at location:", val); |
4853c5cad3aa
More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1552
diff
changeset
|
120 sv->print(); |
4853c5cad3aa
More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1552
diff
changeset
|
121 tty->print_cr(""); |
4853c5cad3aa
More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1552
diff
changeset
|
122 tty->print_cr("one less %d; one more %d", (*(((oop *)value_addr) - 1))->is_oop(), (*(((oop *)value_addr) + 1))->is_oop()); |
4853c5cad3aa
More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1552
diff
changeset
|
123 } |
4853c5cad3aa
More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1552
diff
changeset
|
124 #endif |
858 | 125 Handle h(val); // Wrap a handle around the oop |
0 | 126 return new StackValue(h); |
127 } | |
128 case Location::addr: { | |
129 ShouldNotReachHere(); // both C1 and C2 now inline jsrs | |
130 } | |
131 case Location::normal: { | |
132 // Just copy all other bits straight through | |
133 union { intptr_t p; jint ji;} value; | |
134 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); | |
135 value.ji = *(jint*)value_addr; | |
136 return new StackValue(value.p); | |
137 } | |
138 case Location::invalid: | |
139 return new StackValue(); | |
140 default: | |
141 ShouldNotReachHere(); | |
142 } | |
143 | |
144 } else if (sv->is_constant_int()) { | |
145 // Constant int: treat same as register int. | |
146 union { intptr_t p; jint ji;} value; | |
147 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); | |
148 value.ji = (jint)((ConstantIntValue*)sv)->value(); | |
149 return new StackValue(value.p); | |
150 } else if (sv->is_constant_oop()) { | |
151 // constant oop | |
152 return new StackValue(((ConstantOopReadValue *)sv)->value()); | |
153 #ifdef _LP64 | |
154 } else if (sv->is_constant_double()) { | |
155 // Constant double in a single stack slot | |
156 union { intptr_t p; double d; } value; | |
157 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); | |
158 value.d = ((ConstantDoubleValue *)sv)->value(); | |
159 return new StackValue(value.p); | |
160 } else if (sv->is_constant_long()) { | |
161 // Constant long in a single stack slot | |
162 union { intptr_t p; jlong jl; } value; | |
163 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); | |
164 value.jl = ((ConstantLongValue *)sv)->value(); | |
165 return new StackValue(value.p); | |
166 #endif | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
331
diff
changeset
|
167 } else if (sv->is_object()) { // Scalar replaced object in compiled frame |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
331
diff
changeset
|
168 Handle ov = ((ObjectValue *)sv)->value(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
331
diff
changeset
|
169 return new StackValue(ov, (ov.is_null()) ? 1 : 0); |
0 | 170 } |
171 | |
172 // Unknown ScopeValue type | |
173 ShouldNotReachHere(); | |
174 return new StackValue((intptr_t) 0); // dummy | |
175 } | |
176 | |
177 | |
178 BasicLock* StackValue::resolve_monitor_lock(const frame* fr, Location location) { | |
179 assert(location.is_stack(), "for now we only look at the stack"); | |
180 int word_offset = location.stack_offset() / wordSize; | |
181 // (stack picture) | |
182 // high: [ ] word_offset + 1 | |
183 // low [ ] word_offset | |
184 // | |
185 // sp-> [ ] 0 | |
186 // the word_offset is the distance from the stack pointer to the lowest address | |
187 // The frame's original stack pointer, before any extension by its callee | |
188 // (due to Compiler1 linkage on SPARC), must be used. | |
189 return (BasicLock*) (fr->unextended_sp() + word_offset); | |
190 } | |
191 | |
192 | |
193 #ifndef PRODUCT | |
194 | |
195 void StackValue::print_on(outputStream* st) const { | |
196 switch(_type) { | |
197 case T_INT: | |
198 st->print("%d (int) %f (float) %x (hex)", *(int *)&_i, *(float *)&_i, *(int *)&_i); | |
199 break; | |
200 | |
201 case T_OBJECT: | |
202 _o()->print_value_on(st); | |
203 st->print(" <" INTPTR_FORMAT ">", (address)_o()); | |
204 break; | |
205 | |
206 case T_CONFLICT: | |
207 st->print("conflict"); | |
208 break; | |
209 | |
210 default: | |
211 ShouldNotReachHere(); | |
212 } | |
213 } | |
214 | |
215 #endif |