| 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 "vm/object.h" | 5 #include "vm/object.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 "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 8700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8711 | 8711 |
| 8712 | 8712 |
| 8713 void Library::SetLoadError(const Instance& error) const { | 8713 void Library::SetLoadError(const Instance& error) const { |
| 8714 // Should not be already successfully loaded or just allocated. | 8714 // Should not be already successfully loaded or just allocated. |
| 8715 ASSERT(LoadInProgress() || LoadRequested() || LoadFailed()); | 8715 ASSERT(LoadInProgress() || LoadRequested() || LoadFailed()); |
| 8716 raw_ptr()->load_state_ = RawLibrary::kLoadError; | 8716 raw_ptr()->load_state_ = RawLibrary::kLoadError; |
| 8717 StorePointer(&raw_ptr()->load_error_, error.raw()); | 8717 StorePointer(&raw_ptr()->load_error_, error.raw()); |
| 8718 } | 8718 } |
| 8719 | 8719 |
| 8720 | 8720 |
| 8721 // Traits for looking up Libraries by url in a hash set. |
| 8722 class LibraryUrlTraits { |
| 8723 public: |
| 8724 // Called when growing the table. |
| 8725 static bool IsMatch(const Object& a, const Object& b) { |
| 8726 ASSERT(a.IsLibrary() && b.IsLibrary()); |
| 8727 // Library objects are always canonical. |
| 8728 return a.raw() == b.raw(); |
| 8729 } |
| 8730 static uword Hash(const Object& key) { |
| 8731 return Library::Cast(key).UrlHash(); |
| 8732 } |
| 8733 }; |
| 8734 |
| 8735 |
| 8736 typedef UnorderedHashSet<LibraryUrlTraits> LibraryLoadErrorSet; |
| 8737 |
| 8738 |
| 8721 RawInstance* Library::TransitiveLoadError() const { | 8739 RawInstance* Library::TransitiveLoadError() const { |
| 8722 if (LoadError() != Instance::null()) { | 8740 if (LoadError() != Instance::null()) { |
| 8723 return LoadError(); | 8741 return LoadError(); |
| 8724 } | 8742 } |
| 8743 Isolate* isolate = Isolate::Current(); |
| 8744 ObjectStore* object_store = isolate->object_store(); |
| 8745 LibraryLoadErrorSet set(object_store->library_load_error_table()); |
| 8746 bool present = false; |
| 8747 if (set.GetOrNull(*this, &present) != Object::null()) { |
| 8748 object_store->set_library_load_error_table(set.Release()); |
| 8749 return Instance::null(); |
| 8750 } |
| 8751 // Ensure we don't repeatedly visit the same library again. |
| 8752 set.Insert(*this); |
| 8753 object_store->set_library_load_error_table(set.Release()); |
| 8725 intptr_t num_imp = num_imports(); | 8754 intptr_t num_imp = num_imports(); |
| 8726 Library& lib = Library::Handle(); | 8755 Library& lib = Library::Handle(isolate); |
| 8727 Instance& error = Instance::Handle(); | 8756 Instance& error = Instance::Handle(isolate); |
| 8728 for (intptr_t i = 0; i < num_imp; i++) { | 8757 for (intptr_t i = 0; i < num_imp; i++) { |
| 8758 HANDLESCOPE(isolate); |
| 8729 lib = ImportLibraryAt(i); | 8759 lib = ImportLibraryAt(i); |
| 8730 // Break potential import cycles while recursing through imports. | |
| 8731 set_num_imports(0); | |
| 8732 error = lib.TransitiveLoadError(); | 8760 error = lib.TransitiveLoadError(); |
| 8733 set_num_imports(num_imp); | |
| 8734 if (!error.IsNull()) { | 8761 if (!error.IsNull()) { |
| 8735 break; | 8762 break; |
| 8736 } | 8763 } |
| 8737 } | 8764 } |
| 8738 return error.raw(); | 8765 return error.raw(); |
| 8739 } | 8766 } |
| 8740 | 8767 |
| 8741 | 8768 |
| 8742 static RawString* MakeClassMetaName(const Class& cls) { | 8769 static RawString* MakeClassMetaName(const Class& cls) { |
| 8743 String& cname = String::Handle(cls.Name()); | 8770 String& cname = String::Handle(cls.Name()); |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9907 const Array& imports = Array::Handle(this->imports()); | 9934 const Array& imports = Array::Handle(this->imports()); |
| 9908 Namespace& import = Namespace::Handle(); | 9935 Namespace& import = Namespace::Handle(); |
| 9909 import ^= imports.At(index); | 9936 import ^= imports.At(index); |
| 9910 return import.library(); | 9937 return import.library(); |
| 9911 } | 9938 } |
| 9912 return Library::null(); | 9939 return Library::null(); |
| 9913 } | 9940 } |
| 9914 | 9941 |
| 9915 | 9942 |
| 9916 RawInstance* LibraryPrefix::LoadError() const { | 9943 RawInstance* LibraryPrefix::LoadError() const { |
| 9917 Library& lib = Library::Handle(); | 9944 Isolate* isolate = Isolate::Current(); |
| 9918 Instance& error = Instance::Handle(); | 9945 ObjectStore* object_store = isolate->object_store(); |
| 9946 GrowableObjectArray& libs = |
| 9947 GrowableObjectArray::Handle(isolate, object_store->libraries()); |
| 9948 ASSERT(!libs.IsNull()); |
| 9949 LibraryLoadErrorSet set(HashTables::New<LibraryLoadErrorSet>(libs.Length())); |
| 9950 object_store->set_library_load_error_table(set.Release()); |
| 9951 Library& lib = Library::Handle(isolate); |
| 9952 Instance& error = Instance::Handle(isolate); |
| 9919 for (int32_t i = 0; i < num_imports(); i++) { | 9953 for (int32_t i = 0; i < num_imports(); i++) { |
| 9920 lib = GetLibrary(i); | 9954 lib = GetLibrary(i); |
| 9921 ASSERT(!lib.IsNull()); | 9955 ASSERT(!lib.IsNull()); |
| 9956 HANDLESCOPE(isolate); |
| 9922 error = lib.TransitiveLoadError(); | 9957 error = lib.TransitiveLoadError(); |
| 9923 if (!error.IsNull()) { | 9958 if (!error.IsNull()) { |
| 9924 return error.raw(); | 9959 break; |
| 9925 } | 9960 } |
| 9926 } | 9961 } |
| 9927 return Instance::null(); | 9962 object_store->set_library_load_error_table(Object::empty_array()); |
| 9963 return error.raw(); |
| 9928 } | 9964 } |
| 9929 | 9965 |
| 9930 | 9966 |
| 9931 bool LibraryPrefix::ContainsLibrary(const Library& library) const { | 9967 bool LibraryPrefix::ContainsLibrary(const Library& library) const { |
| 9932 int32_t num_current_imports = num_imports(); | 9968 int32_t num_current_imports = num_imports(); |
| 9933 if (num_current_imports > 0) { | 9969 if (num_current_imports > 0) { |
| 9934 Library& lib = Library::Handle(); | 9970 Library& lib = Library::Handle(); |
| 9935 const String& url = String::Handle(library.url()); | 9971 const String& url = String::Handle(library.url()); |
| 9936 String& lib_url = String::Handle(); | 9972 String& lib_url = String::Handle(); |
| 9937 for (int32_t i = 0; i < num_current_imports; i++) { | 9973 for (int32_t i = 0; i < num_current_imports; i++) { |
| (...skipping 10396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20334 return tag_label.ToCString(); | 20370 return tag_label.ToCString(); |
| 20335 } | 20371 } |
| 20336 | 20372 |
| 20337 | 20373 |
| 20338 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20374 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20339 Instance::PrintJSONImpl(stream, ref); | 20375 Instance::PrintJSONImpl(stream, ref); |
| 20340 } | 20376 } |
| 20341 | 20377 |
| 20342 | 20378 |
| 20343 } // namespace dart | 20379 } // namespace dart |
| OLD | NEW |