< prev index next >

src/hotspot/share/runtime/deoptimization.cpp

Print this page
rev 56251 : imported patch 8226705-v1
rev 56253 : [mq]: 8226705-v3-pat


 281     chunk->push(compiledVFrame::cast(vf));
 282     vf = vf->sender();
 283   }
 284   assert(vf->is_compiled_frame(), "Wrong frame type");
 285   chunk->push(compiledVFrame::cast(vf));
 286 
 287   bool realloc_failures = false;
 288 
 289 #if COMPILER2_OR_JVMCI
 290 #if INCLUDE_JVMCI
 291   bool jvmci_enabled = true;
 292 #else
 293   bool jvmci_enabled = false;
 294 #endif
 295 
 296   // Reallocate the non-escaping objects and restore their fields. Then
 297   // relock objects if synchronization on them was eliminated.
 298   if (jvmci_enabled || ((DoEscapeAnalysis || EliminateNestedLocks) && EliminateAllocations)) {
 299     realloc_failures = eliminate_allocations(thread, exec_mode, cm, deoptee, map, chunk);
 300   }

 301 
 302   // Revoke biases, done with in java state.
 303   // No safepoints allowed after this
 304   revoke_from_deopt_handler(thread, deoptee, &map);
 305 
 306   // Ensure that no safepoint is taken after pointers have been stored
 307   // in fields of rematerialized objects.  If a safepoint occurs from here on
 308   // out the java state residing in the vframeArray will be missed.
 309   // Locks may be rebaised in a safepoint.
 310   NoSafepointVerifier no_safepoint;
 311 

 312   if (jvmci_enabled || ((DoEscapeAnalysis || EliminateNestedLocks) && EliminateLocks)) {
 313     eliminate_locks(thread, chunk, realloc_failures);
 314   }
 315 #endif // COMPILER2_OR_JVMCI
 316 
 317   ScopeDesc* trap_scope = chunk->at(0)->scope();
 318   Handle exceptionObject;
 319   if (trap_scope->rethrow_exception()) {
 320     if (PrintDeoptimizationDetails) {
 321       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());
 322     }
 323     GrowableArray<ScopeValue*>* expressions = trap_scope->expressions();
 324     guarantee(expressions != NULL && expressions->length() > 0, "must have exception to throw");
 325     ScopeValue* topOfStack = expressions->top();
 326     exceptionObject = StackValue::create_stack_value(&deoptee, &map, topOfStack)->get_obj();
 327     guarantee(exceptionObject() != NULL, "exception oop can not be null");
 328   }
 329 
 330   vframeArray* array = create_vframeArray(thread, deoptee, &map, chunk, realloc_failures);
 331 #if COMPILER2_OR_JVMCI


1456   vframe* vf = vframe::new_vframe(&fr, map, thread);
1457   compiledVFrame* cvf = compiledVFrame::cast(vf);
1458   // Revoke monitors' biases in all scopes
1459   while (!cvf->is_top()) {
1460     collect_monitors(cvf, objects_to_revoke);
1461     cvf = compiledVFrame::cast(cvf->sender());
1462   }
1463   collect_monitors(cvf, objects_to_revoke);
1464 }
1465 
1466 void Deoptimization::revoke_from_deopt_handler(JavaThread* thread, frame fr, RegisterMap* map) {
1467   if (!UseBiasedLocking) {
1468     return;
1469   }
1470   GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>();
1471   get_monitors_from_stack(objects_to_revoke, thread, fr, map);
1472 
1473   int len = objects_to_revoke->length();
1474   for (int i = 0; i < len; i++) {
1475     oop obj = (objects_to_revoke->at(i))();
1476     BiasedLocking::revoke_own_locks(objects_to_revoke->at(i), thread);
1477     assert(!obj->mark().has_bias_pattern(), "biases should be revoked by now");
1478   }
1479 }
1480 
1481 
1482 void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr, Deoptimization::DeoptReason reason) {
1483   assert(fr.can_be_deoptimized(), "checking frame type");
1484 
1485   gather_statistics(reason, Action_none, Bytecodes::_illegal);
1486 
1487   if (LogCompilation && xtty != NULL) {
1488     CompiledMethod* cm = fr.cb()->as_compiled_method_or_null();
1489     assert(cm != NULL, "only compiled methods can deopt");
1490 
1491     ttyLocker ttyl;
1492     xtty->begin_head("deoptimized thread='" UINTX_FORMAT "' reason='%s' pc='" INTPTR_FORMAT "'",(uintx)thread->osthread()->thread_id(), trap_reason_name(reason), p2i(fr.pc()));
1493     cm->log_identity(xtty);
1494     xtty->end_head();
1495     for (ScopeDesc* sd = cm->scope_desc_at(fr.pc()); ; sd = sd->sender()) {
1496       xtty->begin_elem("jvms bci='%d'", sd->bci());




 281     chunk->push(compiledVFrame::cast(vf));
 282     vf = vf->sender();
 283   }
 284   assert(vf->is_compiled_frame(), "Wrong frame type");
 285   chunk->push(compiledVFrame::cast(vf));
 286 
 287   bool realloc_failures = false;
 288 
 289 #if COMPILER2_OR_JVMCI
 290 #if INCLUDE_JVMCI
 291   bool jvmci_enabled = true;
 292 #else
 293   bool jvmci_enabled = false;
 294 #endif
 295 
 296   // Reallocate the non-escaping objects and restore their fields. Then
 297   // relock objects if synchronization on them was eliminated.
 298   if (jvmci_enabled || ((DoEscapeAnalysis || EliminateNestedLocks) && EliminateAllocations)) {
 299     realloc_failures = eliminate_allocations(thread, exec_mode, cm, deoptee, map, chunk);
 300   }
 301 #endif // COMPILER2_OR_JVMCI
 302 
 303   // Revoke biases, done with in java state.
 304   // No safepoints allowed after this
 305   revoke_from_deopt_handler(thread, deoptee, &map);
 306 
 307   // Ensure that no safepoint is taken after pointers have been stored
 308   // in fields of rematerialized objects.  If a safepoint occurs from here on
 309   // out the java state residing in the vframeArray will be missed.
 310   // Locks may be rebaised in a safepoint.
 311   NoSafepointVerifier no_safepoint;
 312 
 313 #if COMPILER2_OR_JVMCI
 314   if (jvmci_enabled || ((DoEscapeAnalysis || EliminateNestedLocks) && EliminateLocks)) {
 315     eliminate_locks(thread, chunk, realloc_failures);
 316   }
 317 #endif // COMPILER2_OR_JVMCI
 318 
 319   ScopeDesc* trap_scope = chunk->at(0)->scope();
 320   Handle exceptionObject;
 321   if (trap_scope->rethrow_exception()) {
 322     if (PrintDeoptimizationDetails) {
 323       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());
 324     }
 325     GrowableArray<ScopeValue*>* expressions = trap_scope->expressions();
 326     guarantee(expressions != NULL && expressions->length() > 0, "must have exception to throw");
 327     ScopeValue* topOfStack = expressions->top();
 328     exceptionObject = StackValue::create_stack_value(&deoptee, &map, topOfStack)->get_obj();
 329     guarantee(exceptionObject() != NULL, "exception oop can not be null");
 330   }
 331 
 332   vframeArray* array = create_vframeArray(thread, deoptee, &map, chunk, realloc_failures);
 333 #if COMPILER2_OR_JVMCI


1458   vframe* vf = vframe::new_vframe(&fr, map, thread);
1459   compiledVFrame* cvf = compiledVFrame::cast(vf);
1460   // Revoke monitors' biases in all scopes
1461   while (!cvf->is_top()) {
1462     collect_monitors(cvf, objects_to_revoke);
1463     cvf = compiledVFrame::cast(cvf->sender());
1464   }
1465   collect_monitors(cvf, objects_to_revoke);
1466 }
1467 
1468 void Deoptimization::revoke_from_deopt_handler(JavaThread* thread, frame fr, RegisterMap* map) {
1469   if (!UseBiasedLocking) {
1470     return;
1471   }
1472   GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>();
1473   get_monitors_from_stack(objects_to_revoke, thread, fr, map);
1474 
1475   int len = objects_to_revoke->length();
1476   for (int i = 0; i < len; i++) {
1477     oop obj = (objects_to_revoke->at(i))();
1478     BiasedLocking::revoke_own_lock(objects_to_revoke->at(i), thread);
1479     assert(!obj->mark().has_bias_pattern(), "biases should be revoked by now");
1480   }
1481 }
1482 
1483 
1484 void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr, Deoptimization::DeoptReason reason) {
1485   assert(fr.can_be_deoptimized(), "checking frame type");
1486 
1487   gather_statistics(reason, Action_none, Bytecodes::_illegal);
1488 
1489   if (LogCompilation && xtty != NULL) {
1490     CompiledMethod* cm = fr.cb()->as_compiled_method_or_null();
1491     assert(cm != NULL, "only compiled methods can deopt");
1492 
1493     ttyLocker ttyl;
1494     xtty->begin_head("deoptimized thread='" UINTX_FORMAT "' reason='%s' pc='" INTPTR_FORMAT "'",(uintx)thread->osthread()->thread_id(), trap_reason_name(reason), p2i(fr.pc()));
1495     cm->log_identity(xtty);
1496     xtty->end_head();
1497     for (ScopeDesc* sd = cm->scope_desc_at(fr.pc()); ; sd = sd->sender()) {
1498       xtty->begin_elem("jvms bci='%d'", sd->bci());


< prev index next >