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_ZGC
34 #include "gc/z/zBarrier.inline.hpp"
35 #endif
36 #if INCLUDE_SHENANDOAHGC
37 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
38 #endif
39
40 class RegisterMap;
41 class SmallRegisterMap;
42
43 template StackValue* StackValue::create_stack_value(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv);
44 template StackValue* StackValue::create_stack_value(const frame* fr, const SmallRegisterMap* reg_map, ScopeValue* sv);
45
46 template<typename RegisterMapT>
47 StackValue* StackValue::create_stack_value(const frame* fr, const RegisterMapT* reg_map, ScopeValue* sv) {
48 return create_stack_value(sv, stack_value_address(fr, reg_map, sv), reg_map);
49 }
50
51 static oop oop_from_oop_location(stackChunkOop chunk, void* addr) {
52 if (addr == nullptr) {
53 return nullptr;
54 }
55
56 if (UseCompressedOops) {
57 // When compressed oops is enabled, an oop location may
58 // contain narrow oop values - we deal with that here
59
60 if (chunk != nullptr && chunk->has_bitmap()) {
61 // Transformed stack chunk with narrow oops
62 return chunk->load_oop((narrowOop*)addr);
63 }
64
243 // Constant long in a single stack slot
244 union { intptr_t p; jlong jl; } value;
245 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);
246 value.jl = ((ConstantLongValue *)sv)->value();
247 return new StackValue(value.p);
248 #endif
249 } else if (sv->is_object()) { // Scalar replaced object in compiled frame
250 ObjectValue* ov = (ObjectValue *)sv;
251 Handle hdl = ov->value();
252 return new StackValue(hdl, hdl.is_null() && ov->is_scalar_replaced() ? 1 : 0);
253 } else if (sv->is_marker()) {
254 // Should never need to directly construct a marker.
255 ShouldNotReachHere();
256 }
257 // Unknown ScopeValue type
258 ShouldNotReachHere();
259 return new StackValue((intptr_t) 0); // dummy
260 }
261
262 template address StackValue::stack_value_address(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv);
263 template address StackValue::stack_value_address(const frame* fr, const SmallRegisterMap* reg_map, ScopeValue* sv);
264
265 template<typename RegisterMapT>
266 address StackValue::stack_value_address(const frame* fr, const RegisterMapT* reg_map, ScopeValue* sv) {
267 if (!sv->is_location()) {
268 return nullptr;
269 }
270 Location loc = ((LocationValue *)sv)->location();
271 if (loc.type() == Location::invalid) {
272 return nullptr;
273 }
274
275 if (!reg_map->in_cont()) {
276 address value_addr = loc.is_register()
277 // Value was in a callee-save register
278 ? reg_map->location(VMRegImpl::as_VMReg(loc.register_number()), fr->sp())
279 // Else value was directly saved on the stack. The frame's original stack pointer,
280 // before any extension by its callee (due to Compiler1 linkage on SPARC), must be used.
281 : ((address)fr->unextended_sp()) + loc.stack_offset();
282
283 assert(value_addr == nullptr || reg_map->thread() == nullptr || reg_map->thread()->is_in_usable_stack(value_addr), INTPTR_FORMAT, p2i(value_addr));
|
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_ZGC
34 #include "gc/z/zBarrier.inline.hpp"
35 #endif
36 #if INCLUDE_SHENANDOAHGC
37 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
38 #endif
39
40 class RegisterMap;
41 class SmallRegisterMap;
42
43 template StackValue* StackValue::create_stack_value(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv);
44 template StackValue* StackValue::create_stack_value(const frame* fr, const SmallRegisterMapNoArgs* reg_map, ScopeValue* sv);
45
46 template<typename RegisterMapT>
47 StackValue* StackValue::create_stack_value(const frame* fr, const RegisterMapT* reg_map, ScopeValue* sv) {
48 return create_stack_value(sv, stack_value_address(fr, reg_map, sv), reg_map);
49 }
50
51 static oop oop_from_oop_location(stackChunkOop chunk, void* addr) {
52 if (addr == nullptr) {
53 return nullptr;
54 }
55
56 if (UseCompressedOops) {
57 // When compressed oops is enabled, an oop location may
58 // contain narrow oop values - we deal with that here
59
60 if (chunk != nullptr && chunk->has_bitmap()) {
61 // Transformed stack chunk with narrow oops
62 return chunk->load_oop((narrowOop*)addr);
63 }
64
243 // Constant long in a single stack slot
244 union { intptr_t p; jlong jl; } value;
245 value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);
246 value.jl = ((ConstantLongValue *)sv)->value();
247 return new StackValue(value.p);
248 #endif
249 } else if (sv->is_object()) { // Scalar replaced object in compiled frame
250 ObjectValue* ov = (ObjectValue *)sv;
251 Handle hdl = ov->value();
252 return new StackValue(hdl, hdl.is_null() && ov->is_scalar_replaced() ? 1 : 0);
253 } else if (sv->is_marker()) {
254 // Should never need to directly construct a marker.
255 ShouldNotReachHere();
256 }
257 // Unknown ScopeValue type
258 ShouldNotReachHere();
259 return new StackValue((intptr_t) 0); // dummy
260 }
261
262 template address StackValue::stack_value_address(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv);
263 template address StackValue::stack_value_address(const frame* fr, const SmallRegisterMapNoArgs* reg_map, ScopeValue* sv);
264
265 template<typename RegisterMapT>
266 address StackValue::stack_value_address(const frame* fr, const RegisterMapT* reg_map, ScopeValue* sv) {
267 if (!sv->is_location()) {
268 return nullptr;
269 }
270 Location loc = ((LocationValue *)sv)->location();
271 if (loc.type() == Location::invalid) {
272 return nullptr;
273 }
274
275 if (!reg_map->in_cont()) {
276 address value_addr = loc.is_register()
277 // Value was in a callee-save register
278 ? reg_map->location(VMRegImpl::as_VMReg(loc.register_number()), fr->sp())
279 // Else value was directly saved on the stack. The frame's original stack pointer,
280 // before any extension by its callee (due to Compiler1 linkage on SPARC), must be used.
281 : ((address)fr->unextended_sp()) + loc.stack_offset();
282
283 assert(value_addr == nullptr || reg_map->thread() == nullptr || reg_map->thread()->is_in_usable_stack(value_addr), INTPTR_FORMAT, p2i(value_addr));
|