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

Side by Side Diff: runtime/vm/scavenger.h

Issue 187113003: Track external allocated memory for weak persistent handles. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 months 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_SCAVENGER_H_ 5 #ifndef VM_SCAVENGER_H_
6 #define VM_SCAVENGER_H_ 6 #define VM_SCAVENGER_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "platform/utils.h" 9 #include "platform/utils.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // Accessors to generate code for inlined allocation. 67 // Accessors to generate code for inlined allocation.
68 uword* TopAddress() { return &top_; } 68 uword* TopAddress() { return &top_; }
69 uword* EndAddress() { return &end_; } 69 uword* EndAddress() { return &end_; }
70 static intptr_t top_offset() { return OFFSET_OF(Scavenger, top_); } 70 static intptr_t top_offset() { return OFFSET_OF(Scavenger, top_); }
71 static intptr_t end_offset() { return OFFSET_OF(Scavenger, end_); } 71 static intptr_t end_offset() { return OFFSET_OF(Scavenger, end_); }
72 72
73 intptr_t UsedInWords() const { 73 intptr_t UsedInWords() const {
74 return (top_ - FirstObjectStart()) >> kWordSizeLog2; 74 return (top_ - FirstObjectStart()) >> kWordSizeLog2;
75 } 75 }
76 intptr_t CapacityInWords() const { return space_->size() >> kWordSizeLog2; } 76 intptr_t CapacityInWords() const { return space_->size() >> kWordSizeLog2; }
77 intptr_t ExternalAllocatedInWords() const {
78 return external_allocation_size_ >> kWordSizeLog2;
79 }
77 80
78 void VisitObjects(ObjectVisitor* visitor) const; 81 void VisitObjects(ObjectVisitor* visitor) const;
79 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; 82 void VisitObjectPointers(ObjectPointerVisitor* visitor) const;
80 83
81 void StartEndAddress(uword* start, uword* end) const { 84 void StartEndAddress(uword* start, uword* end) const {
82 *start = to_->start(); 85 *start = to_->start();
83 *end = to_->end(); 86 *end = to_->end();
84 } 87 }
85 88
86 // Returns true if the last scavenge had a promotion failure. 89 // Returns true if the last scavenge had a promotion failure.
(...skipping 14 matching lines...) Expand all
101 void IncrementCollections() { 104 void IncrementCollections() {
102 collections_++; 105 collections_++;
103 } 106 }
104 107
105 intptr_t collections() const { 108 intptr_t collections() const {
106 return collections_; 109 return collections_;
107 } 110 }
108 111
109 void PrintToJSONObject(JSONObject* object); 112 void PrintToJSONObject(JSONObject* object);
110 113
114 void AllocateExternal(intptr_t size);
115 void FreeExternal(intptr_t size);
116
111 private: 117 private:
112 // Ids for time and data records in Heap::GCStats. 118 // Ids for time and data records in Heap::GCStats.
113 enum { 119 enum {
114 // Time 120 // Time
115 kVisitIsolateRoots = 0, 121 kVisitIsolateRoots = 0,
116 kIterateStoreBuffers = 1, 122 kIterateStoreBuffers = 1,
117 kProcessToSpace = 2, 123 kProcessToSpace = 2,
118 kIterateWeaks = 3, 124 kIterateWeaks = 3,
119 // Data 125 // Data
120 kStoreBufferEntries = 0, 126 kStoreBufferEntries = 0,
(...skipping 21 matching lines...) Expand all
142 ScavengerVisitor* visitor, 148 ScavengerVisitor* visitor,
143 bool invoke_api_callbacks); 149 bool invoke_api_callbacks);
144 150
145 bool IsUnreachable(RawObject** p); 151 bool IsUnreachable(RawObject** p);
146 152
147 // During a scavenge we need to remember the promoted objects. 153 // During a scavenge we need to remember the promoted objects.
148 // This is implemented as a stack of objects at the end of the to space. As 154 // This is implemented as a stack of objects at the end of the to space. As
149 // object sizes are always greater than sizeof(uword) and promoted objects do 155 // object sizes are always greater than sizeof(uword) and promoted objects do
150 // not consume space in the to space they leave enough room for this stack. 156 // not consume space in the to space they leave enough room for this stack.
151 void PushToPromotedStack(uword addr) { 157 void PushToPromotedStack(uword addr) {
158 ASSERT(scavenging_);
159 ASSERT(external_allocation_size_ == 0);
152 end_ -= sizeof(addr); 160 end_ -= sizeof(addr);
153 ASSERT(end_ > top_); 161 ASSERT(end_ > top_);
154 *reinterpret_cast<uword*>(end_) = addr; 162 *reinterpret_cast<uword*>(end_) = addr;
155 } 163 }
156 uword PopFromPromotedStack() { 164 uword PopFromPromotedStack() {
165 ASSERT(scavenging_);
166 ASSERT(external_allocation_size_ == 0);
157 uword result = *reinterpret_cast<uword*>(end_); 167 uword result = *reinterpret_cast<uword*>(end_);
158 end_ += sizeof(result); 168 end_ += sizeof(result);
159 ASSERT(end_ <= to_->end()); 169 ASSERT(end_ <= to_->end());
160 return result; 170 return result;
161 } 171 }
162 bool PromotedStackHasMore() const { 172 bool PromotedStackHasMore() const {
173 ASSERT(scavenging_);
174 ASSERT(external_allocation_size_ == 0);
163 return end_ < to_->end(); 175 return end_ < to_->end();
164 } 176 }
165 177
166 void ProcessWeakTables(); 178 void ProcessWeakTables();
167 179
168 VirtualMemory* space_; 180 VirtualMemory* space_;
169 MemoryRegion* to_; 181 MemoryRegion* to_;
170 MemoryRegion* from_; 182 MemoryRegion* from_;
171 183
172 Heap* heap_; 184 Heap* heap_;
(...skipping 14 matching lines...) Expand all
187 uword object_alignment_; 199 uword object_alignment_;
188 200
189 // Keep track whether a scavenge is currently running. 201 // Keep track whether a scavenge is currently running.
190 bool scavenging_; 202 bool scavenging_;
191 // Keep track whether the scavenge had a promotion failure. 203 // Keep track whether the scavenge had a promotion failure.
192 bool had_promotion_failure_; 204 bool had_promotion_failure_;
193 205
194 int64_t gc_time_micros_; 206 int64_t gc_time_micros_;
195 intptr_t collections_; 207 intptr_t collections_;
196 208
209 // The total size of external data associated with objects in this scavenger.
210 // External allocations decrease end_. If promoted stack is in use, this is 0.
211 intptr_t external_allocation_size_;
212
197 friend class ScavengerVisitor; 213 friend class ScavengerVisitor;
198 friend class ScavengerWeakVisitor; 214 friend class ScavengerWeakVisitor;
199 215
200 DISALLOW_COPY_AND_ASSIGN(Scavenger); 216 DISALLOW_COPY_AND_ASSIGN(Scavenger);
201 }; 217 };
202 218
203 } // namespace dart 219 } // namespace dart
204 220
205 #endif // VM_SCAVENGER_H_ 221 #endif // VM_SCAVENGER_H_
OLDNEW
« runtime/vm/pages.cc ('K') | « runtime/vm/pages.cc ('k') | runtime/vm/scavenger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698