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

Unified Diff: src/spaces.h

Issue 5999010: Fix numerous bugs introduced by reducing Page::kMaxHeapObjectSize. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 9 years, 12 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/serialize.cc ('k') | src/spaces.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/spaces.h
diff --git a/src/spaces.h b/src/spaces.h
index 4d4ef4be7ee4c656e5d915cd25db2bd7e5806456..ec64e6e98d13797d0c8274e9df1e4bba5a5db651 100644
--- a/src/spaces.h
+++ b/src/spaces.h
@@ -314,7 +314,10 @@ class Page : public MemoryChunk {
static const int kObjectAreaSize = kPageSize - kObjectStartOffset;
// Maximum object size that fits in a page.
- static const int kMaxHeapObjectSize = kObjectAreaSize >> 4;
+ static const int kMaxHeapObjectSize =
+ OBJECT_POINTER_ALIGN(kObjectAreaSize >> 4);
+
+ STATIC_ASSERT((kMaxHeapObjectSize & kObjectAlignmentMask) == 0);
#ifdef ENABLE_CARDMARKING_WRITE_BARRIER
static const int kDirtyFlagOffset = 2 * kPointerSize;
@@ -1738,6 +1741,24 @@ class OldSpace : public PagedSpace {
return page->ObjectAreaEnd();
}
+ void AddToFreeList(Address start, int size_in_bytes) {
+ // TODO(gc) instead of putting large chunks into free list try to
+ // reuse them for linear allocation.
+ int wasted_bytes = 0;
+
+ while (size_in_bytes >= Page::kMaxHeapObjectSize) {
+ wasted_bytes += free_list_.Free(start, Page::kMaxHeapObjectSize);
+ start += Page::kMaxHeapObjectSize;
+ size_in_bytes -= Page::kMaxHeapObjectSize;
+ }
+
+ if (size_in_bytes > 0) {
+ wasted_bytes += free_list_.Free(start, size_in_bytes);
+ }
+
+ accounting_stats_.WasteBytes(wasted_bytes);
+ }
+
// Give a block of memory to the space's free list. It might be added to
// the free list or accounted as waste.
// If add_to_freelist is false then just accounting stats are updated and
@@ -1745,10 +1766,7 @@ class OldSpace : public PagedSpace {
void Free(Address start, int size_in_bytes, bool add_to_freelist) {
accounting_stats_.DeallocateBytes(size_in_bytes);
- if (add_to_freelist) {
- int wasted_bytes = free_list_.Free(start, size_in_bytes);
- accounting_stats_.WasteBytes(wasted_bytes);
- }
+ if (add_to_freelist) AddToFreeList(start, size_in_bytes);
}
virtual void DeallocateBlock(Address start,
« no previous file with comments | « src/serialize.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698