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

Unified Diff: src/heap/spaces.cc

Issue 1364303002: [heap] Fix PagedSpace::SizeOfObjects calling from within FreeList::Allocate (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: CHECK -> DCHECK Created 5 years, 3 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/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index 9bba6dd89b9cfe6e3e3ba0933d6d89b87dfc78ca..bc0a3d5c144c20301f1cd24d16821ac48f81fb90 100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -2386,16 +2386,14 @@ HeapObject* FreeList::Allocate(int size_in_bytes) {
// skipped when scanning the heap. This also puts it back in the free list
// if it is big enough.
owner_->Free(owner_->top(), old_linear_size);
+ owner_->SetTopAndLimit(nullptr, nullptr);
owner_->heap()->incremental_marking()->OldSpaceStep(size_in_bytes -
old_linear_size);
int new_node_size = 0;
FreeSpace* new_node = FindNodeFor(size_in_bytes, &new_node_size);
- if (new_node == NULL) {
- owner_->SetTopAndLimit(NULL, NULL);
- return NULL;
- }
+ if (new_node == nullptr) return nullptr;
int bytes_left = new_node_size - size_in_bytes;
DCHECK(bytes_left >= 0);
@@ -2439,10 +2437,6 @@ HeapObject* FreeList::Allocate(int size_in_bytes) {
// linear allocation area.
owner_->SetTopAndLimit(new_node->address() + size_in_bytes,
new_node->address() + new_node_size);
- } else {
- // TODO(gc) Try not freeing linear allocation region when bytes_left
- // are zero.
- owner_->SetTopAndLimit(NULL, NULL);
}
return new_node;
@@ -2553,7 +2547,10 @@ intptr_t PagedSpace::SizeOfObjects() {
DCHECK(!FLAG_concurrent_sweeping ||
heap()->mark_compact_collector()->sweeping_in_progress() ||
(unswept_free_bytes_ == 0));
- return Size() - unswept_free_bytes_ - (limit() - top());
+ const intptr_t size = Size() - unswept_free_bytes_ - (limit() - top());
+ DCHECK_GE(size, 0);
+ USE(size);
+ return size;
}
« 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