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 |
327 // Forward declarations. | 381 // Forward declarations. |
328 class HeapStats; | 382 class HeapStats; |
329 class Isolate; | 383 class Isolate; |
330 class WeakObjectRetainer; | 384 class WeakObjectRetainer; |
331 | 385 |
332 | 386 |
333 typedef String* (*ExternalStringTableUpdaterCallback)(Heap* heap, | 387 typedef String* (*ExternalStringTableUpdaterCallback)(Heap* heap, |
334 Object** pointer); | 388 Object** pointer); |
335 | 389 |
336 class StoreBufferRebuilder { | 390 class StoreBufferRebuilder { |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 roots_[kMaterializedObjectsRootIndex] = objects; | 988 roots_[kMaterializedObjectsRootIndex] = objects; |
935 } | 989 } |
936 | 990 |
937 // Generated code can embed this address to get access to the roots. | 991 // Generated code can embed this address to get access to the roots. |
938 Object** roots_array_start() { return roots_; } | 992 Object** roots_array_start() { return roots_; } |
939 | 993 |
940 Address* store_buffer_top_address() { | 994 Address* store_buffer_top_address() { |
941 return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]); | 995 return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]); |
942 } | 996 } |
943 | 997 |
| 998 static bool RootIsImmortalImmovable(int root_index); |
944 void CheckHandleCount(); | 999 void CheckHandleCount(); |
945 | 1000 |
946 #ifdef VERIFY_HEAP | 1001 #ifdef VERIFY_HEAP |
947 // Verify the heap is in its normal state before or after a GC. | 1002 // Verify the heap is in its normal state before or after a GC. |
948 void Verify(); | 1003 void Verify(); |
949 #endif | 1004 #endif |
950 | 1005 |
951 #ifdef DEBUG | 1006 #ifdef DEBUG |
952 void Print(); | 1007 void Print(); |
953 void PrintHandles(); | 1008 void PrintHandles(); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 double MonotonicallyIncreasingTimeInMs(); | 1180 double MonotonicallyIncreasingTimeInMs(); |
1126 | 1181 |
1127 // Declare all the root indices. This defines the root list order. | 1182 // Declare all the root indices. This defines the root list order. |
1128 enum RootListIndex { | 1183 enum RootListIndex { |
1129 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, | 1184 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, |
1130 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) | 1185 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) |
1131 #undef ROOT_INDEX_DECLARATION | 1186 #undef ROOT_INDEX_DECLARATION |
1132 | 1187 |
1133 #define STRING_INDEX_DECLARATION(name, str) k##name##RootIndex, | 1188 #define STRING_INDEX_DECLARATION(name, str) k##name##RootIndex, |
1134 INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION) | 1189 INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION) |
1135 #undef STRING_INDEX_DECLARATION | 1190 #undef STRING_DECLARATION |
1136 | 1191 |
1137 #define SYMBOL_INDEX_DECLARATION(name) k##name##RootIndex, | 1192 #define SYMBOL_INDEX_DECLARATION(name) k##name##RootIndex, |
1138 PRIVATE_SYMBOL_LIST(SYMBOL_INDEX_DECLARATION) | 1193 PRIVATE_SYMBOL_LIST(SYMBOL_INDEX_DECLARATION) |
1139 #undef SYMBOL_INDEX_DECLARATION | 1194 #undef SYMBOL_INDEX_DECLARATION |
1140 | 1195 |
1141 #define SYMBOL_INDEX_DECLARATION(name, varname, description) k##name##RootIndex, | 1196 #define SYMBOL_INDEX_DECLARATION(name, varname, description) k##name##RootIndex, |
1142 PUBLIC_SYMBOL_LIST(SYMBOL_INDEX_DECLARATION) | 1197 PUBLIC_SYMBOL_LIST(SYMBOL_INDEX_DECLARATION) |
1143 #undef SYMBOL_INDEX_DECLARATION | 1198 #undef SYMBOL_INDEX_DECLARATION |
1144 | 1199 |
1145 // Utility type maps | 1200 // Utility type maps |
1146 #define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex, | 1201 #define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex, |
1147 STRUCT_LIST(DECLARE_STRUCT_MAP) | 1202 STRUCT_LIST(DECLARE_STRUCT_MAP) |
1148 #undef DECLARE_STRUCT_MAP | 1203 #undef DECLARE_STRUCT_MAP |
1149 kStringTableRootIndex, | 1204 kStringTableRootIndex, |
1150 | 1205 |
1151 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, | 1206 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, |
1152 SMI_ROOT_LIST(ROOT_INDEX_DECLARATION) | 1207 SMI_ROOT_LIST(ROOT_INDEX_DECLARATION) |
1153 #undef ROOT_INDEX_DECLARATION | 1208 #undef ROOT_INDEX_DECLARATION |
1154 kRootListLength, | 1209 kRootListLength, |
1155 kStrongRootListLength = kStringTableRootIndex, | 1210 kStrongRootListLength = kStringTableRootIndex, |
1156 kSmiRootsStart = kStringTableRootIndex + 1 | 1211 kSmiRootsStart = kStringTableRootIndex + 1 |
1157 }; | 1212 }; |
1158 | 1213 |
1159 // Check if {index} is the index of an immortal immovable root. | |
1160 static bool RootIsImmortalImmovable(RootListIndex index); | |
1161 | |
1162 // Get the root list index for {object} if such a root list index exists. | 1214 // Get the root list index for {object} if such a root list index exists. |
1163 bool GetRootListIndex(Object* object, RootListIndex* index_return) const; | 1215 bool GetRootListIndex(Handle<HeapObject> object, |
| 1216 Heap::RootListIndex* index_return); |
1164 | 1217 |
1165 Object* root(RootListIndex index) { return roots_[index]; } | 1218 Object* root(RootListIndex index) { return roots_[index]; } |
1166 | 1219 |
1167 STATIC_ASSERT(kUndefinedValueRootIndex == | 1220 STATIC_ASSERT(kUndefinedValueRootIndex == |
1168 Internals::kUndefinedValueRootIndex); | 1221 Internals::kUndefinedValueRootIndex); |
1169 STATIC_ASSERT(kNullValueRootIndex == Internals::kNullValueRootIndex); | 1222 STATIC_ASSERT(kNullValueRootIndex == Internals::kNullValueRootIndex); |
1170 STATIC_ASSERT(kTrueValueRootIndex == Internals::kTrueValueRootIndex); | 1223 STATIC_ASSERT(kTrueValueRootIndex == Internals::kTrueValueRootIndex); |
1171 STATIC_ASSERT(kFalseValueRootIndex == Internals::kFalseValueRootIndex); | 1224 STATIC_ASSERT(kFalseValueRootIndex == Internals::kFalseValueRootIndex); |
1172 STATIC_ASSERT(kempty_stringRootIndex == Internals::kEmptyStringRootIndex); | 1225 STATIC_ASSERT(kempty_stringRootIndex == Internals::kEmptyStringRootIndex); |
1173 | 1226 |
(...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2731 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2784 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2732 | 2785 |
2733 private: | 2786 private: |
2734 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2787 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2735 }; | 2788 }; |
2736 #endif // DEBUG | 2789 #endif // DEBUG |
2737 } | 2790 } |
2738 } // namespace v8::internal | 2791 } // namespace v8::internal |
2739 | 2792 |
2740 #endif // V8_HEAP_HEAP_H_ | 2793 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |