hotspot/src/share/vm/runtime/vframeArray.cpp
changeset 28039 bf5a8340bf8a
parent 25717 7493b8ac31b7
child 33160 c59f1676d27e
child 33148 68fa8b6c4340
equal deleted inserted replaced
28038:76e7ca4c8b6e 28039:bf5a8340bf8a
    55      jt->remove_monitor_chunk(chunk);
    55      jt->remove_monitor_chunk(chunk);
    56      delete chunk;
    56      delete chunk;
    57   }
    57   }
    58 }
    58 }
    59 
    59 
    60 void vframeArrayElement::fill_in(compiledVFrame* vf) {
    60 void vframeArrayElement::fill_in(compiledVFrame* vf, bool realloc_failures) {
    61 
    61 
    62 // Copy the information from the compiled vframe to the
    62 // Copy the information from the compiled vframe to the
    63 // interpreter frame we will be creating to replace vf
    63 // interpreter frame we will be creating to replace vf
    64 
    64 
    65   _method = vf->method();
    65   _method = vf->method();
    66   _bci    = vf->raw_bci();
    66   _bci    = vf->raw_bci();
    67   _reexecute = vf->should_reexecute();
    67   _reexecute = vf->should_reexecute();
       
    68 #ifdef ASSERT
       
    69   _removed_monitors = false;
       
    70 #endif
    68 
    71 
    69   int index;
    72   int index;
    70 
    73 
    71   // Get the monitors off-stack
    74   // Get the monitors off-stack
    72 
    75 
    80     vf->thread()->add_monitor_chunk(_monitors);
    83     vf->thread()->add_monitor_chunk(_monitors);
    81 
    84 
    82     // Migrate the BasicLocks from the stack to the monitor chunk
    85     // Migrate the BasicLocks from the stack to the monitor chunk
    83     for (index = 0; index < list->length(); index++) {
    86     for (index = 0; index < list->length(); index++) {
    84       MonitorInfo* monitor = list->at(index);
    87       MonitorInfo* monitor = list->at(index);
    85       assert(!monitor->owner_is_scalar_replaced(), "object should be reallocated already");
    88       assert(!monitor->owner_is_scalar_replaced() || realloc_failures, "object should be reallocated already");
    86       assert(monitor->owner() == NULL || (!monitor->owner()->is_unlocked() && !monitor->owner()->has_bias_pattern()), "object must be null or locked, and unbiased");
       
    87       BasicObjectLock* dest = _monitors->at(index);
    89       BasicObjectLock* dest = _monitors->at(index);
    88       dest->set_obj(monitor->owner());
    90       if (monitor->owner_is_scalar_replaced()) {
    89       monitor->lock()->move_to(monitor->owner(), dest->lock());
    91         dest->set_obj(NULL);
       
    92       } else {
       
    93         assert(monitor->owner() == NULL || (!monitor->owner()->is_unlocked() && !monitor->owner()->has_bias_pattern()), "object must be null or locked, and unbiased");
       
    94         dest->set_obj(monitor->owner());
       
    95         monitor->lock()->move_to(monitor->owner(), dest->lock());
       
    96       }
    90     }
    97     }
    91   }
    98   }
    92 
    99 
    93   // Convert the vframe locals and expressions to off stack
   100   // Convert the vframe locals and expressions to off stack
    94   // values. Because we will not gc all oops can be converted to
   101   // values. Because we will not gc all oops can be converted to
   109   _locals = new StackValueCollection(locs->size());
   116   _locals = new StackValueCollection(locs->size());
   110   for(index = 0; index < locs->size(); index++) {
   117   for(index = 0; index < locs->size(); index++) {
   111     StackValue* value = locs->at(index);
   118     StackValue* value = locs->at(index);
   112     switch(value->type()) {
   119     switch(value->type()) {
   113       case T_OBJECT:
   120       case T_OBJECT:
   114         assert(!value->obj_is_scalar_replaced(), "object should be reallocated already");
   121         assert(!value->obj_is_scalar_replaced() || realloc_failures, "object should be reallocated already");
   115         // preserve object type
   122         // preserve object type
   116         _locals->add( new StackValue(cast_from_oop<intptr_t>((value->get_obj()())), T_OBJECT ));
   123         _locals->add( new StackValue(cast_from_oop<intptr_t>((value->get_obj()())), T_OBJECT ));
   117         break;
   124         break;
   118       case T_CONFLICT:
   125       case T_CONFLICT:
   119         // A dead local.  Will be initialized to null/zero.
   126         // A dead local.  Will be initialized to null/zero.
   134   _expressions = new StackValueCollection(exprs->size());
   141   _expressions = new StackValueCollection(exprs->size());
   135   for(index = 0; index < exprs->size(); index++) {
   142   for(index = 0; index < exprs->size(); index++) {
   136     StackValue* value = exprs->at(index);
   143     StackValue* value = exprs->at(index);
   137     switch(value->type()) {
   144     switch(value->type()) {
   138       case T_OBJECT:
   145       case T_OBJECT:
   139         assert(!value->obj_is_scalar_replaced(), "object should be reallocated already");
   146         assert(!value->obj_is_scalar_replaced() || realloc_failures, "object should be reallocated already");
   140         // preserve object type
   147         // preserve object type
   141         _expressions->add( new StackValue(cast_from_oop<intptr_t>((value->get_obj()())), T_OBJECT ));
   148         _expressions->add( new StackValue(cast_from_oop<intptr_t>((value->get_obj()())), T_OBJECT ));
   142         break;
   149         break;
   143       case T_CONFLICT:
   150       case T_CONFLICT:
   144         // A dead stack element.  Will be initialized to null/zero.
   151         // A dead stack element.  Will be initialized to null/zero.
   285   // we placed in the skeletal frame now that we finally know the
   292   // we placed in the skeletal frame now that we finally know the
   286   // exact interpreter address we should use.
   293   // exact interpreter address we should use.
   287 
   294 
   288   _frame.patch_pc(thread, pc);
   295   _frame.patch_pc(thread, pc);
   289 
   296 
   290   assert (!method()->is_synchronized() || locks > 0, "synchronized methods must have monitors");
   297   assert (!method()->is_synchronized() || locks > 0 || _removed_monitors, "synchronized methods must have monitors");
   291 
   298 
   292   BasicObjectLock* top = iframe()->interpreter_frame_monitor_begin();
   299   BasicObjectLock* top = iframe()->interpreter_frame_monitor_begin();
   293   for (int index = 0; index < locks; index++) {
   300   for (int index = 0; index < locks; index++) {
   294     top = iframe()->previous_monitor_in_interpreter_frame(top);
   301     top = iframe()->previous_monitor_in_interpreter_frame(top);
   295     BasicObjectLock* src = _monitors->at(index);
   302     BasicObjectLock* src = _monitors->at(index);
   437 }
   444 }
   438 
   445 
   439 
   446 
   440 
   447 
   441 vframeArray* vframeArray::allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk,
   448 vframeArray* vframeArray::allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk,
   442                                    RegisterMap *reg_map, frame sender, frame caller, frame self) {
   449                                    RegisterMap *reg_map, frame sender, frame caller, frame self,
       
   450                                    bool realloc_failures) {
   443 
   451 
   444   // Allocate the vframeArray
   452   // Allocate the vframeArray
   445   vframeArray * result = (vframeArray*) AllocateHeap(sizeof(vframeArray) + // fixed part
   453   vframeArray * result = (vframeArray*) AllocateHeap(sizeof(vframeArray) + // fixed part
   446                                                      sizeof(vframeArrayElement) * (chunk->length() - 1), // variable part
   454                                                      sizeof(vframeArrayElement) * (chunk->length() - 1), // variable part
   447                                                      mtCompiler);
   455                                                      mtCompiler);
   449   result->_owner_thread = thread;
   457   result->_owner_thread = thread;
   450   result->_sender = sender;
   458   result->_sender = sender;
   451   result->_caller = caller;
   459   result->_caller = caller;
   452   result->_original = self;
   460   result->_original = self;
   453   result->set_unroll_block(NULL); // initialize it
   461   result->set_unroll_block(NULL); // initialize it
   454   result->fill_in(thread, frame_size, chunk, reg_map);
   462   result->fill_in(thread, frame_size, chunk, reg_map, realloc_failures);
   455   return result;
   463   return result;
   456 }
   464 }
   457 
   465 
   458 void vframeArray::fill_in(JavaThread* thread,
   466 void vframeArray::fill_in(JavaThread* thread,
   459                           int frame_size,
   467                           int frame_size,
   460                           GrowableArray<compiledVFrame*>* chunk,
   468                           GrowableArray<compiledVFrame*>* chunk,
   461                           const RegisterMap *reg_map) {
   469                           const RegisterMap *reg_map,
       
   470                           bool realloc_failures) {
   462   // Set owner first, it is used when adding monitor chunks
   471   // Set owner first, it is used when adding monitor chunks
   463 
   472 
   464   _frame_size = frame_size;
   473   _frame_size = frame_size;
   465   for(int i = 0; i < chunk->length(); i++) {
   474   for(int i = 0; i < chunk->length(); i++) {
   466     element(i)->fill_in(chunk->at(i));
   475     element(i)->fill_in(chunk->at(i), realloc_failures);
   467   }
   476   }
   468 
   477 
   469   // Copy registers for callee-saved registers
   478   // Copy registers for callee-saved registers
   470   if (reg_map != NULL) {
   479   if (reg_map != NULL) {
   471     for(int i = 0; i < RegisterMap::reg_count; i++) {
   480     for(int i = 0; i < RegisterMap::reg_count; i++) {