Index: runtime/lib/isolate.cc |
diff --git a/runtime/lib/isolate.cc b/runtime/lib/isolate.cc |
index dc5279824024337979b7a34babd3307d92ddc72c..db080bd10ada83d565690a7cab2e2f06dc9f3c1d 100644 |
--- a/runtime/lib/isolate.cc |
+++ b/runtime/lib/isolate.cc |
@@ -106,18 +106,23 @@ 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 (obj.IsSmi() || obj.InVMHeap()) { |
+ PortMap::PostMessage(new Message(destination_port_id, |
+ reinterpret_cast<uint8_t*>(obj.raw()), 0, |
+ 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(); |
} |