< prev index next >

src/hotspot/share/runtime/deoptimization.cpp

Print this page




 175 
 176   if (VerifyStack) {
 177     thread->validate_frame_layout();
 178   }
 179 
 180   // Create a growable array of VFrames where each VFrame represents an inlined
 181   // Java frame.  This storage is allocated with the usual system arena.
 182   assert(deoptee.is_compiled_frame(), "Wrong frame type");
 183   GrowableArray<compiledVFrame*>* chunk = new GrowableArray<compiledVFrame*>(10);
 184   vframe* vf = vframe::new_vframe(&deoptee, &map, thread);
 185   while (!vf->is_top()) {
 186     assert(vf->is_compiled_frame(), "Wrong frame type");
 187     chunk->push(compiledVFrame::cast(vf));
 188     vf = vf->sender();
 189   }
 190   assert(vf->is_compiled_frame(), "Wrong frame type");
 191   chunk->push(compiledVFrame::cast(vf));
 192 
 193   bool realloc_failures = false;
 194 
 195 #if defined(COMPILER2) || INCLUDE_JVMCI
 196   // Reallocate the non-escaping objects and restore their fields. Then
 197   // relock objects if synchronization on them was eliminated.
 198 #ifndef INCLUDE_JVMCI
 199   if (DoEscapeAnalysis || EliminateNestedLocks) {
 200     if (EliminateAllocations) {
 201 #endif // INCLUDE_JVMCI
 202       assert (chunk->at(0)->scope() != NULL,"expect only compiled java frames");
 203       GrowableArray<ScopeValue*>* objects = chunk->at(0)->scope()->objects();
 204 
 205       // The flag return_oop() indicates call sites which return oop
 206       // in compiled code. Such sites include java method calls,
 207       // runtime calls (for example, used to allocate new objects/arrays
 208       // on slow code path) and any other calls generated in compiled code.
 209       // It is not guaranteed that we can get such information here only
 210       // by analyzing bytecode in deoptimized frames. This is why this flag
 211       // is set during method compilation (see Compile::Process_OopMap_Node()).
 212       // If the previous frame was popped or if we are dispatching an exception,
 213       // we don't have an oop result.
 214       bool save_oop_result = chunk->at(0)->scope()->return_oop() && !thread->popframe_forcing_deopt_reexecution() && (exec_mode == Unpack_deopt);
 215       Handle return_value;


 265                 if (first) {
 266                   first = false;
 267                   tty->print_cr("RELOCK OBJECTS in thread " INTPTR_FORMAT, p2i(thread));
 268                 }
 269                 if (mi->owner_is_scalar_replaced()) {
 270                   Klass* k = java_lang_Class::as_Klass(mi->owner_klass());
 271                   tty->print_cr("     failed reallocation for klass %s", k->external_name());
 272                 } else {
 273                   tty->print_cr("     object <" INTPTR_FORMAT "> locked", p2i(mi->owner()));
 274                 }
 275               }
 276             }
 277           }
 278 #endif // !PRODUCT
 279         }
 280       }
 281 #ifndef INCLUDE_JVMCI
 282     }
 283   }
 284 #endif // INCLUDE_JVMCI
 285 #endif // COMPILER2 || INCLUDE_JVMCI
 286 
 287   ScopeDesc* trap_scope = chunk->at(0)->scope();
 288   Handle exceptionObject;
 289   if (trap_scope->rethrow_exception()) {
 290     if (PrintDeoptimizationDetails) {
 291       tty->print_cr("Exception to be rethrown in the interpreter for method %s::%s at bci %d", trap_scope->method()->method_holder()->name()->as_C_string(), trap_scope->method()->name()->as_C_string(), trap_scope->bci());
 292     }
 293     GrowableArray<ScopeValue*>* expressions = trap_scope->expressions();
 294     guarantee(expressions != NULL && expressions->length() > 0, "must have exception to throw");
 295     ScopeValue* topOfStack = expressions->top();
 296     exceptionObject = StackValue::create_stack_value(&deoptee, &map, topOfStack)->get_obj();
 297     guarantee(exceptionObject() != NULL, "exception oop can not be null");
 298   }
 299 
 300   // Ensure that no safepoint is taken after pointers have been stored
 301   // in fields of rematerialized objects.  If a safepoint occurs from here on
 302   // out the java state residing in the vframeArray will be missed.
 303   NoSafepointVerifier no_safepoint;
 304 
 305   vframeArray* array = create_vframeArray(thread, deoptee, &map, chunk, realloc_failures);
 306 #if defined(COMPILER2) || INCLUDE_JVMCI
 307   if (realloc_failures) {
 308     pop_frames_failed_reallocs(thread, array);
 309   }
 310 #endif
 311 
 312   assert(thread->vframe_array_head() == NULL, "Pending deopt!");
 313   thread->set_vframe_array_head(array);
 314 
 315   // Now that the vframeArray has been created if we have any deferred local writes
 316   // added by jvmti then we can free up that structure as the data is now in the
 317   // vframeArray
 318 
 319   if (thread->deferred_locals() != NULL) {
 320     GrowableArray<jvmtiDeferredLocalVariableSet*>* list = thread->deferred_locals();
 321     int i = 0;
 322     do {
 323       // Because of inlining we could have multiple vframes for a single frame
 324       // and several of the vframes could have deferred writes. Find them all.
 325       if (list->at(i)->id() == array->original().id()) {
 326         jvmtiDeferredLocalVariableSet* dlv = list->at(i);


 775       callee_size_of_parameters = mh->size_of_parameters();
 776       callee_max_locals = mh->max_locals();
 777       is_top_frame = false;
 778     }
 779   }
 780 #endif /* !PRODUCT */
 781 
 782 
 783   return bt;
 784 JRT_END
 785 
 786 
 787 int Deoptimization::deoptimize_dependents() {
 788   Threads::deoptimized_wrt_marked_nmethods();
 789   return 0;
 790 }
 791 
 792 Deoptimization::DeoptAction Deoptimization::_unloaded_action
 793   = Deoptimization::Action_reinterpret;
 794 
 795 #if defined(COMPILER2) || INCLUDE_JVMCI
 796 bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, GrowableArray<ScopeValue*>* objects, TRAPS) {
 797   Handle pending_exception(THREAD, thread->pending_exception());
 798   const char* exception_file = thread->exception_file();
 799   int exception_line = thread->exception_line();
 800   thread->clear_pending_exception();
 801 
 802   bool failures = false;
 803 
 804   for (int i = 0; i < objects->length(); i++) {
 805     assert(objects->at(i)->is_object(), "invalid debug information");
 806     ObjectValue* sv = (ObjectValue*) objects->at(i);
 807 
 808     Klass* k = java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()());
 809     oop obj = NULL;
 810 
 811     if (k->is_instance_klass()) {
 812       InstanceKlass* ik = InstanceKlass::cast(k);
 813       obj = ik->allocate_instance(THREAD);
 814     } else if (k->is_typeArray_klass()) {
 815       TypeArrayKlass* ak = TypeArrayKlass::cast(k);


1134     ObjectValue* sv = (ObjectValue*) objects->at(i);
1135     Klass* k = java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()());
1136     Handle obj = sv->value();
1137 
1138     tty->print("     object <" INTPTR_FORMAT "> of type ", p2i(sv->value()()));
1139     k->print_value();
1140     assert(obj.not_null() || realloc_failures, "reallocation was missed");
1141     if (obj.is_null()) {
1142       tty->print(" allocation failed");
1143     } else {
1144       tty->print(" allocated (%d bytes)", obj->size() * HeapWordSize);
1145     }
1146     tty->cr();
1147 
1148     if (Verbose && !obj.is_null()) {
1149       k->oop_print_on(obj(), tty);
1150     }
1151   }
1152 }
1153 #endif
1154 #endif // COMPILER2 || INCLUDE_JVMCI
1155 
1156 vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures) {
1157   Events::log(thread, "DEOPT PACKING pc=" INTPTR_FORMAT " sp=" INTPTR_FORMAT, p2i(fr.pc()), p2i(fr.sp()));
1158 
1159 #ifndef PRODUCT
1160   if (PrintDeoptimizationDetails) {
1161     ttyLocker ttyl;
1162     tty->print("DEOPT PACKING thread " INTPTR_FORMAT " ", p2i(thread));
1163     fr.print_on(tty);
1164     tty->print_cr("     Virtual frames (innermost first):");
1165     for (int index = 0; index < chunk->length(); index++) {
1166       compiledVFrame* vf = chunk->at(index);
1167       tty->print("       %2d - ", index);
1168       vf->print_value();
1169       int bci = chunk->at(index)->raw_bci();
1170       const char* code_name;
1171       if (bci == SynchronizationEntryBCI) {
1172         code_name = "sync entry";
1173       } else {
1174         Bytecodes::Code code = vf->method()->code_at(bci);


1194   frame sender = caller;
1195 
1196   // Since the Java thread being deoptimized will eventually adjust it's own stack,
1197   // the vframeArray containing the unpacking information is allocated in the C heap.
1198   // For Compiler1, the caller of the deoptimized frame is saved for use by unpack_frames().
1199   vframeArray* array = vframeArray::allocate(thread, frame_size, chunk, reg_map, sender, caller, fr, realloc_failures);
1200 
1201   // Compare the vframeArray to the collected vframes
1202   assert(array->structural_compare(thread, chunk), "just checking");
1203 
1204 #ifndef PRODUCT
1205   if (PrintDeoptimizationDetails) {
1206     ttyLocker ttyl;
1207     tty->print_cr("     Created vframeArray " INTPTR_FORMAT, p2i(array));
1208   }
1209 #endif // PRODUCT
1210 
1211   return array;
1212 }
1213 
1214 #if defined(COMPILER2) || INCLUDE_JVMCI
1215 void Deoptimization::pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array) {
1216   // Reallocation of some scalar replaced objects failed. Record
1217   // that we need to pop all the interpreter frames for the
1218   // deoptimized compiled frame.
1219   assert(thread->frames_to_pop_failed_realloc() == 0, "missed frames to pop?");
1220   thread->set_frames_to_pop_failed_realloc(array->frames());
1221   // Unlock all monitors here otherwise the interpreter will see a
1222   // mix of locked and unlocked monitors (because of failed
1223   // reallocations of synchronized objects) and be confused.
1224   for (int i = 0; i < array->frames(); i++) {
1225     MonitorChunk* monitors = array->element(i)->monitors();
1226     if (monitors != NULL) {
1227       for (int j = 0; j < monitors->number_of_monitors(); j++) {
1228         BasicObjectLock* src = monitors->at(j);
1229         if (src->obj() != NULL) {
1230           ObjectSynchronizer::fast_exit(src->obj(), src->lock(), thread);
1231         }
1232       }
1233       array->element(i)->free_monitors(thread);
1234 #ifdef ASSERT


1426 JRT_END
1427 
1428 MethodData*
1429 Deoptimization::get_method_data(JavaThread* thread, const methodHandle& m,
1430                                 bool create_if_missing) {
1431   Thread* THREAD = thread;
1432   MethodData* mdo = m()->method_data();
1433   if (mdo == NULL && create_if_missing && !HAS_PENDING_EXCEPTION) {
1434     // Build an MDO.  Ignore errors like OutOfMemory;
1435     // that simply means we won't have an MDO to update.
1436     Method::build_interpreter_method_data(m, THREAD);
1437     if (HAS_PENDING_EXCEPTION) {
1438       assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here");
1439       CLEAR_PENDING_EXCEPTION;
1440     }
1441     mdo = m()->method_data();
1442   }
1443   return mdo;
1444 }
1445 
1446 #if defined(COMPILER2) || INCLUDE_JVMCI
1447 void Deoptimization::load_class_by_index(const constantPoolHandle& constant_pool, int index, TRAPS) {
1448   // in case of an unresolved klass entry, load the class.
1449   if (constant_pool->tag_at(index).is_unresolved_klass()) {
1450     Klass* tk = constant_pool->klass_at_ignore_error(index, CHECK);
1451     return;
1452   }
1453 
1454   if (!constant_pool->tag_at(index).is_symbol()) return;
1455 
1456   Handle class_loader (THREAD, constant_pool->pool_holder()->class_loader());
1457   Symbol*  symbol  = constant_pool->symbol_at(index);
1458 
1459   // class name?
1460   if (symbol->byte_at(0) != '(') {
1461     Handle protection_domain (THREAD, constant_pool->pool_holder()->protection_domain());
1462     SystemDictionary::resolve_or_null(symbol, class_loader, protection_domain, CHECK);
1463     return;
1464   }
1465 
1466   // then it must be a signature!


2343             if (bc_case == BC_CASE_LIMIT && (int)bc == 0)
2344               bc = Bytecodes::_illegal;
2345             sprintf(name, "%s/%s/%s",
2346                     trap_reason_name(reason),
2347                     trap_action_name(action),
2348                     Bytecodes::is_defined(bc)? Bytecodes::name(bc): "other");
2349             juint r = counter >> LSB_BITS;
2350             tty->print_cr("  %40s: " UINT32_FORMAT " (%.1f%%)", name, r, (r * 100.0) / total);
2351             account -= r;
2352           }
2353         }
2354       }
2355     }
2356     if (account != 0) {
2357       PRINT_STAT_LINE("unaccounted", account);
2358     }
2359     #undef PRINT_STAT_LINE
2360     if (xtty != NULL)  xtty->tail("statistics");
2361   }
2362 }
2363 #else // COMPILER2 || INCLUDE_JVMCI
2364 
2365 
2366 // Stubs for C1 only system.
2367 bool Deoptimization::trap_state_is_recompiled(int trap_state) {
2368   return false;
2369 }
2370 
2371 const char* Deoptimization::trap_reason_name(int reason) {
2372   return "unknown";
2373 }
2374 
2375 void Deoptimization::print_statistics() {
2376   // no output
2377 }
2378 
2379 void
2380 Deoptimization::update_method_data_from_interpreter(MethodData* trap_mdo, int trap_bci, int reason) {
2381   // no udpate
2382 }
2383 
2384 int Deoptimization::trap_state_has_reason(int trap_state, int reason) {
2385   return 0;
2386 }
2387 
2388 void Deoptimization::gather_statistics(DeoptReason reason, DeoptAction action,
2389                                        Bytecodes::Code bc) {
2390   // no update
2391 }
2392 
2393 const char* Deoptimization::format_trap_state(char* buf, size_t buflen,
2394                                               int trap_state) {
2395   jio_snprintf(buf, buflen, "#%d", trap_state);
2396   return buf;
2397 }
2398 
2399 #endif // COMPILER2 || INCLUDE_JVMCI


 175 
 176   if (VerifyStack) {
 177     thread->validate_frame_layout();
 178   }
 179 
 180   // Create a growable array of VFrames where each VFrame represents an inlined
 181   // Java frame.  This storage is allocated with the usual system arena.
 182   assert(deoptee.is_compiled_frame(), "Wrong frame type");
 183   GrowableArray<compiledVFrame*>* chunk = new GrowableArray<compiledVFrame*>(10);
 184   vframe* vf = vframe::new_vframe(&deoptee, &map, thread);
 185   while (!vf->is_top()) {
 186     assert(vf->is_compiled_frame(), "Wrong frame type");
 187     chunk->push(compiledVFrame::cast(vf));
 188     vf = vf->sender();
 189   }
 190   assert(vf->is_compiled_frame(), "Wrong frame type");
 191   chunk->push(compiledVFrame::cast(vf));
 192 
 193   bool realloc_failures = false;
 194 
 195 #if COMPILER2_OR_JVMCI
 196   // Reallocate the non-escaping objects and restore their fields. Then
 197   // relock objects if synchronization on them was eliminated.
 198 #ifndef INCLUDE_JVMCI
 199   if (DoEscapeAnalysis || EliminateNestedLocks) {
 200     if (EliminateAllocations) {
 201 #endif // INCLUDE_JVMCI
 202       assert (chunk->at(0)->scope() != NULL,"expect only compiled java frames");
 203       GrowableArray<ScopeValue*>* objects = chunk->at(0)->scope()->objects();
 204 
 205       // The flag return_oop() indicates call sites which return oop
 206       // in compiled code. Such sites include java method calls,
 207       // runtime calls (for example, used to allocate new objects/arrays
 208       // on slow code path) and any other calls generated in compiled code.
 209       // It is not guaranteed that we can get such information here only
 210       // by analyzing bytecode in deoptimized frames. This is why this flag
 211       // is set during method compilation (see Compile::Process_OopMap_Node()).
 212       // If the previous frame was popped or if we are dispatching an exception,
 213       // we don't have an oop result.
 214       bool save_oop_result = chunk->at(0)->scope()->return_oop() && !thread->popframe_forcing_deopt_reexecution() && (exec_mode == Unpack_deopt);
 215       Handle return_value;


 265                 if (first) {
 266                   first = false;
 267                   tty->print_cr("RELOCK OBJECTS in thread " INTPTR_FORMAT, p2i(thread));
 268                 }
 269                 if (mi->owner_is_scalar_replaced()) {
 270                   Klass* k = java_lang_Class::as_Klass(mi->owner_klass());
 271                   tty->print_cr("     failed reallocation for klass %s", k->external_name());
 272                 } else {
 273                   tty->print_cr("     object <" INTPTR_FORMAT "> locked", p2i(mi->owner()));
 274                 }
 275               }
 276             }
 277           }
 278 #endif // !PRODUCT
 279         }
 280       }
 281 #ifndef INCLUDE_JVMCI
 282     }
 283   }
 284 #endif // INCLUDE_JVMCI
 285 #endif // COMPILER2_OR_JVMCI
 286 
 287   ScopeDesc* trap_scope = chunk->at(0)->scope();
 288   Handle exceptionObject;
 289   if (trap_scope->rethrow_exception()) {
 290     if (PrintDeoptimizationDetails) {
 291       tty->print_cr("Exception to be rethrown in the interpreter for method %s::%s at bci %d", trap_scope->method()->method_holder()->name()->as_C_string(), trap_scope->method()->name()->as_C_string(), trap_scope->bci());
 292     }
 293     GrowableArray<ScopeValue*>* expressions = trap_scope->expressions();
 294     guarantee(expressions != NULL && expressions->length() > 0, "must have exception to throw");
 295     ScopeValue* topOfStack = expressions->top();
 296     exceptionObject = StackValue::create_stack_value(&deoptee, &map, topOfStack)->get_obj();
 297     guarantee(exceptionObject() != NULL, "exception oop can not be null");
 298   }
 299 
 300   // Ensure that no safepoint is taken after pointers have been stored
 301   // in fields of rematerialized objects.  If a safepoint occurs from here on
 302   // out the java state residing in the vframeArray will be missed.
 303   NoSafepointVerifier no_safepoint;
 304 
 305   vframeArray* array = create_vframeArray(thread, deoptee, &map, chunk, realloc_failures);
 306 #if COMPILER2_OR_JVMCI
 307   if (realloc_failures) {
 308     pop_frames_failed_reallocs(thread, array);
 309   }
 310 #endif
 311 
 312   assert(thread->vframe_array_head() == NULL, "Pending deopt!");
 313   thread->set_vframe_array_head(array);
 314 
 315   // Now that the vframeArray has been created if we have any deferred local writes
 316   // added by jvmti then we can free up that structure as the data is now in the
 317   // vframeArray
 318 
 319   if (thread->deferred_locals() != NULL) {
 320     GrowableArray<jvmtiDeferredLocalVariableSet*>* list = thread->deferred_locals();
 321     int i = 0;
 322     do {
 323       // Because of inlining we could have multiple vframes for a single frame
 324       // and several of the vframes could have deferred writes. Find them all.
 325       if (list->at(i)->id() == array->original().id()) {
 326         jvmtiDeferredLocalVariableSet* dlv = list->at(i);


 775       callee_size_of_parameters = mh->size_of_parameters();
 776       callee_max_locals = mh->max_locals();
 777       is_top_frame = false;
 778     }
 779   }
 780 #endif /* !PRODUCT */
 781 
 782 
 783   return bt;
 784 JRT_END
 785 
 786 
 787 int Deoptimization::deoptimize_dependents() {
 788   Threads::deoptimized_wrt_marked_nmethods();
 789   return 0;
 790 }
 791 
 792 Deoptimization::DeoptAction Deoptimization::_unloaded_action
 793   = Deoptimization::Action_reinterpret;
 794 
 795 #if COMPILER2_OR_JVMCI
 796 bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, GrowableArray<ScopeValue*>* objects, TRAPS) {
 797   Handle pending_exception(THREAD, thread->pending_exception());
 798   const char* exception_file = thread->exception_file();
 799   int exception_line = thread->exception_line();
 800   thread->clear_pending_exception();
 801 
 802   bool failures = false;
 803 
 804   for (int i = 0; i < objects->length(); i++) {
 805     assert(objects->at(i)->is_object(), "invalid debug information");
 806     ObjectValue* sv = (ObjectValue*) objects->at(i);
 807 
 808     Klass* k = java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()());
 809     oop obj = NULL;
 810 
 811     if (k->is_instance_klass()) {
 812       InstanceKlass* ik = InstanceKlass::cast(k);
 813       obj = ik->allocate_instance(THREAD);
 814     } else if (k->is_typeArray_klass()) {
 815       TypeArrayKlass* ak = TypeArrayKlass::cast(k);


1134     ObjectValue* sv = (ObjectValue*) objects->at(i);
1135     Klass* k = java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()());
1136     Handle obj = sv->value();
1137 
1138     tty->print("     object <" INTPTR_FORMAT "> of type ", p2i(sv->value()()));
1139     k->print_value();
1140     assert(obj.not_null() || realloc_failures, "reallocation was missed");
1141     if (obj.is_null()) {
1142       tty->print(" allocation failed");
1143     } else {
1144       tty->print(" allocated (%d bytes)", obj->size() * HeapWordSize);
1145     }
1146     tty->cr();
1147 
1148     if (Verbose && !obj.is_null()) {
1149       k->oop_print_on(obj(), tty);
1150     }
1151   }
1152 }
1153 #endif
1154 #endif // COMPILER2_OR_JVMCI
1155 
1156 vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures) {
1157   Events::log(thread, "DEOPT PACKING pc=" INTPTR_FORMAT " sp=" INTPTR_FORMAT, p2i(fr.pc()), p2i(fr.sp()));
1158 
1159 #ifndef PRODUCT
1160   if (PrintDeoptimizationDetails) {
1161     ttyLocker ttyl;
1162     tty->print("DEOPT PACKING thread " INTPTR_FORMAT " ", p2i(thread));
1163     fr.print_on(tty);
1164     tty->print_cr("     Virtual frames (innermost first):");
1165     for (int index = 0; index < chunk->length(); index++) {
1166       compiledVFrame* vf = chunk->at(index);
1167       tty->print("       %2d - ", index);
1168       vf->print_value();
1169       int bci = chunk->at(index)->raw_bci();
1170       const char* code_name;
1171       if (bci == SynchronizationEntryBCI) {
1172         code_name = "sync entry";
1173       } else {
1174         Bytecodes::Code code = vf->method()->code_at(bci);


1194   frame sender = caller;
1195 
1196   // Since the Java thread being deoptimized will eventually adjust it's own stack,
1197   // the vframeArray containing the unpacking information is allocated in the C heap.
1198   // For Compiler1, the caller of the deoptimized frame is saved for use by unpack_frames().
1199   vframeArray* array = vframeArray::allocate(thread, frame_size, chunk, reg_map, sender, caller, fr, realloc_failures);
1200 
1201   // Compare the vframeArray to the collected vframes
1202   assert(array->structural_compare(thread, chunk), "just checking");
1203 
1204 #ifndef PRODUCT
1205   if (PrintDeoptimizationDetails) {
1206     ttyLocker ttyl;
1207     tty->print_cr("     Created vframeArray " INTPTR_FORMAT, p2i(array));
1208   }
1209 #endif // PRODUCT
1210 
1211   return array;
1212 }
1213 
1214 #if COMPILER2_OR_JVMCI
1215 void Deoptimization::pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array) {
1216   // Reallocation of some scalar replaced objects failed. Record
1217   // that we need to pop all the interpreter frames for the
1218   // deoptimized compiled frame.
1219   assert(thread->frames_to_pop_failed_realloc() == 0, "missed frames to pop?");
1220   thread->set_frames_to_pop_failed_realloc(array->frames());
1221   // Unlock all monitors here otherwise the interpreter will see a
1222   // mix of locked and unlocked monitors (because of failed
1223   // reallocations of synchronized objects) and be confused.
1224   for (int i = 0; i < array->frames(); i++) {
1225     MonitorChunk* monitors = array->element(i)->monitors();
1226     if (monitors != NULL) {
1227       for (int j = 0; j < monitors->number_of_monitors(); j++) {
1228         BasicObjectLock* src = monitors->at(j);
1229         if (src->obj() != NULL) {
1230           ObjectSynchronizer::fast_exit(src->obj(), src->lock(), thread);
1231         }
1232       }
1233       array->element(i)->free_monitors(thread);
1234 #ifdef ASSERT


1426 JRT_END
1427 
1428 MethodData*
1429 Deoptimization::get_method_data(JavaThread* thread, const methodHandle& m,
1430                                 bool create_if_missing) {
1431   Thread* THREAD = thread;
1432   MethodData* mdo = m()->method_data();
1433   if (mdo == NULL && create_if_missing && !HAS_PENDING_EXCEPTION) {
1434     // Build an MDO.  Ignore errors like OutOfMemory;
1435     // that simply means we won't have an MDO to update.
1436     Method::build_interpreter_method_data(m, THREAD);
1437     if (HAS_PENDING_EXCEPTION) {
1438       assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here");
1439       CLEAR_PENDING_EXCEPTION;
1440     }
1441     mdo = m()->method_data();
1442   }
1443   return mdo;
1444 }
1445 
1446 #if COMPILER2_OR_JVMCI
1447 void Deoptimization::load_class_by_index(const constantPoolHandle& constant_pool, int index, TRAPS) {
1448   // in case of an unresolved klass entry, load the class.
1449   if (constant_pool->tag_at(index).is_unresolved_klass()) {
1450     Klass* tk = constant_pool->klass_at_ignore_error(index, CHECK);
1451     return;
1452   }
1453 
1454   if (!constant_pool->tag_at(index).is_symbol()) return;
1455 
1456   Handle class_loader (THREAD, constant_pool->pool_holder()->class_loader());
1457   Symbol*  symbol  = constant_pool->symbol_at(index);
1458 
1459   // class name?
1460   if (symbol->byte_at(0) != '(') {
1461     Handle protection_domain (THREAD, constant_pool->pool_holder()->protection_domain());
1462     SystemDictionary::resolve_or_null(symbol, class_loader, protection_domain, CHECK);
1463     return;
1464   }
1465 
1466   // then it must be a signature!


2343             if (bc_case == BC_CASE_LIMIT && (int)bc == 0)
2344               bc = Bytecodes::_illegal;
2345             sprintf(name, "%s/%s/%s",
2346                     trap_reason_name(reason),
2347                     trap_action_name(action),
2348                     Bytecodes::is_defined(bc)? Bytecodes::name(bc): "other");
2349             juint r = counter >> LSB_BITS;
2350             tty->print_cr("  %40s: " UINT32_FORMAT " (%.1f%%)", name, r, (r * 100.0) / total);
2351             account -= r;
2352           }
2353         }
2354       }
2355     }
2356     if (account != 0) {
2357       PRINT_STAT_LINE("unaccounted", account);
2358     }
2359     #undef PRINT_STAT_LINE
2360     if (xtty != NULL)  xtty->tail("statistics");
2361   }
2362 }
2363 #else // COMPILER2_OR_JVMCI
2364 
2365 
2366 // Stubs for C1 only system.
2367 bool Deoptimization::trap_state_is_recompiled(int trap_state) {
2368   return false;
2369 }
2370 
2371 const char* Deoptimization::trap_reason_name(int reason) {
2372   return "unknown";
2373 }
2374 
2375 void Deoptimization::print_statistics() {
2376   // no output
2377 }
2378 
2379 void
2380 Deoptimization::update_method_data_from_interpreter(MethodData* trap_mdo, int trap_bci, int reason) {
2381   // no udpate
2382 }
2383 
2384 int Deoptimization::trap_state_has_reason(int trap_state, int reason) {
2385   return 0;
2386 }
2387 
2388 void Deoptimization::gather_statistics(DeoptReason reason, DeoptAction action,
2389                                        Bytecodes::Code bc) {
2390   // no update
2391 }
2392 
2393 const char* Deoptimization::format_trap_state(char* buf, size_t buflen,
2394                                               int trap_state) {
2395   jio_snprintf(buf, buflen, "#%d", trap_state);
2396   return buf;
2397 }
2398 
2399 #endif // COMPILER2_OR_JVMCI
< prev index next >