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

Side by Side Diff: src/heap/spaces.h

Issue 742733002: Reserve code range block for evacuation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test/cctest/test-spaces.cc Created 6 years, 1 month 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
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/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 // 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 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 // Allocates a chunk of memory from the large-object portion of 893 // Allocates a chunk of memory from the large-object portion of
894 // the code range. On platforms with no separate code range, should 894 // the code range. On platforms with no separate code range, should
895 // not be called. 895 // not be called.
896 MUST_USE_RESULT Address AllocateRawMemory(const size_t requested_size, 896 MUST_USE_RESULT Address AllocateRawMemory(const size_t requested_size,
897 const size_t commit_size, 897 const size_t commit_size,
898 size_t* allocated); 898 size_t* allocated);
899 bool CommitRawMemory(Address start, size_t length); 899 bool CommitRawMemory(Address start, size_t length);
900 bool UncommitRawMemory(Address start, size_t length); 900 bool UncommitRawMemory(Address start, size_t length);
901 void FreeRawMemory(Address buf, size_t length); 901 void FreeRawMemory(Address buf, size_t length);
902 902
903 void ReserveEmergencyBlock();
904 void ReleaseEmergencyBlock();
905
903 private: 906 private:
904 Isolate* isolate_; 907 Isolate* isolate_;
905 908
906 // The reserved range of virtual memory that all code objects are put in. 909 // The reserved range of virtual memory that all code objects are put in.
907 base::VirtualMemory* code_range_; 910 base::VirtualMemory* code_range_;
908 // Plain old data class, just a struct plus a constructor. 911 // Plain old data class, just a struct plus a constructor.
909 class FreeBlock { 912 class FreeBlock {
910 public: 913 public:
914 FreeBlock() : start(0), size(0) {}
911 FreeBlock(Address start_arg, size_t size_arg) 915 FreeBlock(Address start_arg, size_t size_arg)
912 : start(start_arg), size(size_arg) { 916 : start(start_arg), size(size_arg) {
913 DCHECK(IsAddressAligned(start, MemoryChunk::kAlignment)); 917 DCHECK(IsAddressAligned(start, MemoryChunk::kAlignment));
914 DCHECK(size >= static_cast<size_t>(Page::kPageSize)); 918 DCHECK(size >= static_cast<size_t>(Page::kPageSize));
915 } 919 }
916 FreeBlock(void* start_arg, size_t size_arg) 920 FreeBlock(void* start_arg, size_t size_arg)
917 : start(static_cast<Address>(start_arg)), size(size_arg) { 921 : start(static_cast<Address>(start_arg)), size(size_arg) {
918 DCHECK(IsAddressAligned(start, MemoryChunk::kAlignment)); 922 DCHECK(IsAddressAligned(start, MemoryChunk::kAlignment));
919 DCHECK(size >= static_cast<size_t>(Page::kPageSize)); 923 DCHECK(size >= static_cast<size_t>(Page::kPageSize));
920 } 924 }
921 925
922 Address start; 926 Address start;
923 size_t size; 927 size_t size;
924 }; 928 };
925 929
926 // Freed blocks of memory are added to the free list. When the allocation 930 // Freed blocks of memory are added to the free list. When the allocation
927 // list is exhausted, the free list is sorted and merged to make the new 931 // list is exhausted, the free list is sorted and merged to make the new
928 // allocation list. 932 // allocation list.
929 List<FreeBlock> free_list_; 933 List<FreeBlock> free_list_;
930 // Memory is allocated from the free blocks on the allocation list. 934 // Memory is allocated from the free blocks on the allocation list.
931 // The block at current_allocation_block_index_ is the current block. 935 // The block at current_allocation_block_index_ is the current block.
932 List<FreeBlock> allocation_list_; 936 List<FreeBlock> allocation_list_;
933 int current_allocation_block_index_; 937 int current_allocation_block_index_;
934 938
939 // Emergency block guarantees that we can always allocate a page for
940 // evacuation candidates when code space is compacted. Emergency block is
941 // reserved immediately after GC and is released immedietely before
942 // allocating a page for evacuation.
943 FreeBlock emergency_block_;
944
935 // Finds a block on the allocation list that contains at least the 945 // Finds a block on the allocation list that contains at least the
936 // requested amount of memory. If none is found, sorts and merges 946 // requested amount of memory. If none is found, sorts and merges
937 // the existing free memory blocks, and searches again. 947 // the existing free memory blocks, and searches again.
938 // If none can be found, returns false. 948 // If none can be found, returns false.
939 bool GetNextAllocationBlock(size_t requested); 949 bool GetNextAllocationBlock(size_t requested);
940 // Compares the start addresses of two free blocks. 950 // Compares the start addresses of two free blocks.
941 static int CompareFreeBlockAddress(const FreeBlock* left, 951 static int CompareFreeBlockAddress(const FreeBlock* left,
942 const FreeBlock* right); 952 const FreeBlock* right);
953 bool ReserveBlock(const size_t requested_size, FreeBlock* block);
954 void ReleaseBlock(const FreeBlock* block);
943 955
944 DISALLOW_COPY_AND_ASSIGN(CodeRange); 956 DISALLOW_COPY_AND_ASSIGN(CodeRange);
945 }; 957 };
946 958
947 959
948 class SkipList { 960 class SkipList {
949 public: 961 public:
950 SkipList() { Clear(); } 962 SkipList() { Clear(); }
951 963
952 void Clear() { 964 void Clear() {
(...skipping 1952 matching lines...) Expand 10 before | Expand all | Expand 10 after
2905 count = 0; 2917 count = 0;
2906 } 2918 }
2907 // Must be small, since an iteration is used for lookup. 2919 // Must be small, since an iteration is used for lookup.
2908 static const int kMaxComments = 64; 2920 static const int kMaxComments = 64;
2909 }; 2921 };
2910 #endif 2922 #endif
2911 } 2923 }
2912 } // namespace v8::internal 2924 } // namespace v8::internal
2913 2925
2914 #endif // V8_HEAP_SPACES_H_ 2926 #endif // V8_HEAP_SPACES_H_
OLDNEW
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698