| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 V(JSObject, message_listeners, MessageListeners) \ | 171 V(JSObject, message_listeners, MessageListeners) \ |
| 172 V(UnseededNumberDictionary, code_stubs, CodeStubs) \ | 172 V(UnseededNumberDictionary, code_stubs, CodeStubs) \ |
| 173 V(UnseededNumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ | 173 V(UnseededNumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ |
| 174 V(PolymorphicCodeCache, polymorphic_code_cache, PolymorphicCodeCache) \ | 174 V(PolymorphicCodeCache, polymorphic_code_cache, PolymorphicCodeCache) \ |
| 175 V(Code, js_entry_code, JsEntryCode) \ | 175 V(Code, js_entry_code, JsEntryCode) \ |
| 176 V(Code, js_construct_entry_code, JsConstructEntryCode) \ | 176 V(Code, js_construct_entry_code, JsConstructEntryCode) \ |
| 177 V(FixedArray, natives_source_cache, NativesSourceCache) \ | 177 V(FixedArray, natives_source_cache, NativesSourceCache) \ |
| 178 V(Smi, last_script_id, LastScriptId) \ | 178 V(Smi, last_script_id, LastScriptId) \ |
| 179 V(Script, empty_script, EmptyScript) \ | 179 V(Script, empty_script, EmptyScript) \ |
| 180 V(Smi, real_stack_limit, RealStackLimit) \ | 180 V(Smi, real_stack_limit, RealStackLimit) \ |
| 181 V(NameDictionary, intrinsic_function_names, IntrinsicFunctionNames) \ | 181 V(NameDictionary, intrinsic_function_names, IntrinsicFunctionNames) \ |
| 182 V(Smi, arguments_adaptor_deopt_pc_offset, ArgumentsAdaptorDeoptPCOffset) \ | 182 V(Smi, arguments_adaptor_deopt_pc_offset, ArgumentsAdaptorDeoptPCOffset) \ |
| 183 V(Smi, construct_stub_deopt_pc_offset, ConstructStubDeoptPCOffset) \ | 183 V(Smi, construct_stub_deopt_pc_offset, ConstructStubDeoptPCOffset) \ |
| 184 V(Smi, getter_stub_deopt_pc_offset, GetterStubDeoptPCOffset) \ | 184 V(Smi, getter_stub_deopt_pc_offset, GetterStubDeoptPCOffset) \ |
| 185 V(Smi, setter_stub_deopt_pc_offset, SetterStubDeoptPCOffset) \ | 185 V(Smi, setter_stub_deopt_pc_offset, SetterStubDeoptPCOffset) \ |
| 186 V(JSObject, observation_state, ObservationState) \ | 186 V(JSObject, observation_state, ObservationState) \ |
| 187 V(Map, external_map, ExternalMap) \ | 187 V(Map, external_map, ExternalMap) \ |
| 188 V(Symbol, frozen_symbol, FrozenSymbol) \ | 188 V(Symbol, frozen_symbol, FrozenSymbol) \ |
| 189 V(Symbol, elements_transition_symbol, ElementsTransitionSymbol) \ |
| 189 V(SeededNumberDictionary, empty_slow_element_dictionary, \ | 190 V(SeededNumberDictionary, empty_slow_element_dictionary, \ |
| 190 EmptySlowElementDictionary) \ | 191 EmptySlowElementDictionary) \ |
| 191 V(Symbol, observed_symbol, ObservedSymbol) \ | 192 V(Symbol, observed_symbol, ObservedSymbol) \ |
| 192 V(HeapObject, i18n_template_one, I18nTemplateOne) \ | 193 V(HeapObject, i18n_template_one, I18nTemplateOne) \ |
| 193 V(HeapObject, i18n_template_two, I18nTemplateTwo) | 194 V(HeapObject, i18n_template_two, I18nTemplateTwo) |
| 194 | 195 |
| 195 #define ROOT_LIST(V) \ | 196 #define ROOT_LIST(V) \ |
| 196 STRONG_ROOT_LIST(V) \ | 197 STRONG_ROOT_LIST(V) \ |
| 197 V(StringTable, string_table, StringTable) | 198 V(StringTable, string_table, StringTable) |
| 198 | 199 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 476 |
| 476 DISALLOW_COPY_AND_ASSIGN(ExternalStringTable); | 477 DISALLOW_COPY_AND_ASSIGN(ExternalStringTable); |
| 477 }; | 478 }; |
| 478 | 479 |
| 479 | 480 |
| 480 enum ArrayStorageAllocationMode { | 481 enum ArrayStorageAllocationMode { |
| 481 DONT_INITIALIZE_ARRAY_ELEMENTS, | 482 DONT_INITIALIZE_ARRAY_ELEMENTS, |
| 482 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE | 483 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE |
| 483 }; | 484 }; |
| 484 | 485 |
| 486 |
| 485 class Heap { | 487 class Heap { |
| 486 public: | 488 public: |
| 487 // Configure heap size before setup. Return false if the heap has been | 489 // Configure heap size before setup. Return false if the heap has been |
| 488 // set up already. | 490 // set up already. |
| 489 bool ConfigureHeap(int max_semispace_size, | 491 bool ConfigureHeap(int max_semispace_size, |
| 490 intptr_t max_old_gen_size, | 492 intptr_t max_old_gen_size, |
| 491 intptr_t max_executable_size); | 493 intptr_t max_executable_size); |
| 492 bool ConfigureHeapDefault(); | 494 bool ConfigureHeapDefault(); |
| 493 | 495 |
| 494 // Prepares the heap, setting up memory areas that are needed in the isolate | 496 // Prepares the heap, setting up memory areas that are needed in the isolate |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 void CollectAllAvailableGarbage(const char* gc_reason = NULL); | 1249 void CollectAllAvailableGarbage(const char* gc_reason = NULL); |
| 1248 | 1250 |
| 1249 // Check whether the heap is currently iterable. | 1251 // Check whether the heap is currently iterable. |
| 1250 bool IsHeapIterable(); | 1252 bool IsHeapIterable(); |
| 1251 | 1253 |
| 1252 // Ensure that we have swept all spaces in such a way that we can iterate | 1254 // Ensure that we have swept all spaces in such a way that we can iterate |
| 1253 // over all objects. May cause a GC. | 1255 // over all objects. May cause a GC. |
| 1254 void EnsureHeapIsIterable(); | 1256 void EnsureHeapIsIterable(); |
| 1255 | 1257 |
| 1256 // Notify the heap that a context has been disposed. | 1258 // Notify the heap that a context has been disposed. |
| 1257 int NotifyContextDisposed(); | 1259 int NotifyContextDisposed() { |
| 1260 flush_monomorphic_ics_ = true; |
| 1261 return ++contexts_disposed_; |
| 1262 } |
| 1258 | 1263 |
| 1259 // Utility to invoke the scavenger. This is needed in test code to | 1264 // Utility to invoke the scavenger. This is needed in test code to |
| 1260 // ensure correct callback for weak global handles. | 1265 // ensure correct callback for weak global handles. |
| 1261 void PerformScavenge(); | 1266 void PerformScavenge(); |
| 1262 | 1267 |
| 1263 inline void increment_scan_on_scavenge_pages() { | 1268 inline void increment_scan_on_scavenge_pages() { |
| 1264 scan_on_scavenge_pages_++; | 1269 scan_on_scavenge_pages_++; |
| 1265 if (FLAG_gc_verbose) { | 1270 if (FLAG_gc_verbose) { |
| 1266 PrintF("Scan-on-scavenge pages: %d\n", scan_on_scavenge_pages_); | 1271 PrintF("Scan-on-scavenge pages: %d\n", scan_on_scavenge_pages_); |
| 1267 } | 1272 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1388 bool Contains(Address addr); | 1393 bool Contains(Address addr); |
| 1389 bool Contains(HeapObject* value); | 1394 bool Contains(HeapObject* value); |
| 1390 | 1395 |
| 1391 // Checks whether an address/object in a space. | 1396 // Checks whether an address/object in a space. |
| 1392 // Currently used by tests, serialization and heap verification only. | 1397 // Currently used by tests, serialization and heap verification only. |
| 1393 bool InSpace(Address addr, AllocationSpace space); | 1398 bool InSpace(Address addr, AllocationSpace space); |
| 1394 bool InSpace(HeapObject* value, AllocationSpace space); | 1399 bool InSpace(HeapObject* value, AllocationSpace space); |
| 1395 | 1400 |
| 1396 // Finds out which space an object should get promoted to based on its type. | 1401 // Finds out which space an object should get promoted to based on its type. |
| 1397 inline OldSpace* TargetSpace(HeapObject* object); | 1402 inline OldSpace* TargetSpace(HeapObject* object); |
| 1398 inline AllocationSpace TargetSpaceId(InstanceType type); | 1403 static inline AllocationSpace TargetSpaceId(InstanceType type); |
| 1399 | 1404 |
| 1400 // Sets the stub_cache_ (only used when expanding the dictionary). | 1405 // Sets the stub_cache_ (only used when expanding the dictionary). |
| 1401 void public_set_code_stubs(UnseededNumberDictionary* value) { | 1406 void public_set_code_stubs(UnseededNumberDictionary* value) { |
| 1402 roots_[kCodeStubsRootIndex] = value; | 1407 roots_[kCodeStubsRootIndex] = value; |
| 1403 } | 1408 } |
| 1404 | 1409 |
| 1405 // Support for computing object sizes for old objects during GCs. Returns | 1410 // Support for computing object sizes for old objects during GCs. Returns |
| 1406 // a function that is guaranteed to be safe for computing object sizes in | 1411 // a function that is guaranteed to be safe for computing object sizes in |
| 1407 // the current GC phase. | 1412 // the current GC phase. |
| 1408 HeapObjectCallback GcSafeSizeOfOldObjectFunction() { | 1413 HeapObjectCallback GcSafeSizeOfOldObjectFunction() { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 // Adjusts the amount of registered external memory. | 1540 // Adjusts the amount of registered external memory. |
| 1536 // Returns the adjusted value. | 1541 // Returns the adjusted value. |
| 1537 inline intptr_t AdjustAmountOfExternalAllocatedMemory( | 1542 inline intptr_t AdjustAmountOfExternalAllocatedMemory( |
| 1538 intptr_t change_in_bytes); | 1543 intptr_t change_in_bytes); |
| 1539 | 1544 |
| 1540 // Allocate uninitialized fixed array. | 1545 // Allocate uninitialized fixed array. |
| 1541 MUST_USE_RESULT MaybeObject* AllocateRawFixedArray(int length); | 1546 MUST_USE_RESULT MaybeObject* AllocateRawFixedArray(int length); |
| 1542 MUST_USE_RESULT MaybeObject* AllocateRawFixedArray(int length, | 1547 MUST_USE_RESULT MaybeObject* AllocateRawFixedArray(int length, |
| 1543 PretenureFlag pretenure); | 1548 PretenureFlag pretenure); |
| 1544 | 1549 |
| 1545 // Predicate that governs global pre-tenuring decisions based on observed | |
| 1546 // promotion rates of previous collections. | |
| 1547 inline bool ShouldGloballyPretenure() { | |
| 1548 return FLAG_pretenuring && new_space_high_promotion_mode_active_; | |
| 1549 } | |
| 1550 | |
| 1551 // This is only needed for testing high promotion mode. | 1550 // This is only needed for testing high promotion mode. |
| 1552 void SetNewSpaceHighPromotionModeActive(bool mode) { | 1551 void SetNewSpaceHighPromotionModeActive(bool mode) { |
| 1553 new_space_high_promotion_mode_active_ = mode; | 1552 new_space_high_promotion_mode_active_ = mode; |
| 1554 } | 1553 } |
| 1555 | 1554 |
| 1555 // Returns the allocation mode (pre-tenuring) based on observed promotion |
| 1556 // rates of previous collections. |
| 1556 inline PretenureFlag GetPretenureMode() { | 1557 inline PretenureFlag GetPretenureMode() { |
| 1557 return new_space_high_promotion_mode_active_ ? TENURED : NOT_TENURED; | 1558 return FLAG_pretenuring && new_space_high_promotion_mode_active_ |
| 1559 ? TENURED : NOT_TENURED; |
| 1558 } | 1560 } |
| 1559 | 1561 |
| 1560 inline Address* NewSpaceHighPromotionModeActiveAddress() { | 1562 inline Address* NewSpaceHighPromotionModeActiveAddress() { |
| 1561 return reinterpret_cast<Address*>(&new_space_high_promotion_mode_active_); | 1563 return reinterpret_cast<Address*>(&new_space_high_promotion_mode_active_); |
| 1562 } | 1564 } |
| 1563 | 1565 |
| 1564 inline intptr_t PromotedTotalSize() { | 1566 inline intptr_t PromotedTotalSize() { |
| 1565 return PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize(); | 1567 return PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize(); |
| 1566 } | 1568 } |
| 1567 | 1569 |
| (...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3047 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 3049 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 3048 | 3050 |
| 3049 private: | 3051 private: |
| 3050 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 3052 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 3051 }; | 3053 }; |
| 3052 #endif // DEBUG | 3054 #endif // DEBUG |
| 3053 | 3055 |
| 3054 } } // namespace v8::internal | 3056 } } // namespace v8::internal |
| 3055 | 3057 |
| 3056 #endif // V8_HEAP_H_ | 3058 #endif // V8_HEAP_H_ |
| OLD | NEW |