OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/bootstrap_natives.h" | 6 #include "vm/bootstrap_natives.h" |
7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
8 #include "vm/dart.h" | 8 #include "vm/dart.h" |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 func_name) + 1; | 250 func_name) + 1; |
251 char* chars = reinterpret_cast<char*>( | 251 char* chars = reinterpret_cast<char*>( |
252 Isolate::Current()->current_zone()->Allocate(len)); | 252 Isolate::Current()->current_zone()->Allocate(len)); |
253 OS::SNPrint(chars, len, kFormat, script_name, class_name, func_name); | 253 OS::SNPrint(chars, len, kFormat, script_name, class_name, func_name); |
254 return chars; | 254 return chars; |
255 } | 255 } |
256 | 256 |
257 | 257 |
258 DEFINE_NATIVE_ENTRY(IsolateNatives_start, 2) { | 258 DEFINE_NATIVE_ENTRY(IsolateNatives_start, 2) { |
259 Isolate* preserved_isolate = Isolate::Current(); | 259 Isolate* preserved_isolate = Isolate::Current(); |
260 const Instance& runnable = Instance::CheckedHandle(arguments->At(0)); | 260 GET_NATIVE_ARGUMENT(Instance, runnable, arguments->At(0)); |
Ivan Posva
2012/03/13 18:19:53
Please make a note that the second argument is ign
| |
261 const Class& runnable_class = Class::Handle(runnable.clazz()); | 261 const Class& runnable_class = Class::Handle(runnable.clazz()); |
262 const char* class_name = String::Handle(runnable_class.Name()).ToCString(); | 262 const char* class_name = String::Handle(runnable_class.Name()).ToCString(); |
263 const Library& library = Library::Handle(runnable_class.library()); | 263 const Library& library = Library::Handle(runnable_class.library()); |
264 ASSERT(!library.IsNull()); | 264 ASSERT(!library.IsNull()); |
265 const char* library_url = String::Handle(library.url()).ToCString(); | 265 const char* library_url = String::Handle(library.url()).ToCString(); |
266 intptr_t port_id = 0; | 266 intptr_t port_id = 0; |
267 LongJump jump; | 267 LongJump jump; |
268 bool init_successful = true; | 268 bool init_successful = true; |
269 Isolate* spawned_isolate = NULL; | 269 Isolate* spawned_isolate = NULL; |
270 void* callback_data = preserved_isolate->init_callback_data(); | 270 void* callback_data = preserved_isolate->init_callback_data(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 PortMap::CreatePort(arguments->isolate()->message_handler()); | 334 PortMap::CreatePort(arguments->isolate()->message_handler()); |
335 const Object& port = Object::Handle(ReceivePortCreate(port_id)); | 335 const Object& port = Object::Handle(ReceivePortCreate(port_id)); |
336 if (port.IsError()) { | 336 if (port.IsError()) { |
337 Exceptions::PropagateError(port); | 337 Exceptions::PropagateError(port); |
338 } | 338 } |
339 arguments->SetReturn(port); | 339 arguments->SetReturn(port); |
340 } | 340 } |
341 | 341 |
342 | 342 |
343 DEFINE_NATIVE_ENTRY(ReceivePortImpl_closeInternal, 1) { | 343 DEFINE_NATIVE_ENTRY(ReceivePortImpl_closeInternal, 1) { |
344 intptr_t id = Smi::CheckedHandle(arguments->At(0)).Value(); | 344 GET_NATIVE_ARGUMENT(Smi, id, arguments->At(0)); |
345 PortMap::ClosePort(id); | 345 PortMap::ClosePort(id.Value()); |
346 } | 346 } |
347 | 347 |
348 | 348 |
349 DEFINE_NATIVE_ENTRY(SendPortImpl_sendInternal_, 3) { | 349 DEFINE_NATIVE_ENTRY(SendPortImpl_sendInternal_, 3) { |
350 intptr_t send_id = Smi::CheckedHandle(arguments->At(0)).Value(); | 350 GET_NATIVE_ARGUMENT(Smi, send_id, arguments->At(0)); |
351 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); | 351 GET_NATIVE_ARGUMENT(Smi, reply_id, arguments->At(1)); |
352 // TODO(iposva): Allow for arbitrary messages to be sent. | 352 // TODO(iposva): Allow for arbitrary messages to be sent. |
353 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); | 353 GET_NATIVE_ARGUMENT(Instance, obj, arguments->At(2)); |
354 uint8_t* data = SerializeObject(obj); | |
354 | 355 |
355 // TODO(turnidge): Throw an exception when the return value is false? | 356 // TODO(turnidge): Throw an exception when the return value is false? |
356 PortMap::PostMessage(new Message( | 357 PortMap::PostMessage(new Message( |
357 send_id, reply_id, data, Message::kNormalPriority)); | 358 send_id.Value(), reply_id.Value(), data, Message::kNormalPriority)); |
358 } | 359 } |
359 | 360 |
360 } // namespace dart | 361 } // namespace dart |
OLD | NEW |