OLD | NEW |
---|---|
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 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 if (port_id == ILLEGAL_PORT) { | 1587 if (port_id == ILLEGAL_PORT) { |
1588 return false; | 1588 return false; |
1589 } | 1589 } |
1590 const Object& object = Object::Handle(Z, Api::UnwrapHandle(handle)); | 1590 |
1591 // Smis and null can be sent without serialization. | |
1592 RawObject* raw_obj = Api::UnwrapHandle(handle); | |
Ivan Posva
2015/12/11 21:02:38
Please make sure that this code is wrapped in a No
zra
2015/12/11 22:01:30
Done.
| |
1593 if (ApiObjectConverter::CanConvert(raw_obj)) { | |
1594 return PortMap::PostMessage(new Message( | |
1595 port_id, raw_obj, Message::kNormalPriority)); | |
1596 } | |
1597 | |
1598 const Object& object = Object::Handle(Z, raw_obj); | |
1591 uint8_t* data = NULL; | 1599 uint8_t* data = NULL; |
1592 MessageWriter writer(&data, &allocator, false); | 1600 MessageWriter writer(&data, &allocator, false); |
1593 writer.WriteMessage(object); | 1601 writer.WriteMessage(object); |
1594 intptr_t len = writer.BytesWritten(); | 1602 intptr_t len = writer.BytesWritten(); |
1595 return PortMap::PostMessage(new Message( | 1603 return PortMap::PostMessage(new Message( |
1596 port_id, data, len, Message::kNormalPriority)); | 1604 port_id, data, len, Message::kNormalPriority)); |
1597 } | 1605 } |
1598 | 1606 |
1599 | 1607 |
1600 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) { | 1608 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) { |
(...skipping 4326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5927 ApiReallocate); | 5935 ApiReallocate); |
5928 writer.WriteFullSnapshot(); | 5936 writer.WriteFullSnapshot(); |
5929 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); | 5937 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); |
5930 *isolate_snapshot_size = writer.IsolateSnapshotSize(); | 5938 *isolate_snapshot_size = writer.IsolateSnapshotSize(); |
5931 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); | 5939 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); |
5932 | 5940 |
5933 return Api::Success(); | 5941 return Api::Success(); |
5934 } | 5942 } |
5935 | 5943 |
5936 } // namespace dart | 5944 } // namespace dart |
OLD | NEW |