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

Side by Side 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 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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 1577
1578 1578
1579 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { 1579 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
1580 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); 1580 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size);
1581 return reinterpret_cast<uint8_t*>(new_ptr); 1581 return reinterpret_cast<uint8_t*>(new_ptr);
1582 } 1582 }
1583 1583
1584 1584
1585 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) { 1585 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) {
1586 DARTSCOPE(Thread::Current()); 1586 DARTSCOPE(Thread::Current());
1587 NoSafepointScope no_safepoint_scope;
1587 if (port_id == ILLEGAL_PORT) { 1588 if (port_id == ILLEGAL_PORT) {
1588 return false; 1589 return false;
1589 } 1590 }
1590 const Object& object = Object::Handle(Z, Api::UnwrapHandle(handle)); 1591
1592 // Smis and null can be sent without serialization.
1593 RawObject* raw_obj = Api::UnwrapHandle(handle);
1594 if (ApiObjectConverter::CanConvert(raw_obj)) {
1595 return PortMap::PostMessage(new Message(
1596 port_id, raw_obj, Message::kNormalPriority));
1597 }
1598
1599 const Object& object = Object::Handle(Z, raw_obj);
1591 uint8_t* data = NULL; 1600 uint8_t* data = NULL;
1592 MessageWriter writer(&data, &allocator, false); 1601 MessageWriter writer(&data, &allocator, false);
1593 writer.WriteMessage(object); 1602 writer.WriteMessage(object);
1594 intptr_t len = writer.BytesWritten(); 1603 intptr_t len = writer.BytesWritten();
1595 return PortMap::PostMessage(new Message( 1604 return PortMap::PostMessage(new Message(
1596 port_id, data, len, Message::kNormalPriority)); 1605 port_id, data, len, Message::kNormalPriority));
1597 } 1606 }
1598 1607
1599 1608
1600 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) { 1609 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) {
(...skipping 4326 matching lines...) Expand 10 before | Expand all | Expand 10 after
5927 ApiReallocate); 5936 ApiReallocate);
5928 writer.WriteFullSnapshot(); 5937 writer.WriteFullSnapshot();
5929 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); 5938 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize();
5930 *isolate_snapshot_size = writer.IsolateSnapshotSize(); 5939 *isolate_snapshot_size = writer.IsolateSnapshotSize();
5931 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); 5940 *instructions_snapshot_size = writer.InstructionsSnapshotSize();
5932 5941
5933 return Api::Success(); 5942 return Api::Success();
5934 } 5943 }
5935 5944
5936 } // namespace dart 5945 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698