hotspot/src/share/vm/runtime/deoptimization.cpp
changeset 11636 3c07b54482a5
parent 11445 3c768dca60f5
child 13195 be27e1b6a4b9
equal deleted inserted replaced
11635:5a16856f871f 11636:3c07b54482a5
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   337   if (deoptee_nm != NULL && deoptee_nm->is_method_handle_return(deoptee.pc()))
   337   if (deoptee_nm != NULL && deoptee_nm->is_method_handle_return(deoptee.pc()))
   338     unpack_sp = deoptee.unextended_sp();
   338     unpack_sp = deoptee.unextended_sp();
   339 
   339 
   340 #ifdef ASSERT
   340 #ifdef ASSERT
   341   assert(cb->is_deoptimization_stub() || cb->is_uncommon_trap_stub(), "just checking");
   341   assert(cb->is_deoptimization_stub() || cb->is_uncommon_trap_stub(), "just checking");
   342   Events::log("fetch unroll sp " INTPTR_FORMAT, unpack_sp);
       
   343 #endif
   342 #endif
   344 #else
   343 #else
   345   intptr_t* unpack_sp = stub_frame.sender(&dummy_map).unextended_sp();
   344   intptr_t* unpack_sp = stub_frame.sender(&dummy_map).unextended_sp();
   346 #endif // !SHARK
   345 #endif // !SHARK
   347 
   346 
   575 #ifndef PRODUCT
   574 #ifndef PRODUCT
   576   if (TraceDeoptimization) {
   575   if (TraceDeoptimization) {
   577     tty->print_cr("DEOPT UNPACKING thread " INTPTR_FORMAT " vframeArray " INTPTR_FORMAT " mode %d", thread, array, exec_mode);
   576     tty->print_cr("DEOPT UNPACKING thread " INTPTR_FORMAT " vframeArray " INTPTR_FORMAT " mode %d", thread, array, exec_mode);
   578   }
   577   }
   579 #endif
   578 #endif
       
   579   Events::log(thread, "DEOPT UNPACKING pc=" INTPTR_FORMAT " sp=" INTPTR_FORMAT " mode %d",
       
   580               stub_frame.pc(), stub_frame.sp(), exec_mode);
   580 
   581 
   581   UnrollBlock* info = array->unroll_block();
   582   UnrollBlock* info = array->unroll_block();
   582 
   583 
   583   // Unpack the interpreter frames and any adapter frame (c2 only) we might create.
   584   // Unpack the interpreter frames and any adapter frame (c2 only) we might create.
   584   array->unpack_to_stack(stub_frame, exec_mode, info->caller_actual_parameters());
   585   array->unpack_to_stack(stub_frame, exec_mode, info->caller_actual_parameters());
   979 }
   980 }
   980 #endif
   981 #endif
   981 #endif // COMPILER2
   982 #endif // COMPILER2
   982 
   983 
   983 vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk) {
   984 vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk) {
       
   985   Events::log(thread, "DEOPT PACKING pc=" INTPTR_FORMAT " sp=" INTPTR_FORMAT, fr.pc(), fr.sp());
   984 
   986 
   985 #ifndef PRODUCT
   987 #ifndef PRODUCT
   986   if (TraceDeoptimization) {
   988   if (TraceDeoptimization) {
   987     ttyLocker ttyl;
   989     ttyLocker ttyl;
   988     tty->print("DEOPT PACKING thread " INTPTR_FORMAT " ", thread);
   990     tty->print("DEOPT PACKING thread " INTPTR_FORMAT " ", thread);
  1024   // For Compiler1, the caller of the deoptimized frame is saved for use by unpack_frames().
  1026   // For Compiler1, the caller of the deoptimized frame is saved for use by unpack_frames().
  1025   vframeArray* array = vframeArray::allocate(thread, frame_size, chunk, reg_map, sender, caller, fr);
  1027   vframeArray* array = vframeArray::allocate(thread, frame_size, chunk, reg_map, sender, caller, fr);
  1026 
  1028 
  1027   // Compare the vframeArray to the collected vframes
  1029   // Compare the vframeArray to the collected vframes
  1028   assert(array->structural_compare(thread, chunk), "just checking");
  1030   assert(array->structural_compare(thread, chunk), "just checking");
  1029   Events::log("# vframes = %d", (intptr_t)chunk->length());
       
  1030 
  1031 
  1031 #ifndef PRODUCT
  1032 #ifndef PRODUCT
  1032   if (TraceDeoptimization) {
  1033   if (TraceDeoptimization) {
  1033     ttyLocker ttyl;
  1034     ttyLocker ttyl;
  1034     tty->print_cr("     Created vframeArray " INTPTR_FORMAT, array);
  1035     tty->print_cr("     Created vframeArray " INTPTR_FORMAT, array);
  1122 void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr) {
  1123 void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr) {
  1123   assert(fr.can_be_deoptimized(), "checking frame type");
  1124   assert(fr.can_be_deoptimized(), "checking frame type");
  1124 
  1125 
  1125   gather_statistics(Reason_constraint, Action_none, Bytecodes::_illegal);
  1126   gather_statistics(Reason_constraint, Action_none, Bytecodes::_illegal);
  1126 
  1127 
  1127   EventMark m("Deoptimization (pc=" INTPTR_FORMAT ", sp=" INTPTR_FORMAT ")", fr.pc(), fr.id());
       
  1128 
       
  1129   // Patch the nmethod so that when execution returns to it we will
  1128   // Patch the nmethod so that when execution returns to it we will
  1130   // deopt the execution state and return to the interpreter.
  1129   // deopt the execution state and return to the interpreter.
  1131   fr.deoptimize(thread);
  1130   fr.deoptimize(thread);
  1132 }
  1131 }
  1133 
  1132 
  1237   frame fr = stub_frame.sender(&reg_map);
  1236   frame fr = stub_frame.sender(&reg_map);
  1238   // Make sure the calling nmethod is not getting deoptimized and removed
  1237   // Make sure the calling nmethod is not getting deoptimized and removed
  1239   // before we are done with it.
  1238   // before we are done with it.
  1240   nmethodLocker nl(fr.pc());
  1239   nmethodLocker nl(fr.pc());
  1241 
  1240 
       
  1241   // Log a message
       
  1242   Events::log_deopt_message(thread, "Uncommon trap %d fr.pc " INTPTR_FORMAT,
       
  1243                             trap_request, fr.pc());
       
  1244 
  1242   {
  1245   {
  1243     ResourceMark rm;
  1246     ResourceMark rm;
  1244 
  1247 
  1245     // Revoke biases of any monitors in the frame to ensure we can migrate them
  1248     // Revoke biases of any monitors in the frame to ensure we can migrate them
  1246     revoke_biases_of_monitors(thread, fr, &reg_map);
  1249     revoke_biases_of_monitors(thread, fr, &reg_map);
  1247 
  1250 
  1248     DeoptReason reason = trap_request_reason(trap_request);
  1251     DeoptReason reason = trap_request_reason(trap_request);
  1249     DeoptAction action = trap_request_action(trap_request);
  1252     DeoptAction action = trap_request_action(trap_request);
  1250     jint unloaded_class_index = trap_request_index(trap_request); // CP idx or -1
  1253     jint unloaded_class_index = trap_request_index(trap_request); // CP idx or -1
  1251 
  1254 
  1252     Events::log("Uncommon trap occurred @" INTPTR_FORMAT " unloaded_class_index = %d", fr.pc(), (int) trap_request);
       
  1253     vframe*  vf  = vframe::new_vframe(&fr, &reg_map, thread);
  1255     vframe*  vf  = vframe::new_vframe(&fr, &reg_map, thread);
  1254     compiledVFrame* cvf = compiledVFrame::cast(vf);
  1256     compiledVFrame* cvf = compiledVFrame::cast(vf);
  1255 
  1257 
  1256     nmethod* nm = cvf->code();
  1258     nmethod* nm = cvf->code();
  1257 
  1259