Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(676)

Side by Side Diff: src/heap/heap.h

Issue 677043002: Flush code faster when doing emergency GCs. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Change ReleaseUnoptimizedCode test to a harder test that fails without this CL Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/heap/heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 // Returns whether there is a chance that another major GC could 729 // Returns whether there is a chance that another major GC could
730 // collect more garbage. 730 // collect more garbage.
731 inline bool CollectGarbage( 731 inline bool CollectGarbage(
732 AllocationSpace space, const char* gc_reason = NULL, 732 AllocationSpace space, const char* gc_reason = NULL,
733 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); 733 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags);
734 734
735 static const int kNoGCFlags = 0; 735 static const int kNoGCFlags = 0;
736 static const int kReduceMemoryFootprintMask = 1; 736 static const int kReduceMemoryFootprintMask = 1;
737 static const int kAbortIncrementalMarkingMask = 2; 737 static const int kAbortIncrementalMarkingMask = 2;
738 738
739 // We do up to 7 GCs when there is a low memory notification.
740 static const int kMaxEmergencyGCs = 7;
741
739 // Making the heap iterable requires us to abort incremental marking. 742 // Making the heap iterable requires us to abort incremental marking.
740 static const int kMakeHeapIterableMask = kAbortIncrementalMarkingMask; 743 static const int kMakeHeapIterableMask = kAbortIncrementalMarkingMask;
741 744
742 // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is 745 // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is
743 // non-zero, then the slower precise sweeper is used, which leaves the heap 746 // non-zero, then the slower precise sweeper is used, which leaves the heap
744 // in a state where we can iterate over the heap visiting all objects. 747 // in a state where we can iterate over the heap visiting all objects.
745 void CollectAllGarbage( 748 void CollectAllGarbage(
746 int flags, const char* gc_reason = NULL, 749 int flags, const char* gc_reason = NULL,
747 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); 750 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags);
748 751
749 // Last hope GC, should try to squeeze as much as possible. 752 // Last hope GC, should try to squeeze as much as possible.
750 void CollectAllAvailableGarbage(const char* gc_reason = NULL); 753 void CollectAllAvailableGarbage(const char* gc_reason = NULL,
754 int maxGCs = kMaxEmergencyGCs);
751 755
752 // Check whether the heap is currently iterable. 756 // Check whether the heap is currently iterable.
753 bool IsHeapIterable(); 757 bool IsHeapIterable();
754 758
755 // Notify the heap that a context has been disposed. 759 // Notify the heap that a context has been disposed.
756 int NotifyContextDisposed(); 760 int NotifyContextDisposed();
757 761
758 inline void increment_scan_on_scavenge_pages() { 762 inline void increment_scan_on_scavenge_pages() {
759 scan_on_scavenge_pages_++; 763 scan_on_scavenge_pages_++;
760 if (FLAG_gc_verbose) { 764 if (FLAG_gc_verbose) {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 INLINE(void RecordWrite(Address address, int offset)); 982 INLINE(void RecordWrite(Address address, int offset));
979 983
980 // Write barrier support for address[start : start + len[ = o. 984 // Write barrier support for address[start : start + len[ = o.
981 INLINE(void RecordWrites(Address address, int start, int len)); 985 INLINE(void RecordWrites(Address address, int start, int len));
982 986
983 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT }; 987 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT };
984 inline HeapState gc_state() { return gc_state_; } 988 inline HeapState gc_state() { return gc_state_; }
985 989
986 inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; } 990 inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; }
987 991
992 bool flush_eagerly() { return flush_eagerly_; }
993 void set_flush_eagerly(bool to) { flush_eagerly_ = to; }
994
988 #ifdef DEBUG 995 #ifdef DEBUG
989 void set_allocation_timeout(int timeout) { allocation_timeout_ = timeout; } 996 void set_allocation_timeout(int timeout) { allocation_timeout_ = timeout; }
990 997
991 void TracePathToObjectFrom(Object* target, Object* root); 998 void TracePathToObjectFrom(Object* target, Object* root);
992 void TracePathToObject(Object* target); 999 void TracePathToObject(Object* target);
993 void TracePathToGlobal(); 1000 void TracePathToGlobal();
994 #endif 1001 #endif
995 1002
996 // Callback function passed to Heap::Iterate etc. Copies an object if 1003 // Callback function passed to Heap::Iterate etc. Copies an object if
997 // necessary, the object might be promoted to an old space. The caller must 1004 // necessary, the object might be promoted to an old space. The caller must
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 ROOT_LIST(ROOT_ACCESSOR) 1551 ROOT_LIST(ROOT_ACCESSOR)
1545 #undef ROOT_ACCESSOR 1552 #undef ROOT_ACCESSOR
1546 1553
1547 #ifdef DEBUG 1554 #ifdef DEBUG
1548 // If the --gc-interval flag is set to a positive value, this 1555 // If the --gc-interval flag is set to a positive value, this
1549 // variable holds the value indicating the number of allocations 1556 // variable holds the value indicating the number of allocations
1550 // remain until the next failure and garbage collection. 1557 // remain until the next failure and garbage collection.
1551 int allocation_timeout_; 1558 int allocation_timeout_;
1552 #endif // DEBUG 1559 #endif // DEBUG
1553 1560
1561 // For emergency memory-freeing GCs.
1562 bool flush_eagerly_;
1563
1554 // Limit that triggers a global GC on the next (normally caused) GC. This 1564 // Limit that triggers a global GC on the next (normally caused) GC. This
1555 // is checked when we have already decided to do a GC to help determine 1565 // is checked when we have already decided to do a GC to help determine
1556 // which collector to invoke, before expanding a paged space in the old 1566 // which collector to invoke, before expanding a paged space in the old
1557 // generation and on every allocation in large object space. 1567 // generation and on every allocation in large object space.
1558 intptr_t old_generation_allocation_limit_; 1568 intptr_t old_generation_allocation_limit_;
1559 1569
1560 // Indicates that an allocation has failed in the old generation since the 1570 // Indicates that an allocation has failed in the old generation since the
1561 // last GC. 1571 // last GC.
1562 bool old_gen_exhausted_; 1572 bool old_gen_exhausted_;
1563 1573
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 intptr_t* memory_allocator_capacity; // 20 2132 intptr_t* memory_allocator_capacity; // 20
2123 int* objects_per_type; // 21 2133 int* objects_per_type; // 21
2124 int* size_per_type; // 22 2134 int* size_per_type; // 22
2125 int* os_error; // 23 2135 int* os_error; // 23
2126 int* end_marker; // 24 2136 int* end_marker; // 24
2127 intptr_t* property_cell_space_size; // 25 2137 intptr_t* property_cell_space_size; // 25
2128 intptr_t* property_cell_space_capacity; // 26 2138 intptr_t* property_cell_space_capacity; // 26
2129 }; 2139 };
2130 2140
2131 2141
2142 class FlushEagerly {
2143 public:
2144 explicit inline FlushEagerly(Heap* heap);
2145 inline ~FlushEagerly();
2146
2147 private:
2148 Heap* heap_;
2149 bool old_state_;
2150 };
2151
2152
2132 class AlwaysAllocateScope { 2153 class AlwaysAllocateScope {
2133 public: 2154 public:
2134 explicit inline AlwaysAllocateScope(Isolate* isolate); 2155 explicit inline AlwaysAllocateScope(Isolate* isolate);
2135 inline ~AlwaysAllocateScope(); 2156 inline ~AlwaysAllocateScope();
2136 2157
2137 private: 2158 private:
2138 // Implicitly disable artificial allocation failures. 2159 // Implicitly disable artificial allocation failures.
2139 Heap* heap_; 2160 Heap* heap_;
2140 DisallowAllocationFailure daf_; 2161 DisallowAllocationFailure daf_;
2141 }; 2162 };
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2548 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. 2569 DisallowHeapAllocation no_allocation; // i.e. no gc allowed.
2549 2570
2550 private: 2571 private:
2551 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); 2572 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
2552 }; 2573 };
2553 #endif // DEBUG 2574 #endif // DEBUG
2554 } 2575 }
2555 } // namespace v8::internal 2576 } // namespace v8::internal
2556 2577
2557 #endif // V8_HEAP_HEAP_H_ 2578 #endif // V8_HEAP_HEAP_H_
OLDNEW
« no previous file with comments | « no previous file | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698