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

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

Issue 573293004: Fix issue 17514770 (https://b2.corp.google.com/issues/17514770) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_store.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) 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 8727 matching lines...) Expand 10 before | Expand all | Expand 10 after
8738 8738
8739 8739
8740 void Library::SetLoadError(const Instance& error) const { 8740 void Library::SetLoadError(const Instance& error) const {
8741 // Should not be already successfully loaded or just allocated. 8741 // Should not be already successfully loaded or just allocated.
8742 ASSERT(LoadInProgress() || LoadRequested() || LoadFailed()); 8742 ASSERT(LoadInProgress() || LoadRequested() || LoadFailed());
8743 raw_ptr()->load_state_ = RawLibrary::kLoadError; 8743 raw_ptr()->load_state_ = RawLibrary::kLoadError;
8744 StorePointer(&raw_ptr()->load_error_, error.raw()); 8744 StorePointer(&raw_ptr()->load_error_, error.raw());
8745 } 8745 }
8746 8746
8747 8747
8748 // Traits for looking up Libraries by url in a hash set.
8749 class LibraryUrlTraits {
8750 public:
8751 // Called when growing the table.
8752 static bool IsMatch(const Object& a, const Object& b) {
8753 ASSERT(a.IsLibrary() && b.IsLibrary());
8754 // Library objects are always canonical.
8755 return a.raw() == b.raw();
8756 }
8757 static uword Hash(const Object& key) {
8758 return Library::Cast(key).UrlHash();
8759 }
8760 };
8761
8762
8763 typedef UnorderedHashSet<LibraryUrlTraits> LibraryLoadErrorSet;
8764
8765
8748 RawInstance* Library::TransitiveLoadError() const { 8766 RawInstance* Library::TransitiveLoadError() const {
8749 if (LoadError() != Instance::null()) { 8767 if (LoadError() != Instance::null()) {
8750 return LoadError(); 8768 return LoadError();
8751 } 8769 }
8770 Isolate* isolate = Isolate::Current();
8771 ObjectStore* object_store = isolate->object_store();
8772 LibraryLoadErrorSet set(object_store->library_load_error_table());
8773 bool present = false;
8774 if (set.GetOrNull(*this, &present) != Object::null()) {
8775 object_store->set_library_load_error_table(set.Release());
8776 return Instance::null();
8777 }
8778 // Ensure we don't repeatedly visit the same library again.
8779 set.Insert(*this);
8780 object_store->set_library_load_error_table(set.Release());
8752 intptr_t num_imp = num_imports(); 8781 intptr_t num_imp = num_imports();
8753 Library& lib = Library::Handle(); 8782 Library& lib = Library::Handle(isolate);
8754 Instance& error = Instance::Handle(); 8783 Instance& error = Instance::Handle(isolate);
8755 for (intptr_t i = 0; i < num_imp; i++) { 8784 for (intptr_t i = 0; i < num_imp; i++) {
8785 HANDLESCOPE(isolate);
8756 lib = ImportLibraryAt(i); 8786 lib = ImportLibraryAt(i);
8757 // Break potential import cycles while recursing through imports.
8758 set_num_imports(0);
8759 error = lib.TransitiveLoadError(); 8787 error = lib.TransitiveLoadError();
8760 set_num_imports(num_imp);
8761 if (!error.IsNull()) { 8788 if (!error.IsNull()) {
8762 break; 8789 break;
8763 } 8790 }
8764 } 8791 }
8765 return error.raw(); 8792 return error.raw();
8766 } 8793 }
8767 8794
8768 8795
8769 static RawString* MakeClassMetaName(const Class& cls) { 8796 static RawString* MakeClassMetaName(const Class& cls) {
8770 String& cname = String::Handle(cls.Name()); 8797 String& cname = String::Handle(cls.Name());
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
9934 const Array& imports = Array::Handle(this->imports()); 9961 const Array& imports = Array::Handle(this->imports());
9935 Namespace& import = Namespace::Handle(); 9962 Namespace& import = Namespace::Handle();
9936 import ^= imports.At(index); 9963 import ^= imports.At(index);
9937 return import.library(); 9964 return import.library();
9938 } 9965 }
9939 return Library::null(); 9966 return Library::null();
9940 } 9967 }
9941 9968
9942 9969
9943 RawInstance* LibraryPrefix::LoadError() const { 9970 RawInstance* LibraryPrefix::LoadError() const {
9944 Library& lib = Library::Handle(); 9971 Isolate* isolate = Isolate::Current();
9945 Instance& error = Instance::Handle(); 9972 ObjectStore* object_store = isolate->object_store();
9973 GrowableObjectArray& libs =
9974 GrowableObjectArray::Handle(isolate, object_store->libraries());
9975 ASSERT(!libs.IsNull());
9976 LibraryLoadErrorSet set(HashTables::New<LibraryLoadErrorSet>(libs.Length()));
9977 object_store->set_library_load_error_table(set.Release());
9978 Library& lib = Library::Handle(isolate);
9979 Instance& error = Instance::Handle(isolate);
9946 for (int32_t i = 0; i < num_imports(); i++) { 9980 for (int32_t i = 0; i < num_imports(); i++) {
9947 lib = GetLibrary(i); 9981 lib = GetLibrary(i);
9948 ASSERT(!lib.IsNull()); 9982 ASSERT(!lib.IsNull());
9983 HANDLESCOPE(isolate);
9949 error = lib.TransitiveLoadError(); 9984 error = lib.TransitiveLoadError();
9950 if (!error.IsNull()) { 9985 if (!error.IsNull()) {
9951 return error.raw(); 9986 break;
9952 } 9987 }
9953 } 9988 }
9954 return Instance::null(); 9989 object_store->set_library_load_error_table(Object::empty_array());
9990 return error.raw();
9955 } 9991 }
9956 9992
9957 9993
9958 bool LibraryPrefix::ContainsLibrary(const Library& library) const { 9994 bool LibraryPrefix::ContainsLibrary(const Library& library) const {
9959 int32_t num_current_imports = num_imports(); 9995 int32_t num_current_imports = num_imports();
9960 if (num_current_imports > 0) { 9996 if (num_current_imports > 0) {
9961 Library& lib = Library::Handle(); 9997 Library& lib = Library::Handle();
9962 const String& url = String::Handle(library.url()); 9998 const String& url = String::Handle(library.url());
9963 String& lib_url = String::Handle(); 9999 String& lib_url = String::Handle();
9964 for (int32_t i = 0; i < num_current_imports; i++) { 10000 for (int32_t i = 0; i < num_current_imports; i++) {
(...skipping 10401 matching lines...) Expand 10 before | Expand all | Expand 10 after
20366 return tag_label.ToCString(); 20402 return tag_label.ToCString();
20367 } 20403 }
20368 20404
20369 20405
20370 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20406 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20371 Instance::PrintJSONImpl(stream, ref); 20407 Instance::PrintJSONImpl(stream, ref);
20372 } 20408 }
20373 20409
20374 20410
20375 } // namespace dart 20411 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698