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

Side by Side Diff: src/spaces.h

Issue 392163003: Fix PagedSpace size accounting. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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/mark-compact.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_SPACES_H_ 5 #ifndef V8_SPACES_H_
6 #define V8_SPACES_H_ 6 #define V8_SPACES_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/base/atomicops.h" 9 #include "src/base/atomicops.h"
10 #include "src/base/platform/mutex.h" 10 #include "src/base/platform/mutex.h"
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 } 1450 }
1451 1451
1452 // Free allocated bytes, making them available (size -> available). 1452 // Free allocated bytes, making them available (size -> available).
1453 void DeallocateBytes(intptr_t size_in_bytes) { 1453 void DeallocateBytes(intptr_t size_in_bytes) {
1454 size_ -= size_in_bytes; 1454 size_ -= size_in_bytes;
1455 ASSERT(size_ >= 0); 1455 ASSERT(size_ >= 0);
1456 } 1456 }
1457 1457
1458 // Waste free bytes (available -> waste). 1458 // Waste free bytes (available -> waste).
1459 void WasteBytes(int size_in_bytes) { 1459 void WasteBytes(int size_in_bytes) {
1460 size_ -= size_in_bytes; 1460 ASSERT(size_in_bytes >= 0);
1461 waste_ += size_in_bytes; 1461 waste_ += size_in_bytes;
1462 ASSERT(size_ >= 0);
1463 } 1462 }
1464 1463
1465 private: 1464 private:
1466 intptr_t capacity_; 1465 intptr_t capacity_;
1467 intptr_t max_capacity_; 1466 intptr_t max_capacity_;
1468 intptr_t size_; 1467 intptr_t size_;
1469 intptr_t waste_; 1468 intptr_t waste_;
1470 }; 1469 };
1471 1470
1472 1471
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 // Allocate the requested number of bytes in the space if possible, return a 1849 // Allocate the requested number of bytes in the space if possible, return a
1851 // failure object if not. 1850 // failure object if not.
1852 MUST_USE_RESULT inline AllocationResult AllocateRaw(int size_in_bytes); 1851 MUST_USE_RESULT inline AllocationResult AllocateRaw(int size_in_bytes);
1853 1852
1854 // Give a block of memory to the space's free list. It might be added to 1853 // Give a block of memory to the space's free list. It might be added to
1855 // the free list or accounted as waste. 1854 // the free list or accounted as waste.
1856 // If add_to_freelist is false then just accounting stats are updated and 1855 // If add_to_freelist is false then just accounting stats are updated and
1857 // no attempt to add area to free list is made. 1856 // no attempt to add area to free list is made.
1858 int Free(Address start, int size_in_bytes) { 1857 int Free(Address start, int size_in_bytes) {
1859 int wasted = free_list_.Free(start, size_in_bytes); 1858 int wasted = free_list_.Free(start, size_in_bytes);
1860 accounting_stats_.DeallocateBytes(size_in_bytes - wasted); 1859 accounting_stats_.DeallocateBytes(size_in_bytes);
1860 accounting_stats_.WasteBytes(wasted);
1861 return size_in_bytes - wasted; 1861 return size_in_bytes - wasted;
1862 } 1862 }
1863 1863
1864 void ResetFreeList() { 1864 void ResetFreeList() {
1865 free_list_.Reset(); 1865 free_list_.Reset();
1866 } 1866 }
1867 1867
1868 // Set space allocation info. 1868 // Set space allocation info.
1869 void SetTopAndLimit(Address top, Address limit) { 1869 void SetTopAndLimit(Address top, Address limit) {
1870 ASSERT(top == limit || 1870 ASSERT(top == limit ||
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
3026 } 3026 }
3027 // Must be small, since an iteration is used for lookup. 3027 // Must be small, since an iteration is used for lookup.
3028 static const int kMaxComments = 64; 3028 static const int kMaxComments = 64;
3029 }; 3029 };
3030 #endif 3030 #endif
3031 3031
3032 3032
3033 } } // namespace v8::internal 3033 } } // namespace v8::internal
3034 3034
3035 #endif // V8_SPACES_H_ 3035 #endif // V8_SPACES_H_
OLDNEW
« no previous file with comments | « src/mark-compact.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698