20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "code/debugInfo.hpp"
26 #include "oops/access.hpp"
27 #include "oops/compressedOops.inline.hpp"
28 #include "oops/oop.hpp"
29 #include "runtime/frame.inline.hpp"
30 #include "runtime/globals.hpp"
31 #include "runtime/handles.inline.hpp"
32 #include "runtime/stackValue.hpp"
33 #if INCLUDE_SHENANDOAHGC
34 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
35 #endif
36
37 class RegisterMap;
38 class SmallRegisterMap;
39
40 template StackValue* StackValue::create_stack_value(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv);
41 template StackValue* StackValue::create_stack_value(const frame* fr, const SmallRegisterMap* reg_map, ScopeValue* sv);
42
43 template<typename RegisterMapT>
44 StackValue* StackValue::create_stack_value(const frame* fr, const RegisterMapT* reg_map, ScopeValue* sv) {
45 return create_stack_value(sv, stack_value_address(fr, reg_map, sv), reg_map);
46 }
47
48 static oop oop_from_oop_location(stackChunkOop chunk, void* addr) {
49 if (addr == nullptr) {
50 return nullptr;
51 }
52
53 if (UseCompressedOops) {
54 // When compressed oops is enabled, an oop location may
55 // contain narrow oop values - we deal with that here
56
57 if (chunk != nullptr && chunk->has_bitmap()) {
58 // Transformed stack chunk with narrow oops
59 return chunk->load_oop((narrowOop*)addr);
60 }
61
62 #ifdef _LP64
63 if (CompressedOops::is_base(*(void**)addr)) {
64 // Compiled code may produce decoded oop = narrow_oop_base
65 // when a narrow oop implicit null check is used.
66 // The narrow_oop_base could be null or be the address
127
128 return val;
129 }
130
131 StackValue* StackValue::create_stack_value_from_oop_location(stackChunkOop chunk, void* addr) {
132 oop val = oop_from_oop_location(chunk, addr);
133 assert(oopDesc::is_oop_or_null(val), "bad oop found at " INTPTR_FORMAT " in_cont: %d compressed: %d",
134 p2i(addr), chunk != nullptr, chunk != nullptr && chunk->has_bitmap() && UseCompressedOops);
135 Handle h(Thread::current(), val); // Wrap a handle around the oop
136 return new StackValue(h);
137 }
138
139 StackValue* StackValue::create_stack_value_from_narrowOop_location(stackChunkOop chunk, void* addr, bool is_register) {
140 oop val = oop_from_narrowOop_location(chunk, addr, is_register);
141 assert(oopDesc::is_oop_or_null(val), "bad oop found at " INTPTR_FORMAT " in_cont: %d compressed: %d",
142 p2i(addr), chunk != nullptr, chunk != nullptr && chunk->has_bitmap() && UseCompressedOops);
143 Handle h(Thread::current(), val); // Wrap a handle around the oop
144 return new StackValue(h);
145 }
146
147 template<typename RegisterMapT>
148 StackValue* StackValue::create_stack_value(ScopeValue* sv, address value_addr, const RegisterMapT* reg_map) {
149 stackChunkOop chunk = reg_map->stack_chunk()();
150 if (sv->is_location()) {
151 // Stack or register value
152 Location loc = ((LocationValue *)sv)->location();
153
154 // Then package it right depending on type
155 // Note: the transfer of the data is thru a union that contains
156 // an intptr_t. This is because an interpreter stack slot is
157 // really an intptr_t. The use of a union containing an intptr_t
158 // ensures that on a 64 bit platform we have proper alignment
159 // and that we store the value where the interpreter will expect
160 // to find it (i.e. proper endian). Similarly on a 32bit platform
161 // using the intptr_t ensures that when a value is larger than
162 // a stack slot (jlong/jdouble) that we capture the proper part
163 // of the value for the stack slot in question.
164 //
165 switch( loc.type() ) {
166 case Location::float_in_dbl: { // Holds a float in a double register?
167 // The callee has no clue whether the register holds a float,
168 // double or is unused. He always saves a double. Here we know
229 } else if (sv->is_constant_oop()) {
230 // constant oop
231 return new StackValue(sv->as_ConstantOopReadValue()->value());
232 #ifdef _LP64
233 } else if (sv->is_constant_double()) {
234 // Constant double in a single stack slot
235 union { intptr_t p; double d; } value;
236 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);
237 value.d = ((ConstantDoubleValue *)sv)->value();
238 return new StackValue(value.p);
239 } else if (sv->is_constant_long()) {
240 // Constant long in a single stack slot
241 union { intptr_t p; jlong jl; } value;
242 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);
243 value.jl = ((ConstantLongValue *)sv)->value();
244 return new StackValue(value.p);
245 #endif
246 } else if (sv->is_object()) { // Scalar replaced object in compiled frame
247 ObjectValue* ov = (ObjectValue *)sv;
248 Handle hdl = ov->value();
249 return new StackValue(hdl, hdl.is_null() && ov->is_scalar_replaced() ? 1 : 0);
250 } else if (sv->is_marker()) {
251 // Should never need to directly construct a marker.
252 ShouldNotReachHere();
253 }
254 // Unknown ScopeValue type
255 ShouldNotReachHere();
256 return new StackValue((intptr_t) 0); // dummy
257 }
258
259 template address StackValue::stack_value_address(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv);
260 template address StackValue::stack_value_address(const frame* fr, const SmallRegisterMap* reg_map, ScopeValue* sv);
261
262 template<typename RegisterMapT>
263 address StackValue::stack_value_address(const frame* fr, const RegisterMapT* reg_map, ScopeValue* sv) {
264 if (!sv->is_location()) {
265 return nullptr;
266 }
267 Location loc = ((LocationValue *)sv)->location();
268 if (loc.type() == Location::invalid) {
269 return nullptr;
|
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "code/debugInfo.hpp"
26 #include "oops/access.hpp"
27 #include "oops/compressedOops.inline.hpp"
28 #include "oops/oop.hpp"
29 #include "runtime/frame.inline.hpp"
30 #include "runtime/globals.hpp"
31 #include "runtime/handles.inline.hpp"
32 #include "runtime/stackValue.hpp"
33 #if INCLUDE_SHENANDOAHGC
34 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
35 #endif
36
37 class RegisterMap;
38 class SmallRegisterMap;
39
40
41 static oop oop_from_oop_location(stackChunkOop chunk, void* addr) {
42 if (addr == nullptr) {
43 return nullptr;
44 }
45
46 if (UseCompressedOops) {
47 // When compressed oops is enabled, an oop location may
48 // contain narrow oop values - we deal with that here
49
50 if (chunk != nullptr && chunk->has_bitmap()) {
51 // Transformed stack chunk with narrow oops
52 return chunk->load_oop((narrowOop*)addr);
53 }
54
55 #ifdef _LP64
56 if (CompressedOops::is_base(*(void**)addr)) {
57 // Compiled code may produce decoded oop = narrow_oop_base
58 // when a narrow oop implicit null check is used.
59 // The narrow_oop_base could be null or be the address
120
121 return val;
122 }
123
124 StackValue* StackValue::create_stack_value_from_oop_location(stackChunkOop chunk, void* addr) {
125 oop val = oop_from_oop_location(chunk, addr);
126 assert(oopDesc::is_oop_or_null(val), "bad oop found at " INTPTR_FORMAT " in_cont: %d compressed: %d",
127 p2i(addr), chunk != nullptr, chunk != nullptr && chunk->has_bitmap() && UseCompressedOops);
128 Handle h(Thread::current(), val); // Wrap a handle around the oop
129 return new StackValue(h);
130 }
131
132 StackValue* StackValue::create_stack_value_from_narrowOop_location(stackChunkOop chunk, void* addr, bool is_register) {
133 oop val = oop_from_narrowOop_location(chunk, addr, is_register);
134 assert(oopDesc::is_oop_or_null(val), "bad oop found at " INTPTR_FORMAT " in_cont: %d compressed: %d",
135 p2i(addr), chunk != nullptr, chunk != nullptr && chunk->has_bitmap() && UseCompressedOops);
136 Handle h(Thread::current(), val); // Wrap a handle around the oop
137 return new StackValue(h);
138 }
139
140
141 template StackValue* StackValue::create_stack_value(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv);
142 template StackValue* StackValue::create_stack_value(const frame* fr, const SmallRegisterMap* reg_map, ScopeValue* sv);
143
144 template<typename RegisterMapT>
145 StackValue* StackValue::create_stack_value(const frame* fr, const RegisterMapT* reg_map, ScopeValue* sv) {
146 address value_addr = stack_value_address(fr, reg_map, sv);
147 stackChunkOop chunk = reg_map->stack_chunk()();
148 if (sv->is_location()) {
149 // Stack or register value
150 Location loc = ((LocationValue *)sv)->location();
151
152 // Then package it right depending on type
153 // Note: the transfer of the data is thru a union that contains
154 // an intptr_t. This is because an interpreter stack slot is
155 // really an intptr_t. The use of a union containing an intptr_t
156 // ensures that on a 64 bit platform we have proper alignment
157 // and that we store the value where the interpreter will expect
158 // to find it (i.e. proper endian). Similarly on a 32bit platform
159 // using the intptr_t ensures that when a value is larger than
160 // a stack slot (jlong/jdouble) that we capture the proper part
161 // of the value for the stack slot in question.
162 //
163 switch( loc.type() ) {
164 case Location::float_in_dbl: { // Holds a float in a double register?
165 // The callee has no clue whether the register holds a float,
166 // double or is unused. He always saves a double. Here we know
227 } else if (sv->is_constant_oop()) {
228 // constant oop
229 return new StackValue(sv->as_ConstantOopReadValue()->value());
230 #ifdef _LP64
231 } else if (sv->is_constant_double()) {
232 // Constant double in a single stack slot
233 union { intptr_t p; double d; } value;
234 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);
235 value.d = ((ConstantDoubleValue *)sv)->value();
236 return new StackValue(value.p);
237 } else if (sv->is_constant_long()) {
238 // Constant long in a single stack slot
239 union { intptr_t p; jlong jl; } value;
240 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);
241 value.jl = ((ConstantLongValue *)sv)->value();
242 return new StackValue(value.p);
243 #endif
244 } else if (sv->is_object()) { // Scalar replaced object in compiled frame
245 ObjectValue* ov = (ObjectValue *)sv;
246 Handle hdl = ov->value();
247 bool scalar_replaced = hdl.is_null() && ov->is_scalar_replaced();
248 if (ov->has_properties()) {
249 Klass* k = java_lang_Class::as_Klass(ov->klass()->as_ConstantOopReadValue()->value()());
250 if (!k->is_array_klass()) {
251 // Don't treat inline type as scalar replaced if it is null
252 jint null_marker = StackValue::create_stack_value(fr, reg_map, ov->properties())->get_jint();
253 scalar_replaced &= (null_marker != 0);
254 }
255 }
256 return new StackValue(hdl, scalar_replaced ? 1 : 0);
257 } else if (sv->is_marker()) {
258 // Should never need to directly construct a marker.
259 ShouldNotReachHere();
260 }
261 // Unknown ScopeValue type
262 ShouldNotReachHere();
263 return new StackValue((intptr_t) 0); // dummy
264 }
265
266 template address StackValue::stack_value_address(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv);
267 template address StackValue::stack_value_address(const frame* fr, const SmallRegisterMap* reg_map, ScopeValue* sv);
268
269 template<typename RegisterMapT>
270 address StackValue::stack_value_address(const frame* fr, const RegisterMapT* reg_map, ScopeValue* sv) {
271 if (!sv->is_location()) {
272 return nullptr;
273 }
274 Location loc = ((LocationValue *)sv)->location();
275 if (loc.type() == Location::invalid) {
276 return nullptr;
|