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

Side by Side 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, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/serialize.cc ('k') | src/spaces.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2010 the V8 project authors. All rights reserved. 1 // Copyright 2006-2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1; 307 static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1;
308 308
309 // The start offset of the object area in a page. Aligned to both maps and 309 // The start offset of the object area in a page. Aligned to both maps and
310 // code alignment to be suitable for both. 310 // code alignment to be suitable for both.
311 static const int kObjectStartOffset = kBodyOffset; 311 static const int kObjectStartOffset = kBodyOffset;
312 312
313 // Object area size in bytes. 313 // Object area size in bytes.
314 static const int kObjectAreaSize = kPageSize - kObjectStartOffset; 314 static const int kObjectAreaSize = kPageSize - kObjectStartOffset;
315 315
316 // Maximum object size that fits in a page. 316 // Maximum object size that fits in a page.
317 static const int kMaxHeapObjectSize = kObjectAreaSize >> 4; 317 static const int kMaxHeapObjectSize =
318 OBJECT_POINTER_ALIGN(kObjectAreaSize >> 4);
319
320 STATIC_ASSERT((kMaxHeapObjectSize & kObjectAlignmentMask) == 0);
318 321
319 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER 322 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER
320 static const int kDirtyFlagOffset = 2 * kPointerSize; 323 static const int kDirtyFlagOffset = 2 * kPointerSize;
321 static const int kRegionSizeLog2 = 8; 324 static const int kRegionSizeLog2 = 8;
322 static const int kRegionSize = 1 << kRegionSizeLog2; 325 static const int kRegionSize = 1 << kRegionSizeLog2;
323 static const intptr_t kRegionAlignmentMask = (kRegionSize - 1); 326 static const intptr_t kRegionAlignmentMask = (kRegionSize - 1);
324 327
325 STATIC_CHECK(kRegionSize == kPageSize / kBitsPerInt); 328 STATIC_CHECK(kRegionSize == kPageSize / kBitsPerInt);
326 #endif 329 #endif
327 330
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 1734
1732 // The bytes available on the free list (ie, not above the linear allocation 1735 // The bytes available on the free list (ie, not above the linear allocation
1733 // pointer). 1736 // pointer).
1734 intptr_t AvailableFree() { return free_list_.available(); } 1737 intptr_t AvailableFree() { return free_list_.available(); }
1735 1738
1736 // The limit of allocation for a page in this space. 1739 // The limit of allocation for a page in this space.
1737 virtual Address PageAllocationLimit(Page* page) { 1740 virtual Address PageAllocationLimit(Page* page) {
1738 return page->ObjectAreaEnd(); 1741 return page->ObjectAreaEnd();
1739 } 1742 }
1740 1743
1744 void AddToFreeList(Address start, int size_in_bytes) {
1745 // TODO(gc) instead of putting large chunks into free list try to
1746 // reuse them for linear allocation.
1747 int wasted_bytes = 0;
1748
1749 while (size_in_bytes >= Page::kMaxHeapObjectSize) {
1750 wasted_bytes += free_list_.Free(start, Page::kMaxHeapObjectSize);
1751 start += Page::kMaxHeapObjectSize;
1752 size_in_bytes -= Page::kMaxHeapObjectSize;
1753 }
1754
1755 if (size_in_bytes > 0) {
1756 wasted_bytes += free_list_.Free(start, size_in_bytes);
1757 }
1758
1759 accounting_stats_.WasteBytes(wasted_bytes);
1760 }
1761
1741 // Give a block of memory to the space's free list. It might be added to 1762 // Give a block of memory to the space's free list. It might be added to
1742 // the free list or accounted as waste. 1763 // the free list or accounted as waste.
1743 // If add_to_freelist is false then just accounting stats are updated and 1764 // If add_to_freelist is false then just accounting stats are updated and
1744 // no attempt to add area to free list is made. 1765 // no attempt to add area to free list is made.
1745 void Free(Address start, int size_in_bytes, bool add_to_freelist) { 1766 void Free(Address start, int size_in_bytes, bool add_to_freelist) {
1746 accounting_stats_.DeallocateBytes(size_in_bytes); 1767 accounting_stats_.DeallocateBytes(size_in_bytes);
1747 1768
1748 if (add_to_freelist) { 1769 if (add_to_freelist) AddToFreeList(start, size_in_bytes);
1749 int wasted_bytes = free_list_.Free(start, size_in_bytes);
1750 accounting_stats_.WasteBytes(wasted_bytes);
1751 }
1752 } 1770 }
1753 1771
1754 virtual void DeallocateBlock(Address start, 1772 virtual void DeallocateBlock(Address start,
1755 int size_in_bytes, 1773 int size_in_bytes,
1756 bool add_to_freelist); 1774 bool add_to_freelist);
1757 1775
1758 // Prepare for full garbage collection. Resets the relocation pointer and 1776 // Prepare for full garbage collection. Resets the relocation pointer and
1759 // clears the free list. 1777 // clears the free list.
1760 virtual void PrepareForMarkCompact(bool will_compact); 1778 virtual void PrepareForMarkCompact(bool will_compact);
1761 1779
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 2111
2094 private: 2112 private:
2095 LargePage* current_; 2113 LargePage* current_;
2096 HeapObjectCallback size_func_; 2114 HeapObjectCallback size_func_;
2097 }; 2115 };
2098 2116
2099 2117
2100 } } // namespace v8::internal 2118 } } // namespace v8::internal
2101 2119
2102 #endif // V8_SPACES_H_ 2120 #endif // V8_SPACES_H_
OLDNEW
« 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