This commit is contained in:
Roland Westrelin 2012-12-07 01:09:03 -08:00
commit d8921b191a
184 changed files with 16121 additions and 16576 deletions

View file

@ -254,6 +254,10 @@ address CodeBuffer::locator_address(int locator) const {
return start + locator_pos(locator);
}
bool CodeBuffer::is_backward_branch(Label& L) {
return L.is_bound() && insts_end() <= locator_address(L.loc());
}
address CodeBuffer::decode_begin() {
address begin = _insts.start();
if (_decode_begin != NULL && _decode_begin > begin)
@ -758,7 +762,18 @@ void CodeBuffer::relocate_code_to(CodeBuffer* dest) const {
// Make the new code copy use the old copy's relocations:
dest_cs->initialize_locs_from(cs);
}
// Do relocation after all sections are copied.
// This is necessary if the code uses constants in stubs, which are
// relocated when the corresponding instruction in the code (e.g., a
// call) is relocated. Stubs are placed behind the main code
// section, so that section has to be copied before relocating.
for (int n = (int) SECT_FIRST; n < (int)SECT_LIMIT; n++) {
// pull code out of each section
const CodeSection* cs = code_section(n);
if (cs->is_empty()) continue; // skip trivial section
CodeSection* dest_cs = dest->code_section(n);
{ // Repair the pc relative information in the code after the move
RelocIterator iter(dest_cs);
while (iter.next()) {