| 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 "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/text_buffer.h" | 10 #include "platform/text_buffer.h" |
| (...skipping 2617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2628 delete[] package_config_; | 2628 delete[] package_config_; |
| 2629 delete[] library_url_; | 2629 delete[] library_url_; |
| 2630 delete[] class_name_; | 2630 delete[] class_name_; |
| 2631 delete[] function_name_; | 2631 delete[] function_name_; |
| 2632 free(serialized_args_); | 2632 free(serialized_args_); |
| 2633 free(serialized_message_); | 2633 free(serialized_message_); |
| 2634 } | 2634 } |
| 2635 | 2635 |
| 2636 | 2636 |
| 2637 RawObject* IsolateSpawnState::ResolveFunction() { | 2637 RawObject* IsolateSpawnState::ResolveFunction() { |
| 2638 const String& func_name = String::Handle(String::New(function_name())); | 2638 Thread* thread = Thread::Current(); |
| 2639 Zone* zone = thread->zone(); |
| 2640 |
| 2641 const String& func_name = String::Handle(zone, String::New(function_name())); |
| 2639 | 2642 |
| 2640 if (library_url() == NULL) { | 2643 if (library_url() == NULL) { |
| 2641 // Handle spawnUri lookup rules. | 2644 // Handle spawnUri lookup rules. |
| 2642 // Check whether the root library defines a main function. | 2645 // Check whether the root library defines a main function. |
| 2643 const Library& lib = Library::Handle(I->object_store()->root_library()); | 2646 const Library& lib = Library::Handle(zone, |
| 2644 Function& func = Function::Handle(lib.LookupLocalFunction(func_name)); | 2647 I->object_store()->root_library()); |
| 2648 Function& func = Function::Handle(zone, lib.LookupLocalFunction(func_name)); |
| 2645 if (func.IsNull()) { | 2649 if (func.IsNull()) { |
| 2646 // Check whether main is reexported from the root library. | 2650 // Check whether main is reexported from the root library. |
| 2647 const Object& obj = Object::Handle(lib.LookupReExport(func_name)); | 2651 const Object& obj = Object::Handle(zone, lib.LookupReExport(func_name)); |
| 2648 if (obj.IsFunction()) { | 2652 if (obj.IsFunction()) { |
| 2649 func ^= obj.raw(); | 2653 func ^= obj.raw(); |
| 2650 } | 2654 } |
| 2651 } | 2655 } |
| 2652 if (func.IsNull()) { | 2656 if (func.IsNull()) { |
| 2653 const String& msg = String::Handle(String::NewFormatted( | 2657 const String& msg = String::Handle(zone, String::NewFormatted( |
| 2654 "Unable to resolve function '%s' in script '%s'.", | 2658 "Unable to resolve function '%s' in script '%s'.", |
| 2655 function_name(), script_url())); | 2659 function_name(), script_url())); |
| 2656 return LanguageError::New(msg); | 2660 return LanguageError::New(msg); |
| 2657 } | 2661 } |
| 2658 return func.raw(); | 2662 return func.raw(); |
| 2659 } | 2663 } |
| 2660 | 2664 |
| 2661 // Lookup the to be spawned function for the Isolate.spawn implementation. | 2665 // Lookup the to be spawned function for the Isolate.spawn implementation. |
| 2662 // Resolve the library. | 2666 // Resolve the library. |
| 2663 const String& lib_url = String::Handle(String::New(library_url())); | 2667 const String& lib_url = String::Handle(zone, String::New(library_url())); |
| 2664 const Library& lib = Library::Handle(Library::LookupLibrary(lib_url)); | 2668 const Library& lib = Library::Handle(zone, |
| 2669 Library::LookupLibrary(thread, lib_url)); |
| 2665 if (lib.IsNull() || lib.IsError()) { | 2670 if (lib.IsNull() || lib.IsError()) { |
| 2666 const String& msg = String::Handle(String::NewFormatted( | 2671 const String& msg = String::Handle(zone, String::NewFormatted( |
| 2667 "Unable to find library '%s'.", library_url())); | 2672 "Unable to find library '%s'.", library_url())); |
| 2668 return LanguageError::New(msg); | 2673 return LanguageError::New(msg); |
| 2669 } | 2674 } |
| 2670 | 2675 |
| 2671 // Resolve the function. | 2676 // Resolve the function. |
| 2672 if (class_name() == NULL) { | 2677 if (class_name() == NULL) { |
| 2673 const Function& func = Function::Handle(lib.LookupLocalFunction(func_name)); | 2678 const Function& func = Function::Handle(zone, |
| 2679 lib.LookupLocalFunction(func_name)); |
| 2674 if (func.IsNull()) { | 2680 if (func.IsNull()) { |
| 2675 const String& msg = String::Handle(String::NewFormatted( | 2681 const String& msg = String::Handle(zone, String::NewFormatted( |
| 2676 "Unable to resolve function '%s' in library '%s'.", | 2682 "Unable to resolve function '%s' in library '%s'.", |
| 2677 function_name(), library_url())); | 2683 function_name(), library_url())); |
| 2678 return LanguageError::New(msg); | 2684 return LanguageError::New(msg); |
| 2679 } | 2685 } |
| 2680 return func.raw(); | 2686 return func.raw(); |
| 2681 } | 2687 } |
| 2682 | 2688 |
| 2683 const String& cls_name = String::Handle(String::New(class_name())); | 2689 const String& cls_name = String::Handle(zone, String::New(class_name())); |
| 2684 const Class& cls = Class::Handle(lib.LookupLocalClass(cls_name)); | 2690 const Class& cls = Class::Handle(zone, lib.LookupLocalClass(cls_name)); |
| 2685 if (cls.IsNull()) { | 2691 if (cls.IsNull()) { |
| 2686 const String& msg = String::Handle(String::NewFormatted( | 2692 const String& msg = String::Handle(zone, String::NewFormatted( |
| 2687 "Unable to resolve class '%s' in library '%s'.", | 2693 "Unable to resolve class '%s' in library '%s'.", |
| 2688 class_name(), | 2694 class_name(), |
| 2689 (library_url() != NULL ? library_url() : script_url()))); | 2695 (library_url() != NULL ? library_url() : script_url()))); |
| 2690 return LanguageError::New(msg); | 2696 return LanguageError::New(msg); |
| 2691 } | 2697 } |
| 2692 const Function& func = | 2698 const Function& func = |
| 2693 Function::Handle(cls.LookupStaticFunctionAllowPrivate(func_name)); | 2699 Function::Handle(zone, cls.LookupStaticFunctionAllowPrivate(func_name)); |
| 2694 if (func.IsNull()) { | 2700 if (func.IsNull()) { |
| 2695 const String& msg = String::Handle(String::NewFormatted( | 2701 const String& msg = String::Handle(zone, String::NewFormatted( |
| 2696 "Unable to resolve static method '%s.%s' in library '%s'.", | 2702 "Unable to resolve static method '%s.%s' in library '%s'.", |
| 2697 class_name(), function_name(), | 2703 class_name(), function_name(), |
| 2698 (library_url() != NULL ? library_url() : script_url()))); | 2704 (library_url() != NULL ? library_url() : script_url()))); |
| 2699 return LanguageError::New(msg); | 2705 return LanguageError::New(msg); |
| 2700 } | 2706 } |
| 2701 return func.raw(); | 2707 return func.raw(); |
| 2702 } | 2708 } |
| 2703 | 2709 |
| 2704 | 2710 |
| 2705 RawInstance* IsolateSpawnState::BuildArgs(Thread* thread) { | 2711 RawInstance* IsolateSpawnState::BuildArgs(Thread* thread) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2716 void IsolateSpawnState::DecrementSpawnCount() { | 2722 void IsolateSpawnState::DecrementSpawnCount() { |
| 2717 ASSERT(spawn_count_monitor_ != NULL); | 2723 ASSERT(spawn_count_monitor_ != NULL); |
| 2718 ASSERT(spawn_count_ != NULL); | 2724 ASSERT(spawn_count_ != NULL); |
| 2719 MonitorLocker ml(spawn_count_monitor_); | 2725 MonitorLocker ml(spawn_count_monitor_); |
| 2720 ASSERT(*spawn_count_ > 0); | 2726 ASSERT(*spawn_count_ > 0); |
| 2721 *spawn_count_ = *spawn_count_ - 1; | 2727 *spawn_count_ = *spawn_count_ - 1; |
| 2722 ml.Notify(); | 2728 ml.Notify(); |
| 2723 } | 2729 } |
| 2724 | 2730 |
| 2725 } // namespace dart | 2731 } // namespace dart |
| OLD | NEW |