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

Unified Diff: runtime/vm/freelist.cc

Issue 474913004: - Account for number of pending tasks in old-space collections. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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 | « runtime/vm/freelist.h ('k') | runtime/vm/heap.h » ('j') | runtime/vm/heap.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/freelist.cc
===================================================================
--- runtime/vm/freelist.cc (revision 39381)
+++ runtime/vm/freelist.cc (working copy)
@@ -5,11 +5,12 @@
#include "vm/freelist.h"
#include <map>
-#include <utility>
#include "vm/bit_set.h"
+#include "vm/lockers.h"
#include "vm/object.h"
#include "vm/raw_object.h"
+#include "vm/thread.h"
namespace dart {
@@ -49,17 +50,24 @@
}
-FreeList::FreeList() {
+FreeList::FreeList() : mutex_(new Mutex()) {
Reset();
}
FreeList::~FreeList() {
- // Nothing to release.
+ delete mutex_;
}
uword FreeList::TryAllocate(intptr_t size, bool is_protected) {
+ MutexLocker ml(mutex_);
+ return TryAllocateLocked(size, is_protected);
+}
+
+
+uword FreeList::TryAllocateLocked(intptr_t size, bool is_protected) {
+ DEBUG_ASSERT(mutex_->Owner() == Isolate::Current());
// Precondition: is_protected is false or else all free list elements are
// in non-writable pages.
@@ -166,6 +174,13 @@
void FreeList::Free(uword addr, intptr_t size) {
+ MutexLocker ml(mutex_);
+ FreeLocked(addr, size);
+}
+
+
+void FreeList::FreeLocked(uword addr, intptr_t size) {
+ DEBUG_ASSERT(mutex_->Owner() == Isolate::Current());
// Precondition required by AsElement and EnqueueElement: the (page
// containing the) header of the freed block should be writable. This is
// the case when called for newly allocated pages because they are
@@ -179,6 +194,7 @@
void FreeList::Reset() {
+ MutexLocker ml(mutex_);
free_map_.Reset();
for (int i = 0; i < (kNumLists + 1); i++) {
free_lists_[i] = NULL;
@@ -220,6 +236,7 @@
intptr_t FreeList::Length(int index) const {
+ MutexLocker ml(mutex_);
ASSERT(index >= 0);
ASSERT(index < kNumLists);
intptr_t result = 0;
@@ -290,6 +307,7 @@
void FreeList::Print() const {
+ MutexLocker ml(mutex_);
PrintSmall();
PrintLarge();
}
« no previous file with comments | « runtime/vm/freelist.h ('k') | runtime/vm/heap.h » ('j') | runtime/vm/heap.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698