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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 Address* OldSpaceAllocationTopAddress() { | 810 Address* OldSpaceAllocationTopAddress() { |
811 return old_space_->allocation_top_address(); | 811 return old_space_->allocation_top_address(); |
812 } | 812 } |
813 Address* OldSpaceAllocationLimitAddress() { | 813 Address* OldSpaceAllocationLimitAddress() { |
814 return old_space_->allocation_limit_address(); | 814 return old_space_->allocation_limit_address(); |
815 } | 815 } |
816 | 816 |
817 // TODO(hpayer): There is still a missmatch between capacity and actual | 817 // TODO(hpayer): There is still a missmatch between capacity and actual |
818 // committed memory size. | 818 // committed memory size. |
819 bool CanExpandOldGeneration(int size) { | 819 bool CanExpandOldGeneration(int size) { |
| 820 if (force_oom_) return false; |
820 return (CommittedOldGenerationMemory() + size) < MaxOldGenerationSize(); | 821 return (CommittedOldGenerationMemory() + size) < MaxOldGenerationSize(); |
821 } | 822 } |
822 | 823 |
823 // Clear the Instanceof cache (used when a prototype changes). | 824 // Clear the Instanceof cache (used when a prototype changes). |
824 inline void ClearInstanceofCache(); | 825 inline void ClearInstanceofCache(); |
825 | 826 |
826 // FreeSpace objects have a null map after deserialization. Update the map. | 827 // FreeSpace objects have a null map after deserialization. Update the map. |
827 void RepairFreeListsAfterDeserialization(); | 828 void RepairFreeListsAfterDeserialization(); |
828 | 829 |
829 // Move len elements within a given array from src_index index to dst_index | 830 // Move len elements within a given array from src_index index to dst_index |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2110 MUST_USE_RESULT AllocationResult | 2111 MUST_USE_RESULT AllocationResult |
2111 AllocateForeign(Address address, PretenureFlag pretenure = NOT_TENURED); | 2112 AllocateForeign(Address address, PretenureFlag pretenure = NOT_TENURED); |
2112 | 2113 |
2113 MUST_USE_RESULT AllocationResult | 2114 MUST_USE_RESULT AllocationResult |
2114 AllocateCode(int object_size, bool immovable); | 2115 AllocateCode(int object_size, bool immovable); |
2115 | 2116 |
2116 MUST_USE_RESULT AllocationResult InternalizeStringWithKey(HashTableKey* key); | 2117 MUST_USE_RESULT AllocationResult InternalizeStringWithKey(HashTableKey* key); |
2117 | 2118 |
2118 MUST_USE_RESULT AllocationResult InternalizeString(String* str); | 2119 MUST_USE_RESULT AllocationResult InternalizeString(String* str); |
2119 | 2120 |
| 2121 void set_force_oom(bool value) { force_oom_ = value; } |
| 2122 |
2120 // The amount of external memory registered through the API kept alive | 2123 // The amount of external memory registered through the API kept alive |
2121 // by global handles | 2124 // by global handles |
2122 int64_t amount_of_external_allocated_memory_; | 2125 int64_t amount_of_external_allocated_memory_; |
2123 | 2126 |
2124 // Caches the amount of external memory registered at the last global gc. | 2127 // Caches the amount of external memory registered at the last global gc. |
2125 int64_t amount_of_external_allocated_memory_at_last_global_gc_; | 2128 int64_t amount_of_external_allocated_memory_at_last_global_gc_; |
2126 | 2129 |
2127 // This can be calculated directly from a pointer to the heap; however, it is | 2130 // This can be calculated directly from a pointer to the heap; however, it is |
2128 // more expedient to get at the isolate directly from within Heap methods. | 2131 // more expedient to get at the isolate directly from within Heap methods. |
2129 Isolate* isolate_; | 2132 Isolate* isolate_; |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2358 base::Mutex relocation_mutex_; | 2361 base::Mutex relocation_mutex_; |
2359 | 2362 |
2360 int gc_callbacks_depth_; | 2363 int gc_callbacks_depth_; |
2361 | 2364 |
2362 bool deserialization_complete_; | 2365 bool deserialization_complete_; |
2363 | 2366 |
2364 StrongRootsList* strong_roots_list_; | 2367 StrongRootsList* strong_roots_list_; |
2365 | 2368 |
2366 ArrayBufferTracker* array_buffer_tracker_; | 2369 ArrayBufferTracker* array_buffer_tracker_; |
2367 | 2370 |
| 2371 // Used for testing purposes. |
| 2372 bool force_oom_; |
| 2373 |
2368 // Classes in "heap" can be friends. | 2374 // Classes in "heap" can be friends. |
2369 friend class AlwaysAllocateScope; | 2375 friend class AlwaysAllocateScope; |
2370 friend class GCCallbacksScope; | 2376 friend class GCCallbacksScope; |
2371 friend class GCTracer; | 2377 friend class GCTracer; |
2372 friend class HeapIterator; | 2378 friend class HeapIterator; |
2373 friend class IdleScavengeObserver; | 2379 friend class IdleScavengeObserver; |
2374 friend class IncrementalMarking; | 2380 friend class IncrementalMarking; |
2375 friend class IteratePointersToFromSpaceVisitor; | 2381 friend class IteratePointersToFromSpaceVisitor; |
2376 friend class MarkCompactCollector; | 2382 friend class MarkCompactCollector; |
2377 friend class MarkCompactMarkingVisitor; | 2383 friend class MarkCompactMarkingVisitor; |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2737 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2743 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2738 | 2744 |
2739 private: | 2745 private: |
2740 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2746 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2741 }; | 2747 }; |
2742 #endif // DEBUG | 2748 #endif // DEBUG |
2743 } // namespace internal | 2749 } // namespace internal |
2744 } // namespace v8 | 2750 } // namespace v8 |
2745 | 2751 |
2746 #endif // V8_HEAP_HEAP_H_ | 2752 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |