OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_HEAP_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 /* Array element maps */ \ | 129 /* Array element maps */ \ |
130 V(Map, fixed_uint8_array_map, FixedUint8ArrayMap) \ | 130 V(Map, fixed_uint8_array_map, FixedUint8ArrayMap) \ |
131 V(Map, fixed_int8_array_map, FixedInt8ArrayMap) \ | 131 V(Map, fixed_int8_array_map, FixedInt8ArrayMap) \ |
132 V(Map, fixed_uint16_array_map, FixedUint16ArrayMap) \ | 132 V(Map, fixed_uint16_array_map, FixedUint16ArrayMap) \ |
133 V(Map, fixed_int16_array_map, FixedInt16ArrayMap) \ | 133 V(Map, fixed_int16_array_map, FixedInt16ArrayMap) \ |
134 V(Map, fixed_uint32_array_map, FixedUint32ArrayMap) \ | 134 V(Map, fixed_uint32_array_map, FixedUint32ArrayMap) \ |
135 V(Map, fixed_int32_array_map, FixedInt32ArrayMap) \ | 135 V(Map, fixed_int32_array_map, FixedInt32ArrayMap) \ |
136 V(Map, fixed_float32_array_map, FixedFloat32ArrayMap) \ | 136 V(Map, fixed_float32_array_map, FixedFloat32ArrayMap) \ |
137 V(Map, fixed_float64_array_map, FixedFloat64ArrayMap) \ | 137 V(Map, fixed_float64_array_map, FixedFloat64ArrayMap) \ |
138 V(Map, fixed_uint8_clamped_array_map, FixedUint8ClampedArrayMap) \ | 138 V(Map, fixed_uint8_clamped_array_map, FixedUint8ClampedArrayMap) \ |
139 /* Oddball maps */ \ | |
140 V(Map, undefined_map, UndefinedMap) \ | |
141 V(Map, the_hole_map, TheHoleMap) \ | |
142 V(Map, null_map, NullMap) \ | |
143 V(Map, boolean_map, BooleanMap) \ | |
144 V(Map, uninitialized_map, UninitializedMap) \ | |
145 V(Map, arguments_marker_map, ArgumentsMarkerMap) \ | |
146 V(Map, exception_map, ExceptionMap) \ | |
147 V(Map, termination_exception_map, TerminationExceptionMap) \ | |
148 V(Map, optimized_out_map, OptimizedOutMap) \ | |
149 V(Map, stale_register_map, StaleRegisterMap) \ | |
150 /* Canonical empty values */ \ | 139 /* Canonical empty values */ \ |
151 V(ByteArray, empty_byte_array, EmptyByteArray) \ | 140 V(ByteArray, empty_byte_array, EmptyByteArray) \ |
152 V(FixedTypedArrayBase, empty_fixed_uint8_array, EmptyFixedUint8Array) \ | 141 V(FixedTypedArrayBase, empty_fixed_uint8_array, EmptyFixedUint8Array) \ |
153 V(FixedTypedArrayBase, empty_fixed_int8_array, EmptyFixedInt8Array) \ | 142 V(FixedTypedArrayBase, empty_fixed_int8_array, EmptyFixedInt8Array) \ |
154 V(FixedTypedArrayBase, empty_fixed_uint16_array, EmptyFixedUint16Array) \ | 143 V(FixedTypedArrayBase, empty_fixed_uint16_array, EmptyFixedUint16Array) \ |
155 V(FixedTypedArrayBase, empty_fixed_int16_array, EmptyFixedInt16Array) \ | 144 V(FixedTypedArrayBase, empty_fixed_int16_array, EmptyFixedInt16Array) \ |
156 V(FixedTypedArrayBase, empty_fixed_uint32_array, EmptyFixedUint32Array) \ | 145 V(FixedTypedArrayBase, empty_fixed_uint32_array, EmptyFixedUint32Array) \ |
157 V(FixedTypedArrayBase, empty_fixed_int32_array, EmptyFixedInt32Array) \ | 146 V(FixedTypedArrayBase, empty_fixed_int32_array, EmptyFixedInt32Array) \ |
158 V(FixedTypedArrayBase, empty_fixed_float32_array, EmptyFixedFloat32Array) \ | 147 V(FixedTypedArrayBase, empty_fixed_float32_array, EmptyFixedFloat32Array) \ |
159 V(FixedTypedArrayBase, empty_fixed_float64_array, EmptyFixedFloat64Array) \ | 148 V(FixedTypedArrayBase, empty_fixed_float64_array, EmptyFixedFloat64Array) \ |
160 V(FixedTypedArrayBase, empty_fixed_uint8_clamped_array, \ | 149 V(FixedTypedArrayBase, empty_fixed_uint8_clamped_array, \ |
161 EmptyFixedUint8ClampedArray) \ | 150 EmptyFixedUint8ClampedArray) \ |
162 V(Script, empty_script, EmptyScript) \ | 151 V(Script, empty_script, EmptyScript) \ |
163 V(Cell, undefined_cell, UndefinedCell) \ | 152 V(Cell, undefined_cell, UndefinedCell) \ |
164 V(FixedArray, empty_sloppy_arguments_elements, EmptySloppyArgumentsElements) \ | 153 V(FixedArray, empty_sloppy_arguments_elements, EmptySloppyArgumentsElements) \ |
165 V(SeededNumberDictionary, empty_slow_element_dictionary, \ | 154 V(SeededNumberDictionary, empty_slow_element_dictionary, \ |
166 EmptySlowElementDictionary) \ | 155 EmptySlowElementDictionary) \ |
167 V(PropertyCell, empty_property_cell, EmptyPropertyCell) \ | 156 V(PropertyCell, empty_property_cell, EmptyPropertyCell) \ |
168 V(WeakCell, empty_weak_cell, EmptyWeakCell) \ | 157 V(WeakCell, empty_weak_cell, EmptyWeakCell) \ |
169 V(InterceptorInfo, noop_interceptor_info, NoOpInterceptorInfo) \ | |
170 /* Protectors */ \ | 158 /* Protectors */ \ |
171 V(PropertyCell, array_protector, ArrayProtector) \ | 159 V(PropertyCell, array_protector, ArrayProtector) \ |
172 V(Cell, is_concat_spreadable_protector, IsConcatSpreadableProtector) \ | 160 V(Cell, is_concat_spreadable_protector, IsConcatSpreadableProtector) \ |
173 V(Cell, species_protector, SpeciesProtector) \ | 161 V(Cell, species_protector, SpeciesProtector) \ |
174 V(PropertyCell, string_length_protector, StringLengthProtector) \ | 162 V(PropertyCell, string_length_protector, StringLengthProtector) \ |
175 V(Cell, fast_array_iteration_protector, FastArrayIterationProtector) \ | 163 V(Cell, fast_array_iteration_protector, FastArrayIterationProtector) \ |
176 V(PropertyCell, array_iterator_protector, ArrayIteratorProtector) \ | 164 V(PropertyCell, array_iterator_protector, ArrayIteratorProtector) \ |
177 V(PropertyCell, array_buffer_neutering_protector, \ | 165 V(PropertyCell, array_buffer_neutering_protector, \ |
178 ArrayBufferNeuteringProtector) \ | 166 ArrayBufferNeuteringProtector) \ |
179 /* JS Entries */ \ | |
180 V(Code, js_entry_code, JsEntryCode) \ | |
181 V(Code, js_construct_entry_code, JsConstructEntryCode) \ | |
182 /* Special numbers */ \ | 167 /* Special numbers */ \ |
183 V(HeapNumber, nan_value, NanValue) \ | 168 V(HeapNumber, nan_value, NanValue) \ |
184 V(HeapNumber, hole_nan_value, HoleNanValue) \ | 169 V(HeapNumber, hole_nan_value, HoleNanValue) \ |
185 V(HeapNumber, infinity_value, InfinityValue) \ | 170 V(HeapNumber, infinity_value, InfinityValue) \ |
186 V(HeapNumber, minus_zero_value, MinusZeroValue) \ | 171 V(HeapNumber, minus_zero_value, MinusZeroValue) \ |
187 V(HeapNumber, minus_infinity_value, MinusInfinityValue) \ | 172 V(HeapNumber, minus_infinity_value, MinusInfinityValue) \ |
188 /* Caches */ \ | 173 /* Caches */ \ |
189 V(FixedArray, number_string_cache, NumberStringCache) \ | 174 V(FixedArray, number_string_cache, NumberStringCache) \ |
190 V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \ | 175 V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \ |
191 V(FixedArray, string_split_cache, StringSplitCache) \ | 176 V(FixedArray, string_split_cache, StringSplitCache) \ |
(...skipping 17 matching lines...) Expand all Loading... |
209 /* slots with even indices refer to the weak object, and the subsequent */ \ | 194 /* slots with even indices refer to the weak object, and the subsequent */ \ |
210 /* slots refer to the code with the reference to the weak object. */ \ | 195 /* slots refer to the code with the reference to the weak object. */ \ |
211 V(ArrayList, weak_new_space_object_to_code_list, \ | 196 V(ArrayList, weak_new_space_object_to_code_list, \ |
212 WeakNewSpaceObjectToCodeList) \ | 197 WeakNewSpaceObjectToCodeList) \ |
213 /* List to hold onto feedback vectors that we need for code coverage */ \ | 198 /* List to hold onto feedback vectors that we need for code coverage */ \ |
214 V(Object, code_coverage_list, CodeCoverageList) \ | 199 V(Object, code_coverage_list, CodeCoverageList) \ |
215 V(Object, weak_stack_trace_list, WeakStackTraceList) \ | 200 V(Object, weak_stack_trace_list, WeakStackTraceList) \ |
216 V(Object, noscript_shared_function_infos, NoScriptSharedFunctionInfos) \ | 201 V(Object, noscript_shared_function_infos, NoScriptSharedFunctionInfos) \ |
217 V(FixedArray, serialized_templates, SerializedTemplates) \ | 202 V(FixedArray, serialized_templates, SerializedTemplates) \ |
218 V(FixedArray, serialized_global_proxy_sizes, SerializedGlobalProxySizes) \ | 203 V(FixedArray, serialized_global_proxy_sizes, SerializedGlobalProxySizes) \ |
| 204 /* Configured values */ \ |
219 V(TemplateList, message_listeners, MessageListeners) \ | 205 V(TemplateList, message_listeners, MessageListeners) \ |
| 206 V(InterceptorInfo, noop_interceptor_info, NoOpInterceptorInfo) \ |
| 207 V(Code, js_entry_code, JsEntryCode) \ |
| 208 V(Code, js_construct_entry_code, JsConstructEntryCode) \ |
| 209 /* Oddball maps */ \ |
| 210 V(Map, undefined_map, UndefinedMap) \ |
| 211 V(Map, the_hole_map, TheHoleMap) \ |
| 212 V(Map, null_map, NullMap) \ |
| 213 V(Map, boolean_map, BooleanMap) \ |
| 214 V(Map, uninitialized_map, UninitializedMap) \ |
| 215 V(Map, arguments_marker_map, ArgumentsMarkerMap) \ |
| 216 V(Map, exception_map, ExceptionMap) \ |
| 217 V(Map, termination_exception_map, TerminationExceptionMap) \ |
| 218 V(Map, optimized_out_map, OptimizedOutMap) \ |
| 219 V(Map, stale_register_map, StaleRegisterMap) \ |
220 /* per-Isolate map for JSPromiseCapability. */ \ | 220 /* per-Isolate map for JSPromiseCapability. */ \ |
221 /* TODO(caitp): Make this a Struct */ \ | 221 /* TODO(caitp): Make this a Struct */ \ |
222 V(Map, js_promise_capability_map, JSPromiseCapabilityMap) | 222 V(Map, js_promise_capability_map, JSPromiseCapabilityMap) |
223 | 223 |
224 // Entries in this list are limited to Smis and are not visited during GC. | 224 // Entries in this list are limited to Smis and are not visited during GC. |
225 #define SMI_ROOT_LIST(V) \ | 225 #define SMI_ROOT_LIST(V) \ |
226 V(Smi, stack_limit, StackLimit) \ | 226 V(Smi, stack_limit, StackLimit) \ |
227 V(Smi, real_stack_limit, RealStackLimit) \ | 227 V(Smi, real_stack_limit, RealStackLimit) \ |
228 V(Smi, last_script_id, LastScriptId) \ | 228 V(Smi, last_script_id, LastScriptId) \ |
229 V(Smi, hash_seed, HashSeed) \ | 229 V(Smi, hash_seed, HashSeed) \ |
(...skipping 11 matching lines...) Expand all Loading... |
241 | 241 |
242 #define ROOT_LIST(V) \ | 242 #define ROOT_LIST(V) \ |
243 STRONG_ROOT_LIST(V) \ | 243 STRONG_ROOT_LIST(V) \ |
244 SMI_ROOT_LIST(V) \ | 244 SMI_ROOT_LIST(V) \ |
245 V(StringTable, string_table, StringTable) | 245 V(StringTable, string_table, StringTable) |
246 | 246 |
247 | 247 |
248 // Heap roots that are known to be immortal immovable, for which we can safely | 248 // Heap roots that are known to be immortal immovable, for which we can safely |
249 // skip write barriers. This list is not complete and has omissions. | 249 // skip write barriers. This list is not complete and has omissions. |
250 #define IMMORTAL_IMMOVABLE_ROOT_LIST(V) \ | 250 #define IMMORTAL_IMMOVABLE_ROOT_LIST(V) \ |
251 V(ArgumentsMarker) \ | |
252 V(ArgumentsMarkerMap) \ | |
253 V(ArrayBufferNeuteringProtector) \ | |
254 V(ArrayIteratorProtector) \ | |
255 V(ArrayProtector) \ | |
256 V(BlockContextMap) \ | |
257 V(BooleanMap) \ | |
258 V(ByteArrayMap) \ | 251 V(ByteArrayMap) \ |
259 V(BytecodeArrayMap) \ | 252 V(BytecodeArrayMap) \ |
260 V(CatchContextMap) \ | 253 V(FreeSpaceMap) \ |
| 254 V(OnePointerFillerMap) \ |
| 255 V(TwoPointerFillerMap) \ |
| 256 V(UndefinedValue) \ |
| 257 V(TheHoleValue) \ |
| 258 V(NullValue) \ |
| 259 V(TrueValue) \ |
| 260 V(FalseValue) \ |
| 261 V(UninitializedValue) \ |
261 V(CellMap) \ | 262 V(CellMap) \ |
| 263 V(GlobalPropertyCellMap) \ |
| 264 V(SharedFunctionInfoMap) \ |
| 265 V(MetaMap) \ |
| 266 V(HeapNumberMap) \ |
| 267 V(MutableHeapNumberMap) \ |
| 268 V(NativeContextMap) \ |
| 269 V(FixedArrayMap) \ |
262 V(CodeMap) \ | 270 V(CodeMap) \ |
| 271 V(ScopeInfoMap) \ |
| 272 V(ModuleInfoMap) \ |
| 273 V(FixedCOWArrayMap) \ |
| 274 V(FixedDoubleArrayMap) \ |
| 275 V(WeakCellMap) \ |
| 276 V(TransitionArrayMap) \ |
| 277 V(HashTableMap) \ |
| 278 V(OrderedHashTableMap) \ |
| 279 V(EmptyFixedArray) \ |
263 V(EmptyByteArray) \ | 280 V(EmptyByteArray) \ |
264 V(EmptyDescriptorArray) \ | 281 V(EmptyDescriptorArray) \ |
265 V(EmptyFixedArray) \ | 282 V(ArgumentsMarker) \ |
266 V(EmptyFixedFloat32Array) \ | 283 V(SymbolMap) \ |
267 V(EmptyFixedFloat64Array) \ | 284 V(SloppyArgumentsElementsMap) \ |
268 V(EmptyFixedInt16Array) \ | 285 V(FunctionContextMap) \ |
269 V(EmptyFixedInt32Array) \ | 286 V(CatchContextMap) \ |
270 V(EmptyFixedInt8Array) \ | 287 V(WithContextMap) \ |
271 V(EmptyFixedUint16Array) \ | 288 V(BlockContextMap) \ |
272 V(EmptyFixedUint32Array) \ | 289 V(ModuleContextMap) \ |
273 V(EmptyFixedUint8Array) \ | 290 V(EvalContextMap) \ |
274 V(EmptyFixedUint8ClampedArray) \ | 291 V(ScriptContextMap) \ |
275 V(EmptyPropertyCell) \ | 292 V(UndefinedMap) \ |
276 V(EmptyScopeInfo) \ | 293 V(TheHoleMap) \ |
277 V(EmptyScript) \ | 294 V(NullMap) \ |
278 V(EmptySloppyArgumentsElements) \ | 295 V(BooleanMap) \ |
279 V(EmptySlowElementDictionary) \ | 296 V(UninitializedMap) \ |
| 297 V(ArgumentsMarkerMap) \ |
| 298 V(JSMessageObjectMap) \ |
| 299 V(ForeignMap) \ |
| 300 V(NoClosuresCellMap) \ |
| 301 V(OneClosureCellMap) \ |
| 302 V(ManyClosuresCellMap) \ |
| 303 V(NanValue) \ |
| 304 V(InfinityValue) \ |
| 305 V(MinusZeroValue) \ |
| 306 V(MinusInfinityValue) \ |
| 307 V(EmptyWeakCell) \ |
280 V(empty_string) \ | 308 V(empty_string) \ |
281 V(EmptyWeakCell) \ | |
282 V(EvalContextMap) \ | |
283 V(Exception) \ | |
284 V(FalseValue) \ | |
285 V(FastArrayIterationProtector) \ | |
286 V(FixedArrayMap) \ | |
287 V(FixedCOWArrayMap) \ | |
288 V(FixedDoubleArrayMap) \ | |
289 V(ForeignMap) \ | |
290 V(FreeSpaceMap) \ | |
291 V(FunctionContextMap) \ | |
292 V(GlobalPropertyCellMap) \ | |
293 V(HashTableMap) \ | |
294 V(HeapNumberMap) \ | |
295 V(HoleNanValue) \ | |
296 V(InfinityValue) \ | |
297 V(IsConcatSpreadableProtector) \ | |
298 V(JsConstructEntryCode) \ | |
299 V(JsEntryCode) \ | |
300 V(JSMessageObjectMap) \ | |
301 V(ManyClosuresCellMap) \ | |
302 V(MetaMap) \ | |
303 V(MinusInfinityValue) \ | |
304 V(MinusZeroValue) \ | |
305 V(ModuleContextMap) \ | |
306 V(ModuleInfoMap) \ | |
307 V(MutableHeapNumberMap) \ | |
308 V(NanValue) \ | |
309 V(NativeContextMap) \ | |
310 V(NoClosuresCellMap) \ | |
311 V(NullMap) \ | |
312 V(NullValue) \ | |
313 V(OneClosureCellMap) \ | |
314 V(OnePointerFillerMap) \ | |
315 V(OptimizedOut) \ | |
316 V(OrderedHashTableMap) \ | |
317 V(ScopeInfoMap) \ | |
318 V(ScriptContextMap) \ | |
319 V(SharedFunctionInfoMap) \ | |
320 V(SloppyArgumentsElementsMap) \ | |
321 V(SpeciesProtector) \ | |
322 V(StaleRegister) \ | |
323 V(StringLengthProtector) \ | |
324 V(SymbolMap) \ | |
325 V(TerminationException) \ | |
326 V(TheHoleMap) \ | |
327 V(TheHoleValue) \ | |
328 V(TransitionArrayMap) \ | |
329 V(TrueValue) \ | |
330 V(TwoPointerFillerMap) \ | |
331 V(UndefinedCell) \ | |
332 V(UndefinedMap) \ | |
333 V(UndefinedValue) \ | |
334 V(UninitializedMap) \ | |
335 V(UninitializedValue) \ | |
336 V(WeakCellMap) \ | |
337 V(WithContextMap) \ | |
338 PRIVATE_SYMBOL_LIST(V) | 309 PRIVATE_SYMBOL_LIST(V) |
339 | 310 |
340 // Forward declarations. | 311 // Forward declarations. |
341 class AllocationObserver; | 312 class AllocationObserver; |
342 class ArrayBufferTracker; | 313 class ArrayBufferTracker; |
343 class ConcurrentMarking; | 314 class ConcurrentMarking; |
344 class GCIdleTimeAction; | 315 class GCIdleTimeAction; |
345 class GCIdleTimeHandler; | 316 class GCIdleTimeHandler; |
346 class GCIdleTimeHeapState; | 317 class GCIdleTimeHeapState; |
347 class GCTracer; | 318 class GCTracer; |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 // Calculates the actual amount of filler required for a given address at the | 659 // Calculates the actual amount of filler required for a given address at the |
689 // given alignment. | 660 // given alignment. |
690 static int GetFillToAlign(Address address, AllocationAlignment alignment); | 661 static int GetFillToAlign(Address address, AllocationAlignment alignment); |
691 | 662 |
692 template <typename T> | 663 template <typename T> |
693 static inline bool IsOneByte(T t, int chars); | 664 static inline bool IsOneByte(T t, int chars); |
694 | 665 |
695 static void FatalProcessOutOfMemory(const char* location, | 666 static void FatalProcessOutOfMemory(const char* location, |
696 bool is_heap_oom = false); | 667 bool is_heap_oom = false); |
697 | 668 |
698 V8_EXPORT_PRIVATE static bool RootIsImmortalImmovable(int root_index); | 669 static bool RootIsImmortalImmovable(int root_index); |
699 | 670 |
700 // Checks whether the space is valid. | 671 // Checks whether the space is valid. |
701 static bool IsValidAllocationSpace(AllocationSpace space); | 672 static bool IsValidAllocationSpace(AllocationSpace space); |
702 | 673 |
703 // Generated code can embed direct references to non-writable roots if | 674 // Generated code can embed direct references to non-writable roots if |
704 // they are in new space. | 675 // they are in new space. |
705 static bool RootCanBeWrittenAfterInitialization(RootListIndex root_index); | 676 static bool RootCanBeWrittenAfterInitialization(RootListIndex root_index); |
706 | 677 |
707 static bool IsUnmodifiedHeapObject(Object** p); | 678 static bool IsUnmodifiedHeapObject(Object** p); |
708 | 679 |
(...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2652 friend class LargeObjectSpace; | 2623 friend class LargeObjectSpace; |
2653 friend class NewSpace; | 2624 friend class NewSpace; |
2654 friend class PagedSpace; | 2625 friend class PagedSpace; |
2655 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); | 2626 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); |
2656 }; | 2627 }; |
2657 | 2628 |
2658 } // namespace internal | 2629 } // namespace internal |
2659 } // namespace v8 | 2630 } // namespace v8 |
2660 | 2631 |
2661 #endif // V8_HEAP_HEAP_H_ | 2632 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |