595 // The instruction at "bci", whose size is "ilen", is changing size by
596 // "delta". Reallocate, move code, recalculate jumps, and enqueue
597 // change items as necessary.
598 bool Relocator::relocate_code(int bci, int ilen, int delta) {
599 int next_bci = bci + ilen;
600 if (delta > 0 && code_length() + delta > code_array_length()) {
601 // Expand allocated code space, if necessary.
602 if (!expand_code_array(delta)) {
603 return false;
604 }
605 }
606
607 // We require 4-byte alignment of code arrays.
608 assert(((intptr_t)code_array() & 3) == 0, "check code alignment");
609 // Change jumps before doing the copying; this routine requires aligned switches.
610 change_jumps(bci, delta);
611
612 // In case we have shrunken a tableswitch/lookupswitch statement, we store the last
613 // bytes that get overwritten. We have to copy the bytes after the change_jumps method
614 // has been called, since it is likely to update last offset in a tableswitch/lookupswitch
615 if (delta < 0) {
616 assert(delta>=-3, "we cannot overwrite more than 3 bytes");
617 memcpy(_overwrite, addr_at(bci + ilen + delta), -delta);
618 }
619
620 memmove(addr_at(next_bci + delta), addr_at(next_bci), code_length() - next_bci);
621 set_code_length(code_length() + delta);
622 // Also adjust exception tables...
623 adjust_exception_table(bci, delta);
624 // Line number tables...
625 adjust_line_no_table(bci, delta);
626 // And local variable table...
627 adjust_local_var_table(bci, delta);
628
629 // Adjust stack maps
630 adjust_stack_map_table(bci, delta);
631
632 // Relocate the pending change stack...
633 for (int j = 0; j < _changes->length(); j++) {
634 ChangeItem* ci = _changes->at(j);
635 ci->relocate(bci, delta);
636 }
|
595 // The instruction at "bci", whose size is "ilen", is changing size by
596 // "delta". Reallocate, move code, recalculate jumps, and enqueue
597 // change items as necessary.
598 bool Relocator::relocate_code(int bci, int ilen, int delta) {
599 int next_bci = bci + ilen;
600 if (delta > 0 && code_length() + delta > code_array_length()) {
601 // Expand allocated code space, if necessary.
602 if (!expand_code_array(delta)) {
603 return false;
604 }
605 }
606
607 // We require 4-byte alignment of code arrays.
608 assert(((intptr_t)code_array() & 3) == 0, "check code alignment");
609 // Change jumps before doing the copying; this routine requires aligned switches.
610 change_jumps(bci, delta);
611
612 // In case we have shrunken a tableswitch/lookupswitch statement, we store the last
613 // bytes that get overwritten. We have to copy the bytes after the change_jumps method
614 // has been called, since it is likely to update last offset in a tableswitch/lookupswitch
615 assert(delta >= -3, "We cannot overwrite more than 3 bytes.");
616 if (delta < 0 && delta >= -3) {
617 memcpy(_overwrite, addr_at(bci + ilen + delta), -delta);
618 }
619
620 memmove(addr_at(next_bci + delta), addr_at(next_bci), code_length() - next_bci);
621 set_code_length(code_length() + delta);
622 // Also adjust exception tables...
623 adjust_exception_table(bci, delta);
624 // Line number tables...
625 adjust_line_no_table(bci, delta);
626 // And local variable table...
627 adjust_local_var_table(bci, delta);
628
629 // Adjust stack maps
630 adjust_stack_map_table(bci, delta);
631
632 // Relocate the pending change stack...
633 for (int j = 0; j < _changes->length(); j++) {
634 ChangeItem* ci = _changes->at(j);
635 ci->relocate(bci, delta);
636 }
|