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

Unified Diff: src/heap.cc

Issue 914003: LiveEdit: patch positions in function (Closed)
Patch Set: merge Created 10 years, 9 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/liveedit.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 d6668754220c9354cdc2c7a06fe82c2a39717691..08a5db8ed6e9a92a96972c113c816c079b5c363e 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -2257,6 +2257,55 @@ Object* Heap::CopyCode(Code* code) {
}
+Object* Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
+ int new_body_size = RoundUp(code->instruction_size() + reloc_info.length(),
+ kObjectAlignment);
+
+ int sinfo_size = code->sinfo_size();
+
+ int new_obj_size = Code::SizeFor(new_body_size, sinfo_size);
+
+ Address old_addr = code->address();
+
+ int relocation_offset = code->relocation_start() - old_addr;
+
+ Object* result;
+ if (new_obj_size > MaxObjectSizeInPagedSpace()) {
+ result = lo_space_->AllocateRawCode(new_obj_size);
+ } else {
+ result = code_space_->AllocateRaw(new_obj_size);
+ }
+
+ if (result->IsFailure()) return result;
+
+ // Copy code object.
+ Address new_addr = reinterpret_cast<HeapObject*>(result)->address();
+
+ // Copy header and instructions.
+ memcpy(new_addr, old_addr, relocation_offset);
+
+ // Copy patched rinfo.
+ memcpy(new_addr + relocation_offset,
+ reloc_info.start(),
+ reloc_info.length());
+
+ Code* new_code = Code::cast(result);
+ new_code->set_relocation_size(reloc_info.length());
+
+ // Copy sinfo.
+ memcpy(new_code->sinfo_start(), code->sinfo_start(), code->sinfo_size());
+
+ // Relocate the copy.
+ ASSERT(!CodeRange::exists() || CodeRange::contains(code->address()));
+ new_code->Relocate(new_addr - old_addr);
+
+#ifdef DEBUG
+ code->Verify();
+#endif
+ return new_code;
+}
+
+
Object* Heap::Allocate(Map* map, AllocationSpace space) {
ASSERT(gc_state_ == NOT_IN_GC);
ASSERT(map->instance_type() != MAP_TYPE);
« no previous file with comments | « src/heap.h ('k') | src/liveedit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698