< prev index next >

src/hotspot/share/runtime/stackValue.cpp

Print this page

 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 

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;
270   }
271 
272   if (!reg_map->in_cont()) {
273     address value_addr = loc.is_register()
274       // Value was in a callee-save register
275       ? reg_map->location(VMRegImpl::as_VMReg(loc.register_number()), fr->sp())
276       // Else value was directly saved on the stack. The frame's original stack pointer,
277       // before any extension by its callee (due to Compiler1 linkage on SPARC), must be used.
278       : ((address)fr->unextended_sp()) + loc.stack_offset();
279 
280     assert(value_addr == nullptr || reg_map->thread() == nullptr || reg_map->thread()->is_in_usable_stack(value_addr), INTPTR_FORMAT, p2i(value_addr));

 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 SmallRegisterMapNoArgs* 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 

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 SmallRegisterMapNoArgs* 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;
270   }
271 
272   if (!reg_map->in_cont()) {
273     address value_addr = loc.is_register()
274       // Value was in a callee-save register
275       ? reg_map->location(VMRegImpl::as_VMReg(loc.register_number()), fr->sp())
276       // Else value was directly saved on the stack. The frame's original stack pointer,
277       // before any extension by its callee (due to Compiler1 linkage on SPARC), must be used.
278       : ((address)fr->unextended_sp()) + loc.stack_offset();
279 
280     assert(value_addr == nullptr || reg_map->thread() == nullptr || reg_map->thread()->is_in_usable_stack(value_addr), INTPTR_FORMAT, p2i(value_addr));
< prev index next >