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/atomic-utils.h" | 9 #include "src/atomic-utils.h" |
10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" |
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 public: | 1250 public: |
1251 enum AllocationMode { | 1251 enum AllocationMode { |
1252 kRegular, | 1252 kRegular, |
1253 kPooled, | 1253 kPooled, |
1254 }; | 1254 }; |
1255 | 1255 |
1256 explicit MemoryAllocator(Isolate* isolate); | 1256 explicit MemoryAllocator(Isolate* isolate); |
1257 | 1257 |
1258 // Initializes its internal bookkeeping structures. | 1258 // Initializes its internal bookkeeping structures. |
1259 // Max capacity of the total space and executable memory limit. | 1259 // Max capacity of the total space and executable memory limit. |
1260 bool SetUp(intptr_t max_capacity, intptr_t capacity_executable); | 1260 bool SetUp(intptr_t max_capacity, intptr_t capacity_executable, |
| 1261 intptr_t code_range_size); |
1261 | 1262 |
1262 void TearDown(); | 1263 void TearDown(); |
1263 | 1264 |
1264 // Allocates either Page or NewSpacePage from the allocator. AllocationMode | 1265 // Allocates either Page or NewSpacePage from the allocator. AllocationMode |
1265 // is used to indicate whether pooled allocation, which only works for | 1266 // is used to indicate whether pooled allocation, which only works for |
1266 // MemoryChunk::kPageSize, should be tried first. | 1267 // MemoryChunk::kPageSize, should be tried first. |
1267 template <typename PageType, MemoryAllocator::AllocationMode mode = kRegular, | 1268 template <typename PageType, MemoryAllocator::AllocationMode mode = kRegular, |
1268 typename SpaceType> | 1269 typename SpaceType> |
1269 PageType* AllocatePage(intptr_t size, SpaceType* owner, | 1270 PageType* AllocatePage(intptr_t size, SpaceType* owner, |
1270 Executability executable); | 1271 Executability executable); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 static int PageAreaSize(AllocationSpace space) { | 1377 static int PageAreaSize(AllocationSpace space) { |
1377 DCHECK_NE(LO_SPACE, space); | 1378 DCHECK_NE(LO_SPACE, space); |
1378 return (space == CODE_SPACE) ? CodePageAreaSize() | 1379 return (space == CODE_SPACE) ? CodePageAreaSize() |
1379 : Page::kAllocatableMemory; | 1380 : Page::kAllocatableMemory; |
1380 } | 1381 } |
1381 | 1382 |
1382 MUST_USE_RESULT bool CommitExecutableMemory(base::VirtualMemory* vm, | 1383 MUST_USE_RESULT bool CommitExecutableMemory(base::VirtualMemory* vm, |
1383 Address start, size_t commit_size, | 1384 Address start, size_t commit_size, |
1384 size_t reserved_size); | 1385 size_t reserved_size); |
1385 | 1386 |
| 1387 CodeRange* code_range() { return code_range_; } |
| 1388 |
1386 private: | 1389 private: |
1387 // See AllocatePage for public interface. Note that currently we only support | 1390 // See AllocatePage for public interface. Note that currently we only support |
1388 // pools for NOT_EXECUTABLE pages of size MemoryChunk::kPageSize. | 1391 // pools for NOT_EXECUTABLE pages of size MemoryChunk::kPageSize. |
1389 template <typename SpaceType> | 1392 template <typename SpaceType> |
1390 MemoryChunk* AllocatePagePooled(SpaceType* owner); | 1393 MemoryChunk* AllocatePagePooled(SpaceType* owner); |
1391 | 1394 |
1392 // Free that chunk into the pool. | 1395 // Free that chunk into the pool. |
1393 void FreePooled(MemoryChunk* chunk); | 1396 void FreePooled(MemoryChunk* chunk); |
1394 | 1397 |
1395 Isolate* isolate_; | 1398 Isolate* isolate_; |
1396 | 1399 |
| 1400 CodeRange* code_range_; |
| 1401 |
1397 // Maximum space size in bytes. | 1402 // Maximum space size in bytes. |
1398 intptr_t capacity_; | 1403 intptr_t capacity_; |
1399 // Maximum subset of capacity_ that can be executable | 1404 // Maximum subset of capacity_ that can be executable |
1400 intptr_t capacity_executable_; | 1405 intptr_t capacity_executable_; |
1401 | 1406 |
1402 // Allocated space size in bytes. | 1407 // Allocated space size in bytes. |
1403 AtomicNumber<intptr_t> size_; | 1408 AtomicNumber<intptr_t> size_; |
1404 // Allocated executable space size in bytes. | 1409 // Allocated executable space size in bytes. |
1405 AtomicNumber<intptr_t> size_executable_; | 1410 AtomicNumber<intptr_t> size_executable_; |
1406 | 1411 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 do { | 1445 do { |
1441 ptr = lowest_ever_allocated_.Value(); | 1446 ptr = lowest_ever_allocated_.Value(); |
1442 } while ((low < ptr) && !lowest_ever_allocated_.TrySetValue(ptr, low)); | 1447 } while ((low < ptr) && !lowest_ever_allocated_.TrySetValue(ptr, low)); |
1443 do { | 1448 do { |
1444 ptr = highest_ever_allocated_.Value(); | 1449 ptr = highest_ever_allocated_.Value(); |
1445 } while ((high > ptr) && !highest_ever_allocated_.TrySetValue(ptr, high)); | 1450 } while ((high > ptr) && !highest_ever_allocated_.TrySetValue(ptr, high)); |
1446 } | 1451 } |
1447 | 1452 |
1448 List<MemoryChunk*> chunk_pool_; | 1453 List<MemoryChunk*> chunk_pool_; |
1449 | 1454 |
| 1455 friend class TestCodeRangeScope; |
| 1456 |
1450 DISALLOW_IMPLICIT_CONSTRUCTORS(MemoryAllocator); | 1457 DISALLOW_IMPLICIT_CONSTRUCTORS(MemoryAllocator); |
1451 }; | 1458 }; |
1452 | 1459 |
1453 | 1460 |
1454 // ----------------------------------------------------------------------------- | 1461 // ----------------------------------------------------------------------------- |
1455 // Interface for heap object iterator to be implemented by all object space | 1462 // Interface for heap object iterator to be implemented by all object space |
1456 // object iterators. | 1463 // object iterators. |
1457 // | 1464 // |
1458 // NOTE: The space specific object iterators also implements the own next() | 1465 // NOTE: The space specific object iterators also implements the own next() |
1459 // method which is used to avoid using virtual functions | 1466 // method which is used to avoid using virtual functions |
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3106 count = 0; | 3113 count = 0; |
3107 } | 3114 } |
3108 // Must be small, since an iteration is used for lookup. | 3115 // Must be small, since an iteration is used for lookup. |
3109 static const int kMaxComments = 64; | 3116 static const int kMaxComments = 64; |
3110 }; | 3117 }; |
3111 #endif | 3118 #endif |
3112 } // namespace internal | 3119 } // namespace internal |
3113 } // namespace v8 | 3120 } // namespace v8 |
3114 | 3121 |
3115 #endif // V8_HEAP_SPACES_H_ | 3122 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |