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

Unified Diff: runtime/vm/thread_test.cc

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/safepoint.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/thread_test.cc
diff --git a/runtime/vm/thread_test.cc b/runtime/vm/thread_test.cc
index d0deba90426383d222693581211bc2a72ff89016..dc2edac807283f925cc052a37e36df39be6a59f1 100644
--- a/runtime/vm/thread_test.cc
+++ b/runtime/vm/thread_test.cc
@@ -405,6 +405,25 @@ VM_TEST_CASE(SafepointTestVM) {
}
+// Test case for recursive safepoint operations.
+VM_TEST_CASE(RecursiveSafepointTest1) {
+ intptr_t count = 0;
+ {
+ SafepointOperationScope safepoint_scope(thread);
+ count += 1;
+ {
+ SafepointOperationScope safepoint_scope(thread);
+ count += 1;
+ {
+ SafepointOperationScope safepoint_scope(thread);
+ count += 1;
+ }
+ }
+ }
+ EXPECT(count == 3);
+}
+
+
VM_TEST_CASE(ThreadIterator_Count) {
intptr_t thread_count_0 = 0;
intptr_t thread_count_1 = 0;
@@ -525,6 +544,46 @@ VM_TEST_CASE(SafepointTestVM2) {
}
+// Test recursive safepoint operation scopes with other threads trying
+// to also start a safepoint operation scope.
+VM_TEST_CASE(RecursiveSafepointTest2) {
+ Isolate* isolate = thread->isolate();
+ Monitor monitor;
+ intptr_t expected_count = 0;
+ intptr_t total_done = 0;
+ intptr_t exited = 0;
+ for (int i = 0; i < SafepointTestTask::kTaskCount; i++) {
+ Dart::thread_pool()->Run(new SafepointTestTask(
+ isolate, &monitor, &expected_count, &total_done, &exited));
+ }
+ bool all_helpers = false;
+ do {
+ SafepointOperationScope safepoint_scope(thread);
+ {
+ SafepointOperationScope safepoint_scope(thread);
+ MonitorLocker ml(&monitor);
+ if (expected_count == SafepointTestTask::kTaskCount) {
+ all_helpers = true;
+ }
+ }
+ } while (!all_helpers);
+ String& label = String::Handle(String::New("foo"));
+ UserTag& tag = UserTag::Handle(UserTag::New(label));
+ isolate->set_current_tag(tag);
+ bool all_exited = false;
+ do {
+ SafepointOperationScope safepoint_scope(thread);
+ {
+ SafepointOperationScope safepoint_scope(thread);
+ MonitorLocker ml(&monitor);
+ if (exited == SafepointTestTask::kTaskCount) {
+ all_exited = true;
+ }
+ }
+ } while (!all_exited);
+}
+
+
class AllocAndGCTask : public ThreadPool::Task {
public:
AllocAndGCTask(Isolate* isolate,
« no previous file with comments | « runtime/vm/safepoint.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698