src/share/vm/runtime/relocator.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/runtime

src/share/vm/runtime/relocator.cpp

Print this page
rev 3510 : 7116786: RFE: Detailed information on VerifyErrors
Summary: Provide additional detail in VerifyError messages
Reviewed-by:


 448   Thread* THREAD = Thread::current();
 449   Handle src_hnd(THREAD, src);
 450   typeArrayOop dst =
 451       oopFactory::new_permanent_byteArray(src->length() + hole_sz, CHECK_NULL);
 452   src = (typeArrayOop)src_hnd();
 453 
 454   address src_addr = (address)src->byte_at_addr(0);
 455   address dst_addr = (address)dst->byte_at_addr(0);
 456 
 457   memcpy(dst_addr, src_addr, where);
 458   memcpy(dst_addr + where + hole_sz,
 459          src_addr + where, src->length() - where);
 460   return dst;
 461 }
 462 
 463 // The width of instruction at "bci" is changing by "delta".  Adjust the stack
 464 // map frames.
 465 void Relocator::adjust_stack_map_table(int bci, int delta) {
 466   if (method()->has_stackmap_table()) {
 467     typeArrayOop data = method()->stackmap_data();
 468     // The data in the array is a classfile representation of the stackmap
 469     // table attribute, less the initial u2 tag and u4 attribute_length fields.
 470     stack_map_table_attribute* attr = stack_map_table_attribute::at(
 471         (address)data->byte_at_addr(0) - (sizeof(u2) + sizeof(u4)));
 472 
 473     int count = attr->number_of_entries();
 474     stack_map_frame* frame = attr->entries();
 475     int bci_iter = -1;
 476     bool offset_adjusted = false; // only need to adjust one offset
 477 
 478     for (int i = 0; i < count; ++i) {
 479       int offset_delta = frame->offset_delta();
 480       bci_iter += offset_delta;
 481 
 482       if (!offset_adjusted && bci_iter > bci) {
 483         int new_offset_delta = offset_delta + delta;
 484 
 485         if (frame->is_valid_offset(new_offset_delta)) {
 486           frame->set_offset_delta(new_offset_delta);
 487         } else {
 488           assert(frame->is_same_frame() ||
 489                  frame->is_same_frame_1_stack_item_frame(),
 490                  "Frame must be one of the compressed forms");
 491           // The new delta exceeds the capacity of the 'same_frame' or
 492           // 'same_frame_1_stack_item_frame' frame types.  We need to
 493           // convert these frames to the extended versions, but the extended
 494           // version is bigger and requires more room.  So we allocate a


 496           // right after the 'frame_type' for the new offset field.
 497           //
 498           // We can safely ignore the reverse situation as a small delta
 499           // can still be used in an extended version of the frame.
 500 
 501           size_t frame_offset = (address)frame - (address)data->byte_at_addr(0);
 502 
 503           data = insert_hole_at(frame_offset + 1, 2, data);
 504           if (data == NULL) {
 505             return; // out-of-memory?
 506           }
 507 
 508           address frame_addr = (address)(data->byte_at_addr(0) + frame_offset);
 509           frame = stack_map_frame::at(frame_addr);
 510 
 511 
 512           // Now convert the frames in place
 513           if (frame->is_same_frame()) {
 514             same_frame_extended::create_at(frame_addr, new_offset_delta);
 515           } else {
 516             same_frame_1_stack_item_extended::create_at(
 517               frame_addr, new_offset_delta, NULL);
 518             // the verification_info_type should already be at the right spot
 519           }
 520         }
 521         offset_adjusted = true; // needs to be done only once, since subsequent
 522                                 // values are offsets from the current
 523       }
 524 
 525       // The stack map frame may contain verification types, if so we need to
 526       // check and update any Uninitialized type's bci (no matter where it is).
 527       int number_of_types = frame->number_of_types();
 528       verification_type_info* types = frame->types();
 529 
 530       for (int i = 0; i < number_of_types; ++i) {
 531         if (types->is_uninitialized() && types->bci() > bci) {
 532           types->set_bci(types->bci() + delta);
 533         }
 534         types = types->next();
 535       }
 536 




 448   Thread* THREAD = Thread::current();
 449   Handle src_hnd(THREAD, src);
 450   typeArrayOop dst =
 451       oopFactory::new_permanent_byteArray(src->length() + hole_sz, CHECK_NULL);
 452   src = (typeArrayOop)src_hnd();
 453 
 454   address src_addr = (address)src->byte_at_addr(0);
 455   address dst_addr = (address)dst->byte_at_addr(0);
 456 
 457   memcpy(dst_addr, src_addr, where);
 458   memcpy(dst_addr + where + hole_sz,
 459          src_addr + where, src->length() - where);
 460   return dst;
 461 }
 462 
 463 // The width of instruction at "bci" is changing by "delta".  Adjust the stack
 464 // map frames.
 465 void Relocator::adjust_stack_map_table(int bci, int delta) {
 466   if (method()->has_stackmap_table()) {
 467     typeArrayOop data = method()->stackmap_data();
 468     // The data in the array is a classfile representation of the stackmap table
 469     stack_map_table* sm_table =
 470         stack_map_table::at((address)data->byte_at_addr(0));

 471 
 472     int count = sm_table->number_of_entries();
 473     stack_map_frame* frame = sm_table->entries();
 474     int bci_iter = -1;
 475     bool offset_adjusted = false; // only need to adjust one offset
 476 
 477     for (int i = 0; i < count; ++i) {
 478       int offset_delta = frame->offset_delta();
 479       bci_iter += offset_delta;
 480 
 481       if (!offset_adjusted && bci_iter > bci) {
 482         int new_offset_delta = offset_delta + delta;
 483 
 484         if (frame->is_valid_offset(new_offset_delta)) {
 485           frame->set_offset_delta(new_offset_delta);
 486         } else {
 487           assert(frame->is_same_frame() ||
 488                  frame->is_same_frame_1_stack_item_frame(),
 489                  "Frame must be one of the compressed forms");
 490           // The new delta exceeds the capacity of the 'same_frame' or
 491           // 'same_frame_1_stack_item_frame' frame types.  We need to
 492           // convert these frames to the extended versions, but the extended
 493           // version is bigger and requires more room.  So we allocate a


 495           // right after the 'frame_type' for the new offset field.
 496           //
 497           // We can safely ignore the reverse situation as a small delta
 498           // can still be used in an extended version of the frame.
 499 
 500           size_t frame_offset = (address)frame - (address)data->byte_at_addr(0);
 501 
 502           data = insert_hole_at(frame_offset + 1, 2, data);
 503           if (data == NULL) {
 504             return; // out-of-memory?
 505           }
 506 
 507           address frame_addr = (address)(data->byte_at_addr(0) + frame_offset);
 508           frame = stack_map_frame::at(frame_addr);
 509 
 510 
 511           // Now convert the frames in place
 512           if (frame->is_same_frame()) {
 513             same_frame_extended::create_at(frame_addr, new_offset_delta);
 514           } else {
 515             same_locals_1_stack_item_extended::create_at(
 516               frame_addr, new_offset_delta, NULL);
 517             // the verification_info_type should already be at the right spot
 518           }
 519         }
 520         offset_adjusted = true; // needs to be done only once, since subsequent
 521                                 // values are offsets from the current
 522       }
 523 
 524       // The stack map frame may contain verification types, if so we need to
 525       // check and update any Uninitialized type's bci (no matter where it is).
 526       int number_of_types = frame->number_of_types();
 527       verification_type_info* types = frame->types();
 528 
 529       for (int i = 0; i < number_of_types; ++i) {
 530         if (types->is_uninitialized() && types->bci() > bci) {
 531           types->set_bci(types->bci() + delta);
 532         }
 533         types = types->next();
 534       }
 535 


src/share/vm/runtime/relocator.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File