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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/pages.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/pages.h
===================================================================
--- runtime/vm/pages.h (revision 41244)
+++ runtime/vm/pages.h (working copy)
@@ -7,6 +7,7 @@
#include "vm/freelist.h"
#include "vm/globals.h"
+#include "vm/lockers.h"
#include "vm/ring_buffer.h"
#include "vm/spaces.h"
#include "vm/virtual_memory.h"
@@ -214,11 +215,25 @@
}
intptr_t UsedInWords() const { return usage_.used_in_words; }
- intptr_t CapacityInWords() const { return usage_.capacity_in_words; }
+ intptr_t CapacityInWords() const {
+ MutexLocker ml(pages_lock_);
+ return usage_.capacity_in_words;
+ }
+ void IncreaseCapacityInWords(intptr_t increase_in_words) {
+ MutexLocker ml(pages_lock_);
+ IncreaseCapacityInWordsLocked(increase_in_words);
+ }
+ void IncreaseCapacityInWordsLocked(intptr_t increase_in_words) {
+ DEBUG_ASSERT(pages_lock_->Owner() == Isolate::Current());
+ usage_.capacity_in_words += increase_in_words;
+ }
intptr_t ExternalInWords() const {
return usage_.external_in_words;
}
- SpaceUsage GetCurrentUsage() const { return usage_; }
+ SpaceUsage GetCurrentUsage() const {
+ MutexLocker ml(pages_lock_);
+ return usage_;
+ }
bool Contains(uword addr) const;
bool Contains(uword addr, HeapPage::PageType type) const;
@@ -385,6 +400,8 @@
// Various sizes being tracked for this generation.
intptr_t max_capacity_in_words_;
+ // NOTE: The capacity component of usage_ is updated by the concurrent
+ // sweeper. Use (Increase)CapacityInWords(Locked) for thread-safe access.
SpaceUsage usage_;
// Keep track of running MarkSweep tasks.
« 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