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