Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Unified Diff: src/heap.cc

Issue 2943002: Reimplement stack manipulations for LiveEdit (Closed)
Patch Set: follow codereview Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap.h ('k') | src/ia32/debug-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « src/heap.h ('k') | src/ia32/debug-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698