| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/isolate.h" | 6 #include "vm/isolate.h" |
| 7 #include "vm/lockers.h" | 7 #include "vm/lockers.h" |
| 8 #include "vm/unit_test.h" | 8 #include "vm/unit_test.h" |
| 9 #include "vm/profiler.h" | 9 #include "vm/profiler.h" |
| 10 #include "vm/thread_pool.h" | 10 #include "vm/thread_pool.h" |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 } | 378 } |
| 379 } | 379 } |
| 380 | 380 |
| 381 | 381 |
| 382 // Test rendezvous of: | 382 // Test rendezvous of: |
| 383 // - helpers in VM code, and | 383 // - helpers in VM code, and |
| 384 // - main thread in VM code, | 384 // - main thread in VM code, |
| 385 // organized by | 385 // organized by |
| 386 // - helpers. | 386 // - helpers. |
| 387 TEST_CASE(SafepointTestVM) { | 387 TEST_CASE(SafepointTestVM) { |
| 388 Thread* thread = Thread::Current(); | |
| 389 Isolate* isolate = thread->isolate(); | 388 Isolate* isolate = thread->isolate(); |
| 390 Mutex mutex; | 389 Mutex mutex; |
| 391 intptr_t expected_count = 0; | 390 intptr_t expected_count = 0; |
| 392 intptr_t total_done = 0; | 391 intptr_t total_done = 0; |
| 393 intptr_t exited = 0; | 392 intptr_t exited = 0; |
| 394 for (int i = 0; i < SafepointTestTask::kTaskCount; i++) { | 393 for (int i = 0; i < SafepointTestTask::kTaskCount; i++) { |
| 395 Dart::thread_pool()->Run(new SafepointTestTask( | 394 Dart::thread_pool()->Run(new SafepointTestTask( |
| 396 isolate, &mutex, &expected_count, &total_done, &exited)); | 395 isolate, &mutex, &expected_count, &total_done, &exited)); |
| 397 } | 396 } |
| 398 String& label = String::Handle(String::New("foo")); | 397 String& label = String::Handle(String::New("foo")); |
| 399 UserTag& tag = UserTag::Handle(UserTag::New(label)); | 398 UserTag& tag = UserTag::Handle(UserTag::New(label)); |
| 400 isolate->set_current_tag(tag); | 399 isolate->set_current_tag(tag); |
| 401 while (true) { | 400 while (true) { |
| 402 isolate->thread_registry()->CheckSafepoint(); | 401 isolate->thread_registry()->CheckSafepoint(); |
| 403 MutexLocker ml(&mutex); | 402 MutexLocker ml(&mutex); |
| 404 if (exited == SafepointTestTask::kTaskCount) { | 403 if (exited == SafepointTestTask::kTaskCount) { |
| 405 break; | 404 break; |
| 406 } | 405 } |
| 407 } | 406 } |
| 408 } | 407 } |
| 409 | 408 |
| 410 | 409 |
| 411 // Test rendezvous of: | 410 // Test rendezvous of: |
| 412 // - helpers in VM code, and | 411 // - helpers in VM code, and |
| 413 // - main thread in VM code, | 412 // - main thread in VM code, |
| 414 // organized by | 413 // organized by |
| 415 // - main thread, and | 414 // - main thread, and |
| 416 // - helpers. | 415 // - helpers. |
| 417 TEST_CASE(SafepointTestVM2) { | 416 TEST_CASE(SafepointTestVM2) { |
| 418 Thread* thread = Thread::Current(); | |
| 419 Isolate* isolate = thread->isolate(); | 417 Isolate* isolate = thread->isolate(); |
| 420 Mutex mutex; | 418 Mutex mutex; |
| 421 intptr_t expected_count = 0; | 419 intptr_t expected_count = 0; |
| 422 intptr_t total_done = 0; | 420 intptr_t total_done = 0; |
| 423 intptr_t exited = 0; | 421 intptr_t exited = 0; |
| 424 for (int i = 0; i < SafepointTestTask::kTaskCount; i++) { | 422 for (int i = 0; i < SafepointTestTask::kTaskCount; i++) { |
| 425 Dart::thread_pool()->Run(new SafepointTestTask( | 423 Dart::thread_pool()->Run(new SafepointTestTask( |
| 426 isolate, &mutex, &expected_count, &total_done, &exited)); | 424 isolate, &mutex, &expected_count, &total_done, &exited)); |
| 427 } | 425 } |
| 428 bool all_helpers = false; | 426 bool all_helpers = false; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 isolate->thread_registry()->CheckSafepoint(); | 500 isolate->thread_registry()->CheckSafepoint(); |
| 503 MonitorLocker ml(&done_monitor); | 501 MonitorLocker ml(&done_monitor); |
| 504 if (done) { | 502 if (done) { |
| 505 break; | 503 break; |
| 506 } | 504 } |
| 507 } | 505 } |
| 508 } | 506 } |
| 509 } | 507 } |
| 510 | 508 |
| 511 } // namespace dart | 509 } // namespace dart |
| OLD | NEW |