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

Unified Diff: runtime/vm/dart_api_impl.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/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index f607b189a0cd005500ddd7ce5959c4976a70e346..d4eb65e98e5398b2b6ef563100409a33fe20cc0c 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -1584,10 +1584,19 @@ static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) {
DARTSCOPE(Thread::Current());
+ NoSafepointScope no_safepoint_scope;
if (port_id == ILLEGAL_PORT) {
return false;
}
- const Object& object = Object::Handle(Z, Api::UnwrapHandle(handle));
+
+ // Smis and null can be sent without serialization.
+ RawObject* raw_obj = Api::UnwrapHandle(handle);
+ if (ApiObjectConverter::CanConvert(raw_obj)) {
+ return PortMap::PostMessage(new Message(
+ port_id, raw_obj, Message::kNormalPriority));
+ }
+
+ const Object& object = Object::Handle(Z, raw_obj);
uint8_t* data = NULL;
MessageWriter writer(&data, &allocator, false);
writer.WriteMessage(object);

Powered by Google App Engine
This is Rietveld 408576698