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

Unified Diff: src/heap.cc

Issue 2800044: Fix crash introduced in r5019.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.cc
===================================================================
--- src/heap.cc (revision 5027)
+++ src/heap.cc (working copy)
@@ -2351,6 +2351,11 @@
ZoneScopeInfo* sinfo,
Code::Flags flags,
Handle<Object> self_reference) {
+ // Allocate ByteArray before the Code object, so that we do not risk
+ // leaving uninitialized Code object (and breaking the heap).
+ Object* reloc_info = AllocateByteArray(desc.reloc_size, TENURED);
+ if (reloc_info->IsFailure()) return reloc_info;
+
// Compute size
int body_size = RoundUp(desc.instr_size, kObjectAlignment);
int sinfo_size = 0;
@@ -2366,9 +2371,6 @@
if (result->IsFailure()) return result;
- Object* reloc_info = AllocateByteArray(desc.reloc_size, TENURED);
- if (reloc_info->IsFailure()) return reloc_info;
-
// Initialize the object
HeapObject::cast(result)->set_map(code_map());
Code* code = Code::cast(result);
@@ -2422,6 +2424,11 @@
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);
int sinfo_size = code->sinfo_size();
@@ -2442,9 +2449,6 @@
if (result->IsFailure()) return result;
- Object* reloc_info_array = AllocateByteArray(reloc_info.length(), TENURED);
- if (reloc_info_array->IsFailure()) return reloc_info_array;
-
// Copy code object.
Address new_addr = reinterpret_cast<HeapObject*>(result)->address();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698