src/share/vm/jvmci/jvmciRuntime.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/jvmci

src/share/vm/jvmci/jvmciRuntime.cpp

Print this page




  87   frame caller_frame = runtime_frame.sender(&reg_map);
  88   assert(caller_frame.is_compiled_frame(), "must be compiled");
  89   return caller_frame.is_deoptimized_frame();
  90 }
  91 
  92 // Stress deoptimization
  93 static void deopt_caller() {
  94   if ( !caller_is_deopted()) {
  95     JavaThread* thread = JavaThread::current();
  96     RegisterMap reg_map(thread, false);
  97     frame runtime_frame = thread->last_frame();
  98     frame caller_frame = runtime_frame.sender(&reg_map);
  99     Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint);
 100     assert(caller_is_deopted(), "Must be deoptimized");
 101   }
 102 }
 103 
 104 JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_instance(JavaThread* thread, Klass* klass))
 105   JRT_BLOCK;
 106   assert(klass->is_klass(), "not a class");

 107   instanceKlassHandle h(thread, klass);
 108   h->check_valid_for_instantiation(true, CHECK);
 109   // make sure klass is initialized
 110   h->initialize(CHECK);
 111   // allocate instance and return via TLS
 112   oop obj = h->allocate_instance(CHECK);
 113   thread->set_vm_result(obj);
 114   JRT_BLOCK_END;
 115 
 116   if (ReduceInitialCardMarks) {
 117     new_store_pre_barrier(thread);
 118   }
 119 JRT_END
 120 
 121 JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length))
 122   JRT_BLOCK;
 123   // Note: no handle for klass needed since they are not used
 124   //       anymore after new_objArray() and no GC can happen before.
 125   //       (This may have to change if this code changes!)
 126   assert(array_klass->is_klass(), "not a class");
 127   oop obj;
 128   if (array_klass->is_typeArray_klass()) {
 129     BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type();
 130     obj = oopFactory::new_typeArray(elt_type, length, CHECK);
 131   } else {

 132     Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass();
 133     obj = oopFactory::new_objArray(elem_klass, length, CHECK);
 134   }
 135   thread->set_vm_result(obj);
 136   // This is pretty rare but this runtime patch is stressful to deoptimization
 137   // if we deoptimize here so force a deopt to stress the path.
 138   if (DeoptimizeALot) {
 139     static int deopts = 0;
 140     // Alternate between deoptimizing and raising an error (which will also cause a deopt)
 141     if (deopts++ % 2 == 0) {
 142       ResourceMark rm(THREAD);
 143       THROW(vmSymbols::java_lang_OutOfMemoryError());
 144     } else {
 145       deopt_caller();
 146     }
 147   }
 148   JRT_BLOCK_END;
 149 
 150   if (ReduceInitialCardMarks) {
 151     new_store_pre_barrier(thread);


 155 void JVMCIRuntime::new_store_pre_barrier(JavaThread* thread) {
 156   // After any safepoint, just before going back to compiled code,
 157   // we inform the GC that we will be doing initializing writes to
 158   // this object in the future without emitting card-marks, so
 159   // GC may take any compensating steps.
 160   // NOTE: Keep this code consistent with GraphKit::store_barrier.
 161 
 162   oop new_obj = thread->vm_result();
 163   if (new_obj == NULL)  return;
 164 
 165   assert(Universe::heap()->can_elide_tlab_store_barriers(),
 166          "compiler must check this first");
 167   // GC may decide to give back a safer copy of new_obj.
 168   new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj);
 169   thread->set_vm_result(new_obj);
 170 }
 171 
 172 JRT_ENTRY(void, JVMCIRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims))
 173   assert(klass->is_klass(), "not a class");
 174   assert(rank >= 1, "rank must be nonzero");

 175   oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
 176   thread->set_vm_result(obj);
 177 JRT_END
 178 
 179 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length))
 180   oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK);
 181   thread->set_vm_result(obj);
 182 JRT_END
 183 
 184 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror))
 185   instanceKlassHandle klass(THREAD, java_lang_Class::as_Klass(type_mirror));
 186 
 187   if (klass == NULL) {
 188     ResourceMark rm(THREAD);
 189     THROW(vmSymbols::java_lang_InstantiationException());
 190   }
 191 
 192   // Create new instance (the receiver)
 193   klass->check_valid_for_instantiation(false, CHECK);
 194 




  87   frame caller_frame = runtime_frame.sender(&reg_map);
  88   assert(caller_frame.is_compiled_frame(), "must be compiled");
  89   return caller_frame.is_deoptimized_frame();
  90 }
  91 
  92 // Stress deoptimization
  93 static void deopt_caller() {
  94   if ( !caller_is_deopted()) {
  95     JavaThread* thread = JavaThread::current();
  96     RegisterMap reg_map(thread, false);
  97     frame runtime_frame = thread->last_frame();
  98     frame caller_frame = runtime_frame.sender(&reg_map);
  99     Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint);
 100     assert(caller_is_deopted(), "Must be deoptimized");
 101   }
 102 }
 103 
 104 JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_instance(JavaThread* thread, Klass* klass))
 105   JRT_BLOCK;
 106   assert(klass->is_klass(), "not a class");
 107   Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
 108   instanceKlassHandle h(thread, klass);
 109   h->check_valid_for_instantiation(true, CHECK);
 110   // make sure klass is initialized
 111   h->initialize(CHECK);
 112   // allocate instance and return via TLS
 113   oop obj = h->allocate_instance(CHECK);
 114   thread->set_vm_result(obj);
 115   JRT_BLOCK_END;
 116 
 117   if (ReduceInitialCardMarks) {
 118     new_store_pre_barrier(thread);
 119   }
 120 JRT_END
 121 
 122 JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length))
 123   JRT_BLOCK;
 124   // Note: no handle for klass needed since they are not used
 125   //       anymore after new_objArray() and no GC can happen before.
 126   //       (This may have to change if this code changes!)
 127   assert(array_klass->is_klass(), "not a class");
 128   oop obj;
 129   if (array_klass->is_typeArray_klass()) {
 130     BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type();
 131     obj = oopFactory::new_typeArray(elt_type, length, CHECK);
 132   } else {
 133     Handle holder(THREAD, array_klass->klass_holder()); // keep the klass alive
 134     Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass();
 135     obj = oopFactory::new_objArray(elem_klass, length, CHECK);
 136   }
 137   thread->set_vm_result(obj);
 138   // This is pretty rare but this runtime patch is stressful to deoptimization
 139   // if we deoptimize here so force a deopt to stress the path.
 140   if (DeoptimizeALot) {
 141     static int deopts = 0;
 142     // Alternate between deoptimizing and raising an error (which will also cause a deopt)
 143     if (deopts++ % 2 == 0) {
 144       ResourceMark rm(THREAD);
 145       THROW(vmSymbols::java_lang_OutOfMemoryError());
 146     } else {
 147       deopt_caller();
 148     }
 149   }
 150   JRT_BLOCK_END;
 151 
 152   if (ReduceInitialCardMarks) {
 153     new_store_pre_barrier(thread);


 157 void JVMCIRuntime::new_store_pre_barrier(JavaThread* thread) {
 158   // After any safepoint, just before going back to compiled code,
 159   // we inform the GC that we will be doing initializing writes to
 160   // this object in the future without emitting card-marks, so
 161   // GC may take any compensating steps.
 162   // NOTE: Keep this code consistent with GraphKit::store_barrier.
 163 
 164   oop new_obj = thread->vm_result();
 165   if (new_obj == NULL)  return;
 166 
 167   assert(Universe::heap()->can_elide_tlab_store_barriers(),
 168          "compiler must check this first");
 169   // GC may decide to give back a safer copy of new_obj.
 170   new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj);
 171   thread->set_vm_result(new_obj);
 172 }
 173 
 174 JRT_ENTRY(void, JVMCIRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims))
 175   assert(klass->is_klass(), "not a class");
 176   assert(rank >= 1, "rank must be nonzero");
 177   Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
 178   oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
 179   thread->set_vm_result(obj);
 180 JRT_END
 181 
 182 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length))
 183   oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK);
 184   thread->set_vm_result(obj);
 185 JRT_END
 186 
 187 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror))
 188   instanceKlassHandle klass(THREAD, java_lang_Class::as_Klass(type_mirror));
 189 
 190   if (klass == NULL) {
 191     ResourceMark rm(THREAD);
 192     THROW(vmSymbols::java_lang_InstantiationException());
 193   }
 194 
 195   // Create new instance (the receiver)
 196   klass->check_valid_for_instantiation(false, CHECK);
 197 


src/share/vm/jvmci/jvmciRuntime.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File