463 // The width of instruction at "bci" is changing by "delta". Adjust the stack |
463 // The width of instruction at "bci" is changing by "delta". Adjust the stack |
464 // map frames. |
464 // map frames. |
465 void Relocator::adjust_stack_map_table(int bci, int delta) { |
465 void Relocator::adjust_stack_map_table(int bci, int delta) { |
466 if (method()->has_stackmap_table()) { |
466 if (method()->has_stackmap_table()) { |
467 typeArrayOop data = method()->stackmap_data(); |
467 typeArrayOop data = method()->stackmap_data(); |
468 // The data in the array is a classfile representation of the stackmap |
468 // The data in the array is a classfile representation of the stackmap table |
469 // table attribute, less the initial u2 tag and u4 attribute_length fields. |
469 stack_map_table* sm_table = |
470 stack_map_table_attribute* attr = stack_map_table_attribute::at( |
470 stack_map_table::at((address)data->byte_at_addr(0)); |
471 (address)data->byte_at_addr(0) - (sizeof(u2) + sizeof(u4))); |
471 |
472 |
472 int count = sm_table->number_of_entries(); |
473 int count = attr->number_of_entries(); |
473 stack_map_frame* frame = sm_table->entries(); |
474 stack_map_frame* frame = attr->entries(); |
|
475 int bci_iter = -1; |
474 int bci_iter = -1; |
476 bool offset_adjusted = false; // only need to adjust one offset |
475 bool offset_adjusted = false; // only need to adjust one offset |
477 |
476 |
478 for (int i = 0; i < count; ++i) { |
477 for (int i = 0; i < count; ++i) { |
479 int offset_delta = frame->offset_delta(); |
478 int offset_delta = frame->offset_delta(); |
484 |
483 |
485 if (frame->is_valid_offset(new_offset_delta)) { |
484 if (frame->is_valid_offset(new_offset_delta)) { |
486 frame->set_offset_delta(new_offset_delta); |
485 frame->set_offset_delta(new_offset_delta); |
487 } else { |
486 } else { |
488 assert(frame->is_same_frame() || |
487 assert(frame->is_same_frame() || |
489 frame->is_same_frame_1_stack_item_frame(), |
488 frame->is_same_locals_1_stack_item_frame(), |
490 "Frame must be one of the compressed forms"); |
489 "Frame must be one of the compressed forms"); |
491 // The new delta exceeds the capacity of the 'same_frame' or |
490 // The new delta exceeds the capacity of the 'same_frame' or |
492 // 'same_frame_1_stack_item_frame' frame types. We need to |
491 // 'same_frame_1_stack_item_frame' frame types. We need to |
493 // convert these frames to the extended versions, but the extended |
492 // convert these frames to the extended versions, but the extended |
494 // version is bigger and requires more room. So we allocate a |
493 // version is bigger and requires more room. So we allocate a |
511 |
510 |
512 // Now convert the frames in place |
511 // Now convert the frames in place |
513 if (frame->is_same_frame()) { |
512 if (frame->is_same_frame()) { |
514 same_frame_extended::create_at(frame_addr, new_offset_delta); |
513 same_frame_extended::create_at(frame_addr, new_offset_delta); |
515 } else { |
514 } else { |
516 same_frame_1_stack_item_extended::create_at( |
515 same_locals_1_stack_item_extended::create_at( |
517 frame_addr, new_offset_delta, NULL); |
516 frame_addr, new_offset_delta, NULL); |
518 // the verification_info_type should already be at the right spot |
517 // the verification_info_type should already be at the right spot |
519 } |
518 } |
520 } |
519 } |
521 offset_adjusted = true; // needs to be done only once, since subsequent |
520 offset_adjusted = true; // needs to be done only once, since subsequent |