| 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 "lib/stacktrace.h" | 10 #include "lib/stacktrace.h" |
| (...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1773 | 1773 |
| 1774 | 1774 |
| 1775 DART_EXPORT bool Dart_HasLivePorts() { | 1775 DART_EXPORT bool Dart_HasLivePorts() { |
| 1776 Isolate* isolate = Isolate::Current(); | 1776 Isolate* isolate = Isolate::Current(); |
| 1777 ASSERT(isolate); | 1777 ASSERT(isolate); |
| 1778 NoSafepointScope no_safepoint_scope; | 1778 NoSafepointScope no_safepoint_scope; |
| 1779 return isolate->message_handler()->HasLivePorts(); | 1779 return isolate->message_handler()->HasLivePorts(); |
| 1780 } | 1780 } |
| 1781 | 1781 |
| 1782 | 1782 |
| 1783 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 1783 static uint8_t* malloc_allocator(uint8_t* ptr, |
| 1784 intptr_t old_size, |
| 1785 intptr_t new_size) { |
| 1784 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 1786 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
| 1785 return reinterpret_cast<uint8_t*>(new_ptr); | 1787 return reinterpret_cast<uint8_t*>(new_ptr); |
| 1786 } | 1788 } |
| 1787 | 1789 |
| 1788 | 1790 |
| 1791 static void malloc_deallocator(uint8_t* ptr) { |
| 1792 free(reinterpret_cast<void*>(ptr)); |
| 1793 } |
| 1794 |
| 1795 |
| 1789 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) { | 1796 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) { |
| 1790 DARTSCOPE(Thread::Current()); | 1797 DARTSCOPE(Thread::Current()); |
| 1791 API_TIMELINE_DURATION; | 1798 API_TIMELINE_DURATION; |
| 1792 NoSafepointScope no_safepoint_scope; | 1799 NoSafepointScope no_safepoint_scope; |
| 1793 if (port_id == ILLEGAL_PORT) { | 1800 if (port_id == ILLEGAL_PORT) { |
| 1794 return false; | 1801 return false; |
| 1795 } | 1802 } |
| 1796 | 1803 |
| 1797 // Smis and null can be sent without serialization. | 1804 // Smis and null can be sent without serialization. |
| 1798 RawObject* raw_obj = Api::UnwrapHandle(handle); | 1805 RawObject* raw_obj = Api::UnwrapHandle(handle); |
| 1799 if (ApiObjectConverter::CanConvert(raw_obj)) { | 1806 if (ApiObjectConverter::CanConvert(raw_obj)) { |
| 1800 return PortMap::PostMessage( | 1807 return PortMap::PostMessage( |
| 1801 new Message(port_id, raw_obj, Message::kNormalPriority)); | 1808 new Message(port_id, raw_obj, Message::kNormalPriority)); |
| 1802 } | 1809 } |
| 1803 | 1810 |
| 1804 const Object& object = Object::Handle(Z, raw_obj); | 1811 const Object& object = Object::Handle(Z, raw_obj); |
| 1805 uint8_t* data = NULL; | 1812 uint8_t* data = NULL; |
| 1806 MessageWriter writer(&data, &allocator, false); | 1813 MessageWriter writer(&data, &malloc_allocator, &malloc_deallocator, false); |
| 1807 writer.WriteMessage(object); | 1814 writer.WriteMessage(object); |
| 1808 intptr_t len = writer.BytesWritten(); | 1815 intptr_t len = writer.BytesWritten(); |
| 1809 return PortMap::PostMessage( | 1816 return PortMap::PostMessage( |
| 1810 new Message(port_id, data, len, Message::kNormalPriority)); | 1817 new Message(port_id, data, len, Message::kNormalPriority)); |
| 1811 } | 1818 } |
| 1812 | 1819 |
| 1813 | 1820 |
| 1814 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) { | 1821 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) { |
| 1815 DARTSCOPE(Thread::Current()); | 1822 DARTSCOPE(Thread::Current()); |
| 1816 CHECK_CALLBACK_STATE(T); | 1823 CHECK_CALLBACK_STATE(T); |
| (...skipping 4998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6815 } | 6822 } |
| 6816 | 6823 |
| 6817 | 6824 |
| 6818 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { | 6825 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { |
| 6819 #ifndef PRODUCT | 6826 #ifndef PRODUCT |
| 6820 Profiler::DumpStackTrace(context); | 6827 Profiler::DumpStackTrace(context); |
| 6821 #endif | 6828 #endif |
| 6822 } | 6829 } |
| 6823 | 6830 |
| 6824 } // namespace dart | 6831 } // namespace dart |
| OLD | NEW |