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

Unified Diff: runtime/vm/scavenger.h

Issue 320463003: Make unused semispace available to other isolates. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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/memory_region.h ('k') | runtime/vm/scavenger.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scavenger.h
===================================================================
--- runtime/vm/scavenger.h (revision 37032)
+++ runtime/vm/scavenger.h (working copy)
@@ -25,6 +25,42 @@
DECLARE_FLAG(bool, gc_at_alloc);
+
+// Wrapper around VirtualMemory that adds caching and handles the empty case.
+class SemiSpace {
+ public:
+ static void InitOnce();
+
+ // Get a space of the given size. Returns NULL on out of memory. If size is 0,
+ // returns an empty space: pointer(), start() and end() all return NULL/0.
+ static SemiSpace* New(intptr_t size);
+
+ // Hand back an unused space.
+ void Delete();
+
+ void* pointer() const { return region_.pointer(); }
+ uword start() const { return region_.start(); }
+ uword end() const { return region_.end(); }
+ intptr_t size() const { return static_cast<intptr_t>(region_.size()); }
+ bool Contains(uword address) const { return region_.Contains(address); }
+
+ // Set write protection mode for this space. The space must not be protected
+ // when Delete is called.
+ // TODO(koda): Remember protection mode in VirtualMemory and assert this.
+ void WriteProtect(bool read_only);
+
+ private:
+ explicit SemiSpace(VirtualMemory* reserved);
+ ~SemiSpace();
+
+ VirtualMemory* reserved_; // NULL for an emtpy space.
+ MemoryRegion region_;
+
+ static SemiSpace* cache_;
+ static Mutex* mutex_;
+};
+
+
class Scavenger {
public:
Scavenger(Heap* heap, intptr_t max_capacity_in_words, uword object_alignment);
@@ -38,7 +74,7 @@
// No reasonable algorithm should be checking for objects in from space. At
// least unless it is debugging code. This might need to be relaxed later,
// but currently it helps prevent dumb bugs.
- ASSERT(!from_->Contains(addr));
+ ASSERT(from_ == NULL || !from_->Contains(addr));
return to_->Contains(addr);
}
@@ -183,9 +219,8 @@
void ProcessWeakTables();
- VirtualMemory* space_;
- MemoryRegion* to_;
- MemoryRegion* from_;
+ SemiSpace* from_;
+ SemiSpace* to_;
Heap* heap_;
« no previous file with comments | « runtime/vm/memory_region.h ('k') | runtime/vm/scavenger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698