Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: runtime/vm/isolate.cc

Issue 1947393003: - Use a map to lookup libraries by URL. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/debugger_api_impl.cc ('k') | runtime/vm/method_recognizer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2612 matching lines...) Expand 10 before | Expand all | Expand 10 after
2623 delete[] package_config_; 2623 delete[] package_config_;
2624 delete[] library_url_; 2624 delete[] library_url_;
2625 delete[] class_name_; 2625 delete[] class_name_;
2626 delete[] function_name_; 2626 delete[] function_name_;
2627 free(serialized_args_); 2627 free(serialized_args_);
2628 free(serialized_message_); 2628 free(serialized_message_);
2629 } 2629 }
2630 2630
2631 2631
2632 RawObject* IsolateSpawnState::ResolveFunction() { 2632 RawObject* IsolateSpawnState::ResolveFunction() {
2633 const String& func_name = String::Handle(String::New(function_name())); 2633 Thread* thread = Thread::Current();
2634 Zone* zone = thread->zone();
2635
2636 const String& func_name = String::Handle(zone, String::New(function_name()));
2634 2637
2635 if (library_url() == NULL) { 2638 if (library_url() == NULL) {
2636 // Handle spawnUri lookup rules. 2639 // Handle spawnUri lookup rules.
2637 // Check whether the root library defines a main function. 2640 // Check whether the root library defines a main function.
2638 const Library& lib = Library::Handle(I->object_store()->root_library()); 2641 const Library& lib = Library::Handle(zone,
2639 Function& func = Function::Handle(lib.LookupLocalFunction(func_name)); 2642 I->object_store()->root_library());
2643 Function& func = Function::Handle(zone, lib.LookupLocalFunction(func_name));
2640 if (func.IsNull()) { 2644 if (func.IsNull()) {
2641 // Check whether main is reexported from the root library. 2645 // Check whether main is reexported from the root library.
2642 const Object& obj = Object::Handle(lib.LookupReExport(func_name)); 2646 const Object& obj = Object::Handle(zone, lib.LookupReExport(func_name));
2643 if (obj.IsFunction()) { 2647 if (obj.IsFunction()) {
2644 func ^= obj.raw(); 2648 func ^= obj.raw();
2645 } 2649 }
2646 } 2650 }
2647 if (func.IsNull()) { 2651 if (func.IsNull()) {
2648 const String& msg = String::Handle(String::NewFormatted( 2652 const String& msg = String::Handle(zone, String::NewFormatted(
2649 "Unable to resolve function '%s' in script '%s'.", 2653 "Unable to resolve function '%s' in script '%s'.",
2650 function_name(), script_url())); 2654 function_name(), script_url()));
2651 return LanguageError::New(msg); 2655 return LanguageError::New(msg);
2652 } 2656 }
2653 return func.raw(); 2657 return func.raw();
2654 } 2658 }
2655 2659
2656 // Lookup the to be spawned function for the Isolate.spawn implementation. 2660 // Lookup the to be spawned function for the Isolate.spawn implementation.
2657 // Resolve the library. 2661 // Resolve the library.
2658 const String& lib_url = String::Handle(String::New(library_url())); 2662 const String& lib_url = String::Handle(zone, String::New(library_url()));
2659 const Library& lib = Library::Handle(Library::LookupLibrary(lib_url)); 2663 const Library& lib = Library::Handle(zone,
2664 Library::LookupLibrary(thread, lib_url));
2660 if (lib.IsNull() || lib.IsError()) { 2665 if (lib.IsNull() || lib.IsError()) {
2661 const String& msg = String::Handle(String::NewFormatted( 2666 const String& msg = String::Handle(zone, String::NewFormatted(
2662 "Unable to find library '%s'.", library_url())); 2667 "Unable to find library '%s'.", library_url()));
2663 return LanguageError::New(msg); 2668 return LanguageError::New(msg);
2664 } 2669 }
2665 2670
2666 // Resolve the function. 2671 // Resolve the function.
2667 if (class_name() == NULL) { 2672 if (class_name() == NULL) {
2668 const Function& func = Function::Handle(lib.LookupLocalFunction(func_name)); 2673 const Function& func = Function::Handle(zone,
2674 lib.LookupLocalFunction(func_name));
2669 if (func.IsNull()) { 2675 if (func.IsNull()) {
2670 const String& msg = String::Handle(String::NewFormatted( 2676 const String& msg = String::Handle(zone, String::NewFormatted(
2671 "Unable to resolve function '%s' in library '%s'.", 2677 "Unable to resolve function '%s' in library '%s'.",
2672 function_name(), library_url())); 2678 function_name(), library_url()));
2673 return LanguageError::New(msg); 2679 return LanguageError::New(msg);
2674 } 2680 }
2675 return func.raw(); 2681 return func.raw();
2676 } 2682 }
2677 2683
2678 const String& cls_name = String::Handle(String::New(class_name())); 2684 const String& cls_name = String::Handle(zone, String::New(class_name()));
2679 const Class& cls = Class::Handle(lib.LookupLocalClass(cls_name)); 2685 const Class& cls = Class::Handle(zone, lib.LookupLocalClass(cls_name));
2680 if (cls.IsNull()) { 2686 if (cls.IsNull()) {
2681 const String& msg = String::Handle(String::NewFormatted( 2687 const String& msg = String::Handle(zone, String::NewFormatted(
2682 "Unable to resolve class '%s' in library '%s'.", 2688 "Unable to resolve class '%s' in library '%s'.",
2683 class_name(), 2689 class_name(),
2684 (library_url() != NULL ? library_url() : script_url()))); 2690 (library_url() != NULL ? library_url() : script_url())));
2685 return LanguageError::New(msg); 2691 return LanguageError::New(msg);
2686 } 2692 }
2687 const Function& func = 2693 const Function& func =
2688 Function::Handle(cls.LookupStaticFunctionAllowPrivate(func_name)); 2694 Function::Handle(zone, cls.LookupStaticFunctionAllowPrivate(func_name));
2689 if (func.IsNull()) { 2695 if (func.IsNull()) {
2690 const String& msg = String::Handle(String::NewFormatted( 2696 const String& msg = String::Handle(zone, String::NewFormatted(
2691 "Unable to resolve static method '%s.%s' in library '%s'.", 2697 "Unable to resolve static method '%s.%s' in library '%s'.",
2692 class_name(), function_name(), 2698 class_name(), function_name(),
2693 (library_url() != NULL ? library_url() : script_url()))); 2699 (library_url() != NULL ? library_url() : script_url())));
2694 return LanguageError::New(msg); 2700 return LanguageError::New(msg);
2695 } 2701 }
2696 return func.raw(); 2702 return func.raw();
2697 } 2703 }
2698 2704
2699 2705
2700 RawInstance* IsolateSpawnState::BuildArgs(Thread* thread) { 2706 RawInstance* IsolateSpawnState::BuildArgs(Thread* thread) {
(...skipping 10 matching lines...) Expand all
2711 void IsolateSpawnState::DecrementSpawnCount() { 2717 void IsolateSpawnState::DecrementSpawnCount() {
2712 ASSERT(spawn_count_monitor_ != NULL); 2718 ASSERT(spawn_count_monitor_ != NULL);
2713 ASSERT(spawn_count_ != NULL); 2719 ASSERT(spawn_count_ != NULL);
2714 MonitorLocker ml(spawn_count_monitor_); 2720 MonitorLocker ml(spawn_count_monitor_);
2715 ASSERT(*spawn_count_ > 0); 2721 ASSERT(*spawn_count_ > 0);
2716 *spawn_count_ = *spawn_count_ - 1; 2722 *spawn_count_ = *spawn_count_ - 1;
2717 ml.Notify(); 2723 ml.Notify();
2718 } 2724 }
2719 2725
2720 } // namespace dart 2726 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger_api_impl.cc ('k') | runtime/vm/method_recognizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698