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) \ |
139 /* Canonical empty values */ \ | 150 /* Canonical empty values */ \ |
140 V(ByteArray, empty_byte_array, EmptyByteArray) \ | 151 V(ByteArray, empty_byte_array, EmptyByteArray) \ |
141 V(FixedTypedArrayBase, empty_fixed_uint8_array, EmptyFixedUint8Array) \ | 152 V(FixedTypedArrayBase, empty_fixed_uint8_array, EmptyFixedUint8Array) \ |
142 V(FixedTypedArrayBase, empty_fixed_int8_array, EmptyFixedInt8Array) \ | 153 V(FixedTypedArrayBase, empty_fixed_int8_array, EmptyFixedInt8Array) \ |
143 V(FixedTypedArrayBase, empty_fixed_uint16_array, EmptyFixedUint16Array) \ | 154 V(FixedTypedArrayBase, empty_fixed_uint16_array, EmptyFixedUint16Array) \ |
144 V(FixedTypedArrayBase, empty_fixed_int16_array, EmptyFixedInt16Array) \ | 155 V(FixedTypedArrayBase, empty_fixed_int16_array, EmptyFixedInt16Array) \ |
145 V(FixedTypedArrayBase, empty_fixed_uint32_array, EmptyFixedUint32Array) \ | 156 V(FixedTypedArrayBase, empty_fixed_uint32_array, EmptyFixedUint32Array) \ |
146 V(FixedTypedArrayBase, empty_fixed_int32_array, EmptyFixedInt32Array) \ | 157 V(FixedTypedArrayBase, empty_fixed_int32_array, EmptyFixedInt32Array) \ |
147 V(FixedTypedArrayBase, empty_fixed_float32_array, EmptyFixedFloat32Array) \ | 158 V(FixedTypedArrayBase, empty_fixed_float32_array, EmptyFixedFloat32Array) \ |
148 V(FixedTypedArrayBase, empty_fixed_float64_array, EmptyFixedFloat64Array) \ | 159 V(FixedTypedArrayBase, empty_fixed_float64_array, EmptyFixedFloat64Array) \ |
149 V(FixedTypedArrayBase, empty_fixed_uint8_clamped_array, \ | 160 V(FixedTypedArrayBase, empty_fixed_uint8_clamped_array, \ |
150 EmptyFixedUint8ClampedArray) \ | 161 EmptyFixedUint8ClampedArray) \ |
151 V(Script, empty_script, EmptyScript) \ | 162 V(Script, empty_script, EmptyScript) \ |
152 V(Cell, undefined_cell, UndefinedCell) \ | 163 V(Cell, undefined_cell, UndefinedCell) \ |
153 V(FixedArray, empty_sloppy_arguments_elements, EmptySloppyArgumentsElements) \ | 164 V(FixedArray, empty_sloppy_arguments_elements, EmptySloppyArgumentsElements) \ |
154 V(SeededNumberDictionary, empty_slow_element_dictionary, \ | 165 V(SeededNumberDictionary, empty_slow_element_dictionary, \ |
155 EmptySlowElementDictionary) \ | 166 EmptySlowElementDictionary) \ |
156 V(PropertyCell, empty_property_cell, EmptyPropertyCell) \ | 167 V(PropertyCell, empty_property_cell, EmptyPropertyCell) \ |
157 V(WeakCell, empty_weak_cell, EmptyWeakCell) \ | 168 V(WeakCell, empty_weak_cell, EmptyWeakCell) \ |
| 169 V(InterceptorInfo, noop_interceptor_info, NoOpInterceptorInfo) \ |
158 /* Protectors */ \ | 170 /* Protectors */ \ |
159 V(PropertyCell, array_protector, ArrayProtector) \ | 171 V(PropertyCell, array_protector, ArrayProtector) \ |
160 V(Cell, is_concat_spreadable_protector, IsConcatSpreadableProtector) \ | 172 V(Cell, is_concat_spreadable_protector, IsConcatSpreadableProtector) \ |
161 V(Cell, species_protector, SpeciesProtector) \ | 173 V(Cell, species_protector, SpeciesProtector) \ |
162 V(PropertyCell, string_length_protector, StringLengthProtector) \ | 174 V(PropertyCell, string_length_protector, StringLengthProtector) \ |
163 V(Cell, fast_array_iteration_protector, FastArrayIterationProtector) \ | 175 V(Cell, fast_array_iteration_protector, FastArrayIterationProtector) \ |
164 V(PropertyCell, array_iterator_protector, ArrayIteratorProtector) \ | 176 V(PropertyCell, array_iterator_protector, ArrayIteratorProtector) \ |
165 V(PropertyCell, array_buffer_neutering_protector, \ | 177 V(PropertyCell, array_buffer_neutering_protector, \ |
166 ArrayBufferNeuteringProtector) \ | 178 ArrayBufferNeuteringProtector) \ |
167 /* Special numbers */ \ | 179 /* Special numbers */ \ |
(...skipping 26 matching lines...) Expand all Loading... |
194 /* slots with even indices refer to the weak object, and the subsequent */ \ | 206 /* slots with even indices refer to the weak object, and the subsequent */ \ |
195 /* slots refer to the code with the reference to the weak object. */ \ | 207 /* slots refer to the code with the reference to the weak object. */ \ |
196 V(ArrayList, weak_new_space_object_to_code_list, \ | 208 V(ArrayList, weak_new_space_object_to_code_list, \ |
197 WeakNewSpaceObjectToCodeList) \ | 209 WeakNewSpaceObjectToCodeList) \ |
198 /* List to hold onto feedback vectors that we need for code coverage */ \ | 210 /* List to hold onto feedback vectors that we need for code coverage */ \ |
199 V(Object, code_coverage_list, CodeCoverageList) \ | 211 V(Object, code_coverage_list, CodeCoverageList) \ |
200 V(Object, weak_stack_trace_list, WeakStackTraceList) \ | 212 V(Object, weak_stack_trace_list, WeakStackTraceList) \ |
201 V(Object, noscript_shared_function_infos, NoScriptSharedFunctionInfos) \ | 213 V(Object, noscript_shared_function_infos, NoScriptSharedFunctionInfos) \ |
202 V(FixedArray, serialized_templates, SerializedTemplates) \ | 214 V(FixedArray, serialized_templates, SerializedTemplates) \ |
203 V(FixedArray, serialized_global_proxy_sizes, SerializedGlobalProxySizes) \ | 215 V(FixedArray, serialized_global_proxy_sizes, SerializedGlobalProxySizes) \ |
204 /* Configured values */ \ | |
205 V(TemplateList, message_listeners, MessageListeners) \ | 216 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. */ \ | 217 /* per-Isolate map for JSPromiseCapability. */ \ |
221 /* TODO(caitp): Make this a Struct */ \ | 218 /* TODO(caitp): Make this a Struct */ \ |
222 V(Map, js_promise_capability_map, JSPromiseCapabilityMap) | 219 V(Map, js_promise_capability_map, JSPromiseCapabilityMap) \ |
| 220 /* JS Entries */ \ |
| 221 V(Code, js_entry_code, JsEntryCode) \ |
| 222 V(Code, js_construct_entry_code, JsConstructEntryCode) |
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) \ |
230 /* To distinguish the function templates, so that we can find them in the */ \ | 230 /* To distinguish the function templates, so that we can find them in the */ \ |
231 /* function cache of the native context. */ \ | 231 /* function cache of the native context. */ \ |
232 V(Smi, next_template_serial_number, NextTemplateSerialNumber) \ | 232 V(Smi, next_template_serial_number, NextTemplateSerialNumber) \ |
233 V(Smi, arguments_adaptor_deopt_pc_offset, ArgumentsAdaptorDeoptPCOffset) \ | 233 V(Smi, arguments_adaptor_deopt_pc_offset, ArgumentsAdaptorDeoptPCOffset) \ |
234 V(Smi, construct_stub_create_deopt_pc_offset, \ | 234 V(Smi, construct_stub_create_deopt_pc_offset, \ |
235 ConstructStubCreateDeoptPCOffset) \ | 235 ConstructStubCreateDeoptPCOffset) \ |
236 V(Smi, construct_stub_invoke_deopt_pc_offset, \ | 236 V(Smi, construct_stub_invoke_deopt_pc_offset, \ |
237 ConstructStubInvokeDeoptPCOffset) \ | 237 ConstructStubInvokeDeoptPCOffset) \ |
238 V(Smi, getter_stub_deopt_pc_offset, GetterStubDeoptPCOffset) \ | 238 V(Smi, getter_stub_deopt_pc_offset, GetterStubDeoptPCOffset) \ |
239 V(Smi, setter_stub_deopt_pc_offset, SetterStubDeoptPCOffset) \ | 239 V(Smi, setter_stub_deopt_pc_offset, SetterStubDeoptPCOffset) \ |
240 V(Smi, interpreter_entry_return_pc_offset, InterpreterEntryReturnPCOffset) | 240 V(Smi, interpreter_entry_return_pc_offset, InterpreterEntryReturnPCOffset) |
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) \ |
251 V(ByteArrayMap) \ | 258 V(ByteArrayMap) \ |
252 V(BytecodeArrayMap) \ | 259 V(BytecodeArrayMap) \ |
253 V(FreeSpaceMap) \ | 260 V(CatchContextMap) \ |
254 V(OnePointerFillerMap) \ | 261 V(CellMap) \ |
255 V(TwoPointerFillerMap) \ | 262 V(CodeMap) \ |
256 V(UndefinedValue) \ | 263 V(EmptyByteArray) \ |
257 V(TheHoleValue) \ | 264 V(EmptyDescriptorArray) \ |
258 V(NullValue) \ | 265 V(EmptyFixedArray) \ |
259 V(TrueValue) \ | 266 V(EmptyFixedFloat32Array) \ |
| 267 V(EmptyFixedFloat64Array) \ |
| 268 V(EmptyFixedInt16Array) \ |
| 269 V(EmptyFixedInt32Array) \ |
| 270 V(EmptyFixedInt8Array) \ |
| 271 V(EmptyFixedUint16Array) \ |
| 272 V(EmptyFixedUint32Array) \ |
| 273 V(EmptyFixedUint8Array) \ |
| 274 V(EmptyFixedUint8ClampedArray) \ |
| 275 V(EmptyPropertyCell) \ |
| 276 V(EmptyScopeInfo) \ |
| 277 V(EmptyScript) \ |
| 278 V(EmptySloppyArgumentsElements) \ |
| 279 V(EmptySlowElementDictionary) \ |
| 280 V(empty_string) \ |
| 281 V(EmptyWeakCell) \ |
| 282 V(EvalContextMap) \ |
| 283 V(Exception) \ |
260 V(FalseValue) \ | 284 V(FalseValue) \ |
261 V(UninitializedValue) \ | 285 V(FastArrayIterationProtector) \ |
262 V(CellMap) \ | |
263 V(GlobalPropertyCellMap) \ | |
264 V(SharedFunctionInfoMap) \ | |
265 V(MetaMap) \ | |
266 V(HeapNumberMap) \ | |
267 V(MutableHeapNumberMap) \ | |
268 V(NativeContextMap) \ | |
269 V(FixedArrayMap) \ | 286 V(FixedArrayMap) \ |
270 V(CodeMap) \ | |
271 V(ScopeInfoMap) \ | |
272 V(ModuleInfoMap) \ | |
273 V(FixedCOWArrayMap) \ | 287 V(FixedCOWArrayMap) \ |
274 V(FixedDoubleArrayMap) \ | 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) \ |
275 V(WeakCellMap) \ | 336 V(WeakCellMap) \ |
276 V(TransitionArrayMap) \ | |
277 V(HashTableMap) \ | |
278 V(OrderedHashTableMap) \ | |
279 V(EmptyFixedArray) \ | |
280 V(EmptyByteArray) \ | |
281 V(EmptyDescriptorArray) \ | |
282 V(ArgumentsMarker) \ | |
283 V(SymbolMap) \ | |
284 V(SloppyArgumentsElementsMap) \ | |
285 V(FunctionContextMap) \ | |
286 V(CatchContextMap) \ | |
287 V(WithContextMap) \ | 337 V(WithContextMap) \ |
288 V(BlockContextMap) \ | |
289 V(ModuleContextMap) \ | |
290 V(EvalContextMap) \ | |
291 V(ScriptContextMap) \ | |
292 V(UndefinedMap) \ | |
293 V(TheHoleMap) \ | |
294 V(NullMap) \ | |
295 V(BooleanMap) \ | |
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) \ | |
308 V(empty_string) \ | |
309 PRIVATE_SYMBOL_LIST(V) | 338 PRIVATE_SYMBOL_LIST(V) |
310 | 339 |
311 // Forward declarations. | 340 // Forward declarations. |
312 class AllocationObserver; | 341 class AllocationObserver; |
313 class ArrayBufferTracker; | 342 class ArrayBufferTracker; |
314 class ConcurrentMarking; | 343 class ConcurrentMarking; |
315 class GCIdleTimeAction; | 344 class GCIdleTimeAction; |
316 class GCIdleTimeHandler; | 345 class GCIdleTimeHandler; |
317 class GCIdleTimeHeapState; | 346 class GCIdleTimeHeapState; |
318 class GCTracer; | 347 class GCTracer; |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 // Calculates the actual amount of filler required for a given address at the | 688 // Calculates the actual amount of filler required for a given address at the |
660 // given alignment. | 689 // given alignment. |
661 static int GetFillToAlign(Address address, AllocationAlignment alignment); | 690 static int GetFillToAlign(Address address, AllocationAlignment alignment); |
662 | 691 |
663 template <typename T> | 692 template <typename T> |
664 static inline bool IsOneByte(T t, int chars); | 693 static inline bool IsOneByte(T t, int chars); |
665 | 694 |
666 static void FatalProcessOutOfMemory(const char* location, | 695 static void FatalProcessOutOfMemory(const char* location, |
667 bool is_heap_oom = false); | 696 bool is_heap_oom = false); |
668 | 697 |
669 static bool RootIsImmortalImmovable(int root_index); | 698 V8_EXPORT_PRIVATE static bool RootIsImmortalImmovable(int root_index); |
670 | 699 |
671 // Checks whether the space is valid. | 700 // Checks whether the space is valid. |
672 static bool IsValidAllocationSpace(AllocationSpace space); | 701 static bool IsValidAllocationSpace(AllocationSpace space); |
673 | 702 |
674 // Generated code can embed direct references to non-writable roots if | 703 // Generated code can embed direct references to non-writable roots if |
675 // they are in new space. | 704 // they are in new space. |
676 static bool RootCanBeWrittenAfterInitialization(RootListIndex root_index); | 705 static bool RootCanBeWrittenAfterInitialization(RootListIndex root_index); |
677 | 706 |
678 static bool IsUnmodifiedHeapObject(Object** p); | 707 static bool IsUnmodifiedHeapObject(Object** p); |
679 | 708 |
(...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2623 friend class LargeObjectSpace; | 2652 friend class LargeObjectSpace; |
2624 friend class NewSpace; | 2653 friend class NewSpace; |
2625 friend class PagedSpace; | 2654 friend class PagedSpace; |
2626 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); | 2655 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); |
2627 }; | 2656 }; |
2628 | 2657 |
2629 } // namespace internal | 2658 } // namespace internal |
2630 } // namespace v8 | 2659 } // namespace v8 |
2631 | 2660 |
2632 #endif // V8_HEAP_HEAP_H_ | 2661 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |