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 "vm/isolate.h" | 5 #include "vm/isolate.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "platform/json.h" | 9 #include "platform/json.h" |
10 #include "lib/mirrors.h" | 10 #include "lib/mirrors.h" |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 // communicate with the spawner to receive the initial message before it | 528 // communicate with the spawner to receive the initial message before it |
529 // executes the real entry point. | 529 // executes the real entry point. |
530 // Since this function ("RunIsolate") is used for both Isolate.spawn and | 530 // Since this function ("RunIsolate") is used for both Isolate.spawn and |
531 // Isolate.spawnUri we also send a boolean flag as argument so that the | 531 // Isolate.spawnUri we also send a boolean flag as argument so that the |
532 // "_startIsolate" function can act corresponding to how the isolate was | 532 // "_startIsolate" function can act corresponding to how the isolate was |
533 // created. | 533 // created. |
534 const Array& args = Array::Handle(Array::New(2)); | 534 const Array& args = Array::Handle(Array::New(2)); |
535 args.SetAt(0, Instance::Handle(func.ImplicitStaticClosure())); | 535 args.SetAt(0, Instance::Handle(func.ImplicitStaticClosure())); |
536 args.SetAt(1, is_spawn_uri ? Bool::True() : Bool::False()); | 536 args.SetAt(1, is_spawn_uri ? Bool::True() : Bool::False()); |
537 | 537 |
538 // Dispatching through _startIsolate will open a control port as a live | |
539 // port. Account for this by increasing the number of open control ports. | |
540 isolate->message_handler()->increment_control_ports(); | |
541 | |
542 const Library& lib = Library::Handle(Library::IsolateLibrary()); | 538 const Library& lib = Library::Handle(Library::IsolateLibrary()); |
543 const String& entry_name = String::Handle(String::New("_startIsolate")); | 539 const String& entry_name = String::Handle(String::New("_startIsolate")); |
544 const Function& entry_point = | 540 const Function& entry_point = |
545 Function::Handle(lib.LookupLocalFunction(entry_name)); | 541 Function::Handle(lib.LookupLocalFunction(entry_name)); |
546 ASSERT(entry_point.IsFunction() && !entry_point.IsNull()); | 542 ASSERT(entry_point.IsFunction() && !entry_point.IsNull()); |
547 | 543 |
548 result = DartEntry::InvokeFunction(entry_point, args); | 544 result = DartEntry::InvokeFunction(entry_point, args); |
549 if (result.IsError()) { | 545 if (result.IsError()) { |
550 StoreError(isolate, result); | 546 StoreError(isolate, result); |
551 return false; | 547 return false; |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 return func.raw(); | 1058 return func.raw(); |
1063 } | 1059 } |
1064 | 1060 |
1065 | 1061 |
1066 void IsolateSpawnState::Cleanup() { | 1062 void IsolateSpawnState::Cleanup() { |
1067 SwitchIsolateScope switch_scope(isolate()); | 1063 SwitchIsolateScope switch_scope(isolate()); |
1068 Dart::ShutdownIsolate(); | 1064 Dart::ShutdownIsolate(); |
1069 } | 1065 } |
1070 | 1066 |
1071 } // namespace dart | 1067 } // namespace dart |
OLD | NEW |