OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 V(Map, scope_info_map, ScopeInfoMap) \ | 71 V(Map, scope_info_map, ScopeInfoMap) \ |
72 V(Map, fixed_cow_array_map, FixedCOWArrayMap) \ | 72 V(Map, fixed_cow_array_map, FixedCOWArrayMap) \ |
73 V(Map, fixed_double_array_map, FixedDoubleArrayMap) \ | 73 V(Map, fixed_double_array_map, FixedDoubleArrayMap) \ |
74 V(Map, constant_pool_array_map, ConstantPoolArrayMap) \ | 74 V(Map, constant_pool_array_map, ConstantPoolArrayMap) \ |
75 V(Object, no_interceptor_result_sentinel, NoInterceptorResultSentinel) \ | 75 V(Object, no_interceptor_result_sentinel, NoInterceptorResultSentinel) \ |
76 V(Map, hash_table_map, HashTableMap) \ | 76 V(Map, hash_table_map, HashTableMap) \ |
77 V(FixedArray, empty_fixed_array, EmptyFixedArray) \ | 77 V(FixedArray, empty_fixed_array, EmptyFixedArray) \ |
78 V(ByteArray, empty_byte_array, EmptyByteArray) \ | 78 V(ByteArray, empty_byte_array, EmptyByteArray) \ |
79 V(DescriptorArray, empty_descriptor_array, EmptyDescriptorArray) \ | 79 V(DescriptorArray, empty_descriptor_array, EmptyDescriptorArray) \ |
80 V(ConstantPoolArray, empty_constant_pool_array, EmptyConstantPoolArray) \ | 80 V(ConstantPoolArray, empty_constant_pool_array, EmptyConstantPoolArray) \ |
81 V(Smi, stack_limit, StackLimit) \ | |
82 V(Oddball, arguments_marker, ArgumentsMarker) \ | 81 V(Oddball, arguments_marker, ArgumentsMarker) \ |
83 /* The roots above this line should be boring from a GC point of view. */ \ | 82 /* The roots above this line should be boring from a GC point of view. */ \ |
84 /* This means they are never in new space and never on a page that is */ \ | 83 /* This means they are never in new space and never on a page that is */ \ |
85 /* being compacted. */ \ | 84 /* being compacted. */ \ |
86 V(FixedArray, number_string_cache, NumberStringCache) \ | 85 V(FixedArray, number_string_cache, NumberStringCache) \ |
87 V(Object, instanceof_cache_function, InstanceofCacheFunction) \ | 86 V(Object, instanceof_cache_function, InstanceofCacheFunction) \ |
88 V(Object, instanceof_cache_map, InstanceofCacheMap) \ | 87 V(Object, instanceof_cache_map, InstanceofCacheMap) \ |
89 V(Object, instanceof_cache_answer, InstanceofCacheAnswer) \ | 88 V(Object, instanceof_cache_answer, InstanceofCacheAnswer) \ |
90 V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \ | 89 V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \ |
91 V(FixedArray, string_split_cache, StringSplitCache) \ | 90 V(FixedArray, string_split_cache, StringSplitCache) \ |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 V(HeapNumber, infinity_value, InfinityValue) \ | 178 V(HeapNumber, infinity_value, InfinityValue) \ |
180 V(HeapNumber, minus_zero_value, MinusZeroValue) \ | 179 V(HeapNumber, minus_zero_value, MinusZeroValue) \ |
181 V(Map, neander_map, NeanderMap) \ | 180 V(Map, neander_map, NeanderMap) \ |
182 V(JSObject, message_listeners, MessageListeners) \ | 181 V(JSObject, message_listeners, MessageListeners) \ |
183 V(UnseededNumberDictionary, code_stubs, CodeStubs) \ | 182 V(UnseededNumberDictionary, code_stubs, CodeStubs) \ |
184 V(UnseededNumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ | 183 V(UnseededNumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ |
185 V(PolymorphicCodeCache, polymorphic_code_cache, PolymorphicCodeCache) \ | 184 V(PolymorphicCodeCache, polymorphic_code_cache, PolymorphicCodeCache) \ |
186 V(Code, js_entry_code, JsEntryCode) \ | 185 V(Code, js_entry_code, JsEntryCode) \ |
187 V(Code, js_construct_entry_code, JsConstructEntryCode) \ | 186 V(Code, js_construct_entry_code, JsConstructEntryCode) \ |
188 V(FixedArray, natives_source_cache, NativesSourceCache) \ | 187 V(FixedArray, natives_source_cache, NativesSourceCache) \ |
189 V(Smi, last_script_id, LastScriptId) \ | |
190 V(Script, empty_script, EmptyScript) \ | 188 V(Script, empty_script, EmptyScript) \ |
191 V(Smi, real_stack_limit, RealStackLimit) \ | |
192 V(NameDictionary, intrinsic_function_names, IntrinsicFunctionNames) \ | 189 V(NameDictionary, intrinsic_function_names, IntrinsicFunctionNames) \ |
193 V(Smi, arguments_adaptor_deopt_pc_offset, ArgumentsAdaptorDeoptPCOffset) \ | |
194 V(Smi, construct_stub_deopt_pc_offset, ConstructStubDeoptPCOffset) \ | |
195 V(Smi, getter_stub_deopt_pc_offset, GetterStubDeoptPCOffset) \ | |
196 V(Smi, setter_stub_deopt_pc_offset, SetterStubDeoptPCOffset) \ | |
197 V(Cell, undefined_cell, UndefineCell) \ | 190 V(Cell, undefined_cell, UndefineCell) \ |
198 V(JSObject, observation_state, ObservationState) \ | 191 V(JSObject, observation_state, ObservationState) \ |
199 V(Map, external_map, ExternalMap) \ | 192 V(Map, external_map, ExternalMap) \ |
200 V(Symbol, frozen_symbol, FrozenSymbol) \ | 193 V(Symbol, frozen_symbol, FrozenSymbol) \ |
201 V(Symbol, elements_transition_symbol, ElementsTransitionSymbol) \ | 194 V(Symbol, elements_transition_symbol, ElementsTransitionSymbol) \ |
202 V(SeededNumberDictionary, empty_slow_element_dictionary, \ | 195 V(SeededNumberDictionary, empty_slow_element_dictionary, \ |
203 EmptySlowElementDictionary) \ | 196 EmptySlowElementDictionary) \ |
204 V(Symbol, observed_symbol, ObservedSymbol) \ | 197 V(Symbol, observed_symbol, ObservedSymbol) \ |
205 V(FixedArray, materialized_objects, MaterializedObjects) \ | 198 V(FixedArray, materialized_objects, MaterializedObjects) \ |
206 V(FixedArray, allocation_sites_scratchpad, AllocationSitesScratchpad) \ | 199 V(FixedArray, allocation_sites_scratchpad, AllocationSitesScratchpad) \ |
207 V(JSObject, microtask_state, MicrotaskState) | 200 V(JSObject, microtask_state, MicrotaskState) |
208 | 201 |
| 202 // Entries in this list are limited to Smis and are not visited during GC. |
| 203 #define SMI_ROOT_LIST(V) \ |
| 204 V(Smi, stack_limit, StackLimit) \ |
| 205 V(Smi, real_stack_limit, RealStackLimit) \ |
| 206 V(Smi, last_script_id, LastScriptId) \ |
| 207 V(Smi, arguments_adaptor_deopt_pc_offset, ArgumentsAdaptorDeoptPCOffset) \ |
| 208 V(Smi, construct_stub_deopt_pc_offset, ConstructStubDeoptPCOffset) \ |
| 209 V(Smi, getter_stub_deopt_pc_offset, GetterStubDeoptPCOffset) \ |
| 210 V(Smi, setter_stub_deopt_pc_offset, SetterStubDeoptPCOffset) |
| 211 |
209 #define ROOT_LIST(V) \ | 212 #define ROOT_LIST(V) \ |
210 STRONG_ROOT_LIST(V) \ | 213 STRONG_ROOT_LIST(V) \ |
| 214 SMI_ROOT_LIST(V) \ |
211 V(StringTable, string_table, StringTable) | 215 V(StringTable, string_table, StringTable) |
212 | 216 |
213 // Heap roots that are known to be immortal immovable, for which we can safely | 217 // Heap roots that are known to be immortal immovable, for which we can safely |
214 // skip write barriers. | 218 // skip write barriers. |
215 #define IMMORTAL_IMMOVABLE_ROOT_LIST(V) \ | 219 #define IMMORTAL_IMMOVABLE_ROOT_LIST(V) \ |
216 V(byte_array_map) \ | 220 V(byte_array_map) \ |
217 V(free_space_map) \ | 221 V(free_space_map) \ |
218 V(one_pointer_filler_map) \ | 222 V(one_pointer_filler_map) \ |
219 V(two_pointer_filler_map) \ | 223 V(two_pointer_filler_map) \ |
220 V(undefined_value) \ | 224 V(undefined_value) \ |
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 | 1344 |
1341 Object* weak_object_to_code_table() { return weak_object_to_code_table_; } | 1345 Object* weak_object_to_code_table() { return weak_object_to_code_table_; } |
1342 | 1346 |
1343 // Number of mark-sweeps. | 1347 // Number of mark-sweeps. |
1344 unsigned int ms_count() { return ms_count_; } | 1348 unsigned int ms_count() { return ms_count_; } |
1345 | 1349 |
1346 // Iterates over all roots in the heap. | 1350 // Iterates over all roots in the heap. |
1347 void IterateRoots(ObjectVisitor* v, VisitMode mode); | 1351 void IterateRoots(ObjectVisitor* v, VisitMode mode); |
1348 // Iterates over all strong roots in the heap. | 1352 // Iterates over all strong roots in the heap. |
1349 void IterateStrongRoots(ObjectVisitor* v, VisitMode mode); | 1353 void IterateStrongRoots(ObjectVisitor* v, VisitMode mode); |
| 1354 // Iterates over entries in the smi roots list. Only interesting to the |
| 1355 // serializer/deserializer, since GC does not care about smis. |
| 1356 void IterateSmiRoots(ObjectVisitor* v); |
1350 // Iterates over all the other roots in the heap. | 1357 // Iterates over all the other roots in the heap. |
1351 void IterateWeakRoots(ObjectVisitor* v, VisitMode mode); | 1358 void IterateWeakRoots(ObjectVisitor* v, VisitMode mode); |
1352 | 1359 |
1353 // Iterate pointers to from semispace of new space found in memory interval | 1360 // Iterate pointers to from semispace of new space found in memory interval |
1354 // from start to end. | 1361 // from start to end. |
1355 void IterateAndMarkPointersToFromSpace(Address start, | 1362 void IterateAndMarkPointersToFromSpace(Address start, |
1356 Address end, | 1363 Address end, |
1357 ObjectSlotCallback callback); | 1364 ObjectSlotCallback callback); |
1358 | 1365 |
1359 // Returns whether the object resides in new space. | 1366 // Returns whether the object resides in new space. |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1575 // Indicates whether inline bump-pointer allocation has been disabled. | 1582 // Indicates whether inline bump-pointer allocation has been disabled. |
1576 bool inline_allocation_disabled() { return inline_allocation_disabled_; } | 1583 bool inline_allocation_disabled() { return inline_allocation_disabled_; } |
1577 | 1584 |
1578 // Switch whether inline bump-pointer allocation should be used. | 1585 // Switch whether inline bump-pointer allocation should be used. |
1579 void EnableInlineAllocation(); | 1586 void EnableInlineAllocation(); |
1580 void DisableInlineAllocation(); | 1587 void DisableInlineAllocation(); |
1581 | 1588 |
1582 // Implements the corresponding V8 API function. | 1589 // Implements the corresponding V8 API function. |
1583 bool IdleNotification(int hint); | 1590 bool IdleNotification(int hint); |
1584 | 1591 |
1585 // Declare all the root indices. | 1592 // Declare all the root indices. This defines the root list order. |
1586 enum RootListIndex { | 1593 enum RootListIndex { |
1587 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, | 1594 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, |
1588 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) | 1595 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) |
1589 #undef ROOT_INDEX_DECLARATION | 1596 #undef ROOT_INDEX_DECLARATION |
1590 | 1597 |
1591 #define STRING_INDEX_DECLARATION(name, str) k##name##RootIndex, | 1598 #define STRING_INDEX_DECLARATION(name, str) k##name##RootIndex, |
1592 INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION) | 1599 INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION) |
1593 #undef STRING_DECLARATION | 1600 #undef STRING_DECLARATION |
1594 | 1601 |
1595 // Utility type maps | 1602 // Utility type maps |
1596 #define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex, | 1603 #define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex, |
1597 STRUCT_LIST(DECLARE_STRUCT_MAP) | 1604 STRUCT_LIST(DECLARE_STRUCT_MAP) |
1598 #undef DECLARE_STRUCT_MAP | 1605 #undef DECLARE_STRUCT_MAP |
1599 | 1606 |
1600 kStringTableRootIndex, | 1607 kStringTableRootIndex, |
| 1608 |
| 1609 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, |
| 1610 SMI_ROOT_LIST(ROOT_INDEX_DECLARATION) |
| 1611 #undef ROOT_INDEX_DECLARATION |
| 1612 |
| 1613 kRootListLength, |
1601 kStrongRootListLength = kStringTableRootIndex, | 1614 kStrongRootListLength = kStringTableRootIndex, |
1602 kRootListLength | 1615 kSmiRootsStart = kStringTableRootIndex + 1 |
1603 }; | 1616 }; |
1604 | 1617 |
1605 STATIC_CHECK(kUndefinedValueRootIndex == Internals::kUndefinedValueRootIndex); | 1618 STATIC_CHECK(kUndefinedValueRootIndex == Internals::kUndefinedValueRootIndex); |
1606 STATIC_CHECK(kNullValueRootIndex == Internals::kNullValueRootIndex); | 1619 STATIC_CHECK(kNullValueRootIndex == Internals::kNullValueRootIndex); |
1607 STATIC_CHECK(kTrueValueRootIndex == Internals::kTrueValueRootIndex); | 1620 STATIC_CHECK(kTrueValueRootIndex == Internals::kTrueValueRootIndex); |
1608 STATIC_CHECK(kFalseValueRootIndex == Internals::kFalseValueRootIndex); | 1621 STATIC_CHECK(kFalseValueRootIndex == Internals::kFalseValueRootIndex); |
1609 STATIC_CHECK(kempty_stringRootIndex == Internals::kEmptyStringRootIndex); | 1622 STATIC_CHECK(kempty_stringRootIndex == Internals::kEmptyStringRootIndex); |
1610 | 1623 |
1611 // Generated code can embed direct references to non-writable roots if | 1624 // Generated code can embed direct references to non-writable roots if |
1612 // they are in new space. | 1625 // they are in new space. |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2582 // or care about intergenerational references. All heap object pointers have to | 2595 // or care about intergenerational references. All heap object pointers have to |
2583 // point into the heap to a location that has a map pointer at its first word. | 2596 // point into the heap to a location that has a map pointer at its first word. |
2584 // Caveat: Heap::Contains is an approximation because it can return true for | 2597 // Caveat: Heap::Contains is an approximation because it can return true for |
2585 // objects in a heap space but above the allocation pointer. | 2598 // objects in a heap space but above the allocation pointer. |
2586 class VerifyPointersVisitor: public ObjectVisitor { | 2599 class VerifyPointersVisitor: public ObjectVisitor { |
2587 public: | 2600 public: |
2588 inline void VisitPointers(Object** start, Object** end); | 2601 inline void VisitPointers(Object** start, Object** end); |
2589 }; | 2602 }; |
2590 | 2603 |
2591 | 2604 |
| 2605 // Verify that all objects are Smis. |
| 2606 class VerifySmisVisitor: public ObjectVisitor { |
| 2607 public: |
| 2608 inline void VisitPointers(Object** start, Object** end); |
| 2609 }; |
| 2610 |
| 2611 |
2592 // Space iterator for iterating over all spaces of the heap. Returns each space | 2612 // Space iterator for iterating over all spaces of the heap. Returns each space |
2593 // in turn, and null when it is done. | 2613 // in turn, and null when it is done. |
2594 class AllSpaces BASE_EMBEDDED { | 2614 class AllSpaces BASE_EMBEDDED { |
2595 public: | 2615 public: |
2596 explicit AllSpaces(Heap* heap) : heap_(heap), counter_(FIRST_SPACE) {} | 2616 explicit AllSpaces(Heap* heap) : heap_(heap), counter_(FIRST_SPACE) {} |
2597 Space* next(); | 2617 Space* next(); |
2598 private: | 2618 private: |
2599 Heap* heap_; | 2619 Heap* heap_; |
2600 int counter_; | 2620 int counter_; |
2601 }; | 2621 }; |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3091 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 3111 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
3092 | 3112 |
3093 private: | 3113 private: |
3094 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 3114 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
3095 }; | 3115 }; |
3096 #endif // DEBUG | 3116 #endif // DEBUG |
3097 | 3117 |
3098 } } // namespace v8::internal | 3118 } } // namespace v8::internal |
3099 | 3119 |
3100 #endif // V8_HEAP_H_ | 3120 #endif // V8_HEAP_H_ |
OLD | NEW |