Reviewers: Vitaly,

Description:
Fix crash introduced in r5019.

Note to self: never leave uninitialized objects in the code space.


Please review this at http://codereview.chromium.org/2800044/show

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/heap.cc


Index: src/heap.cc
===================================================================
--- src/heap.cc (revision 5027)
+++ src/heap.cc (working copy)
@@ -2351,6 +2351,9 @@
                          ZoneScopeInfo* sinfo,
                          Code::Flags flags,
                          Handle<Object> self_reference) {
+  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 +2369,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 +2422,9 @@


 Object* Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
+ 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 +2445,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();



--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to