| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
| 6 | 6 |
| 7 #include "vm/assert.h" | 7 #include "vm/assert.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/dart.h" | 9 #include "vm/dart.h" |
| 10 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
| 11 #include "vm/exceptions.h" | 12 #include "vm/exceptions.h" |
| 12 #include "vm/longjump.h" | 13 #include "vm/longjump.h" |
| 13 #include "vm/object.h" | 14 #include "vm/object.h" |
| 14 #include "vm/object_store.h" | 15 #include "vm/object_store.h" |
| 15 #include "vm/port.h" | 16 #include "vm/port.h" |
| 16 #include "vm/resolver.h" | 17 #include "vm/resolver.h" |
| 17 #include "vm/snapshot.h" | 18 #include "vm/snapshot.h" |
| 18 #include "vm/thread.h" | 19 #include "vm/thread.h" |
| 19 | 20 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 36 intptr_t port_id_; | 37 intptr_t port_id_; |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 | 40 |
| 40 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 41 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
| 41 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 42 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
| 42 return reinterpret_cast<uint8_t*>(new_ptr); | 43 return reinterpret_cast<uint8_t*>(new_ptr); |
| 43 } | 44 } |
| 44 | 45 |
| 45 | 46 |
| 46 static void* SerializeObject(const Instance& obj) { | 47 static uint8_t* SerializeObject(const Instance& obj) { |
| 47 uint8_t* result = NULL; | 48 uint8_t* result = NULL; |
| 48 SnapshotWriter writer(false, &result, &allocator); | 49 SnapshotWriter writer(false, &result, &allocator); |
| 49 writer.WriteObject(obj.raw()); | 50 writer.WriteObject(obj.raw()); |
| 50 writer.FinalizeBuffer(); | 51 writer.FinalizeBuffer(); |
| 51 return result; | 52 return result; |
| 52 } | 53 } |
| 53 | 54 |
| 54 | 55 |
| 55 static void ProcessUnhandledException(const UnhandledException& uhe) { | 56 static void ProcessUnhandledException(const UnhandledException& uhe) { |
| 56 const Instance& exception = Instance::Handle(uhe.exception()); | 57 const Instance& exception = Instance::Handle(uhe.exception()); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 DEFINE_NATIVE_ENTRY(ReceivePortImpl_closeInternal, 1) { | 332 DEFINE_NATIVE_ENTRY(ReceivePortImpl_closeInternal, 1) { |
| 332 intptr_t id = Smi::CheckedHandle(arguments->At(0)).Value(); | 333 intptr_t id = Smi::CheckedHandle(arguments->At(0)).Value(); |
| 333 PortMap::ClosePort(id); | 334 PortMap::ClosePort(id); |
| 334 } | 335 } |
| 335 | 336 |
| 336 | 337 |
| 337 DEFINE_NATIVE_ENTRY(SendPortImpl_sendInternal_, 3) { | 338 DEFINE_NATIVE_ENTRY(SendPortImpl_sendInternal_, 3) { |
| 338 intptr_t send_id = Smi::CheckedHandle(arguments->At(0)).Value(); | 339 intptr_t send_id = Smi::CheckedHandle(arguments->At(0)).Value(); |
| 339 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); | 340 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); |
| 340 // TODO(iposva): Allow for arbitrary messages to be sent. | 341 // TODO(iposva): Allow for arbitrary messages to be sent. |
| 341 void* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); | 342 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); |
| 342 | 343 |
| 343 // TODO(turnidge): Throw an exception when the return value is false? | 344 // TODO(turnidge): Throw an exception when the return value is false? |
| 344 PortMap::PostMessage(send_id, reply_id, data); | 345 PortMap::PostMessage(send_id, reply_id, Api::CastMessage(data)); |
| 345 } | 346 } |
| 346 | 347 |
| 347 } // namespace dart | 348 } // namespace dart |
| OLD | NEW |