622 return -1; |
622 return -1; |
623 } |
623 } |
624 |
624 |
625 csize_t CodeBuffer::total_relocation_size() const { |
625 csize_t CodeBuffer::total_relocation_size() const { |
626 csize_t total = copy_relocations_to(NULL); // dry run only |
626 csize_t total = copy_relocations_to(NULL); // dry run only |
627 return (csize_t) align_size_up(total, HeapWordSize); |
627 return (csize_t) align_up(total, HeapWordSize); |
628 } |
628 } |
629 |
629 |
630 csize_t CodeBuffer::copy_relocations_to(address buf, csize_t buf_limit, bool only_inst) const { |
630 csize_t CodeBuffer::copy_relocations_to(address buf, csize_t buf_limit, bool only_inst) const { |
631 csize_t buf_offset = 0; |
631 csize_t buf_offset = 0; |
632 csize_t code_end_so_far = 0; |
632 csize_t code_end_so_far = 0; |
767 const CodeSection* cs = code_section(n); |
767 const CodeSection* cs = code_section(n); |
768 if (cs->is_empty()) continue; // skip trivial section |
768 if (cs->is_empty()) continue; // skip trivial section |
769 CodeSection* dest_cs = dest->code_section(n); |
769 CodeSection* dest_cs = dest->code_section(n); |
770 assert(cs->size() == dest_cs->size(), "sanity"); |
770 assert(cs->size() == dest_cs->size(), "sanity"); |
771 csize_t usize = dest_cs->size(); |
771 csize_t usize = dest_cs->size(); |
772 csize_t wsize = align_size_up(usize, HeapWordSize); |
772 csize_t wsize = align_up(usize, HeapWordSize); |
773 assert(dest_cs->start() + wsize <= dest_end, "no overflow"); |
773 assert(dest_cs->start() + wsize <= dest_end, "no overflow"); |
774 // Copy the code as aligned machine words. |
774 // Copy the code as aligned machine words. |
775 // This may also include an uninitialized partial word at the end. |
775 // This may also include an uninitialized partial word at the end. |
776 Copy::disjoint_words((HeapWord*)cs->start(), |
776 Copy::disjoint_words((HeapWord*)cs->start(), |
777 (HeapWord*)dest_cs->start(), |
777 (HeapWord*)dest_cs->start(), |