Chromium Code Reviews| 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/bigint_store.h" | 9 #include "vm/bigint_store.h" |
| 10 #include "vm/code_index_table.h" | 10 #include "vm/code_index_table.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 } | 60 } |
| 61 | 61 |
| 62 const char* IsolateMessageHandler::name() const { | 62 const char* IsolateMessageHandler::name() const { |
| 63 return isolate_->name(); | 63 return isolate_->name(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 | 66 |
| 67 void IsolateMessageHandler::MessageNotify(Message::Priority priority) { | 67 void IsolateMessageHandler::MessageNotify(Message::Priority priority) { |
| 68 if (priority >= Message::kOOBPriority) { | 68 if (priority >= Message::kOOBPriority) { |
| 69 // Handle out of band messages even if the isolate is busy. | 69 // Handle out of band messages even if the isolate is busy. |
| 70 // isolate_->ScheduleInterrupts(Isolate::kMessageInterrupt); | 70 isolate_->ScheduleInterrupts(Isolate::kMessageInterrupt); |
| 71 UNIMPLEMENTED(); | |
| 72 } | 71 } |
| 73 Dart_MessageNotifyCallback callback = isolate_->message_notify_callback(); | 72 Dart_MessageNotifyCallback callback = isolate_->message_notify_callback(); |
| 74 if (callback) { | 73 if (callback) { |
| 75 // Allow the embedder to handle message notification. | 74 // Allow the embedder to handle message notification. |
| 76 (*callback)(Api::CastIsolate(isolate_)); | 75 (*callback)(Api::CastIsolate(isolate_)); |
| 77 } | 76 } |
| 78 } | 77 } |
| 79 | 78 |
| 80 | 79 |
| 81 #if defined(DEBUG) | 80 #if defined(DEBUG) |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 static RawInstance* DeserializeMessage(void* data) { | 376 static RawInstance* DeserializeMessage(void* data) { |
| 378 // Create a snapshot object using the buffer. | 377 // Create a snapshot object using the buffer. |
| 379 const Snapshot* snapshot = Snapshot::SetupFromBuffer(data); | 378 const Snapshot* snapshot = Snapshot::SetupFromBuffer(data); |
| 380 ASSERT(snapshot->IsMessageSnapshot()); | 379 ASSERT(snapshot->IsMessageSnapshot()); |
| 381 | 380 |
| 382 // Read object back from the snapshot. | 381 // Read object back from the snapshot. |
| 383 SnapshotReader reader(snapshot, Isolate::Current()); | 382 SnapshotReader reader(snapshot, Isolate::Current()); |
| 384 Instance& instance = Instance::Handle(); | 383 Instance& instance = Instance::Handle(); |
| 385 instance ^= reader.ReadObject(); | 384 instance ^= reader.ReadObject(); |
| 386 return instance.raw(); | 385 return instance.raw(); |
| 387 } | 386 } |
|
siva
2012/02/18 01:25:55
Ditto comment about code being duplicated here.
| |
| 388 | 387 |
| 389 | 388 |
| 390 | 389 |
| 391 RawError* Isolate::StandardRunLoop() { | 390 RawError* Isolate::StandardRunLoop() { |
| 392 ASSERT(message_notify_callback() == NULL); | 391 ASSERT(message_notify_callback() == NULL); |
| 393 ASSERT(message_handler() != NULL); | 392 ASSERT(message_handler() != NULL); |
| 394 | 393 |
| 395 while (message_handler()->HasLivePorts()) { | 394 while (message_handler()->HasLivePorts()) { |
| 396 ASSERT(this == Isolate::Current()); | 395 ASSERT(this == Isolate::Current()); |
| 397 Zone zone(this); | 396 Zone zone(this); |
| 398 HandleScope handle_scope(this); | 397 HandleScope handle_scope(this); |
| 399 | 398 |
| 400 Message* message = message_handler()->queue()->Dequeue(0); | 399 Message* message = message_handler()->queue()->Dequeue(0); |
| 401 if (message != NULL) { | 400 if (message != NULL) { |
| 402 if (message->priority() >= Message::kOOBPriority) { | |
| 403 // TODO(turnidge): Out of band messages will not go through the | |
| 404 // regular message handler. Instead they will be dispatched to | |
| 405 // special vm code. Implement. | |
| 406 UNIMPLEMENTED(); | |
| 407 } | |
| 408 const Instance& msg = | 401 const Instance& msg = |
| 409 Instance::Handle(DeserializeMessage(message->data())); | 402 Instance::Handle(DeserializeMessage(message->data())); |
| 410 const Object& result = Object::Handle( | 403 if (message->priority() >= Message::kOOBPriority) { |
| 411 DartLibraryCalls::HandleMessage( | 404 // For now the only OOB messages are Mirrors messages. |
| 412 message->dest_port(), message->reply_port(), msg)); | 405 const Object& result = Object::Handle( |
| 413 delete message; | 406 DartLibraryCalls::HandleMirrorsMessage( |
| 414 if (result.IsError()) { | 407 message->dest_port(), message->reply_port(), msg)); |
| 415 Error& error = Error::Handle(); | 408 delete message; |
| 416 error ^= result.raw(); | 409 if (result.IsError()) { |
| 417 return error.raw(); | 410 // TODO(turnidge): Propagating the error is probably wrong here. |
| 411 Error& error = Error::Handle(); | |
| 412 error ^= result.raw(); | |
| 413 return error.raw(); | |
| 414 } | |
| 415 ASSERT(result.IsNull()); | |
| 416 } else { | |
| 417 const Object& result = Object::Handle( | |
| 418 DartLibraryCalls::HandleMessage( | |
| 419 message->dest_port(), message->reply_port(), msg)); | |
| 420 delete message; | |
| 421 if (result.IsError()) { | |
| 422 Error& error = Error::Handle(); | |
| 423 error ^= result.raw(); | |
| 424 return error.raw(); | |
| 425 } | |
| 426 ASSERT(result.IsNull()); | |
|
siva
2012/02/18 01:25:55
Ditto comment about code being duplicated here.
| |
| 418 } | 427 } |
| 419 ASSERT(result.IsNull()); | |
| 420 } | 428 } |
| 421 } | 429 } |
| 422 | 430 |
| 423 // Indicates success. | 431 // Indicates success. |
| 424 return Error::null(); | 432 return Error::null(); |
| 425 } | 433 } |
| 426 | 434 |
| 427 | 435 |
| 428 void Isolate::VisitObjectPointers(ObjectPointerVisitor* visitor, | 436 void Isolate::VisitObjectPointers(ObjectPointerVisitor* visitor, |
| 429 bool validate_frames) { | 437 bool validate_frames) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 } | 472 } |
| 465 | 473 |
| 466 | 474 |
| 467 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor) { | 475 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor) { |
| 468 if (api_state() != NULL) { | 476 if (api_state() != NULL) { |
| 469 api_state()->VisitWeakHandles(visitor); | 477 api_state()->VisitWeakHandles(visitor); |
| 470 } | 478 } |
| 471 } | 479 } |
| 472 | 480 |
| 473 } // namespace dart | 481 } // namespace dart |
| OLD | NEW |