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 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 V(Smi, arguments_adaptor_deopt_pc_offset, ArgumentsAdaptorDeoptPCOffset) \ | 191 V(Smi, arguments_adaptor_deopt_pc_offset, ArgumentsAdaptorDeoptPCOffset) \ |
192 V(Smi, construct_stub_deopt_pc_offset, ConstructStubDeoptPCOffset) \ | 192 V(Smi, construct_stub_deopt_pc_offset, ConstructStubDeoptPCOffset) \ |
193 V(Smi, getter_stub_deopt_pc_offset, GetterStubDeoptPCOffset) \ | 193 V(Smi, getter_stub_deopt_pc_offset, GetterStubDeoptPCOffset) \ |
194 V(Smi, setter_stub_deopt_pc_offset, SetterStubDeoptPCOffset) | 194 V(Smi, setter_stub_deopt_pc_offset, SetterStubDeoptPCOffset) |
195 | 195 |
196 #define ROOT_LIST(V) \ | 196 #define ROOT_LIST(V) \ |
197 STRONG_ROOT_LIST(V) \ | 197 STRONG_ROOT_LIST(V) \ |
198 SMI_ROOT_LIST(V) \ | 198 SMI_ROOT_LIST(V) \ |
199 V(StringTable, string_table, StringTable) | 199 V(StringTable, string_table, StringTable) |
200 | 200 |
201 // Heap roots that are known to be immortal immovable, for which we can safely | |
202 // skip write barriers. | |
203 #define IMMORTAL_IMMOVABLE_ROOT_LIST(V) \ | |
204 V(byte_array_map) \ | |
205 V(free_space_map) \ | |
206 V(one_pointer_filler_map) \ | |
207 V(two_pointer_filler_map) \ | |
208 V(undefined_value) \ | |
209 V(the_hole_value) \ | |
210 V(null_value) \ | |
211 V(true_value) \ | |
212 V(false_value) \ | |
213 V(uninitialized_value) \ | |
214 V(cell_map) \ | |
215 V(global_property_cell_map) \ | |
216 V(shared_function_info_map) \ | |
217 V(meta_map) \ | |
218 V(heap_number_map) \ | |
219 V(mutable_heap_number_map) \ | |
220 V(native_context_map) \ | |
221 V(fixed_array_map) \ | |
222 V(code_map) \ | |
223 V(scope_info_map) \ | |
224 V(fixed_cow_array_map) \ | |
225 V(fixed_double_array_map) \ | |
226 V(constant_pool_array_map) \ | |
227 V(weak_cell_map) \ | |
228 V(no_interceptor_result_sentinel) \ | |
229 V(hash_table_map) \ | |
230 V(ordered_hash_table_map) \ | |
231 V(empty_fixed_array) \ | |
232 V(empty_byte_array) \ | |
233 V(empty_descriptor_array) \ | |
234 V(empty_constant_pool_array) \ | |
235 V(arguments_marker) \ | |
236 V(symbol_map) \ | |
237 V(sloppy_arguments_elements_map) \ | |
238 V(function_context_map) \ | |
239 V(catch_context_map) \ | |
240 V(with_context_map) \ | |
241 V(block_context_map) \ | |
242 V(module_context_map) \ | |
243 V(global_context_map) \ | |
244 V(undefined_map) \ | |
245 V(the_hole_map) \ | |
246 V(null_map) \ | |
247 V(boolean_map) \ | |
248 V(uninitialized_map) \ | |
249 V(message_object_map) \ | |
250 V(foreign_map) \ | |
251 V(neander_map) | |
252 | |
253 #define INTERNALIZED_STRING_LIST(V) \ | 201 #define INTERNALIZED_STRING_LIST(V) \ |
254 V(Object_string, "Object") \ | 202 V(Object_string, "Object") \ |
255 V(proto_string, "__proto__") \ | 203 V(proto_string, "__proto__") \ |
256 V(arguments_string, "arguments") \ | 204 V(arguments_string, "arguments") \ |
257 V(Arguments_string, "Arguments") \ | 205 V(Arguments_string, "Arguments") \ |
258 V(caller_string, "caller") \ | 206 V(caller_string, "caller") \ |
259 V(boolean_string, "boolean") \ | 207 V(boolean_string, "boolean") \ |
260 V(Boolean_string, "Boolean") \ | 208 V(Boolean_string, "Boolean") \ |
261 V(callee_string, "callee") \ | 209 V(callee_string, "callee") \ |
262 V(constructor_string, "constructor") \ | 210 V(constructor_string, "constructor") \ |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 V(normal_ic_symbol) \ | 292 V(normal_ic_symbol) \ |
345 V(home_object_symbol) \ | 293 V(home_object_symbol) \ |
346 V(intl_initialized_marker_symbol) \ | 294 V(intl_initialized_marker_symbol) \ |
347 V(intl_impl_object_symbol) \ | 295 V(intl_impl_object_symbol) \ |
348 V(promise_debug_marker_symbol) \ | 296 V(promise_debug_marker_symbol) \ |
349 V(promise_has_handler_symbol) \ | 297 V(promise_has_handler_symbol) \ |
350 V(class_script_symbol) \ | 298 V(class_script_symbol) \ |
351 V(class_start_position_symbol) \ | 299 V(class_start_position_symbol) \ |
352 V(class_end_position_symbol) | 300 V(class_end_position_symbol) |
353 | 301 |
| 302 // Heap roots that are known to be immortal immovable, for which we can safely |
| 303 // skip write barriers. This list is not complete and has omissions. |
| 304 #define IMMORTAL_IMMOVABLE_ROOT_LIST(V) \ |
| 305 V(ByteArrayMap) \ |
| 306 V(FreeSpaceMap) \ |
| 307 V(OnePointerFillerMap) \ |
| 308 V(TwoPointerFillerMap) \ |
| 309 V(UndefinedValue) \ |
| 310 V(TheHoleValue) \ |
| 311 V(NullValue) \ |
| 312 V(TrueValue) \ |
| 313 V(FalseValue) \ |
| 314 V(UninitializedValue) \ |
| 315 V(CellMap) \ |
| 316 V(GlobalPropertyCellMap) \ |
| 317 V(SharedFunctionInfoMap) \ |
| 318 V(MetaMap) \ |
| 319 V(HeapNumberMap) \ |
| 320 V(MutableHeapNumberMap) \ |
| 321 V(NativeContextMap) \ |
| 322 V(FixedArrayMap) \ |
| 323 V(CodeMap) \ |
| 324 V(ScopeInfoMap) \ |
| 325 V(FixedCOWArrayMap) \ |
| 326 V(FixedDoubleArrayMap) \ |
| 327 V(ConstantPoolArrayMap) \ |
| 328 V(WeakCellMap) \ |
| 329 V(NoInterceptorResultSentinel) \ |
| 330 V(HashTableMap) \ |
| 331 V(OrderedHashTableMap) \ |
| 332 V(EmptyFixedArray) \ |
| 333 V(EmptyByteArray) \ |
| 334 V(EmptyDescriptorArray) \ |
| 335 V(EmptyConstantPoolArray) \ |
| 336 V(ArgumentsMarker) \ |
| 337 V(SymbolMap) \ |
| 338 V(SloppyArgumentsElementsMap) \ |
| 339 V(FunctionContextMap) \ |
| 340 V(CatchContextMap) \ |
| 341 V(WithContextMap) \ |
| 342 V(BlockContextMap) \ |
| 343 V(ModuleContextMap) \ |
| 344 V(GlobalContextMap) \ |
| 345 V(UndefinedMap) \ |
| 346 V(TheHoleMap) \ |
| 347 V(NullMap) \ |
| 348 V(BooleanMap) \ |
| 349 V(UninitializedMap) \ |
| 350 V(ArgumentsMarkerMap) \ |
| 351 V(JSMessageObjectMap) \ |
| 352 V(ForeignMap) \ |
| 353 V(NeanderMap) \ |
| 354 PRIVATE_SYMBOL_LIST(V) |
| 355 |
354 // Forward declarations. | 356 // Forward declarations. |
355 class HeapStats; | 357 class HeapStats; |
356 class Isolate; | 358 class Isolate; |
357 class WeakObjectRetainer; | 359 class WeakObjectRetainer; |
358 | 360 |
359 | 361 |
360 typedef String* (*ExternalStringTableUpdaterCallback)(Heap* heap, | 362 typedef String* (*ExternalStringTableUpdaterCallback)(Heap* heap, |
361 Object** pointer); | 363 Object** pointer); |
362 | 364 |
363 class StoreBufferRebuilder { | 365 class StoreBufferRebuilder { |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 roots_[kMaterializedObjectsRootIndex] = objects; | 923 roots_[kMaterializedObjectsRootIndex] = objects; |
922 } | 924 } |
923 | 925 |
924 // Generated code can embed this address to get access to the roots. | 926 // Generated code can embed this address to get access to the roots. |
925 Object** roots_array_start() { return roots_; } | 927 Object** roots_array_start() { return roots_; } |
926 | 928 |
927 Address* store_buffer_top_address() { | 929 Address* store_buffer_top_address() { |
928 return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]); | 930 return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]); |
929 } | 931 } |
930 | 932 |
| 933 static bool RootIsImmortalImmovable(int root_index); |
| 934 |
931 #ifdef VERIFY_HEAP | 935 #ifdef VERIFY_HEAP |
932 // Verify the heap is in its normal state before or after a GC. | 936 // Verify the heap is in its normal state before or after a GC. |
933 void Verify(); | 937 void Verify(); |
934 | 938 |
935 | 939 |
936 bool weak_embedded_objects_verification_enabled() { | 940 bool weak_embedded_objects_verification_enabled() { |
937 return no_weak_object_verification_scope_depth_ == 0; | 941 return no_weak_object_verification_scope_depth_ == 0; |
938 } | 942 } |
939 #endif | 943 #endif |
940 | 944 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 kStringTableRootIndex, | 1113 kStringTableRootIndex, |
1110 | 1114 |
1111 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, | 1115 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, |
1112 SMI_ROOT_LIST(ROOT_INDEX_DECLARATION) | 1116 SMI_ROOT_LIST(ROOT_INDEX_DECLARATION) |
1113 #undef ROOT_INDEX_DECLARATION | 1117 #undef ROOT_INDEX_DECLARATION |
1114 kRootListLength, | 1118 kRootListLength, |
1115 kStrongRootListLength = kStringTableRootIndex, | 1119 kStrongRootListLength = kStringTableRootIndex, |
1116 kSmiRootsStart = kStringTableRootIndex + 1 | 1120 kSmiRootsStart = kStringTableRootIndex + 1 |
1117 }; | 1121 }; |
1118 | 1122 |
| 1123 Object* root(RootListIndex index) { return roots_[index]; } |
| 1124 |
1119 STATIC_ASSERT(kUndefinedValueRootIndex == | 1125 STATIC_ASSERT(kUndefinedValueRootIndex == |
1120 Internals::kUndefinedValueRootIndex); | 1126 Internals::kUndefinedValueRootIndex); |
1121 STATIC_ASSERT(kNullValueRootIndex == Internals::kNullValueRootIndex); | 1127 STATIC_ASSERT(kNullValueRootIndex == Internals::kNullValueRootIndex); |
1122 STATIC_ASSERT(kTrueValueRootIndex == Internals::kTrueValueRootIndex); | 1128 STATIC_ASSERT(kTrueValueRootIndex == Internals::kTrueValueRootIndex); |
1123 STATIC_ASSERT(kFalseValueRootIndex == Internals::kFalseValueRootIndex); | 1129 STATIC_ASSERT(kFalseValueRootIndex == Internals::kFalseValueRootIndex); |
1124 STATIC_ASSERT(kempty_stringRootIndex == Internals::kEmptyStringRootIndex); | 1130 STATIC_ASSERT(kempty_stringRootIndex == Internals::kEmptyStringRootIndex); |
1125 | 1131 |
1126 // Generated code can embed direct references to non-writable roots if | 1132 // Generated code can embed direct references to non-writable roots if |
1127 // they are in new space. | 1133 // they are in new space. |
1128 static bool RootCanBeWrittenAfterInitialization(RootListIndex root_index); | 1134 static bool RootCanBeWrittenAfterInitialization(RootListIndex root_index); |
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2548 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2554 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2549 | 2555 |
2550 private: | 2556 private: |
2551 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2557 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2552 }; | 2558 }; |
2553 #endif // DEBUG | 2559 #endif // DEBUG |
2554 } | 2560 } |
2555 } // namespace v8::internal | 2561 } // namespace v8::internal |
2556 | 2562 |
2557 #endif // V8_HEAP_HEAP_H_ | 2563 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |