Chromium Code Reviews| 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 ROOT_SMI_LIST(V) \ | |
|
Michael Starzinger
2014/02/14 14:24:01
nit: Can we call it SMI_ROOT_LIST instead?
| |
| 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 ROOT_SMI_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 root smis list. Only interesting to the | |
| 1355 // serializer/deserializer, since GC does not care about smis. | |
| 1356 void IterateRootSmis(ObjectVisitor* v); | |
|
Michael Starzinger
2014/02/14 14:24:01
nit: Likewise IterateSmiRoots() here.
| |
| 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. |
| 1593 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, | |
|
Michael Starzinger
2014/02/14 14:24:01
nit: Can we move the #define and #undef pragmas in
| |
| 1594 #define STRING_INDEX_DECLARATION(name, str) k##name##RootIndex, | |
| 1595 #define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex, | |
| 1596 | |
| 1586 enum RootListIndex { | 1597 enum RootListIndex { |
| 1587 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, | |
| 1588 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) | 1598 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) |
| 1599 INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION) | |
| 1600 // Utility type maps | |
| 1601 STRUCT_LIST(DECLARE_STRUCT_MAP) | |
| 1602 kStringTableRootIndex, | |
| 1603 ROOT_SMI_LIST(ROOT_INDEX_DECLARATION) | |
| 1604 kRootListLength, | |
| 1605 kStrongRootListLength = kStringTableRootIndex, | |
| 1606 kRootSmisStart = kStringTableRootIndex + 1 | |
| 1607 }; | |
| 1608 | |
| 1609 #undef DECLARE_STRUCT_MAP | |
| 1610 #undef STRING_DECLARATION | |
| 1589 #undef ROOT_INDEX_DECLARATION | 1611 #undef ROOT_INDEX_DECLARATION |
| 1590 | 1612 |
| 1591 #define STRING_INDEX_DECLARATION(name, str) k##name##RootIndex, | |
| 1592 INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION) | |
| 1593 #undef STRING_DECLARATION | |
| 1594 | |
| 1595 // Utility type maps | |
| 1596 #define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex, | |
| 1597 STRUCT_LIST(DECLARE_STRUCT_MAP) | |
| 1598 #undef DECLARE_STRUCT_MAP | |
| 1599 | |
| 1600 kStringTableRootIndex, | |
| 1601 kStrongRootListLength = kStringTableRootIndex, | |
| 1602 kRootListLength | |
| 1603 }; | |
| 1604 | |
| 1605 STATIC_CHECK(kUndefinedValueRootIndex == Internals::kUndefinedValueRootIndex); | 1613 STATIC_CHECK(kUndefinedValueRootIndex == Internals::kUndefinedValueRootIndex); |
| 1606 STATIC_CHECK(kNullValueRootIndex == Internals::kNullValueRootIndex); | 1614 STATIC_CHECK(kNullValueRootIndex == Internals::kNullValueRootIndex); |
| 1607 STATIC_CHECK(kTrueValueRootIndex == Internals::kTrueValueRootIndex); | 1615 STATIC_CHECK(kTrueValueRootIndex == Internals::kTrueValueRootIndex); |
| 1608 STATIC_CHECK(kFalseValueRootIndex == Internals::kFalseValueRootIndex); | 1616 STATIC_CHECK(kFalseValueRootIndex == Internals::kFalseValueRootIndex); |
| 1609 STATIC_CHECK(kempty_stringRootIndex == Internals::kEmptyStringRootIndex); | 1617 STATIC_CHECK(kempty_stringRootIndex == Internals::kEmptyStringRootIndex); |
| 1610 | 1618 |
| 1611 // Generated code can embed direct references to non-writable roots if | 1619 // Generated code can embed direct references to non-writable roots if |
| 1612 // they are in new space. | 1620 // they are in new space. |
| 1613 static bool RootCanBeWrittenAfterInitialization(RootListIndex root_index); | 1621 static bool RootCanBeWrittenAfterInitialization(RootListIndex root_index); |
| 1614 // Generated code can treat direct references to this root as constant. | 1622 // Generated code can treat direct references to this root as constant. |
| (...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2582 // or care about intergenerational references. All heap object pointers have to | 2590 // 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. | 2591 // 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 | 2592 // Caveat: Heap::Contains is an approximation because it can return true for |
| 2585 // objects in a heap space but above the allocation pointer. | 2593 // objects in a heap space but above the allocation pointer. |
| 2586 class VerifyPointersVisitor: public ObjectVisitor { | 2594 class VerifyPointersVisitor: public ObjectVisitor { |
| 2587 public: | 2595 public: |
| 2588 inline void VisitPointers(Object** start, Object** end); | 2596 inline void VisitPointers(Object** start, Object** end); |
| 2589 }; | 2597 }; |
| 2590 | 2598 |
| 2591 | 2599 |
| 2600 // Verify that all objects are Smis. | |
| 2601 class VerifySmisVisitor: public ObjectVisitor { | |
| 2602 public: | |
| 2603 inline void VisitPointers(Object** start, Object** end); | |
| 2604 }; | |
| 2605 | |
| 2606 | |
| 2592 // Space iterator for iterating over all spaces of the heap. Returns each space | 2607 // Space iterator for iterating over all spaces of the heap. Returns each space |
| 2593 // in turn, and null when it is done. | 2608 // in turn, and null when it is done. |
| 2594 class AllSpaces BASE_EMBEDDED { | 2609 class AllSpaces BASE_EMBEDDED { |
| 2595 public: | 2610 public: |
| 2596 explicit AllSpaces(Heap* heap) : heap_(heap), counter_(FIRST_SPACE) {} | 2611 explicit AllSpaces(Heap* heap) : heap_(heap), counter_(FIRST_SPACE) {} |
| 2597 Space* next(); | 2612 Space* next(); |
| 2598 private: | 2613 private: |
| 2599 Heap* heap_; | 2614 Heap* heap_; |
| 2600 int counter_; | 2615 int counter_; |
| 2601 }; | 2616 }; |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3091 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 3106 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 3092 | 3107 |
| 3093 private: | 3108 private: |
| 3094 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 3109 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 3095 }; | 3110 }; |
| 3096 #endif // DEBUG | 3111 #endif // DEBUG |
| 3097 | 3112 |
| 3098 } } // namespace v8::internal | 3113 } } // namespace v8::internal |
| 3099 | 3114 |
| 3100 #endif // V8_HEAP_H_ | 3115 #endif // V8_HEAP_H_ |
| OLD | NEW |