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

Unified Diff: runtime/lib/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: Cleanup 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 side-by-side diff with in-line comments
Download patch
Index: runtime/lib/isolate.cc
diff --git a/runtime/lib/isolate.cc b/runtime/lib/isolate.cc
index dc5279824024337979b7a34babd3307d92ddc72c..700256053770e6a47ab0afc676b74d90fc52f220 100644
--- a/runtime/lib/isolate.cc
+++ b/runtime/lib/isolate.cc
@@ -8,6 +8,7 @@
#include "vm/class_finalizer.h"
#include "vm/dart.h"
#include "vm/dart_api_impl.h"
+#include "vm/dart_api_message.h"
#include "vm/dart_entry.h"
#include "vm/exceptions.h"
#include "vm/lockers.h"
@@ -106,18 +107,22 @@ DEFINE_NATIVE_ENTRY(SendPortImpl_sendInternal_, 2) {
// TODO(iposva): Allow for arbitrary messages to be sent.
GET_NON_NULL_NATIVE_ARGUMENT(Instance, obj, arguments->NativeArgAt(1));
- uint8_t* data = NULL;
-
const Dart_Port destination_port_id = port.Id();
const bool can_send_any_object = isolate->origin_id() == port.origin_id();
- MessageWriter writer(&data, &allocator, can_send_any_object);
- writer.WriteMessage(obj);
-
- // TODO(turnidge): Throw an exception when the return value is false?
- PortMap::PostMessage(new Message(destination_port_id,
- data, writer.BytesWritten(),
- Message::kNormalPriority));
+ if (ApiObjectConverter::CanConvert(obj.raw())) {
+ PortMap::PostMessage(new Message(
+ destination_port_id, obj.raw(), Message::kNormalPriority));
+ } else {
+ uint8_t* data = NULL;
+ MessageWriter writer(&data, &allocator, can_send_any_object);
+ writer.WriteMessage(obj);
+
+ // TODO(turnidge): Throw an exception when the return value is false?
+ PortMap::PostMessage(new Message(destination_port_id,
+ data, writer.BytesWritten(),
+ Message::kNormalPriority));
+ }
return Object::null();
}

Powered by Google App Engine
This is Rietveld 408576698