Chromium Code Reviews| 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 8527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8538 } | 8538 } |
| 8539 | 8539 |
| 8540 | 8540 |
| 8541 void Library::SetLoaded() const { | 8541 void Library::SetLoaded() const { |
| 8542 // Should not be already loaded or just allocated. | 8542 // Should not be already loaded or just allocated. |
| 8543 ASSERT(LoadInProgress() || LoadRequested()); | 8543 ASSERT(LoadInProgress() || LoadRequested()); |
| 8544 raw_ptr()->load_state_ = RawLibrary::kLoaded; | 8544 raw_ptr()->load_state_ = RawLibrary::kLoaded; |
| 8545 } | 8545 } |
| 8546 | 8546 |
| 8547 | 8547 |
| 8548 void Library::SetLoadError() const { | 8548 void Library::SetLoadError(const Object& error) const { |
| 8549 // Should not be already successfully loaded or just allocated. | 8549 // Should not be already successfully loaded or just allocated. |
| 8550 ASSERT(LoadInProgress() || LoadRequested() || LoadError()); | 8550 ASSERT(LoadInProgress() || LoadRequested() || LoadFailed()); |
| 8551 raw_ptr()->load_state_ = RawLibrary::kLoadError; | 8551 raw_ptr()->load_state_ = RawLibrary::kLoadError; |
| 8552 StorePointer(&raw_ptr()->load_error_, error.raw()); | |
| 8553 } | |
| 8554 | |
| 8555 | |
| 8556 RawObject* Library::TransitiveLoadError() const { | |
| 8557 if (LoadError() != Error::null()) { | |
| 8558 return LoadError(); | |
| 8559 } | |
| 8560 intptr_t num_imp = num_imports(); | |
| 8561 Library& lib = Library::Handle(); | |
| 8562 Object& error = Object::Handle(); | |
| 8563 for (intptr_t i = 0; i < num_imp; i++) { | |
| 8564 lib = ImportLibraryAt(i); | |
| 8565 // Break potential import cycles while recursing through imports. | |
| 8566 set_num_imports(0); | |
| 8567 error = lib.TransitiveLoadError(); | |
| 8568 set_num_imports(num_imp); | |
| 8569 if (!error.IsNull()) { | |
| 8570 break; | |
| 8571 } | |
| 8572 } | |
| 8573 return error.raw(); | |
| 8552 } | 8574 } |
| 8553 | 8575 |
| 8554 | 8576 |
| 8555 static RawString* MakeClassMetaName(const Class& cls) { | 8577 static RawString* MakeClassMetaName(const Class& cls) { |
| 8556 String& cname = String::Handle(cls.Name()); | 8578 String& cname = String::Handle(cls.Name()); |
| 8557 return String::Concat(Symbols::At(), cname); | 8579 return String::Concat(Symbols::At(), cname); |
| 8558 } | 8580 } |
| 8559 | 8581 |
| 8560 | 8582 |
| 8561 static RawString* MakeFieldMetaName(const Field& field) { | 8583 static RawString* MakeFieldMetaName(const Field& field) { |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9344 result.StorePointer(&result.raw_ptr()->url_, url.raw()); | 9366 result.StorePointer(&result.raw_ptr()->url_, url.raw()); |
| 9345 result.raw_ptr()->resolved_names_ = Object::empty_array().raw(); | 9367 result.raw_ptr()->resolved_names_ = Object::empty_array().raw(); |
| 9346 result.raw_ptr()->dictionary_ = Object::empty_array().raw(); | 9368 result.raw_ptr()->dictionary_ = Object::empty_array().raw(); |
| 9347 result.StorePointer(&result.raw_ptr()->metadata_, | 9369 result.StorePointer(&result.raw_ptr()->metadata_, |
| 9348 GrowableObjectArray::New(4, Heap::kOld)); | 9370 GrowableObjectArray::New(4, Heap::kOld)); |
| 9349 result.raw_ptr()->anonymous_classes_ = Object::empty_array().raw(); | 9371 result.raw_ptr()->anonymous_classes_ = Object::empty_array().raw(); |
| 9350 result.raw_ptr()->num_anonymous_ = 0; | 9372 result.raw_ptr()->num_anonymous_ = 0; |
| 9351 result.raw_ptr()->imports_ = Object::empty_array().raw(); | 9373 result.raw_ptr()->imports_ = Object::empty_array().raw(); |
| 9352 result.raw_ptr()->exports_ = Object::empty_array().raw(); | 9374 result.raw_ptr()->exports_ = Object::empty_array().raw(); |
| 9353 result.raw_ptr()->loaded_scripts_ = Array::null(); | 9375 result.raw_ptr()->loaded_scripts_ = Array::null(); |
| 9376 result.raw_ptr()->load_error_ = Object::null(); | |
| 9354 result.set_native_entry_resolver(NULL); | 9377 result.set_native_entry_resolver(NULL); |
| 9355 result.set_native_entry_symbol_resolver(NULL); | 9378 result.set_native_entry_symbol_resolver(NULL); |
| 9356 result.raw_ptr()->corelib_imported_ = true; | 9379 result.raw_ptr()->corelib_imported_ = true; |
| 9357 result.set_debuggable(false); | 9380 result.set_debuggable(false); |
| 9358 result.set_is_dart_scheme(url.StartsWith(Symbols::DartScheme())); | 9381 result.set_is_dart_scheme(url.StartsWith(Symbols::DartScheme())); |
| 9359 result.raw_ptr()->load_state_ = RawLibrary::kAllocated; | 9382 result.raw_ptr()->load_state_ = RawLibrary::kAllocated; |
| 9360 result.raw_ptr()->index_ = -1; | 9383 result.raw_ptr()->index_ = -1; |
| 9361 const intptr_t kInitialNameCacheSize = 64; | 9384 const intptr_t kInitialNameCacheSize = 64; |
| 9362 result.InitResolvedNamesCache(kInitialNameCacheSize); | 9385 result.InitResolvedNamesCache(kInitialNameCacheSize); |
| 9363 result.InitClassDictionary(); | 9386 result.InitClassDictionary(); |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9720 if ((index >= 0) || (index < num_imports())) { | 9743 if ((index >= 0) || (index < num_imports())) { |
| 9721 const Array& imports = Array::Handle(this->imports()); | 9744 const Array& imports = Array::Handle(this->imports()); |
| 9722 Namespace& import = Namespace::Handle(); | 9745 Namespace& import = Namespace::Handle(); |
| 9723 import ^= imports.At(index); | 9746 import ^= imports.At(index); |
| 9724 return import.library(); | 9747 return import.library(); |
| 9725 } | 9748 } |
| 9726 return Library::null(); | 9749 return Library::null(); |
| 9727 } | 9750 } |
| 9728 | 9751 |
| 9729 | 9752 |
| 9753 RawObject* LibraryPrefix::LoadError() const { | |
| 9754 Library& lib = Library::Handle(); | |
| 9755 Object& error = Object::Handle(); | |
| 9756 for (int32_t i = 0; i < num_imports(); i++) { | |
| 9757 lib = GetLibrary(i); | |
| 9758 ASSERT(!lib.IsNull()); | |
| 9759 error = lib.TransitiveLoadError(); | |
| 9760 if (!error.IsNull()) { | |
| 9761 return error.raw(); | |
| 9762 } | |
| 9763 } | |
| 9764 return Object::null(); | |
| 9765 } | |
| 9766 | |
| 9767 | |
| 9730 bool LibraryPrefix::ContainsLibrary(const Library& library) const { | 9768 bool LibraryPrefix::ContainsLibrary(const Library& library) const { |
| 9731 intptr_t num_current_imports = num_imports(); | 9769 int32_t num_current_imports = num_imports(); |
| 9732 if (num_current_imports > 0) { | 9770 if (num_current_imports > 0) { |
| 9733 Library& lib = Library::Handle(); | 9771 Library& lib = Library::Handle(); |
| 9734 const String& url = String::Handle(library.url()); | 9772 const String& url = String::Handle(library.url()); |
| 9735 String& lib_url = String::Handle(); | 9773 String& lib_url = String::Handle(); |
| 9736 for (intptr_t i = 0; i < num_current_imports; i++) { | 9774 for (int32_t i = 0; i < num_current_imports; i++) { |
| 9737 lib = GetLibrary(i); | 9775 lib = GetLibrary(i); |
| 9738 ASSERT(!lib.IsNull()); | 9776 ASSERT(!lib.IsNull()); |
| 9739 lib_url = lib.url(); | 9777 lib_url = lib.url(); |
| 9740 if (url.Equals(lib_url)) { | 9778 if (url.Equals(lib_url)) { |
| 9741 return true; | 9779 return true; |
| 9742 } | 9780 } |
| 9743 } | 9781 } |
| 9744 } | 9782 } |
| 9745 return false; | 9783 return false; |
| 9746 } | 9784 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9837 // - mark this prefixes as loaded; | 9875 // - mark this prefixes as loaded; |
| 9838 // - complete the future associated with this prefix. | 9876 // - complete the future associated with this prefix. |
| 9839 const Library& deferred_lib = Library::Handle(GetLibrary(0)); | 9877 const Library& deferred_lib = Library::Handle(GetLibrary(0)); |
| 9840 if (deferred_lib.Loaded()) { | 9878 if (deferred_lib.Loaded()) { |
| 9841 this->set_is_loaded(); | 9879 this->set_is_loaded(); |
| 9842 return true; | 9880 return true; |
| 9843 } else if (deferred_lib.LoadNotStarted()) { | 9881 } else if (deferred_lib.LoadNotStarted()) { |
| 9844 Isolate* isolate = Isolate::Current(); | 9882 Isolate* isolate = Isolate::Current(); |
| 9845 Api::Scope api_scope(isolate); | 9883 Api::Scope api_scope(isolate); |
| 9846 deferred_lib.SetLoadRequested(); | 9884 deferred_lib.SetLoadRequested(); |
| 9885 const GrowableObjectArray& pending_deferred_loads = | |
| 9886 GrowableObjectArray::Handle( | |
| 9887 isolate->object_store()->pending_deferred_loads()); | |
| 9888 pending_deferred_loads.Add(deferred_lib); | |
|
Ivan Posva
2014/07/31 18:29:04
Please make sure this is reset when the loads are
hausner
2014/07/31 21:12:45
Added to Dart_FinalizeLoading()
| |
| 9847 const String& lib_url = String::Handle(isolate, deferred_lib.url()); | 9889 const String& lib_url = String::Handle(isolate, deferred_lib.url()); |
| 9848 Dart_LibraryTagHandler handler = isolate->library_tag_handler(); | 9890 Dart_LibraryTagHandler handler = isolate->library_tag_handler(); |
| 9849 handler(Dart_kImportTag, | 9891 handler(Dart_kImportTag, |
| 9850 Api::NewHandle(isolate, importer()), | 9892 Api::NewHandle(isolate, importer()), |
| 9851 Api::NewHandle(isolate, lib_url.raw())); | 9893 Api::NewHandle(isolate, lib_url.raw())); |
| 9852 } else { | 9894 } else { |
| 9853 // Another load request is in flight. | 9895 // Another load request is in flight. |
| 9854 ASSERT(deferred_lib.LoadRequested()); | 9896 ASSERT(deferred_lib.LoadRequested()); |
| 9855 } | 9897 } |
| 9856 return false; // Load request not yet completed. | 9898 return false; // Load request not yet completed. |
| (...skipping 9495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 19352 return tag_label.ToCString(); | 19394 return tag_label.ToCString(); |
| 19353 } | 19395 } |
| 19354 | 19396 |
| 19355 | 19397 |
| 19356 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19398 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 19357 Instance::PrintJSONImpl(stream, ref); | 19399 Instance::PrintJSONImpl(stream, ref); |
| 19358 } | 19400 } |
| 19359 | 19401 |
| 19360 | 19402 |
| 19361 } // namespace dart | 19403 } // namespace dart |
| OLD | NEW |