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

Side by Side Diff: src/spaces.h

Issue 7607031: Update gc branch to bleeding_edge revision 8862. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Fix bug in weak-map merge Created 9 years, 4 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/shell.h ('k') | src/spaces.cc » ('j') | 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 // 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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 744
745 // ---------------------------------------------------------------------------- 745 // ----------------------------------------------------------------------------
746 // All heap objects containing executable code (code objects) must be allocated 746 // All heap objects containing executable code (code objects) must be allocated
747 // from a 2 GB range of memory, so that they can call each other using 32-bit 747 // from a 2 GB range of memory, so that they can call each other using 32-bit
748 // displacements. This happens automatically on 32-bit platforms, where 32-bit 748 // displacements. This happens automatically on 32-bit platforms, where 32-bit
749 // displacements cover the entire 4GB virtual address space. On 64-bit 749 // displacements cover the entire 4GB virtual address space. On 64-bit
750 // platforms, we support this using the CodeRange object, which reserves and 750 // platforms, we support this using the CodeRange object, which reserves and
751 // manages a range of virtual memory. 751 // manages a range of virtual memory.
752 class CodeRange { 752 class CodeRange {
753 public: 753 public:
754 explicit CodeRange(Isolate* isolate);
755
754 // Reserves a range of virtual memory, but does not commit any of it. 756 // Reserves a range of virtual memory, but does not commit any of it.
755 // Can only be called once, at heap initialization time. 757 // Can only be called once, at heap initialization time.
756 // Returns false on failure. 758 // Returns false on failure.
757 bool Setup(const size_t requested_size); 759 bool Setup(const size_t requested_size);
758 760
759 // Frees the range of virtual memory, and frees the data structures used to 761 // Frees the range of virtual memory, and frees the data structures used to
760 // manage it. 762 // manage it.
761 void TearDown(); 763 void TearDown();
762 764
763 bool exists() { return code_range_ != NULL; } 765 bool exists() { return this != NULL && code_range_ != NULL; }
764 bool contains(Address address) { 766 bool contains(Address address) {
765 if (code_range_ == NULL) return false; 767 if (this == NULL || code_range_ == NULL) return false;
766 Address start = static_cast<Address>(code_range_->address()); 768 Address start = static_cast<Address>(code_range_->address());
767 return start <= address && address < start + code_range_->size(); 769 return start <= address && address < start + code_range_->size();
768 } 770 }
769 771
770 // Allocates a chunk of memory from the large-object portion of 772 // Allocates a chunk of memory from the large-object portion of
771 // the code range. On platforms with no separate code range, should 773 // the code range. On platforms with no separate code range, should
772 // not be called. 774 // not be called.
773 MUST_USE_RESULT Address AllocateRawMemory(const size_t requested, 775 MUST_USE_RESULT Address AllocateRawMemory(const size_t requested,
774 size_t* allocated); 776 size_t* allocated);
775 void FreeRawMemory(Address buf, size_t length); 777 void FreeRawMemory(Address buf, size_t length);
776 778
777 private: 779 private:
778 CodeRange(); 780 Isolate* isolate_;
779 781
780 // The reserved range of virtual memory that all code objects are put in. 782 // The reserved range of virtual memory that all code objects are put in.
781 VirtualMemory* code_range_; 783 VirtualMemory* code_range_;
782 // Plain old data class, just a struct plus a constructor. 784 // Plain old data class, just a struct plus a constructor.
783 class FreeBlock { 785 class FreeBlock {
784 public: 786 public:
785 FreeBlock(Address start_arg, size_t size_arg) 787 FreeBlock(Address start_arg, size_t size_arg)
786 : start(start_arg), size(size_arg) { 788 : start(start_arg), size(size_arg) {
787 ASSERT(IsAddressAligned(start, MemoryChunk::kAlignment)); 789 ASSERT(IsAddressAligned(start, MemoryChunk::kAlignment));
788 ASSERT(size >= static_cast<size_t>(Page::kPageSize)); 790 ASSERT(size >= static_cast<size_t>(Page::kPageSize));
(...skipping 19 matching lines...) Expand all
808 810
809 // Finds a block on the allocation list that contains at least the 811 // Finds a block on the allocation list that contains at least the
810 // requested amount of memory. If none is found, sorts and merges 812 // requested amount of memory. If none is found, sorts and merges
811 // the existing free memory blocks, and searches again. 813 // the existing free memory blocks, and searches again.
812 // If none can be found, terminates V8 with FatalProcessOutOfMemory. 814 // If none can be found, terminates V8 with FatalProcessOutOfMemory.
813 void GetNextAllocationBlock(size_t requested); 815 void GetNextAllocationBlock(size_t requested);
814 // Compares the start addresses of two free blocks. 816 // Compares the start addresses of two free blocks.
815 static int CompareFreeBlockAddress(const FreeBlock* left, 817 static int CompareFreeBlockAddress(const FreeBlock* left,
816 const FreeBlock* right); 818 const FreeBlock* right);
817 819
818 friend class Isolate;
819
820 Isolate* isolate_;
821
822 DISALLOW_COPY_AND_ASSIGN(CodeRange); 820 DISALLOW_COPY_AND_ASSIGN(CodeRange);
823 }; 821 };
824 822
825 823
826 // ---------------------------------------------------------------------------- 824 // ----------------------------------------------------------------------------
827 // A space acquires chunks of memory from the operating system. The memory 825 // A space acquires chunks of memory from the operating system. The memory
828 // allocator allocated and deallocates pages for the paged heap spaces and large 826 // allocator allocated and deallocates pages for the paged heap spaces and large
829 // pages for large object space. 827 // pages for large object space.
830 // 828 //
831 // Each space has to manage it's own pages. 829 // Each space has to manage it's own pages.
832 // 830 //
833 class MemoryAllocator { 831 class MemoryAllocator {
834 public: 832 public:
833 explicit MemoryAllocator(Isolate* isolate);
834
835 // Initializes its internal bookkeeping structures. 835 // Initializes its internal bookkeeping structures.
836 // Max capacity of the total space and executable memory limit. 836 // Max capacity of the total space and executable memory limit.
837 bool Setup(intptr_t max_capacity, intptr_t capacity_executable); 837 bool Setup(intptr_t max_capacity, intptr_t capacity_executable);
838 838
839 void TearDown(); 839 void TearDown();
840 840
841 Page* AllocatePage(PagedSpace* owner, Executability executable); 841 Page* AllocatePage(PagedSpace* owner, Executability executable);
842 842
843 LargePage* AllocateLargePage(intptr_t object_size, 843 LargePage* AllocateLargePage(intptr_t object_size,
844 Executability executable, 844 Executability executable,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 AllocationAction action); 911 AllocationAction action);
912 912
913 void RemoveMemoryAllocationCallback( 913 void RemoveMemoryAllocationCallback(
914 MemoryAllocationCallback callback); 914 MemoryAllocationCallback callback);
915 915
916 bool MemoryAllocationCallbackRegistered( 916 bool MemoryAllocationCallbackRegistered(
917 MemoryAllocationCallback callback); 917 MemoryAllocationCallback callback);
918 918
919 919
920 // TODO(gc) ISOLATSE 920 // TODO(gc) ISOLATSE
921 Isolate* isolate_;
922 921
923 private: 922 private:
923 Isolate* isolate_;
924 924
925 // Maximum space size in bytes. 925 // Maximum space size in bytes.
926 size_t capacity_; 926 size_t capacity_;
927 // Maximum subset of capacity_ that can be executable 927 // Maximum subset of capacity_ that can be executable
928 size_t capacity_executable_; 928 size_t capacity_executable_;
929 929
930 // Allocated space size in bytes. 930 // Allocated space size in bytes.
931 size_t size_; 931 size_t size_;
932 // Allocated executable space size in bytes. 932 // Allocated executable space size in bytes.
933 size_t size_executable_; 933 size_t size_executable_;
(...skipping 12 matching lines...) Expand all
946 // A List of callback that are triggered when memory is allocated or free'd 946 // A List of callback that are triggered when memory is allocated or free'd
947 List<MemoryAllocationCallbackRegistration> 947 List<MemoryAllocationCallbackRegistration>
948 memory_allocation_callbacks_; 948 memory_allocation_callbacks_;
949 949
950 // Initializes pages in a chunk. Returns the first page address. 950 // Initializes pages in a chunk. Returns the first page address.
951 // This function and GetChunkId() are provided for the mark-compact 951 // This function and GetChunkId() are provided for the mark-compact
952 // collector to rebuild page headers in the from space, which is 952 // collector to rebuild page headers in the from space, which is
953 // used as a marking stack and its page headers are destroyed. 953 // used as a marking stack and its page headers are destroyed.
954 Page* InitializePagesInChunk(int chunk_id, int pages_in_chunk, 954 Page* InitializePagesInChunk(int chunk_id, int pages_in_chunk,
955 PagedSpace* owner); 955 PagedSpace* owner);
956
957 DISALLOW_IMPLICIT_CONSTRUCTORS(MemoryAllocator);
956 }; 958 };
957 959
958 960
959 // ----------------------------------------------------------------------------- 961 // -----------------------------------------------------------------------------
960 // Interface for heap object iterator to be implemented by all object space 962 // Interface for heap object iterator to be implemented by all object space
961 // object iterators. 963 // object iterators.
962 // 964 //
963 // NOTE: The space specific object iterators also implements the own next() 965 // NOTE: The space specific object iterators also implements the own next()
964 // method which is used to avoid using virtual functions 966 // method which is used to avoid using virtual functions
965 // iterating a specific space. 967 // iterating a specific space.
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
2518 } 2520 }
2519 // Must be small, since an iteration is used for lookup. 2521 // Must be small, since an iteration is used for lookup.
2520 static const int kMaxComments = 64; 2522 static const int kMaxComments = 64;
2521 }; 2523 };
2522 #endif 2524 #endif
2523 2525
2524 2526
2525 } } // namespace v8::internal 2527 } } // namespace v8::internal
2526 2528
2527 #endif // V8_SPACES_H_ 2529 #endif // V8_SPACES_H_
OLDNEW
« no previous file with comments | « src/shell.h ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698