| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 // but keep track of allocated bytes as part of heap. | 560 // but keep track of allocated bytes as part of heap. |
| 561 // If the flag is EXECUTABLE and a code range exists, the requested | 561 // If the flag is EXECUTABLE and a code range exists, the requested |
| 562 // memory is allocated from the code range. If a code range exists | 562 // memory is allocated from the code range. If a code range exists |
| 563 // and the freed memory is in it, the code range manages the freed memory. | 563 // and the freed memory is in it, the code range manages the freed memory. |
| 564 static void* AllocateRawMemory(const size_t requested, | 564 static void* AllocateRawMemory(const size_t requested, |
| 565 size_t* allocated, | 565 size_t* allocated, |
| 566 Executability executable); | 566 Executability executable); |
| 567 static void FreeRawMemory(void* buf, | 567 static void FreeRawMemory(void* buf, |
| 568 size_t length, | 568 size_t length, |
| 569 Executability executable); | 569 Executability executable); |
| 570 static void PerformAllocationCallback(ObjectSpace space, |
| 571 AllocationAction action, |
| 572 int size); |
| 573 |
| 574 static void AddMemoryAllocationCallback(MemoryAllocationCallback callback, |
| 575 ObjectSpace space, |
| 576 AllocationAction action); |
| 577 static void RemoveMemoryAllocationCallback( |
| 578 MemoryAllocationCallback callback); |
| 579 static bool MemoryAllocationCallbackRegistered( |
| 580 MemoryAllocationCallback callback); |
| 570 | 581 |
| 571 // Returns the maximum available bytes of heaps. | 582 // Returns the maximum available bytes of heaps. |
| 572 static int Available() { return capacity_ < size_ ? 0 : capacity_ - size_; } | 583 static int Available() { return capacity_ < size_ ? 0 : capacity_ - size_; } |
| 573 | 584 |
| 574 // Returns allocated spaces in bytes. | 585 // Returns allocated spaces in bytes. |
| 575 static int Size() { return size_; } | 586 static int Size() { return size_; } |
| 576 | 587 |
| 577 // Returns allocated executable spaces in bytes. | 588 // Returns allocated executable spaces in bytes. |
| 578 static int SizeExecutable() { return size_executable_; } | 589 static int SizeExecutable() { return size_executable_; } |
| 579 | 590 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 | 647 |
| 637 private: | 648 private: |
| 638 // Maximum space size in bytes. | 649 // Maximum space size in bytes. |
| 639 static int capacity_; | 650 static int capacity_; |
| 640 | 651 |
| 641 // Allocated space size in bytes. | 652 // Allocated space size in bytes. |
| 642 static int size_; | 653 static int size_; |
| 643 // Allocated executable space size in bytes. | 654 // Allocated executable space size in bytes. |
| 644 static int size_executable_; | 655 static int size_executable_; |
| 645 | 656 |
| 657 struct MemoryAllocationCallbackRegistration { |
| 658 MemoryAllocationCallbackRegistration(MemoryAllocationCallback callback, |
| 659 ObjectSpace space, |
| 660 AllocationAction action) |
| 661 : callback(callback), space(space), action(action) { |
| 662 } |
| 663 MemoryAllocationCallback callback; |
| 664 ObjectSpace space; |
| 665 AllocationAction action; |
| 666 }; |
| 667 // A List of callback that are triggered when memory is allocated or free'd |
| 668 static List<MemoryAllocationCallbackRegistration> |
| 669 memory_allocation_callbacks_; |
| 670 |
| 646 // The initial chunk of virtual memory. | 671 // The initial chunk of virtual memory. |
| 647 static VirtualMemory* initial_chunk_; | 672 static VirtualMemory* initial_chunk_; |
| 648 | 673 |
| 649 // Allocated chunk info: chunk start address, chunk size, and owning space. | 674 // Allocated chunk info: chunk start address, chunk size, and owning space. |
| 650 class ChunkInfo BASE_EMBEDDED { | 675 class ChunkInfo BASE_EMBEDDED { |
| 651 public: | 676 public: |
| 652 ChunkInfo() : address_(NULL), size_(0), owner_(NULL) {} | 677 ChunkInfo() : address_(NULL), size_(0), owner_(NULL) {} |
| 653 void init(Address a, size_t s, PagedSpace* o) { | 678 void init(Address a, size_t s, PagedSpace* o) { |
| 654 address_ = a; | 679 address_ = a; |
| 655 size_ = s; | 680 size_ = s; |
| (...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2222 | 2247 |
| 2223 private: | 2248 private: |
| 2224 LargeObjectChunk* current_; | 2249 LargeObjectChunk* current_; |
| 2225 HeapObjectCallback size_func_; | 2250 HeapObjectCallback size_func_; |
| 2226 }; | 2251 }; |
| 2227 | 2252 |
| 2228 | 2253 |
| 2229 } } // namespace v8::internal | 2254 } } // namespace v8::internal |
| 2230 | 2255 |
| 2231 #endif // V8_SPACES_H_ | 2256 #endif // V8_SPACES_H_ |
| OLD | NEW |