< prev index next >

src/hotspot/share/runtime/vframe_hp.cpp

Print this page




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  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 "classfile/javaClasses.inline.hpp"
  27 #include "code/codeCache.hpp"
  28 #include "code/debugInfoRec.hpp"
  29 #include "code/nmethod.hpp"
  30 #include "code/pcDesc.hpp"
  31 #include "code/scopeDesc.hpp"
  32 #include "interpreter/interpreter.hpp"
  33 #include "interpreter/oopMapCache.hpp"
  34 #include "oops/instanceKlass.hpp"
  35 #include "oops/oop.inline.hpp"
  36 #include "runtime/basicLock.hpp"

  37 #include "runtime/frame.inline.hpp"
  38 #include "runtime/handles.inline.hpp"
  39 #include "runtime/monitorChunk.hpp"
  40 #include "runtime/signature.hpp"
  41 #include "runtime/stubRoutines.hpp"
  42 #include "runtime/vframeArray.hpp"
  43 #include "runtime/vframe_hp.hpp"
  44 #ifdef COMPILER2
  45 #include "opto/matcher.hpp"
  46 #endif
  47 
  48 
  49 // ------------- compiledVFrame --------------
  50 
  51 StackValueCollection* compiledVFrame::locals() const {
  52   // Natives has no scope
  53   if (scope() == NULL) return new StackValueCollection(0);
  54   GrowableArray<ScopeValue*>*  scv_list = scope()->locals();
  55   if (scv_list == NULL) return new StackValueCollection(0);
  56 
  57   // scv_list is the list of ScopeValues describing the JVM stack state.
  58   // There is one scv_list entry for every JVM stack state in use.
  59   int length = scv_list->length();
  60   StackValueCollection* result = new StackValueCollection(length);
  61   for (int i = 0; i < length; i++) {
  62     result->add(create_stack_value(scv_list->at(i)));
  63   }
  64 
  65   // Replace the original values with any stores that have been
  66   // performed through compiledVFrame::update_locals.
  67   GrowableArray<jvmtiDeferredLocalVariableSet*>* list = thread()->deferred_locals();
  68   if (list != NULL ) {
  69     // In real life this never happens or is typically a single element search
  70     for (int i = 0; i < list->length(); i++) {
  71       if (list->at(i)->matches(this)) {
  72         list->at(i)->update_locals(result);
  73         break;


  74       }
  75     }
  76   }
  77 
  78   return result;
  79 }
  80 
  81 
  82 void compiledVFrame::set_locals(StackValueCollection* values) const {
  83 
  84   fatal("Should use update_local for each local update");
  85 }
  86 
  87 void compiledVFrame::update_local(BasicType type, int index, jvalue value) {
  88   assert(index >= 0 && index < method()->max_locals(), "out of bounds");
  89   update_deferred_value(type, index, value);
  90 }
  91 
  92 void compiledVFrame::update_stack(BasicType type, int index, jvalue value) {
  93   assert(index >= 0 && index < method()->max_stack(), "out of bounds");
  94   update_deferred_value(type, index + method()->max_locals(), value);
  95 }
  96 
  97 void compiledVFrame::update_monitor(int index, MonitorInfo* val) {
  98   assert(index >= 0, "out of bounds");
  99   jvalue value;
 100   value.l = (jobject) val->owner();
 101   update_deferred_value(T_OBJECT, index + method()->max_locals() + method()->max_stack(), value);
 102 }
 103 
 104 void compiledVFrame::update_deferred_value(BasicType type, int index, jvalue value) {
 105   assert(fr().is_deoptimized_frame() || thread()->must_deopt_id() == fr().id(),
 106          "frame must be scheduled for deoptimization");

 107   GrowableArray<jvmtiDeferredLocalVariableSet*>* deferred = thread()->deferred_locals();
 108   jvmtiDeferredLocalVariableSet* locals = NULL;
 109   if (deferred != NULL ) {
 110     // See if this vframe has already had locals with deferred writes
 111     for (int f = 0; f < deferred->length(); f++ ) {
 112       if (deferred->at(f)->matches(this)) {
 113         locals = deferred->at(f);
 114         break;
 115       }
 116     }
 117     // No matching vframe must push a new vframe
 118   } else {
 119     // No deferred updates pending for this thread.
 120     // allocate in C heap
 121     deferred =  new(ResourceObj::C_HEAP, mtCompiler) GrowableArray<jvmtiDeferredLocalVariableSet*> (1, true);
 122     thread()->set_deferred_locals(deferred);
 123   }
 124   if (locals == NULL) {
 125     locals = new jvmtiDeferredLocalVariableSet(method(), bci(), fr().id(), vframe_id());
 126     deferred->push(locals);
 127     assert(locals->id() == fr().id(), "Huh? Must match");
 128   }
 129   locals->set_value_at(index, type, value);
 130 }
 131 
 132 StackValueCollection* compiledVFrame::expressions() const {
 133   // Natives has no scope
 134   if (scope() == NULL) return new StackValueCollection(0);
 135   GrowableArray<ScopeValue*>*  scv_list = scope()->expressions();
 136   if (scv_list == NULL) return new StackValueCollection(0);
 137 
 138   // scv_list is the list of ScopeValues describing the JVM stack state.
 139   // There is one scv_list entry for every JVM stack state in use.
 140   int length = scv_list->length();
 141   StackValueCollection* result = new StackValueCollection(length);
 142   for (int i = 0; i < length; i++) {
 143     result->add(create_stack_value(scv_list->at(i)));
 144   }
 145 
 146   // Replace the original values with any stores that have been
 147   // performed through compiledVFrame::update_stack.
 148   GrowableArray<jvmtiDeferredLocalVariableSet*>* list = thread()->deferred_locals();
 149   if (list != NULL ) {
 150     // In real life this never happens or is typically a single element search
 151     for (int i = 0; i < list->length(); i++) {
 152       if (list->at(i)->matches(this)) {
 153         list->at(i)->update_stack(result);
 154         break;


 155       }
 156     }
 157   }
 158 
 159   return result;
 160 }
 161 
 162 
 163 // The implementation of the following two methods was factorized into the
 164 // class StackValue because it is also used from within deoptimization.cpp for
 165 // rematerialization and relocking of non-escaping objects.
 166 
 167 StackValue *compiledVFrame::create_stack_value(ScopeValue *sv) const {
 168   return StackValue::create_stack_value(&_fr, register_map(), sv);
 169 }
 170 
 171 BasicLock* compiledVFrame::resolve_monitor_lock(Location location) const {
 172   return StackValue::resolve_monitor_lock(&_fr, location);
 173 }
 174 




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  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 "classfile/javaClasses.inline.hpp"
  27 #include "code/codeCache.hpp"
  28 #include "code/debugInfoRec.hpp"
  29 #include "code/nmethod.hpp"
  30 #include "code/pcDesc.hpp"
  31 #include "code/scopeDesc.hpp"
  32 #include "interpreter/interpreter.hpp"
  33 #include "interpreter/oopMapCache.hpp"
  34 #include "oops/instanceKlass.hpp"
  35 #include "oops/oop.inline.hpp"
  36 #include "runtime/basicLock.hpp"
  37 #include "runtime/continuation.hpp"
  38 #include "runtime/frame.inline.hpp"
  39 #include "runtime/handles.inline.hpp"
  40 #include "runtime/monitorChunk.hpp"
  41 #include "runtime/signature.hpp"
  42 #include "runtime/stubRoutines.hpp"
  43 #include "runtime/vframeArray.hpp"
  44 #include "runtime/vframe_hp.hpp"
  45 #ifdef COMPILER2
  46 #include "opto/matcher.hpp"
  47 #endif
  48 
  49 
  50 // ------------- compiledVFrame --------------
  51 
  52 StackValueCollection* compiledVFrame::locals() const {
  53   // Natives has no scope
  54   if (scope() == NULL) return new StackValueCollection(0);
  55   GrowableArray<ScopeValue*>*  scv_list = scope()->locals();
  56   if (scv_list == NULL) return new StackValueCollection(0);
  57 
  58   // scv_list is the list of ScopeValues describing the JVM stack state.
  59   // There is one scv_list entry for every JVM stack state in use.
  60   int length = scv_list->length();
  61   StackValueCollection* result = new StackValueCollection(length);
  62   for (int i = 0; i < length; i++) {
  63     result->add(create_stack_value(scv_list->at(i)));
  64   }
  65 
  66   // Replace the original values with any stores that have been
  67   // performed through compiledVFrame::update_locals.
  68   if (register_map()->cont() == NULL) { // LOOM TODO
  69     GrowableArray<jvmtiDeferredLocalVariableSet*>* list = thread()->deferred_locals();
  70     if (list != NULL ) {
  71       // In real life this never happens or is typically a single element search
  72       for (int i = 0; i < list->length(); i++) {
  73         if (list->at(i)->matches(this)) {
  74           list->at(i)->update_locals(result);
  75           break;
  76         }
  77       }
  78     }
  79   }
  80 
  81   return result;
  82 }
  83 
  84 
  85 void compiledVFrame::set_locals(StackValueCollection* values) const {
  86 
  87   fatal("Should use update_local for each local update");
  88 }
  89 
  90 void compiledVFrame::update_local(BasicType type, int index, jvalue value) {
  91   assert(index >= 0 && index < method()->max_locals(), "out of bounds");
  92   update_deferred_value(type, index, value);
  93 }
  94 
  95 void compiledVFrame::update_stack(BasicType type, int index, jvalue value) {
  96   assert(index >= 0 && index < method()->max_stack(), "out of bounds");
  97   update_deferred_value(type, index + method()->max_locals(), value);
  98 }
  99 
 100 void compiledVFrame::update_monitor(int index, MonitorInfo* val) {
 101   assert(index >= 0, "out of bounds");
 102   jvalue value;
 103   value.l = (jobject) val->owner();
 104   update_deferred_value(T_OBJECT, index + method()->max_locals() + method()->max_stack(), value);
 105 }
 106 
 107 void compiledVFrame::update_deferred_value(BasicType type, int index, jvalue value) {
 108   assert(fr().is_deoptimized_frame() || thread()->must_deopt_id() == fr().id(),
 109          "frame must be scheduled for deoptimization");
 110   assert(!Continuation::is_frame_in_continuation(thread(), fr()), "No support for deferred values in continuations");
 111   GrowableArray<jvmtiDeferredLocalVariableSet*>* deferred = thread()->deferred_locals();
 112   jvmtiDeferredLocalVariableSet* locals = NULL;
 113   if (deferred != NULL ) {
 114     // See if this vframe has already had locals with deferred writes
 115     for (int f = 0; f < deferred->length(); f++ ) {
 116       if (deferred->at(f)->matches(this)) {
 117         locals = deferred->at(f);
 118         break;
 119       }
 120     }
 121     // No matching vframe must push a new vframe
 122   } else {
 123     // No deferred updates pending for this thread.
 124     // allocate in C heap
 125     deferred =  new(ResourceObj::C_HEAP, mtCompiler) GrowableArray<jvmtiDeferredLocalVariableSet*> (1, true);
 126     thread()->set_deferred_locals(deferred);
 127   }
 128   if (locals == NULL) {
 129     locals = new jvmtiDeferredLocalVariableSet(method(), bci(), fr().id(), vframe_id());
 130     deferred->push(locals);
 131     assert(locals->id() == fr().id(), "Huh? Must match");
 132   }
 133   locals->set_value_at(index, type, value);
 134 }
 135 
 136 StackValueCollection* compiledVFrame::expressions() const {
 137   // Natives has no scope
 138   if (scope() == NULL) return new StackValueCollection(0);
 139   GrowableArray<ScopeValue*>*  scv_list = scope()->expressions();
 140   if (scv_list == NULL) return new StackValueCollection(0);
 141 
 142   // scv_list is the list of ScopeValues describing the JVM stack state.
 143   // There is one scv_list entry for every JVM stack state in use.
 144   int length = scv_list->length();
 145   StackValueCollection* result = new StackValueCollection(length);
 146   for (int i = 0; i < length; i++) {
 147     result->add(create_stack_value(scv_list->at(i)));
 148   }
 149 
 150   if (register_map()->cont() == NULL) { // LOOM TODO
 151     // Replace the original values with any stores that have been
 152     // performed through compiledVFrame::update_stack.
 153     GrowableArray<jvmtiDeferredLocalVariableSet*>* list = thread()->deferred_locals();
 154     if (list != NULL ) {
 155       // In real life this never happens or is typically a single element search
 156       for (int i = 0; i < list->length(); i++) {
 157         if (list->at(i)->matches(this)) {
 158           list->at(i)->update_stack(result);
 159           break;
 160         }
 161       }
 162     }
 163   }
 164 
 165   return result;
 166 }
 167 
 168 
 169 // The implementation of the following two methods was factorized into the
 170 // class StackValue because it is also used from within deoptimization.cpp for
 171 // rematerialization and relocking of non-escaping objects.
 172 
 173 StackValue *compiledVFrame::create_stack_value(ScopeValue *sv) const {
 174   return StackValue::create_stack_value(&_fr, register_map(), sv);
 175 }
 176 
 177 BasicLock* compiledVFrame::resolve_monitor_lock(Location location) const {
 178   return StackValue::resolve_monitor_lock(&_fr, location);
 179 }
 180 


< prev index next >