| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/message_handler.h" | 5 #include "vm/message_handler.h" |
| 6 | 6 |
| 7 #include "vm/dart.h" | 7 #include "vm/dart.h" |
| 8 #include "vm/lockers.h" | 8 #include "vm/lockers.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 status = HandleMessages(&ml, false, false); | 339 status = HandleMessages(&ml, false, false); |
| 340 if (ShouldPauseOnStart(status)) { | 340 if (ShouldPauseOnStart(status)) { |
| 341 // Still paused. | 341 // Still paused. |
| 342 ASSERT(oob_queue_->IsEmpty()); | 342 ASSERT(oob_queue_->IsEmpty()); |
| 343 task_ = NULL; // No task in queue. | 343 task_ = NULL; // No task in queue. |
| 344 return; | 344 return; |
| 345 } else { | 345 } else { |
| 346 PausedOnStartLocked(&ml, false); | 346 PausedOnStartLocked(&ml, false); |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 #endif | 349 if (is_paused_on_exit()) { |
| 350 status = HandleMessages(&ml, false, false); |
| 351 if (ShouldPauseOnExit(status)) { |
| 352 // Still paused. |
| 353 ASSERT(oob_queue_->IsEmpty()); |
| 354 task_ = NULL; // No task in queue. |
| 355 return; |
| 356 } else { |
| 357 PausedOnExitLocked(&ml, false); |
| 358 } |
| 359 } |
| 360 #endif // !defined(PRODUCT) |
| 350 | 361 |
| 351 if (status == kOK) { | 362 if (status == kOK) { |
| 352 if (start_callback_) { | 363 if (start_callback_) { |
| 353 // Initialize the message handler by running its start function, | 364 // Initialize the message handler by running its start function, |
| 354 // if we have one. For an isolate, this will run the isolate's | 365 // if we have one. For an isolate, this will run the isolate's |
| 355 // main() function. | 366 // main() function. |
| 356 // | 367 // |
| 357 // Release the monitor_ temporarily while we call the start callback. | 368 // Release the monitor_ temporarily while we call the start callback. |
| 358 ml.Exit(); | 369 ml.Exit(); |
| 359 status = start_callback_(callback_data_); | 370 status = start_callback_(callback_data_); |
| 360 ASSERT(Isolate::Current() == NULL); | 371 ASSERT(Isolate::Current() == NULL); |
| 361 start_callback_ = NULL; | 372 start_callback_ = NULL; |
| 362 ml.Enter(); | 373 ml.Enter(); |
| 363 } | 374 } |
| 364 | 375 |
| 365 // Handle any pending messages for this message handler. | 376 // Handle any pending messages for this message handler. |
| 366 if (status != kShutdown) { | 377 if (status != kShutdown) { |
| 367 status = HandleMessages(&ml, (status == kOK), true); | 378 status = HandleMessages(&ml, (status == kOK), true); |
| 368 } | 379 } |
| 369 } | 380 } |
| 370 | 381 |
| 371 // The isolate exits when it encounters an error or when it no | 382 // The isolate exits when it encounters an error or when it no |
| 372 // longer has live ports. | 383 // longer has live ports. |
| 373 if (status != kOK || !HasLivePorts()) { | 384 if (status != kOK || !HasLivePorts()) { |
| 374 #if !defined(PRODUCT) | 385 #if !defined(PRODUCT) |
| 375 if (ShouldPauseOnExit(status)) { | 386 if (ShouldPauseOnExit(status)) { |
| 376 if (!is_paused_on_exit()) { | 387 if (FLAG_trace_service_pause_events) { |
| 377 if (FLAG_trace_service_pause_events) { | 388 OS::PrintErr( |
| 378 OS::PrintErr( | 389 "Isolate %s paused before exiting. " |
| 379 "Isolate %s paused before exiting. " | 390 "Use the Observatory to release it.\n", |
| 380 "Use the Observatory to release it.\n", | 391 name()); |
| 381 name()); | |
| 382 } | |
| 383 PausedOnExitLocked(&ml, true); | |
| 384 // More messages may have come in while we released the monitor. | |
| 385 status = HandleMessages(&ml, false, false); | |
| 386 } | 392 } |
| 393 PausedOnExitLocked(&ml, true); |
| 394 // More messages may have come in while we released the monitor. |
| 395 status = HandleMessages(&ml, false, false); |
| 387 if (ShouldPauseOnExit(status)) { | 396 if (ShouldPauseOnExit(status)) { |
| 388 // Still paused. | 397 // Still paused. |
| 389 ASSERT(oob_queue_->IsEmpty()); | 398 ASSERT(oob_queue_->IsEmpty()); |
| 390 task_ = NULL; // No task in queue. | 399 task_ = NULL; // No task in queue. |
| 391 return; | 400 return; |
| 392 } else { | 401 } else { |
| 393 PausedOnExitLocked(&ml, false); | 402 PausedOnExitLocked(&ml, false); |
| 394 } | 403 } |
| 395 } | 404 } |
| 396 #endif // !defined(PRODUCT) | 405 #endif // !defined(PRODUCT) |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 ASSERT(handler != NULL); | 579 ASSERT(handler != NULL); |
| 571 handler_->oob_message_handling_allowed_ = false; | 580 handler_->oob_message_handling_allowed_ = false; |
| 572 } | 581 } |
| 573 | 582 |
| 574 MessageHandler::AcquiredQueues::~AcquiredQueues() { | 583 MessageHandler::AcquiredQueues::~AcquiredQueues() { |
| 575 ASSERT(handler_ != NULL); | 584 ASSERT(handler_ != NULL); |
| 576 handler_->oob_message_handling_allowed_ = true; | 585 handler_->oob_message_handling_allowed_ = true; |
| 577 } | 586 } |
| 578 | 587 |
| 579 } // namespace dart | 588 } // namespace dart |
| OLD | NEW |