< prev index next >

src/hotspot/share/runtime/stackValue.cpp

Print this page




  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/debugInfo.hpp"
  27 #include "oops/compressedOops.inline.hpp"
  28 #include "oops/oop.hpp"
  29 #include "runtime/frame.inline.hpp"
  30 #include "runtime/handles.inline.hpp"
  31 #include "runtime/stackValue.hpp"
  32 #if INCLUDE_ZGC
  33 #include "gc/z/zBarrier.inline.hpp"
  34 #endif
  35 #if INCLUDE_SHENANDOAHGC
  36 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
  37 #endif
  38 
  39 StackValue* StackValue::create_stack_value(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv) {
  40   if (sv->is_location()) {
  41     // Stack or register value
  42     Location loc = ((LocationValue *)sv)->location();
  43 
  44 #ifdef SPARC
  45     // %%%%% Callee-save floats will NOT be working on a Sparc until we
  46     // handle the case of a 2 floats in a single double register.
  47     assert( !(loc.is_register() && loc.type() == Location::float_in_dbl), "Sparc does not handle callee-save floats yet" );
  48 #endif // SPARC
  49 
  50     // First find address of value
  51 
  52     address value_addr = loc.is_register()
  53       // Value was in a callee-save register
  54       ? reg_map->location(VMRegImpl::as_VMReg(loc.register_number()))
  55       // Else value was directly saved on the stack. The frame's original stack pointer,
  56       // before any extension by its callee (due to Compiler1 linkage on SPARC), must be used.
  57       : ((address)fr->unextended_sp()) + loc.stack_offset();
  58 
  59     // Then package it right depending on type
  60     // Note: the transfer of the data is thru a union that contains
  61     // an intptr_t. This is because an interpreter stack slot is
  62     // really an intptr_t. The use of a union containing an intptr_t
  63     // ensures that on a 64 bit platform we have proper alignment
  64     // and that we store the value where the interpreter will expect
  65     // to find it (i.e. proper endian). Similarly on a 32bit platform
  66     // using the intptr_t ensures that when a value is larger than
  67     // a stack slot (jlong/jdouble) that we capture the proper part
  68     // of the value for the stack slot in question.
  69     //
  70     switch( loc.type() ) {
  71     case Location::float_in_dbl: { // Holds a float in a double register?
  72       // The callee has no clue whether the register holds a float,
  73       // double or is unused.  He always saves a double.  Here we know
  74       // a double was saved, but we only want a float back.  Narrow the
  75       // saved double to the float that the JVM wants.
  76       assert( loc.is_register(), "floats always saved to stack in 1 word" );
  77       union { intptr_t p; jfloat jf; } value;
  78       value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);


  81     }
  82     case Location::int_in_long: { // Holds an int in a long register?
  83       // The callee has no clue whether the register holds an int,
  84       // long or is unused.  He always saves a long.  Here we know
  85       // a long was saved, but we only want an int back.  Narrow the
  86       // saved long to the int that the JVM wants.
  87       assert( loc.is_register(), "ints always saved to stack in 1 word" );
  88       union { intptr_t p; jint ji;} value;
  89       value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);
  90       value.ji = (jint) *(jlong*) value_addr;
  91       return new StackValue(value.p); // 64-bit high half is stack junk
  92     }
  93 #ifdef _LP64
  94     case Location::dbl:
  95       // Double value in an aligned adjacent pair
  96       return new StackValue(*(intptr_t*)value_addr);
  97     case Location::lng:
  98       // Long   value in an aligned adjacent pair
  99       return new StackValue(*(intptr_t*)value_addr);
 100     case Location::narrowoop: {

 101       union { intptr_t p; narrowOop noop;} value;
 102       value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);
 103       if (loc.is_register()) {
 104         // The callee has no clue whether the register holds an int,
 105         // long or is unused.  He always saves a long.  Here we know
 106         // a long was saved, but we only want an int back.  Narrow the
 107         // saved long to the int that the JVM wants.
 108         value.noop =  (narrowOop) *(julong*) value_addr;
 109       } else {
 110         value.noop = *(narrowOop*) value_addr;
 111       }
 112       // Decode narrowoop
 113       oop val = CompressedOops::decode(value.noop);
 114       // Deoptimization must make sure all oops have passed load barriers
 115 #if INCLUDE_SHENANDOAHGC
 116       if (UseShenandoahGC) {
 117         val = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(val);
 118       }
 119 #endif
 120       Handle h(Thread::current(), val); // Wrap a handle around the oop
 121       return new StackValue(h);
 122     }
 123 #endif
 124     case Location::oop: {






 125       oop val = *(oop *)value_addr;
 126 #ifdef _LP64
 127       if (CompressedOops::is_base(val)) {
 128          // Compiled code may produce decoded oop = narrow_oop_base
 129          // when a narrow oop implicit null check is used.
 130          // The narrow_oop_base could be NULL or be the address
 131          // of the page below heap. Use NULL value for both cases.
 132          val = (oop)NULL;
 133       }
 134 #endif
 135       // Deoptimization must make sure all oops have passed load barriers
 136 #if INCLUDE_SHENANDOAHGC
 137       if (UseShenandoahGC) {
 138         val = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(val);
 139       }
 140 #endif
 141       assert(oopDesc::is_oop_or_null(val, false), "bad oop found");
 142       Handle h(Thread::current(), val); // Wrap a handle around the oop
 143       return new StackValue(h);
 144     }




  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/debugInfo.hpp"
  27 #include "oops/compressedOops.inline.hpp"
  28 #include "oops/oop.hpp"
  29 #include "runtime/frame.inline.hpp"
  30 #include "runtime/handles.inline.hpp"
  31 #include "runtime/stackValue.hpp"
  32 #if INCLUDE_ZGC
  33 #include "gc/z/zBarrier.inline.hpp"
  34 #endif
  35 #if INCLUDE_SHENANDOAHGC
  36 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
  37 #endif
  38 
  39 StackValue* StackValue::create_stack_value(ScopeValue* sv, address value_addr, bool in_cont) {
  40   if (sv->is_location()) {
  41     // Stack or register value
  42     Location loc = ((LocationValue *)sv)->location();
  43 
  44 #ifdef SPARC
  45     // %%%%% Callee-save floats will NOT be working on a Sparc until we
  46     // handle the case of a 2 floats in a single double register.
  47     assert( !(loc.is_register() && loc.type() == Location::float_in_dbl), "Sparc does not handle callee-save floats yet" );
  48 #endif // SPARC
  49 









  50     // Then package it right depending on type
  51     // Note: the transfer of the data is thru a union that contains
  52     // an intptr_t. This is because an interpreter stack slot is
  53     // really an intptr_t. The use of a union containing an intptr_t
  54     // ensures that on a 64 bit platform we have proper alignment
  55     // and that we store the value where the interpreter will expect
  56     // to find it (i.e. proper endian). Similarly on a 32bit platform
  57     // using the intptr_t ensures that when a value is larger than
  58     // a stack slot (jlong/jdouble) that we capture the proper part
  59     // of the value for the stack slot in question.
  60     //
  61     switch( loc.type() ) {
  62     case Location::float_in_dbl: { // Holds a float in a double register?
  63       // The callee has no clue whether the register holds a float,
  64       // double or is unused.  He always saves a double.  Here we know
  65       // a double was saved, but we only want a float back.  Narrow the
  66       // saved double to the float that the JVM wants.
  67       assert( loc.is_register(), "floats always saved to stack in 1 word" );
  68       union { intptr_t p; jfloat jf; } value;
  69       value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);


  72     }
  73     case Location::int_in_long: { // Holds an int in a long register?
  74       // The callee has no clue whether the register holds an int,
  75       // long or is unused.  He always saves a long.  Here we know
  76       // a long was saved, but we only want an int back.  Narrow the
  77       // saved long to the int that the JVM wants.
  78       assert( loc.is_register(), "ints always saved to stack in 1 word" );
  79       union { intptr_t p; jint ji;} value;
  80       value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);
  81       value.ji = (jint) *(jlong*) value_addr;
  82       return new StackValue(value.p); // 64-bit high half is stack junk
  83     }
  84 #ifdef _LP64
  85     case Location::dbl:
  86       // Double value in an aligned adjacent pair
  87       return new StackValue(*(intptr_t*)value_addr);
  88     case Location::lng:
  89       // Long   value in an aligned adjacent pair
  90       return new StackValue(*(intptr_t*)value_addr);
  91     case Location::narrowoop: {
  92       assert (UseCompressedOops, "");
  93       union { intptr_t p; narrowOop noop;} value;
  94       value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF);
  95       if (loc.is_register()) {
  96         // The callee has no clue whether the register holds an int,
  97         // long or is unused.  He always saves a long.  Here we know
  98         // a long was saved, but we only want an int back.  Narrow the
  99         // saved long to the int that the JVM wants.
 100         value.noop =  (narrowOop) *(julong*) value_addr;
 101       } else {
 102         value.noop = *(narrowOop*) value_addr;
 103       }
 104       // Decode narrowoop
 105       oop val = CompressedOops::decode(value.noop);
 106       // Deoptimization must make sure all oops have passed load barriers
 107 #if INCLUDE_SHENANDOAHGC
 108       if (UseShenandoahGC) {
 109         val = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(val);
 110       }
 111 #endif
 112       Handle h(Thread::current(), val); // Wrap a handle around the oop
 113       return new StackValue(h);
 114     }
 115 #endif
 116     case Location::oop: {
 117       if (in_cont && UseCompressedOops) {
 118         narrowOop noop = *(narrowOop*) value_addr;
 119         Handle h(Thread::current(), CompressedOops::decode(noop));
 120         return new StackValue(h);
 121       } 
 122       
 123       oop val = *(oop *)value_addr;
 124 #ifdef _LP64
 125       if (CompressedOops::is_base(val)) {
 126          // Compiled code may produce decoded oop = narrow_oop_base
 127          // when a narrow oop implicit null check is used.
 128          // The narrow_oop_base could be NULL or be the address
 129          // of the page below heap. Use NULL value for both cases.
 130          val = (oop)NULL;
 131       }
 132 #endif
 133       // Deoptimization must make sure all oops have passed load barriers
 134 #if INCLUDE_SHENANDOAHGC
 135       if (UseShenandoahGC) {
 136         val = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(val);
 137       }
 138 #endif
 139       assert(oopDesc::is_oop_or_null(val, false), "bad oop found");
 140       Handle h(Thread::current(), val); // Wrap a handle around the oop
 141       return new StackValue(h);
 142     }


< prev index next >