Index: src/spaces.cc |
diff --git a/src/spaces.cc b/src/spaces.cc |
index df1c3ef126031728d13241c97f4a475df36f87ca..099ad93a1e02e4196f60de68b5e962559400d146 100644 |
--- a/src/spaces.cc |
+++ b/src/spaces.cc |
@@ -2304,14 +2304,6 @@ HeapObject* FreeList::Allocate(int size_in_bytes) { |
// Don't free list allocate if there is linear space available. |
ASSERT(owner_->limit() - owner_->top() < size_in_bytes); |
- int new_node_size = 0; |
- FreeListNode* new_node = FindNodeFor(size_in_bytes, &new_node_size); |
- if (new_node == NULL) return NULL; |
- |
- |
- int bytes_left = new_node_size - size_in_bytes; |
- ASSERT(bytes_left >= 0); |
- |
int old_linear_size = static_cast<int>(owner_->limit() - owner_->top()); |
// Mark the old linear allocation area with a free space map so it can be |
// skipped when scanning the heap. This also puts it back in the free list |
@@ -2321,6 +2313,16 @@ HeapObject* FreeList::Allocate(int size_in_bytes) { |
owner_->heap()->incremental_marking()->OldSpaceStep( |
size_in_bytes - old_linear_size); |
+ int new_node_size = 0; |
+ FreeListNode* new_node = FindNodeFor(size_in_bytes, &new_node_size); |
+ if (new_node == NULL) { |
+ owner_->SetTop(NULL, NULL); |
+ return NULL; |
+ } |
+ |
+ int bytes_left = new_node_size - size_in_bytes; |
+ ASSERT(bytes_left >= 0); |
+ |
#ifdef DEBUG |
for (int i = 0; i < size_in_bytes / kPointerSize; i++) { |
reinterpret_cast<Object**>(new_node->address())[i] = |