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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 317 |
318 #define PUBLIC_SYMBOL_LIST(V) \ | 318 #define PUBLIC_SYMBOL_LIST(V) \ |
319 V(has_instance_symbol, symbolHasInstance, Symbol.hasInstance) \ | 319 V(has_instance_symbol, symbolHasInstance, Symbol.hasInstance) \ |
320 V(is_concat_spreadable_symbol, symbolIsConcatSpreadable, \ | 320 V(is_concat_spreadable_symbol, symbolIsConcatSpreadable, \ |
321 Symbol.isConcatSpreadable) \ | 321 Symbol.isConcatSpreadable) \ |
322 V(is_regexp_symbol, symbolIsRegExp, Symbol.isRegExp) \ | 322 V(is_regexp_symbol, symbolIsRegExp, Symbol.isRegExp) \ |
323 V(iterator_symbol, symbolIterator, Symbol.iterator) \ | 323 V(iterator_symbol, symbolIterator, Symbol.iterator) \ |
324 V(to_string_tag_symbol, symbolToStringTag, Symbol.toStringTag) \ | 324 V(to_string_tag_symbol, symbolToStringTag, Symbol.toStringTag) \ |
325 V(unscopables_symbol, symbolUnscopables, Symbol.unscopables) | 325 V(unscopables_symbol, symbolUnscopables, Symbol.unscopables) |
326 | 326 |
327 // Heap roots that are known to be immortal immovable, for which we can safely | |
328 // skip write barriers. This list is not complete and has omissions. | |
329 #define IMMORTAL_IMMOVABLE_ROOT_LIST(V) \ | |
330 V(ByteArrayMap) \ | |
331 V(FreeSpaceMap) \ | |
332 V(OnePointerFillerMap) \ | |
333 V(TwoPointerFillerMap) \ | |
334 V(UndefinedValue) \ | |
335 V(TheHoleValue) \ | |
336 V(NullValue) \ | |
337 V(TrueValue) \ | |
338 V(FalseValue) \ | |
339 V(UninitializedValue) \ | |
340 V(CellMap) \ | |
341 V(GlobalPropertyCellMap) \ | |
342 V(SharedFunctionInfoMap) \ | |
343 V(MetaMap) \ | |
344 V(HeapNumberMap) \ | |
345 V(MutableHeapNumberMap) \ | |
346 V(Float32x4Map) \ | |
347 V(NativeContextMap) \ | |
348 V(FixedArrayMap) \ | |
349 V(CodeMap) \ | |
350 V(ScopeInfoMap) \ | |
351 V(FixedCOWArrayMap) \ | |
352 V(FixedDoubleArrayMap) \ | |
353 V(WeakCellMap) \ | |
354 V(NoInterceptorResultSentinel) \ | |
355 V(HashTableMap) \ | |
356 V(OrderedHashTableMap) \ | |
357 V(EmptyFixedArray) \ | |
358 V(EmptyByteArray) \ | |
359 V(EmptyDescriptorArray) \ | |
360 V(ArgumentsMarker) \ | |
361 V(SymbolMap) \ | |
362 V(SloppyArgumentsElementsMap) \ | |
363 V(FunctionContextMap) \ | |
364 V(CatchContextMap) \ | |
365 V(WithContextMap) \ | |
366 V(BlockContextMap) \ | |
367 V(ModuleContextMap) \ | |
368 V(ScriptContextMap) \ | |
369 V(UndefinedMap) \ | |
370 V(TheHoleMap) \ | |
371 V(NullMap) \ | |
372 V(BooleanMap) \ | |
373 V(UninitializedMap) \ | |
374 V(ArgumentsMarkerMap) \ | |
375 V(JSMessageObjectMap) \ | |
376 V(ForeignMap) \ | |
377 V(NeanderMap) \ | |
378 V(empty_string) \ | |
379 PRIVATE_SYMBOL_LIST(V) | |
380 | |
381 // Forward declarations. | 327 // Forward declarations. |
382 class HeapStats; | 328 class HeapStats; |
383 class Isolate; | 329 class Isolate; |
384 class WeakObjectRetainer; | 330 class WeakObjectRetainer; |
385 | 331 |
386 | 332 |
387 typedef String* (*ExternalStringTableUpdaterCallback)(Heap* heap, | 333 typedef String* (*ExternalStringTableUpdaterCallback)(Heap* heap, |
388 Object** pointer); | 334 Object** pointer); |
389 | 335 |
390 class StoreBufferRebuilder { | 336 class StoreBufferRebuilder { |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 roots_[kMaterializedObjectsRootIndex] = objects; | 934 roots_[kMaterializedObjectsRootIndex] = objects; |
989 } | 935 } |
990 | 936 |
991 // Generated code can embed this address to get access to the roots. | 937 // Generated code can embed this address to get access to the roots. |
992 Object** roots_array_start() { return roots_; } | 938 Object** roots_array_start() { return roots_; } |
993 | 939 |
994 Address* store_buffer_top_address() { | 940 Address* store_buffer_top_address() { |
995 return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]); | 941 return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]); |
996 } | 942 } |
997 | 943 |
998 static bool RootIsImmortalImmovable(int root_index); | |
999 void CheckHandleCount(); | 944 void CheckHandleCount(); |
1000 | 945 |
1001 #ifdef VERIFY_HEAP | 946 #ifdef VERIFY_HEAP |
1002 // Verify the heap is in its normal state before or after a GC. | 947 // Verify the heap is in its normal state before or after a GC. |
1003 void Verify(); | 948 void Verify(); |
1004 #endif | 949 #endif |
1005 | 950 |
1006 #ifdef DEBUG | 951 #ifdef DEBUG |
1007 void Print(); | 952 void Print(); |
1008 void PrintHandles(); | 953 void PrintHandles(); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 double MonotonicallyIncreasingTimeInMs(); | 1125 double MonotonicallyIncreasingTimeInMs(); |
1181 | 1126 |
1182 // Declare all the root indices. This defines the root list order. | 1127 // Declare all the root indices. This defines the root list order. |
1183 enum RootListIndex { | 1128 enum RootListIndex { |
1184 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, | 1129 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, |
1185 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) | 1130 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) |
1186 #undef ROOT_INDEX_DECLARATION | 1131 #undef ROOT_INDEX_DECLARATION |
1187 | 1132 |
1188 #define STRING_INDEX_DECLARATION(name, str) k##name##RootIndex, | 1133 #define STRING_INDEX_DECLARATION(name, str) k##name##RootIndex, |
1189 INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION) | 1134 INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION) |
1190 #undef STRING_DECLARATION | 1135 #undef STRING_INDEX_DECLARATION |
1191 | 1136 |
1192 #define SYMBOL_INDEX_DECLARATION(name) k##name##RootIndex, | 1137 #define SYMBOL_INDEX_DECLARATION(name) k##name##RootIndex, |
1193 PRIVATE_SYMBOL_LIST(SYMBOL_INDEX_DECLARATION) | 1138 PRIVATE_SYMBOL_LIST(SYMBOL_INDEX_DECLARATION) |
1194 #undef SYMBOL_INDEX_DECLARATION | 1139 #undef SYMBOL_INDEX_DECLARATION |
1195 | 1140 |
1196 #define SYMBOL_INDEX_DECLARATION(name, varname, description) k##name##RootIndex, | 1141 #define SYMBOL_INDEX_DECLARATION(name, varname, description) k##name##RootIndex, |
1197 PUBLIC_SYMBOL_LIST(SYMBOL_INDEX_DECLARATION) | 1142 PUBLIC_SYMBOL_LIST(SYMBOL_INDEX_DECLARATION) |
1198 #undef SYMBOL_INDEX_DECLARATION | 1143 #undef SYMBOL_INDEX_DECLARATION |
1199 | 1144 |
1200 // Utility type maps | 1145 // Utility type maps |
1201 #define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex, | 1146 #define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex, |
1202 STRUCT_LIST(DECLARE_STRUCT_MAP) | 1147 STRUCT_LIST(DECLARE_STRUCT_MAP) |
1203 #undef DECLARE_STRUCT_MAP | 1148 #undef DECLARE_STRUCT_MAP |
1204 kStringTableRootIndex, | 1149 kStringTableRootIndex, |
1205 | 1150 |
1206 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, | 1151 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, |
1207 SMI_ROOT_LIST(ROOT_INDEX_DECLARATION) | 1152 SMI_ROOT_LIST(ROOT_INDEX_DECLARATION) |
1208 #undef ROOT_INDEX_DECLARATION | 1153 #undef ROOT_INDEX_DECLARATION |
1209 kRootListLength, | 1154 kRootListLength, |
1210 kStrongRootListLength = kStringTableRootIndex, | 1155 kStrongRootListLength = kStringTableRootIndex, |
1211 kSmiRootsStart = kStringTableRootIndex + 1 | 1156 kSmiRootsStart = kStringTableRootIndex + 1 |
1212 }; | 1157 }; |
1213 | 1158 |
| 1159 // Check if {index} is the index of an immortal immovable root. |
| 1160 static bool RootIsImmortalImmovable(RootListIndex index); |
| 1161 |
1214 // Get the root list index for {object} if such a root list index exists. | 1162 // Get the root list index for {object} if such a root list index exists. |
1215 bool GetRootListIndex(Handle<HeapObject> object, | 1163 bool GetRootListIndex(Object* object, RootListIndex* index_return) const; |
1216 Heap::RootListIndex* index_return); | |
1217 | 1164 |
1218 Object* root(RootListIndex index) { return roots_[index]; } | 1165 Object* root(RootListIndex index) { return roots_[index]; } |
1219 | 1166 |
1220 STATIC_ASSERT(kUndefinedValueRootIndex == | 1167 STATIC_ASSERT(kUndefinedValueRootIndex == |
1221 Internals::kUndefinedValueRootIndex); | 1168 Internals::kUndefinedValueRootIndex); |
1222 STATIC_ASSERT(kNullValueRootIndex == Internals::kNullValueRootIndex); | 1169 STATIC_ASSERT(kNullValueRootIndex == Internals::kNullValueRootIndex); |
1223 STATIC_ASSERT(kTrueValueRootIndex == Internals::kTrueValueRootIndex); | 1170 STATIC_ASSERT(kTrueValueRootIndex == Internals::kTrueValueRootIndex); |
1224 STATIC_ASSERT(kFalseValueRootIndex == Internals::kFalseValueRootIndex); | 1171 STATIC_ASSERT(kFalseValueRootIndex == Internals::kFalseValueRootIndex); |
1225 STATIC_ASSERT(kempty_stringRootIndex == Internals::kEmptyStringRootIndex); | 1172 STATIC_ASSERT(kempty_stringRootIndex == Internals::kEmptyStringRootIndex); |
1226 | 1173 |
(...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2784 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2731 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2785 | 2732 |
2786 private: | 2733 private: |
2787 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2734 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2788 }; | 2735 }; |
2789 #endif // DEBUG | 2736 #endif // DEBUG |
2790 } | 2737 } |
2791 } // namespace v8::internal | 2738 } // namespace v8::internal |
2792 | 2739 |
2793 #endif // V8_HEAP_HEAP_H_ | 2740 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |