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 "vm/isolate.h" | 5 #include "vm/isolate.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/code_index_table.h" | 9 #include "vm/code_index_table.h" |
10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 59 } |
60 | 60 |
61 const char* IsolateMessageHandler::name() const { | 61 const char* IsolateMessageHandler::name() const { |
62 return isolate_->name(); | 62 return isolate_->name(); |
63 } | 63 } |
64 | 64 |
65 | 65 |
66 void IsolateMessageHandler::MessageNotify(Message::Priority priority) { | 66 void IsolateMessageHandler::MessageNotify(Message::Priority priority) { |
67 if (priority >= Message::kOOBPriority) { | 67 if (priority >= Message::kOOBPriority) { |
68 // Handle out of band messages even if the isolate is busy. | 68 // Handle out of band messages even if the isolate is busy. |
69 // isolate_->ScheduleInterrupts(Isolate::kMessageInterrupt); | 69 isolate_->ScheduleInterrupts(Isolate::kMessageInterrupt); |
70 UNIMPLEMENTED(); | |
71 } | 70 } |
72 Dart_MessageNotifyCallback callback = isolate_->message_notify_callback(); | 71 Dart_MessageNotifyCallback callback = isolate_->message_notify_callback(); |
73 if (callback) { | 72 if (callback) { |
74 // Allow the embedder to handle message notification. | 73 // Allow the embedder to handle message notification. |
75 (*callback)(Api::CastIsolate(isolate_)); | 74 (*callback)(Api::CastIsolate(isolate_)); |
76 } | 75 } |
77 } | 76 } |
78 | 77 |
79 | 78 |
80 #if defined(DEBUG) | 79 #if defined(DEBUG) |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 ASSERT(message_notify_callback() == NULL); | 388 ASSERT(message_notify_callback() == NULL); |
390 ASSERT(message_handler() != NULL); | 389 ASSERT(message_handler() != NULL); |
391 | 390 |
392 while (message_handler()->HasLivePorts()) { | 391 while (message_handler()->HasLivePorts()) { |
393 ASSERT(this == Isolate::Current()); | 392 ASSERT(this == Isolate::Current()); |
394 Zone zone(this); | 393 Zone zone(this); |
395 HandleScope handle_scope(this); | 394 HandleScope handle_scope(this); |
396 | 395 |
397 Message* message = message_handler()->queue()->Dequeue(0); | 396 Message* message = message_handler()->queue()->Dequeue(0); |
398 if (message != NULL) { | 397 if (message != NULL) { |
399 if (message->priority() >= Message::kOOBPriority) { | |
400 // TODO(turnidge): Out of band messages will not go through the | |
401 // regular message handler. Instead they will be dispatched to | |
402 // special vm code. Implement. | |
403 UNIMPLEMENTED(); | |
404 } | |
405 const Instance& msg = | 398 const Instance& msg = |
406 Instance::Handle(DeserializeMessage(message->data())); | 399 Instance::Handle(DeserializeMessage(message->data())); |
407 const Object& result = Object::Handle( | 400 if (message->priority() >= Message::kOOBPriority) { |
408 DartLibraryCalls::HandleMessage( | 401 // For now the only OOB messages are Mirrors messages. |
409 message->dest_port(), message->reply_port(), msg)); | 402 const Object& result = Object::Handle( |
410 delete message; | 403 DartLibraryCalls::HandleMirrorsMessage( |
411 if (result.IsError()) { | 404 message->dest_port(), message->reply_port(), msg)); |
412 Error& error = Error::Handle(); | 405 delete message; |
413 error ^= result.raw(); | 406 if (result.IsError()) { |
414 return error.raw(); | 407 // TODO(turnidge): Propagating the error is probably wrong here. |
| 408 Error& error = Error::Handle(); |
| 409 error ^= result.raw(); |
| 410 return error.raw(); |
| 411 } |
| 412 ASSERT(result.IsNull()); |
| 413 } else { |
| 414 const Object& result = Object::Handle( |
| 415 DartLibraryCalls::HandleMessage( |
| 416 message->dest_port(), message->reply_port(), msg)); |
| 417 delete message; |
| 418 if (result.IsError()) { |
| 419 Error& error = Error::Handle(); |
| 420 error ^= result.raw(); |
| 421 return error.raw(); |
| 422 } |
| 423 ASSERT(result.IsNull()); |
415 } | 424 } |
416 ASSERT(result.IsNull()); | |
417 } | 425 } |
418 } | 426 } |
419 | 427 |
420 // Indicates success. | 428 // Indicates success. |
421 return Error::null(); | 429 return Error::null(); |
422 } | 430 } |
423 | 431 |
424 | 432 |
425 void Isolate::VisitObjectPointers(ObjectPointerVisitor* visitor, | 433 void Isolate::VisitObjectPointers(ObjectPointerVisitor* visitor, |
426 bool validate_frames) { | 434 bool validate_frames) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 } | 469 } |
462 | 470 |
463 | 471 |
464 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor) { | 472 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor) { |
465 if (api_state() != NULL) { | 473 if (api_state() != NULL) { |
466 api_state()->VisitWeakHandles(visitor); | 474 api_state()->VisitWeakHandles(visitor); |
467 } | 475 } |
468 } | 476 } |
469 | 477 |
470 } // namespace dart | 478 } // namespace dart |
OLD | NEW |