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

Unified Diff: runtime/vm/safepoint.h

Issue 2126413002: Allow for recursive invocation of SafepointOperationScopes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address code review comments. Created 4 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
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/safepoint.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/safepoint.h
diff --git a/runtime/vm/safepoint.h b/runtime/vm/safepoint.h
index 58afb493f2b90e4d3e3f66df653e4dcf3afed1b4..15c2c983ba06e2ccce96eea48bda70c7beb88d27 100644
--- a/runtime/vm/safepoint.h
+++ b/runtime/vm/safepoint.h
@@ -33,21 +33,45 @@ class SafepointHandler {
void EnterSafepointUsingLock(Thread* T);
void ExitSafepointUsingLock(Thread* T);
- void SafepointThreads(Thread* T);
- void ResumeThreads(Thread* T);
-
void BlockForSafepoint(Thread* T);
private:
+ void SafepointThreads(Thread* T);
+ void ResumeThreads(Thread* T);
+
Isolate* isolate() const { return isolate_; }
Monitor* threads_lock() const { return isolate_->threads_lock(); }
- bool safepoint_in_progress() const {
+ bool SafepointInProgress() const {
+ ASSERT(threads_lock()->IsOwnedByCurrentThread());
+ return ((safepoint_operation_count_ > 0) && (owner_ != NULL));
+ }
+ void SetSafepointInProgress(Thread* T) {
ASSERT(threads_lock()->IsOwnedByCurrentThread());
- return safepoint_in_progress_;
+ ASSERT(owner_ == NULL);
+ ASSERT(safepoint_operation_count_ == 0);
+ safepoint_operation_count_ = 1;
+ owner_ = T;
}
- void set_safepoint_in_progress(bool value) {
+ void ResetSafepointInProgress(Thread* T) {
ASSERT(threads_lock()->IsOwnedByCurrentThread());
- safepoint_in_progress_ = value;
+ ASSERT(owner_ == T);
+ ASSERT(safepoint_operation_count_ == 1);
+ safepoint_operation_count_ = 0;
+ owner_ = NULL;
+ }
+ int32_t safepoint_operation_count() const {
+ ASSERT(threads_lock()->IsOwnedByCurrentThread());
+ return safepoint_operation_count_;
+ }
+ void increment_safepoint_operation_count() {
+ ASSERT(threads_lock()->IsOwnedByCurrentThread());
+ ASSERT(safepoint_operation_count_ < kMaxInt32);
+ safepoint_operation_count_ += 1;
+ }
+ void decrement_safepoint_operation_count() {
+ ASSERT(threads_lock()->IsOwnedByCurrentThread());
+ ASSERT(safepoint_operation_count_ > 0);
+ safepoint_operation_count_ -= 1;
}
Isolate* isolate_;
@@ -57,8 +81,14 @@ class SafepointHandler {
Monitor* safepoint_lock_;
int32_t number_threads_not_at_safepoint_;
- // Flag to indicate if a safepoint operation is currently in progress.
- bool safepoint_in_progress_;
+ // Count that indicates if a safepoint operation is currently in progress
+ // and also tracks the number of recursive safepoint operations on the
+ // same thread.
+ int32_t safepoint_operation_count_;
+
+ // If a safepoint operation is currently in progress, this field contains
+ // the thread that initiated the safepoint operation, otherwise it is NULL.
+ Thread* owner_;
friend class Isolate;
friend class SafepointOperationScope;
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/safepoint.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698