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

Unified Diff: runtime/vm/scavenger.cc

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 side-by-side diff with in-line comments
Download patch
« runtime/vm/dart_api_state.h ('K') | « runtime/vm/scavenger.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scavenger.cc
===================================================================
--- runtime/vm/scavenger.cc (revision 33396)
+++ runtime/vm/scavenger.cc (working copy)
@@ -278,12 +278,13 @@
void VisitHandle(uword addr, bool is_prologue_weak) {
FinalizablePersistentHandle* handle =
- reinterpret_cast<FinalizablePersistentHandle*>(addr);
+ reinterpret_cast<FinalizablePersistentHandle*>(addr);
RawObject** p = handle->raw_addr();
+ Heap::Space before = handle->SpaceForExternal();
if (scavenger_->IsUnreachable(p)) {
- FinalizablePersistentHandle::Finalize(isolate(),
- handle,
- is_prologue_weak);
+ handle->UpdateUnreachable(isolate(), is_prologue_weak);
+ } else {
+ handle->UpdateRelocated(before, isolate());
}
}
@@ -324,7 +325,8 @@
object_alignment_(object_alignment),
scavenging_(false),
gc_time_micros_(0),
- collections_(0) {
+ collections_(0),
+ external_size_(0) {
// Verify assumptions about the first word in objects which the scavenger is
// going to use for forwarding pointers.
ASSERT(Object::tags_offset() == 0);
@@ -686,6 +688,11 @@
OS::PrintErr(" done.\n");
}
+ // During from/to flip and promoted stack use, move external allocation
+ // out of tospace temporarily.
+ intptr_t saved_external = external_size_;
+ FreeExternal(saved_external);
+
// Setup the visitor and run a scavenge.
ScavengerVisitor visitor(isolate, this);
Prologue(isolate, invoke_api_callbacks);
@@ -694,6 +701,9 @@
ProcessToSpace(&visitor);
int64_t middle = OS::GetCurrentTimeMicros();
IterateWeakReferences(isolate, &visitor);
+ // Done with promoted stack; restore external allocation.
+ ASSERT(!PromotedStackHasMore());
+ AllocateExternal(saved_external);
ScavengerWeakVisitor weak_visitor(this);
IterateWeakRoots(isolate, &weak_visitor, invoke_api_callbacks);
visitor.Finalize();
@@ -734,4 +744,19 @@
}
+void Scavenger::AllocateExternal(intptr_t size) {
+ ASSERT(size >= 0);
+ external_size_ += size;
+ intptr_t remaining = end_ - top_;
+ end_ -= Utils::Minimum(remaining, size);
+}
+
+
+void Scavenger::FreeExternal(intptr_t size) {
+ ASSERT(size >= 0);
+ external_size_ -= size;
+ ASSERT(external_size_ >= 0);
+ end_ = Utils::Minimum(to_->end(), end_ + size);
+}
+
} // namespace dart
« runtime/vm/dart_api_state.h ('K') | « runtime/vm/scavenger.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698