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/pages.h

Issue 670973002: Avoid races in capacity accounting. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | runtime/vm/pages.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 (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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_PAGES_H_ 5 #ifndef VM_PAGES_H_
6 #define VM_PAGES_H_ 6 #define VM_PAGES_H_
7 7
8 #include "vm/freelist.h" 8 #include "vm/freelist.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/lockers.h"
10 #include "vm/ring_buffer.h" 11 #include "vm/ring_buffer.h"
11 #include "vm/spaces.h" 12 #include "vm/spaces.h"
12 #include "vm/virtual_memory.h" 13 #include "vm/virtual_memory.h"
13 14
14 namespace dart { 15 namespace dart {
15 16
16 DECLARE_FLAG(bool, collect_code); 17 DECLARE_FLAG(bool, collect_code);
17 DECLARE_FLAG(bool, log_code_drop); 18 DECLARE_FLAG(bool, log_code_drop);
18 DECLARE_FLAG(bool, always_drop_code); 19 DECLARE_FLAG(bool, always_drop_code);
19 DECLARE_FLAG(bool, write_protect_code); 20 DECLARE_FLAG(bool, write_protect_code);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 return TryAllocateInternal( 208 return TryAllocateInternal(
208 size, type, growth_policy, is_protected, is_locked); 209 size, type, growth_policy, is_protected, is_locked);
209 } 210 }
210 211
211 bool NeedsGarbageCollection() const { 212 bool NeedsGarbageCollection() const {
212 return page_space_controller_.NeedsGarbageCollection(usage_) || 213 return page_space_controller_.NeedsGarbageCollection(usage_) ||
213 NeedsExternalGC(); 214 NeedsExternalGC();
214 } 215 }
215 216
216 intptr_t UsedInWords() const { return usage_.used_in_words; } 217 intptr_t UsedInWords() const { return usage_.used_in_words; }
217 intptr_t CapacityInWords() const { return usage_.capacity_in_words; } 218 intptr_t CapacityInWords() const {
219 MutexLocker ml(pages_lock_);
220 return usage_.capacity_in_words;
221 }
222 void IncreaseCapacityInWords(intptr_t increase_in_words) {
223 MutexLocker ml(pages_lock_);
224 IncreaseCapacityInWordsLocked(increase_in_words);
225 }
226 void IncreaseCapacityInWordsLocked(intptr_t increase_in_words) {
227 DEBUG_ASSERT(pages_lock_->Owner() == Isolate::Current());
228 usage_.capacity_in_words += increase_in_words;
229 }
218 intptr_t ExternalInWords() const { 230 intptr_t ExternalInWords() const {
219 return usage_.external_in_words; 231 return usage_.external_in_words;
220 } 232 }
221 SpaceUsage GetCurrentUsage() const { return usage_; } 233 SpaceUsage GetCurrentUsage() const {
234 MutexLocker ml(pages_lock_);
235 return usage_;
236 }
222 237
223 bool Contains(uword addr) const; 238 bool Contains(uword addr) const;
224 bool Contains(uword addr, HeapPage::PageType type) const; 239 bool Contains(uword addr, HeapPage::PageType type) const;
225 bool IsValidAddress(uword addr) const { 240 bool IsValidAddress(uword addr) const {
226 return Contains(addr); 241 return Contains(addr);
227 } 242 }
228 243
229 void VisitObjects(ObjectVisitor* visitor) const; 244 void VisitObjects(ObjectVisitor* visitor) const;
230 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; 245 void VisitObjectPointers(ObjectPointerVisitor* visitor) const;
231 246
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 HeapPage* exec_pages_tail_; 393 HeapPage* exec_pages_tail_;
379 HeapPage* large_pages_; 394 HeapPage* large_pages_;
380 395
381 // A block of memory in a data page, managed by bump allocation. The remainder 396 // A block of memory in a data page, managed by bump allocation. The remainder
382 // is kept formatted as a FreeListElement, but is not in any freelist. 397 // is kept formatted as a FreeListElement, but is not in any freelist.
383 uword bump_top_; 398 uword bump_top_;
384 uword bump_end_; 399 uword bump_end_;
385 400
386 // Various sizes being tracked for this generation. 401 // Various sizes being tracked for this generation.
387 intptr_t max_capacity_in_words_; 402 intptr_t max_capacity_in_words_;
403 // NOTE: The capacity component of usage_ is updated by the concurrent
404 // sweeper. Use (Increase)CapacityInWords(Locked) for thread-safe access.
388 SpaceUsage usage_; 405 SpaceUsage usage_;
389 406
390 // Keep track of running MarkSweep tasks. 407 // Keep track of running MarkSweep tasks.
391 Monitor* tasks_lock_; 408 Monitor* tasks_lock_;
392 intptr_t tasks_; 409 intptr_t tasks_;
393 410
394 PageSpaceController page_space_controller_; 411 PageSpaceController page_space_controller_;
395 412
396 int64_t gc_time_micros_; 413 int64_t gc_time_micros_;
397 intptr_t collections_; 414 intptr_t collections_;
398 415
399 friend class ExclusivePageIterator; 416 friend class ExclusivePageIterator;
400 friend class PageSpaceController; 417 friend class PageSpaceController;
401 friend class SweeperTask; 418 friend class SweeperTask;
402 419
403 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); 420 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace);
404 }; 421 };
405 422
406 } // namespace dart 423 } // namespace dart
407 424
408 #endif // VM_PAGES_H_ 425 #endif // VM_PAGES_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/pages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698