Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: runtime/vm/isolate.cc

Issue 1499853004: Adds a special case for sending an int over a port with the native API. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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->len() > 0) {
Ivan Posva 2015/12/09 22:45:28 How about turning it around: if (message->IsRaw())
zra 2015/12/10 00:07:29 Done.
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->len() == 0);
491 msg ^= message->raw_obj();
492 ASSERT(msg.IsSmi() || msg.InVMHeap());
477 } 493 }
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 494
490 MessageStatus status = kOK; 495 MessageStatus status = kOK;
491 if (message->IsOOB()) { 496 if (message->IsOOB()) {
492 // OOB messages are expected to be fixed length arrays where the first 497 // 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 498 // element is a Smi describing the OOB destination. Messages that do not
494 // confirm to this layout are silently ignored. 499 // confirm to this layout are silently ignored.
495 if (msg.IsArray()) { 500 if (msg.IsArray()) {
496 const Array& oob_msg = Array::Cast(msg); 501 const Array& oob_msg = Array::Cast(msg);
497 if (oob_msg.Length() > 0) { 502 if (oob_msg.Length() > 0) {
498 const Object& oob_tag = Object::Handle(zone, oob_msg.At(0)); 503 const Object& oob_tag = Object::Handle(zone, oob_msg.At(0));
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after
2494 } 2499 }
2495 2500
2496 2501
2497 RawInstance* IsolateSpawnState::BuildMessage(Thread* thread) { 2502 RawInstance* IsolateSpawnState::BuildMessage(Thread* thread) {
2498 return DeserializeObject(thread, 2503 return DeserializeObject(thread,
2499 serialized_message_, serialized_message_len_); 2504 serialized_message_, serialized_message_len_);
2500 } 2505 }
2501 2506
2502 2507
2503 } // namespace dart 2508 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698