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

Unified Diff: runtime/vm/store_buffer.cc

Issue 14348026: Drain StoreBufferBlock into store buffer instead of iterating over it directly. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: unify draining Created 7 years, 8 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/store_buffer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/store_buffer.cc
diff --git a/runtime/vm/store_buffer.cc b/runtime/vm/store_buffer.cc
index ebfd64a6705e0c30331cbcb304b006e733a785d5..d07728aa3d3e3b250f64d8a08d9ab6ffbe8d47e9 100644
--- a/runtime/vm/store_buffer.cc
+++ b/runtime/vm/store_buffer.cc
@@ -21,12 +21,7 @@ void StoreBufferBlock::ProcessBuffer() {
void StoreBufferBlock::ProcessBuffer(Isolate* isolate) {
- StoreBuffer* buffer = isolate->store_buffer();
- int32_t end = top_;
- for (int32_t i = 0; i < end; i++) {
- buffer->AddPointer(pointers_[i]);
- }
- top_ = 0; // Reset back to the beginning.
+ isolate->store_buffer()->ProcessBlock(this);
}
@@ -61,19 +56,51 @@ void StoreBuffer::Reset() {
}
-void StoreBuffer::AddPointer(uword address) {
+bool StoreBuffer::AddPointerInternal(uword address) {
ASSERT(dedup_sets_ != NULL);
ASSERT(Isolate::Current()->heap()->OldContains(address));
ASSERT((address & kSmiTagMask) != kSmiTag);
if (!dedup_sets_->set()->Add(address)) {
- // Add a new DedupSet. Schedule an interrupt if we have run over the max
- // number of DedupSets.
+ // Add a new DedupSet.
dedup_sets_ = new DedupSet(dedup_sets_);
count_++;
- // TODO(iposva): Fix magic number.
- if (count_ > 100) {
- Isolate::Current()->ScheduleInterrupts(Isolate::kStoreBufferInterrupt);
- }
+ return true;
+ }
+ return false;
+}
+
+
+void StoreBuffer::AddPointer(uword address) {
+ if (AddPointerInternal(address)) {
+ // Had to create a new DedupSet.
+ CheckThreshold();
+ }
+}
+
+
+bool StoreBuffer::DrainBlock(StoreBufferBlock* block) {
+ const intptr_t old_count = count_;
+ intptr_t entries = block->Count();
+ for (intptr_t i = 0; i < entries; i++) {
+ AddPointerInternal(block->At(i));
+ }
+ block->Reset();
+ return (count_ > old_count);
+}
+
+
+void StoreBuffer::CheckThreshold() {
+ // Schedule an interrupt if we have run over the max number of DedupSets.
+ // TODO(iposva): Fix magic number.
+ if (count_ > 100) {
+ Isolate::Current()->ScheduleInterrupts(Isolate::kStoreBufferInterrupt);
+ }
+}
+
+
+void StoreBuffer::ProcessBlock(StoreBufferBlock* block) {
+ if (DrainBlock(block)) {
+ CheckThreshold();
}
}
« no previous file with comments | « runtime/vm/store_buffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698