| Index: src/heap.cc
|
| diff --git a/src/heap.cc b/src/heap.cc
|
| index 1b625897d11dd732c4556fd8e3c6c7116702518c..7cae8a1826a0dd086d70eaa4f7f9c68502126c31 100644
|
| --- a/src/heap.cc
|
| +++ b/src/heap.cc
|
| @@ -2423,13 +2423,10 @@ Object* Heap::CopyCode(Code* code) {
|
| }
|
|
|
|
|
| -Object* Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
|
| - // Allocate ByteArray before the Code object, so that we do not risk
|
| - // leaving uninitialized Code object (and breaking the heap).
|
| - Object* reloc_info_array = AllocateByteArray(reloc_info.length(), TENURED);
|
| - if (reloc_info_array->IsFailure()) return reloc_info_array;
|
| -
|
| - int new_body_size = RoundUp(code->instruction_size(), kObjectAlignment);
|
| +Object* Heap::AddPatchToCode(Code* code, Code* patch) {
|
| + int space_size = patch->instruction_size();
|
| + int new_body_size = RoundUp(code->instruction_size() + space_size,
|
| + kObjectAlignment);
|
|
|
| int sinfo_size = code->sinfo_size();
|
|
|
| @@ -2437,9 +2434,6 @@ Object* Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
|
|
|
| Address old_addr = code->address();
|
|
|
| - size_t relocation_offset =
|
| - static_cast<size_t>(code->instruction_end() - old_addr);
|
| -
|
| Object* result;
|
| if (new_obj_size > MaxObjectSizeInPagedSpace()) {
|
| result = lo_space_->AllocateRawCode(new_obj_size);
|
| @@ -2452,14 +2446,18 @@ Object* Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
|
| // Copy code object.
|
| Address new_addr = reinterpret_cast<HeapObject*>(result)->address();
|
|
|
| + int first_part_size =
|
| + code->instruction_start() + code->instruction_size() - old_addr;
|
| +
|
| // Copy header and instructions.
|
| - memcpy(new_addr, old_addr, relocation_offset);
|
| + memcpy(new_addr, old_addr, first_part_size);
|
|
|
| Code* new_code = Code::cast(result);
|
| - new_code->set_relocation_info(ByteArray::cast(reloc_info_array));
|
| + new_code->set_instruction_size(code->instruction_size() + space_size);
|
| +
|
| + // Copy patch instructions ignoring its rinfo/sinfo.
|
| + memcpy(new_addr + first_part_size, patch->instruction_start(), space_size);
|
|
|
| - // Copy patched rinfo.
|
| - memcpy(new_code->relocation_start(), reloc_info.start(), reloc_info.length());
|
| // Copy sinfo.
|
| memcpy(new_code->sinfo_start(), code->sinfo_start(), code->sinfo_size());
|
|
|
| @@ -2468,7 +2466,7 @@ Object* Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
|
| new_code->Relocate(new_addr - old_addr);
|
|
|
| #ifdef DEBUG
|
| - code->Verify();
|
| + new_code->Verify();
|
| #endif
|
| return new_code;
|
| }
|
|
|