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

Side by Side Diff: src/spaces.h

Issue 23903008: Drop OS::IsOutsideAllocatedSpace() and move the tracking to the MemoryAllocator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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
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 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 } 1076 }
1077 1077
1078 // Returns allocated executable spaces in bytes. 1078 // Returns allocated executable spaces in bytes.
1079 intptr_t SizeExecutable() { return size_executable_; } 1079 intptr_t SizeExecutable() { return size_executable_; }
1080 1080
1081 // Returns maximum available bytes that the old space can have. 1081 // Returns maximum available bytes that the old space can have.
1082 intptr_t MaxAvailable() { 1082 intptr_t MaxAvailable() {
1083 return (Available() / Page::kPageSize) * Page::kMaxNonCodeHeapObjectSize; 1083 return (Available() / Page::kPageSize) * Page::kMaxNonCodeHeapObjectSize;
1084 } 1084 }
1085 1085
1086 // Returns an indication of whether a pointer is in a space that has
1087 // been allocated by this MemoryAllocator.
1088 V8_INLINE(bool IsOutsideAllocatedSpace(const void* address)) const {
1089 // return address < lowest_ever_allocated_ ||
1090 // address >= highest_ever_allocated_;
1091 return false;
Michael Starzinger 2013/09/04 15:49:25 This looks like debugging leftovers. Let's use the
Benedikt Meurer 2013/09/05 08:06:46 Ups, indeed.. :-)
1092 }
1093
1086 #ifdef DEBUG 1094 #ifdef DEBUG
1087 // Reports statistic info of the space. 1095 // Reports statistic info of the space.
1088 void ReportStatistics(); 1096 void ReportStatistics();
1089 #endif 1097 #endif
1090 1098
1091 // Returns a MemoryChunk in which the memory region from commit_area_size to 1099 // Returns a MemoryChunk in which the memory region from commit_area_size to
1092 // reserve_area_size of the chunk area is reserved but not committed, it 1100 // reserve_area_size of the chunk area is reserved but not committed, it
1093 // could be committed later by calling MemoryChunk::CommitArea. 1101 // could be committed later by calling MemoryChunk::CommitArea.
1094 MemoryChunk* AllocateChunk(intptr_t reserve_area_size, 1102 MemoryChunk* AllocateChunk(intptr_t reserve_area_size,
1095 intptr_t commit_area_size, 1103 intptr_t commit_area_size,
1096 Executability executable, 1104 Executability executable,
1097 Space* space); 1105 Space* space);
1098 1106
1099 Address ReserveAlignedMemory(size_t requested, 1107 Address ReserveAlignedMemory(size_t requested,
1100 size_t alignment, 1108 size_t alignment,
1101 VirtualMemory* controller); 1109 VirtualMemory* controller);
1102 Address AllocateAlignedMemory(size_t reserve_size, 1110 Address AllocateAlignedMemory(size_t reserve_size,
1103 size_t commit_size, 1111 size_t commit_size,
1104 size_t alignment, 1112 size_t alignment,
1105 Executability executable, 1113 Executability executable,
1106 VirtualMemory* controller); 1114 VirtualMemory* controller);
1107 1115
1116 bool CommitMemory(Address addr, size_t size, Executability executable);
1117
1108 void FreeMemory(VirtualMemory* reservation, Executability executable); 1118 void FreeMemory(VirtualMemory* reservation, Executability executable);
1109 void FreeMemory(Address addr, size_t size, Executability executable); 1119 void FreeMemory(Address addr, size_t size, Executability executable);
1110 1120
1111 // Commit a contiguous block of memory from the initial chunk. Assumes that 1121 // Commit a contiguous block of memory from the initial chunk. Assumes that
1112 // the address is not NULL, the size is greater than zero, and that the 1122 // the address is not NULL, the size is greater than zero, and that the
1113 // block is contained in the initial chunk. Returns true if it succeeded 1123 // block is contained in the initial chunk. Returns true if it succeeded
1114 // and false otherwise. 1124 // and false otherwise.
1115 bool CommitBlock(Address start, size_t size, Executability executable); 1125 bool CommitBlock(Address start, size_t size, Executability executable);
1116 1126
1117 // Uncommit a contiguous block of memory [start..(start+size)[. 1127 // Uncommit a contiguous block of memory [start..(start+size)[.
(...skipping 25 matching lines...) Expand all
1143 static int CodePageGuardSize(); 1153 static int CodePageGuardSize();
1144 1154
1145 static int CodePageAreaStartOffset(); 1155 static int CodePageAreaStartOffset();
1146 1156
1147 static int CodePageAreaEndOffset(); 1157 static int CodePageAreaEndOffset();
1148 1158
1149 static int CodePageAreaSize() { 1159 static int CodePageAreaSize() {
1150 return CodePageAreaEndOffset() - CodePageAreaStartOffset(); 1160 return CodePageAreaEndOffset() - CodePageAreaStartOffset();
1151 } 1161 }
1152 1162
1153 MUST_USE_RESULT static bool CommitExecutableMemory(VirtualMemory* vm, 1163 MUST_USE_RESULT bool CommitExecutableMemory(VirtualMemory* vm,
1154 Address start, 1164 Address start,
1155 size_t commit_size, 1165 size_t commit_size,
1156 size_t reserved_size); 1166 size_t reserved_size);
1157 1167
1158 private: 1168 private:
1159 Isolate* isolate_; 1169 Isolate* isolate_;
1160 1170
1161 // Maximum space size in bytes. 1171 // Maximum space size in bytes.
1162 size_t capacity_; 1172 size_t capacity_;
1163 // Maximum subset of capacity_ that can be executable 1173 // Maximum subset of capacity_ that can be executable
1164 size_t capacity_executable_; 1174 size_t capacity_executable_;
1165 1175
1166 // Allocated space size in bytes. 1176 // Allocated space size in bytes.
1167 size_t size_; 1177 size_t size_;
1168 // Allocated executable space size in bytes. 1178 // Allocated executable space size in bytes.
1169 size_t size_executable_; 1179 size_t size_executable_;
1170 1180
1181 // We keep the lowest and highest addresses allocated as a quick way
1182 // of determining that pointers are outside the heap. The estimate is
1183 // conservative, i.e. not all addrsses in 'allocated' space are allocated
1184 // to our heap. The range is [lowest, highest[, inclusive on the low end
1185 // and exclusive on the high end.
1186 void* lowest_ever_allocated_;
1187 void* highest_ever_allocated_;
1188
1171 struct MemoryAllocationCallbackRegistration { 1189 struct MemoryAllocationCallbackRegistration {
1172 MemoryAllocationCallbackRegistration(MemoryAllocationCallback callback, 1190 MemoryAllocationCallbackRegistration(MemoryAllocationCallback callback,
1173 ObjectSpace space, 1191 ObjectSpace space,
1174 AllocationAction action) 1192 AllocationAction action)
1175 : callback(callback), space(space), action(action) { 1193 : callback(callback), space(space), action(action) {
1176 } 1194 }
1177 MemoryAllocationCallback callback; 1195 MemoryAllocationCallback callback;
1178 ObjectSpace space; 1196 ObjectSpace space;
1179 AllocationAction action; 1197 AllocationAction action;
1180 }; 1198 };
1181 1199
1182 // A List of callback that are triggered when memory is allocated or free'd 1200 // A List of callback that are triggered when memory is allocated or free'd
1183 List<MemoryAllocationCallbackRegistration> 1201 List<MemoryAllocationCallbackRegistration>
1184 memory_allocation_callbacks_; 1202 memory_allocation_callbacks_;
1185 1203
1186 // Initializes pages in a chunk. Returns the first page address. 1204 // Initializes pages in a chunk. Returns the first page address.
1187 // This function and GetChunkId() are provided for the mark-compact 1205 // This function and GetChunkId() are provided for the mark-compact
1188 // collector to rebuild page headers in the from space, which is 1206 // collector to rebuild page headers in the from space, which is
1189 // used as a marking stack and its page headers are destroyed. 1207 // used as a marking stack and its page headers are destroyed.
1190 Page* InitializePagesInChunk(int chunk_id, int pages_in_chunk, 1208 Page* InitializePagesInChunk(int chunk_id, int pages_in_chunk,
1191 PagedSpace* owner); 1209 PagedSpace* owner);
1192 1210
1211 void UpdateAllocatedSpaceLimits(void* low, void* high) {
1212 lowest_ever_allocated_ = Min(lowest_ever_allocated_, low);
1213 highest_ever_allocated_ = Max(highest_ever_allocated_, high);
1214 }
1215
1193 DISALLOW_IMPLICIT_CONSTRUCTORS(MemoryAllocator); 1216 DISALLOW_IMPLICIT_CONSTRUCTORS(MemoryAllocator);
1194 }; 1217 };
1195 1218
1196 1219
1197 // ----------------------------------------------------------------------------- 1220 // -----------------------------------------------------------------------------
1198 // Interface for heap object iterator to be implemented by all object space 1221 // Interface for heap object iterator to be implemented by all object space
1199 // object iterators. 1222 // object iterators.
1200 // 1223 //
1201 // NOTE: The space specific object iterators also implements the own next() 1224 // NOTE: The space specific object iterators also implements the own next()
1202 // method which is used to avoid using virtual functions 1225 // method which is used to avoid using virtual functions
(...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after
2874 } 2897 }
2875 // Must be small, since an iteration is used for lookup. 2898 // Must be small, since an iteration is used for lookup.
2876 static const int kMaxComments = 64; 2899 static const int kMaxComments = 64;
2877 }; 2900 };
2878 #endif 2901 #endif
2879 2902
2880 2903
2881 } } // namespace v8::internal 2904 } } // namespace v8::internal
2882 2905
2883 #endif // V8_SPACES_H_ 2906 #endif // V8_SPACES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698