| 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_api_impl.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 | 40 |
| 41 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) { |
| 42 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 42 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
| 43 return reinterpret_cast<uint8_t*>(new_ptr); | 43 return reinterpret_cast<uint8_t*>(new_ptr); |
| 44 } | 44 } |
| 45 | 45 |
| 46 | 46 |
| 47 static uint8_t* SerializeObject(const Instance& obj) { | 47 static uint8_t* SerializeObject(const Instance& obj) { |
| 48 uint8_t* result = NULL; | 48 uint8_t* result = NULL; |
| 49 SnapshotWriter writer(false, &result, &allocator); | 49 SnapshotWriter writer(Snapshot::kMessage, &result, &allocator); |
| 50 writer.WriteObject(obj.raw()); | 50 writer.WriteObject(obj.raw()); |
| 51 writer.FinalizeBuffer(); | 51 writer.FinalizeBuffer(); |
| 52 return result; | 52 return result; |
| 53 } | 53 } |
| 54 | 54 |
| 55 | 55 |
| 56 static void ProcessUnhandledException(const UnhandledException& uhe) { | 56 static void ProcessUnhandledException(const UnhandledException& uhe) { |
| 57 const Instance& exception = Instance::Handle(uhe.exception()); | 57 const Instance& exception = Instance::Handle(uhe.exception()); |
| 58 Instance& string = Instance::Handle(DartLibraryCalls::ToString(exception)); | 58 Instance& string = Instance::Handle(DartLibraryCalls::ToString(exception)); |
| 59 const char* str = string.ToCString(); | 59 const char* str = string.ToCString(); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 intptr_t send_id = Smi::CheckedHandle(arguments->At(0)).Value(); | 339 intptr_t send_id = Smi::CheckedHandle(arguments->At(0)).Value(); |
| 340 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); | 340 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); |
| 341 // TODO(iposva): Allow for arbitrary messages to be sent. | 341 // TODO(iposva): Allow for arbitrary messages to be sent. |
| 342 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); | 342 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); |
| 343 | 343 |
| 344 // TODO(turnidge): Throw an exception when the return value is false? | 344 // TODO(turnidge): Throw an exception when the return value is false? |
| 345 PortMap::PostMessage(send_id, reply_id, Api::CastMessage(data)); | 345 PortMap::PostMessage(send_id, reply_id, Api::CastMessage(data)); |
| 346 } | 346 } |
| 347 | 347 |
| 348 } // namespace dart | 348 } // namespace dart |
| OLD | NEW |