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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 error, | 319 error, |
320 library_url, | 320 library_url, |
321 class_name); | 321 class_name); |
322 } | 322 } |
323 | 323 |
324 // TODO(turnidge): Move this code up before we launch the new | 324 // TODO(turnidge): Move this code up before we launch the new |
325 // thread. That way we won't have a thread hanging around that we | 325 // thread. That way we won't have a thread hanging around that we |
326 // can't talk to. | 326 // can't talk to. |
327 const Object& port = Object::Handle(DartLibraryCalls::NewSendPort(port_id)); | 327 const Object& port = Object::Handle(DartLibraryCalls::NewSendPort(port_id)); |
328 if (port.IsError()) { | 328 if (port.IsError()) { |
329 Exceptions::PropagateError(port); | 329 Exceptions::PropagateError(Error::Cast(port)); |
330 } | 330 } |
331 arguments->SetReturn(port); | 331 arguments->SetReturn(port); |
332 } | 332 } |
333 | 333 |
334 | 334 |
335 DEFINE_NATIVE_ENTRY(ReceivePortImpl_factory, 1) { | 335 DEFINE_NATIVE_ENTRY(ReceivePortImpl_factory, 1) { |
336 ASSERT(AbstractTypeArguments::CheckedHandle(arguments->At(0)).IsNull()); | 336 ASSERT(AbstractTypeArguments::CheckedHandle(arguments->At(0)).IsNull()); |
337 intptr_t port_id = | 337 intptr_t port_id = |
338 PortMap::CreatePort(arguments->isolate()->message_handler()); | 338 PortMap::CreatePort(arguments->isolate()->message_handler()); |
339 const Object& port = Object::Handle(ReceivePortCreate(port_id)); | 339 const Object& port = Object::Handle(ReceivePortCreate(port_id)); |
340 if (port.IsError()) { | 340 if (port.IsError()) { |
341 Exceptions::PropagateError(port); | 341 Exceptions::PropagateError(Error::Cast(port)); |
342 } | 342 } |
343 arguments->SetReturn(port); | 343 arguments->SetReturn(port); |
344 } | 344 } |
345 | 345 |
346 | 346 |
347 DEFINE_NATIVE_ENTRY(ReceivePortImpl_closeInternal, 1) { | 347 DEFINE_NATIVE_ENTRY(ReceivePortImpl_closeInternal, 1) { |
348 GET_NATIVE_ARGUMENT(Smi, id, arguments->At(0)); | 348 GET_NATIVE_ARGUMENT(Smi, id, arguments->At(0)); |
349 PortMap::ClosePort(id.Value()); | 349 PortMap::ClosePort(id.Value()); |
350 } | 350 } |
351 | 351 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 free(error); | 586 free(error); |
587 ThrowIsolateSpawnException(msg); | 587 ThrowIsolateSpawnException(msg); |
588 } | 588 } |
589 | 589 |
590 // Try to create a SendPort for the new isolate. | 590 // Try to create a SendPort for the new isolate. |
591 const Object& port = Object::Handle( | 591 const Object& port = Object::Handle( |
592 DartLibraryCalls::NewSendPort(state->isolate()->main_port())); | 592 DartLibraryCalls::NewSendPort(state->isolate()->main_port())); |
593 if (port.IsError()) { | 593 if (port.IsError()) { |
594 state->Cleanup(); | 594 state->Cleanup(); |
595 delete state; | 595 delete state; |
596 Exceptions::PropagateError(port); | 596 Exceptions::PropagateError(Error::Cast(port)); |
597 } | 597 } |
598 | 598 |
599 // Start the new isolate. | 599 // Start the new isolate. |
600 state->isolate()->set_spawn_data(reinterpret_cast<uword>(state)); | 600 state->isolate()->set_spawn_data(reinterpret_cast<uword>(state)); |
601 state->isolate()->message_handler()->Run( | 601 state->isolate()->message_handler()->Run( |
602 Dart::thread_pool(), RunIsolate2, ShutdownIsolate, | 602 Dart::thread_pool(), RunIsolate2, ShutdownIsolate, |
603 reinterpret_cast<uword>(state->isolate())); | 603 reinterpret_cast<uword>(state->isolate())); |
604 | 604 |
605 arguments->SetReturn(port); | 605 arguments->SetReturn(port); |
606 } | 606 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 ThrowIsolateSpawnException(msg); | 641 ThrowIsolateSpawnException(msg); |
642 } | 642 } |
643 | 643 |
644 Spawn(arguments, new SpawnState(canonical_uri)); | 644 Spawn(arguments, new SpawnState(canonical_uri)); |
645 } | 645 } |
646 | 646 |
647 | 647 |
648 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) { | 648 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) { |
649 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port())); | 649 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port())); |
650 if (port.IsError()) { | 650 if (port.IsError()) { |
651 Exceptions::PropagateError(port); | 651 Exceptions::PropagateError(Error::Cast(port)); |
652 } | 652 } |
653 arguments->SetReturn(port); | 653 arguments->SetReturn(port); |
654 } | 654 } |
655 | 655 |
656 } // namespace dart | 656 } // namespace dart |
OLD | NEW |