| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/text_buffer.h" | 10 #include "platform/text_buffer.h" |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 if (message->RedirectToDeliveryFailurePort()) { | 461 if (message->RedirectToDeliveryFailurePort()) { |
| 462 PortMap::PostMessage(message); | 462 PortMap::PostMessage(message); |
| 463 } else { | 463 } else { |
| 464 delete message; | 464 delete message; |
| 465 } | 465 } |
| 466 return kOK; | 466 return kOK; |
| 467 } | 467 } |
| 468 } | 468 } |
| 469 | 469 |
| 470 // Parse the message. | 470 // Parse the message. |
| 471 MessageSnapshotReader reader(message->data(), message->len(), thread); | 471 Instance& msg = Instance::Handle(zone); |
| 472 const Object& msg_obj = Object::Handle(zone, reader.ReadObject()); | 472 if (message->type() == Message::kDataType) { |
| 473 if (msg_obj.IsError()) { | 473 MessageSnapshotReader reader(message->data(), message->len(), thread); |
| 474 // An error occurred while reading the message. | 474 const Object& msg_obj = Object::Handle(zone, reader.ReadObject()); |
| 475 delete message; | 475 if (msg_obj.IsError()) { |
| 476 return ProcessUnhandledException(Error::Cast(msg_obj)); | 476 // An error occurred while reading the message. |
| 477 delete message; |
| 478 return ProcessUnhandledException(Error::Cast(msg_obj)); |
| 479 } |
| 480 if (!msg_obj.IsNull() && !msg_obj.IsInstance()) { |
| 481 // TODO(turnidge): We need to decide what an isolate does with |
| 482 // malformed messages. If they (eventually) come from a remote |
| 483 // machine, then it might make sense to drop the message entirely. |
| 484 // In the case that the message originated locally, which is |
| 485 // always true for now, then this should never occur. |
| 486 UNREACHABLE(); |
| 487 } |
| 488 msg ^= msg_obj.raw(); // Can't use Instance::Cast because may be null. |
| 489 } else { |
| 490 ASSERT(message->type() == Message::kIntegerType); |
| 491 msg ^= Smi::New(message->integer()); |
| 477 } | 492 } |
| 478 if (!msg_obj.IsNull() && !msg_obj.IsInstance()) { | |
| 479 // TODO(turnidge): We need to decide what an isolate does with | |
| 480 // malformed messages. If they (eventually) come from a remote | |
| 481 // machine, then it might make sense to drop the message entirely. | |
| 482 // In the case that the message originated locally, which is | |
| 483 // always true for now, then this should never occur. | |
| 484 UNREACHABLE(); | |
| 485 } | |
| 486 | |
| 487 Instance& msg = Instance::Handle(zone); | |
| 488 msg ^= msg_obj.raw(); // Can't use Instance::Cast because may be null. | |
| 489 | 493 |
| 490 MessageStatus status = kOK; | 494 MessageStatus status = kOK; |
| 491 if (message->IsOOB()) { | 495 if (message->IsOOB()) { |
| 492 // OOB messages are expected to be fixed length arrays where the first | 496 // OOB messages are expected to be fixed length arrays where the first |
| 493 // element is a Smi describing the OOB destination. Messages that do not | 497 // element is a Smi describing the OOB destination. Messages that do not |
| 494 // confirm to this layout are silently ignored. | 498 // confirm to this layout are silently ignored. |
| 495 if (msg.IsArray()) { | 499 if (msg.IsArray()) { |
| 496 const Array& oob_msg = Array::Cast(msg); | 500 const Array& oob_msg = Array::Cast(msg); |
| 497 if (oob_msg.Length() > 0) { | 501 if (oob_msg.Length() > 0) { |
| 498 const Object& oob_tag = Object::Handle(zone, oob_msg.At(0)); | 502 const Object& oob_tag = Object::Handle(zone, oob_msg.At(0)); |
| (...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2494 } | 2498 } |
| 2495 | 2499 |
| 2496 | 2500 |
| 2497 RawInstance* IsolateSpawnState::BuildMessage(Thread* thread) { | 2501 RawInstance* IsolateSpawnState::BuildMessage(Thread* thread) { |
| 2498 return DeserializeObject(thread, | 2502 return DeserializeObject(thread, |
| 2499 serialized_message_, serialized_message_len_); | 2503 serialized_message_, serialized_message_len_); |
| 2500 } | 2504 } |
| 2501 | 2505 |
| 2502 | 2506 |
| 2503 } // namespace dart | 2507 } // namespace dart |
| OLD | NEW |