Mercurial > hg > truffle
annotate src/share/vm/runtime/stackValue.cpp @ 7090:05ce1defa4f9
Common out some parts of UnsafeLoad/Store in UnsafeAccess
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Thu, 29 Nov 2012 13:24:08 +0100 |
parents | e522a00b91aa |
children | b8f261ba79c6 |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
2 * Copyright (c) 1997, 2012, 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 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "code/debugInfo.hpp" | |
27 #include "oops/oop.inline.hpp" | |
28 #include "runtime/frame.inline.hpp" | |
29 #include "runtime/handles.inline.hpp" | |
30 #include "runtime/stackValue.hpp" | |
0 | 31 |
32 StackValue* StackValue::create_stack_value(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv) { | |
33 if (sv->is_location()) { | |
34 // Stack or register value | |
35 Location loc = ((LocationValue *)sv)->location(); | |
36 | |
37 #ifdef SPARC | |
38 // %%%%% Callee-save floats will NOT be working on a Sparc until we | |
39 // handle the case of a 2 floats in a single double register. | |
40 assert( !(loc.is_register() && loc.type() == Location::float_in_dbl), "Sparc does not handle callee-save floats yet" ); | |
41 #endif // SPARC | |
42 | |
43 // First find address of value | |
44 | |
45 address value_addr = loc.is_register() | |
46 // Value was in a callee-save register | |
47 ? reg_map->location(VMRegImpl::as_VMReg(loc.register_number())) | |
48 // Else value was directly saved on the stack. The frame's original stack pointer, | |
49 // before any extension by its callee (due to Compiler1 linkage on SPARC), must be used. | |
50 : ((address)fr->unextended_sp()) + loc.stack_offset(); | |
51 | |
52 // Then package it right depending on type | |
53 // Note: the transfer of the data is thru a union that contains | |
54 // an intptr_t. This is because an interpreter stack slot is | |
55 // really an intptr_t. The use of a union containing an intptr_t | |
56 // ensures that on a 64 bit platform we have proper alignment | |
57 // and that we store the value where the interpreter will expect | |
58 // to find it (i.e. proper endian). Similarly on a 32bit platform | |
59 // using the intptr_t ensures that when a value is larger than | |
60 // a stack slot (jlong/jdouble) that we capture the proper part | |
61 // of the value for the stack slot in question. | |
62 // | |
63 switch( loc.type() ) { | |
64 case Location::float_in_dbl: { // Holds a float in a double register? | |
65 // The callee has no clue whether the register holds a float, | |
66 // double or is unused. He always saves a double. Here we know | |
67 // a double was saved, but we only want a float back. Narrow the | |
68 // saved double to the float that the JVM wants. | |
69 assert( loc.is_register(), "floats always saved to stack in 1 word" ); | |
70 union { intptr_t p; jfloat jf; } value; | |
71 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); | |
72 value.jf = (jfloat) *(jdouble*) value_addr; | |
73 return new StackValue(value.p); // 64-bit high half is stack junk | |
74 } | |
75 case Location::int_in_long: { // Holds an int in a long register? | |
76 // The callee has no clue whether the register holds an int, | |
77 // long or is unused. He always saves a long. Here we know | |
78 // a long was saved, but we only want an int back. Narrow the | |
79 // saved long to the int that the JVM wants. | |
80 assert( loc.is_register(), "ints always saved to stack in 1 word" ); | |
81 union { intptr_t p; jint ji;} value; | |
82 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); | |
83 value.ji = (jint) *(jlong*) value_addr; | |
84 return new StackValue(value.p); // 64-bit high half is stack junk | |
85 } | |
86 #ifdef _LP64 | |
87 case Location::dbl: | |
88 // Double value in an aligned adjacent pair | |
89 return new StackValue(*(intptr_t*)value_addr); | |
90 case Location::lng: | |
91 // Long value in an aligned adjacent pair | |
92 return new StackValue(*(intptr_t*)value_addr); | |
331 | 93 case Location::narrowoop: { |
94 union { intptr_t p; narrowOop noop;} value; | |
95 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); | |
96 if (loc.is_register()) { | |
97 // The callee has no clue whether the register holds an int, | |
98 // long or is unused. He always saves a long. Here we know | |
99 // a long was saved, but we only want an int back. Narrow the | |
100 // saved long to the int that the JVM wants. | |
101 value.noop = (narrowOop) *(julong*) value_addr; | |
102 } else { | |
103 value.noop = *(narrowOop*) value_addr; | |
104 } | |
105 // Decode narrowoop and wrap a handle around the oop | |
106 Handle h(oopDesc::decode_heap_oop(value.noop)); | |
107 return new StackValue(h); | |
108 } | |
0 | 109 #endif |
110 case Location::oop: { | |
858 | 111 oop val = *(oop *)value_addr; |
112 #ifdef _LP64 | |
113 if (Universe::is_narrow_oop_base(val)) { | |
114 // Compiled code may produce decoded oop = narrow_oop_base | |
115 // when a narrow oop implicit null check is used. | |
116 // The narrow_oop_base could be NULL or be the address | |
117 // of the page below heap. Use NULL value for both cases. | |
118 val = (oop)NULL; | |
119 } | |
120 #endif | |
1937
4853c5cad3aa
More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1552
diff
changeset
|
121 #ifndef PRODUCT |
1939
b7fb5f1e0747
Two new flags: -XX:MaxCompilationID (to enable debugging binary search for problematic method) and -XX:C1XBailoutIsFatal.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1938
diff
changeset
|
122 if (val != NULL && !val->is_oop()) { |
1942
00bc9eaf0e24
Support for -XX:+UseFastLocking flag. Fixed monitor enter XIR template for correct debug info at the runtime call.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1939
diff
changeset
|
123 ResourceMark rm; |
00bc9eaf0e24
Support for -XX:+UseFastLocking flag. Fixed monitor enter XIR template for correct debug info at the runtime call.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1939
diff
changeset
|
124 tty->print_cr("found wrong oop " INTPTR_FORMAT " at location " INTPTR_FORMAT " (%d):", val, value_addr, val->is_oop()); |
00bc9eaf0e24
Support for -XX:+UseFastLocking flag. Fixed monitor enter XIR template for correct debug info at the runtime call.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1939
diff
changeset
|
125 if (fr->cb() != NULL) { |
00bc9eaf0e24
Support for -XX:+UseFastLocking flag. Fixed monitor enter XIR template for correct debug info at the runtime call.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1939
diff
changeset
|
126 CodeBlob* cb = fr->cb(); |
00bc9eaf0e24
Support for -XX:+UseFastLocking flag. Fixed monitor enter XIR template for correct debug info at the runtime call.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1939
diff
changeset
|
127 if (cb->is_nmethod()) { |
00bc9eaf0e24
Support for -XX:+UseFastLocking flag. Fixed monitor enter XIR template for correct debug info at the runtime call.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1939
diff
changeset
|
128 nmethod* nm = (nmethod*)cb; |
00bc9eaf0e24
Support for -XX:+UseFastLocking flag. Fixed monitor enter XIR template for correct debug info at the runtime call.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1939
diff
changeset
|
129 tty->print_cr("method is %s", nm->method()->name()->as_C_string()); |
00bc9eaf0e24
Support for -XX:+UseFastLocking flag. Fixed monitor enter XIR template for correct debug info at the runtime call.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1939
diff
changeset
|
130 } |
00bc9eaf0e24
Support for -XX:+UseFastLocking flag. Fixed monitor enter XIR template for correct debug info at the runtime call.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1939
diff
changeset
|
131 } |
1937
4853c5cad3aa
More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1552
diff
changeset
|
132 sv->print(); |
4853c5cad3aa
More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1552
diff
changeset
|
133 tty->print_cr(""); |
4853c5cad3aa
More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1552
diff
changeset
|
134 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
|
135 } |
4853c5cad3aa
More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1552
diff
changeset
|
136 #endif |
858 | 137 Handle h(val); // Wrap a handle around the oop |
0 | 138 return new StackValue(h); |
139 } | |
140 case Location::addr: { | |
141 ShouldNotReachHere(); // both C1 and C2 now inline jsrs | |
142 } | |
143 case Location::normal: { | |
144 // Just copy all other bits straight through | |
145 union { intptr_t p; jint ji;} value; | |
146 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); | |
147 value.ji = *(jint*)value_addr; | |
148 return new StackValue(value.p); | |
149 } | |
150 case Location::invalid: | |
151 return new StackValue(); | |
152 default: | |
153 ShouldNotReachHere(); | |
154 } | |
155 | |
156 } else if (sv->is_constant_int()) { | |
157 // Constant int: treat same as register int. | |
158 union { intptr_t p; jint ji;} value; | |
159 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); | |
160 value.ji = (jint)((ConstantIntValue*)sv)->value(); | |
161 return new StackValue(value.p); | |
162 } else if (sv->is_constant_oop()) { | |
163 // constant oop | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
164 return new StackValue(sv->as_ConstantOopReadValue()->value()); |
0 | 165 #ifdef _LP64 |
166 } else if (sv->is_constant_double()) { | |
167 // Constant double in a single stack slot | |
168 union { intptr_t p; double d; } value; | |
169 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); | |
170 value.d = ((ConstantDoubleValue *)sv)->value(); | |
171 return new StackValue(value.p); | |
172 } else if (sv->is_constant_long()) { | |
173 // Constant long in a single stack slot | |
174 union { intptr_t p; jlong jl; } value; | |
175 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); | |
176 value.jl = ((ConstantLongValue *)sv)->value(); | |
177 return new StackValue(value.p); | |
178 #endif | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
331
diff
changeset
|
179 } 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
|
180 Handle ov = ((ObjectValue *)sv)->value(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
331
diff
changeset
|
181 return new StackValue(ov, (ov.is_null()) ? 1 : 0); |
0 | 182 } |
183 | |
184 // Unknown ScopeValue type | |
185 ShouldNotReachHere(); | |
186 return new StackValue((intptr_t) 0); // dummy | |
187 } | |
188 | |
189 | |
190 BasicLock* StackValue::resolve_monitor_lock(const frame* fr, Location location) { | |
191 assert(location.is_stack(), "for now we only look at the stack"); | |
192 int word_offset = location.stack_offset() / wordSize; | |
193 // (stack picture) | |
194 // high: [ ] word_offset + 1 | |
195 // low [ ] word_offset | |
196 // | |
197 // sp-> [ ] 0 | |
198 // the word_offset is the distance from the stack pointer to the lowest address | |
199 // The frame's original stack pointer, before any extension by its callee | |
200 // (due to Compiler1 linkage on SPARC), must be used. | |
201 return (BasicLock*) (fr->unextended_sp() + word_offset); | |
202 } | |
203 | |
204 | |
205 #ifndef PRODUCT | |
206 | |
207 void StackValue::print_on(outputStream* st) const { | |
208 switch(_type) { | |
209 case T_INT: | |
210 st->print("%d (int) %f (float) %x (hex)", *(int *)&_i, *(float *)&_i, *(int *)&_i); | |
211 break; | |
212 | |
213 case T_OBJECT: | |
214 _o()->print_value_on(st); | |
215 st->print(" <" INTPTR_FORMAT ">", (address)_o()); | |
216 break; | |
217 | |
218 case T_CONFLICT: | |
219 st->print("conflict"); | |
220 break; | |
221 | |
222 default: | |
223 ShouldNotReachHere(); | |
224 } | |
225 } | |
226 | |
227 #endif |