| 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 <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1439 // Uncommit a contiguous block of memory [start..(start+size)[. | 1439 // Uncommit a contiguous block of memory [start..(start+size)[. |
| 1440 // start is not NULL, the size is greater than zero, and the | 1440 // start is not NULL, the size is greater than zero, and the |
| 1441 // block is contained in the initial chunk. Returns true if it succeeded | 1441 // block is contained in the initial chunk. Returns true if it succeeded |
| 1442 // and false otherwise. | 1442 // and false otherwise. |
| 1443 bool UncommitBlock(Address start, size_t size); | 1443 bool UncommitBlock(Address start, size_t size); |
| 1444 | 1444 |
| 1445 // Zaps a contiguous block of memory [start..(start+size)[ thus | 1445 // Zaps a contiguous block of memory [start..(start+size)[ thus |
| 1446 // filling it up with a recognizable non-NULL bit pattern. | 1446 // filling it up with a recognizable non-NULL bit pattern. |
| 1447 void ZapBlock(Address start, size_t size); | 1447 void ZapBlock(Address start, size_t size); |
| 1448 | 1448 |
| 1449 void PerformAllocationCallback(ObjectSpace space, AllocationAction action, | |
| 1450 size_t size); | |
| 1451 | |
| 1452 void AddMemoryAllocationCallback(MemoryAllocationCallback callback, | |
| 1453 ObjectSpace space, AllocationAction action); | |
| 1454 | |
| 1455 void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback); | |
| 1456 | |
| 1457 bool MemoryAllocationCallbackRegistered(MemoryAllocationCallback callback); | |
| 1458 | |
| 1459 static int CodePageGuardStartOffset(); | 1449 static int CodePageGuardStartOffset(); |
| 1460 | 1450 |
| 1461 static int CodePageGuardSize(); | 1451 static int CodePageGuardSize(); |
| 1462 | 1452 |
| 1463 static int CodePageAreaStartOffset(); | 1453 static int CodePageAreaStartOffset(); |
| 1464 | 1454 |
| 1465 static int CodePageAreaEndOffset(); | 1455 static int CodePageAreaEndOffset(); |
| 1466 | 1456 |
| 1467 static int CodePageAreaSize() { | 1457 static int CodePageAreaSize() { |
| 1468 return CodePageAreaEndOffset() - CodePageAreaStartOffset(); | 1458 return CodePageAreaEndOffset() - CodePageAreaStartOffset(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 base::AtomicNumber<intptr_t> size_executable_; | 1499 base::AtomicNumber<intptr_t> size_executable_; |
| 1510 | 1500 |
| 1511 // We keep the lowest and highest addresses allocated as a quick way | 1501 // We keep the lowest and highest addresses allocated as a quick way |
| 1512 // of determining that pointers are outside the heap. The estimate is | 1502 // of determining that pointers are outside the heap. The estimate is |
| 1513 // conservative, i.e. not all addrsses in 'allocated' space are allocated | 1503 // conservative, i.e. not all addrsses in 'allocated' space are allocated |
| 1514 // to our heap. The range is [lowest, highest[, inclusive on the low end | 1504 // to our heap. The range is [lowest, highest[, inclusive on the low end |
| 1515 // and exclusive on the high end. | 1505 // and exclusive on the high end. |
| 1516 base::AtomicValue<void*> lowest_ever_allocated_; | 1506 base::AtomicValue<void*> lowest_ever_allocated_; |
| 1517 base::AtomicValue<void*> highest_ever_allocated_; | 1507 base::AtomicValue<void*> highest_ever_allocated_; |
| 1518 | 1508 |
| 1519 struct MemoryAllocationCallbackRegistration { | |
| 1520 MemoryAllocationCallbackRegistration(MemoryAllocationCallback callback, | |
| 1521 ObjectSpace space, | |
| 1522 AllocationAction action) | |
| 1523 : callback(callback), space(space), action(action) {} | |
| 1524 MemoryAllocationCallback callback; | |
| 1525 ObjectSpace space; | |
| 1526 AllocationAction action; | |
| 1527 }; | |
| 1528 | |
| 1529 // A List of callback that are triggered when memory is allocated or free'd | |
| 1530 List<MemoryAllocationCallbackRegistration> memory_allocation_callbacks_; | |
| 1531 | |
| 1532 // Initializes pages in a chunk. Returns the first page address. | 1509 // Initializes pages in a chunk. Returns the first page address. |
| 1533 // This function and GetChunkId() are provided for the mark-compact | 1510 // This function and GetChunkId() are provided for the mark-compact |
| 1534 // collector to rebuild page headers in the from space, which is | 1511 // collector to rebuild page headers in the from space, which is |
| 1535 // used as a marking stack and its page headers are destroyed. | 1512 // used as a marking stack and its page headers are destroyed. |
| 1536 Page* InitializePagesInChunk(int chunk_id, int pages_in_chunk, | 1513 Page* InitializePagesInChunk(int chunk_id, int pages_in_chunk, |
| 1537 PagedSpace* owner); | 1514 PagedSpace* owner); |
| 1538 | 1515 |
| 1539 void UpdateAllocatedSpaceLimits(void* low, void* high) { | 1516 void UpdateAllocatedSpaceLimits(void* low, void* high) { |
| 1540 // The use of atomic primitives does not guarantee correctness (wrt. | 1517 // The use of atomic primitives does not guarantee correctness (wrt. |
| 1541 // desired semantics) by default. The loop here ensures that we update the | 1518 // desired semantics) by default. The loop here ensures that we update the |
| (...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3144 count = 0; | 3121 count = 0; |
| 3145 } | 3122 } |
| 3146 // Must be small, since an iteration is used for lookup. | 3123 // Must be small, since an iteration is used for lookup. |
| 3147 static const int kMaxComments = 64; | 3124 static const int kMaxComments = 64; |
| 3148 }; | 3125 }; |
| 3149 #endif | 3126 #endif |
| 3150 } // namespace internal | 3127 } // namespace internal |
| 3151 } // namespace v8 | 3128 } // namespace v8 |
| 3152 | 3129 |
| 3153 #endif // V8_HEAP_SPACES_H_ | 3130 #endif // V8_HEAP_SPACES_H_ |
| OLD | NEW |