OLD | NEW |
---|---|
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_HEAP_SPACES_H_ | 5 #ifndef V8_HEAP_SPACES_H_ |
6 #define V8_HEAP_SPACES_H_ | 6 #define V8_HEAP_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/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 2417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2428 return to_space_.MaximumCommittedMemory() + | 2428 return to_space_.MaximumCommittedMemory() + |
2429 from_space_.MaximumCommittedMemory(); | 2429 from_space_.MaximumCommittedMemory(); |
2430 } | 2430 } |
2431 | 2431 |
2432 // Approximate amount of physical memory committed for this space. | 2432 // Approximate amount of physical memory committed for this space. |
2433 size_t CommittedPhysicalMemory() override; | 2433 size_t CommittedPhysicalMemory() override; |
2434 | 2434 |
2435 // Return the available bytes without growing. | 2435 // Return the available bytes without growing. |
2436 intptr_t Available() override { return Capacity() - Size(); } | 2436 intptr_t Available() override { return Capacity() - Size(); } |
2437 | 2437 |
2438 intptr_t PagesFromStart(Address addr) { | |
2439 return static_cast<int>(addr - bottom()) / Page::kPageSize; | |
Hannes Payer (out of office)
2015/05/12 17:04:17
cast to intptr_t
ulan
2015/05/18 12:45:51
Done.
| |
2440 } | |
2441 | |
2442 size_t AllocatedSinceLastGC() { | |
2443 intptr_t allocated = top() - to_space_.age_mark(); | |
2444 if (allocated < 0) { | |
2445 // Runtime has lowered the top below the age mark. | |
2446 return 0; | |
2447 } | |
2448 // Correctly account for non-allocatable regions at the beginning of | |
2449 // each page from the age_mark() to the top(). | |
2450 intptr_t pages = | |
2451 PagesFromStart(top()) - PagesFromStart(to_space_.age_mark()); | |
2452 allocated -= pages * (NewSpacePage::kObjectStartOffset); | |
2453 DCHECK(0 <= allocated && allocated <= Size()); | |
2454 return static_cast<size_t>(allocated); | |
2455 } | |
2456 | |
2438 // Return the maximum capacity of a semispace. | 2457 // Return the maximum capacity of a semispace. |
2439 int MaximumCapacity() { | 2458 int MaximumCapacity() { |
2440 DCHECK(to_space_.MaximumTotalCapacity() == | 2459 DCHECK(to_space_.MaximumTotalCapacity() == |
2441 from_space_.MaximumTotalCapacity()); | 2460 from_space_.MaximumTotalCapacity()); |
2442 return to_space_.MaximumTotalCapacity(); | 2461 return to_space_.MaximumTotalCapacity(); |
2443 } | 2462 } |
2444 | 2463 |
2445 bool IsAtMaximumCapacity() { return TotalCapacity() == MaximumCapacity(); } | 2464 bool IsAtMaximumCapacity() { return TotalCapacity() == MaximumCapacity(); } |
2446 | 2465 |
2447 // Returns the initial capacity of a semispace. | 2466 // Returns the initial capacity of a semispace. |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2873 count = 0; | 2892 count = 0; |
2874 } | 2893 } |
2875 // Must be small, since an iteration is used for lookup. | 2894 // Must be small, since an iteration is used for lookup. |
2876 static const int kMaxComments = 64; | 2895 static const int kMaxComments = 64; |
2877 }; | 2896 }; |
2878 #endif | 2897 #endif |
2879 } | 2898 } |
2880 } // namespace v8::internal | 2899 } // namespace v8::internal |
2881 | 2900 |
2882 #endif // V8_HEAP_SPACES_H_ | 2901 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |