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

Unified Diff: runtime/vm/store_buffer.cc

Issue 1259223005: Safepoint interface and unit tests. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add comment about overflow. Created 5 years, 5 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
Index: runtime/vm/store_buffer.cc
diff --git a/runtime/vm/store_buffer.cc b/runtime/vm/store_buffer.cc
index a590c28fb7627d806ad52a8468a427e7f6583878..f4fbad79f51c17274c5eb471934b049a79ec2675 100644
--- a/runtime/vm/store_buffer.cc
+++ b/runtime/vm/store_buffer.cc
@@ -78,9 +78,14 @@ void StoreBuffer::PushBlock(StoreBufferBlock* block, bool check_threshold) {
MutexLocker ml(mutex_);
partial_.Push(block);
}
- if (check_threshold) {
+ if (check_threshold && Overflowed()) {
MutexLocker ml(mutex_);
- CheckThresholdNonEmpty();
+ Isolate* isolate = Isolate::Current();
+ // Sanity check: it makes no sense to schedule the GC in another isolate.
+ // (If Isolate ever gets multiple store buffers, we should avoid this
+ // coupling by passing in an explicit callback+parameter at construction.)
+ ASSERT(isolate->store_buffer() == this);
+ isolate->ScheduleInterrupts(Isolate::kVMInterrupt);
}
}
@@ -139,16 +144,9 @@ void StoreBuffer::List::Push(StoreBufferBlock* block) {
}
-void StoreBuffer::CheckThresholdNonEmpty() {
- DEBUG_ASSERT(mutex_->IsOwnedByCurrentThread());
- if (full_.length() + partial_.length() > kMaxNonEmpty) {
- Isolate* isolate = Isolate::Current();
- // Sanity check: it makes no sense to schedule the GC in another isolate.
- // (If Isolate ever gets multiple store buffers, we should avoid this
- // coupling by passing in an explicit callback+parameter at construction.)
- ASSERT(isolate->store_buffer() == this);
- isolate->ScheduleInterrupts(Isolate::kStoreBufferInterrupt);
- }
+bool StoreBuffer::Overflowed() {
+ MutexLocker ml(mutex_);
+ return (full_.length() + partial_.length()) > kMaxNonEmpty;
}

Powered by Google App Engine
This is Rietveld 408576698