diff --git a/runtime/bin/gen_snapshot.cc b/runtime/bin/gen_snapshot.cc index f10a328fd44..d7a2a4e9a15 100644 --- a/runtime/bin/gen_snapshot.cc +++ b/runtime/bin/gen_snapshot.cc @@ -864,11 +864,6 @@ int main(int argc, char** argv) { TimerUtils::InitOnce(); EventHandler::Start(); -#if !defined(PRODUCT) - // Constant true in PRODUCT mode. - vm_options.AddArgument("--load_deferred_eagerly"); -#endif - if (IsSnapshottingForPrecompilation()) { vm_options.AddArgument("--precompilation"); } else if ((snapshot_kind == kCoreJIT) || (snapshot_kind == kAppJIT)) { diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc index 1ab061fa2c7..f23de4027d9 100644 --- a/runtime/bin/main.cc +++ b/runtime/bin/main.cc @@ -1139,13 +1139,6 @@ void main(int argc, char** argv) { &app_isolate_snapshot_instructions); } -#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) - // Constant true if PRODUCT or DART_PRECOMPILED_RUNTIME. - if ((Options::gen_snapshot_kind() != kNone) || vm_run_app_snapshot) { - vm_options.AddArgument("--load_deferred_eagerly"); - } -#endif - if (Options::gen_snapshot_kind() == kAppJIT) { vm_options.AddArgument("--fields_may_be_reset"); } diff --git a/runtime/include/dart_api.h b/runtime/include/dart_api.h index 7e60a43b362..3d060bef867 100644 --- a/runtime/include/dart_api.h +++ b/runtime/include/dart_api.h @@ -3456,7 +3456,6 @@ DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_SortClasses(); * current VM. The instructions piece must be loaded with read and execute * permissions; the data piece may be loaded as read-only. * - * - Requires the VM to have been started with --load-deferred-eagerly. * - Requires the VM to have not been started with --precompilation. * - Not supported when targeting IA32 or DBC. * - The VM writing the snapshot and the VM reading the snapshot must be the diff --git a/runtime/lib/lib_prefix.dart b/runtime/lib/lib_prefix.dart index fe12660f793..f588ee33e4f 100644 --- a/runtime/lib/lib_prefix.dart +++ b/runtime/lib/lib_prefix.dart @@ -11,74 +11,7 @@ class _LibraryPrefix { throw "Unreachable"; } - bool _load() native "LibraryPrefix_load"; - Object _loadError() native "LibraryPrefix_loadError"; - bool isLoaded() native "LibraryPrefix_isLoaded"; - bool _invalidateDependentCode() - native "LibraryPrefix_invalidateDependentCode"; + bool isLoaded() => true; - loadLibrary() { - for (int i = 0; i < _outstandingLoadRequests.length; i++) { - if (_outstandingLoadRequests[i][0] == this) { - return _outstandingLoadRequests[i][1].future; - } - } - - var completer = new Completer(); - var pair = new List(); - pair.add(this); - pair.add(completer); - _outstandingLoadRequests.add(pair); - Timer.run(() { - var hasCompleted = this._load(); - // Loading can complete immediately, for example when the same - // library has been loaded eagerly or through another deferred - // prefix. If that is the case, we must invalidate the dependent - // code and complete the future now since there will be no callback - // from the VM. - if (hasCompleted && !completer.isCompleted) { - _invalidateDependentCode(); - completer.complete(true); - _outstandingLoadRequests.remove(pair); - } - }); - return completer.future; - } -} - -// A list of two element lists. The first element is the _LibraryPrefix. The -// second element is the Completer for the load request. -var _outstandingLoadRequests = new List(); - -// Called from the VM when an outstanding load request has finished. -@pragma("vm:entry-point", "call") -_completeDeferredLoads() { - // Determine which outstanding load requests have completed and complete - // their completer (with an error or true). For outstanding load requests - // which have not completed, remember them for next time in - // stillOutstandingLoadRequests. - var stillOutstandingLoadRequests = new List(); - - // Make a copy of the outstandingRequests because the call to _load below - // may recursively trigger another call to |_completeDeferredLoads|, which - // can cause |_outstandingLoadRequests| to be modified. - var outstandingRequests = _outstandingLoadRequests.toList(); - for (int i = 0; i < outstandingRequests.length; i++) { - var prefix = outstandingRequests[i][0]; - var completer = outstandingRequests[i][1]; - var error = prefix._loadError(); - if (completer.isCompleted) { - // Already completed. Skip. - continue; - } - if (error != null) { - completer.completeError(error); - } else if (prefix._load()) { - prefix._invalidateDependentCode(); - completer.complete(true); - } else { - stillOutstandingLoadRequests.add(outstandingRequests[i]); - } - } - _outstandingLoadRequests = stillOutstandingLoadRequests; + loadLibrary() => new Future.value(true); } diff --git a/runtime/lib/object.cc b/runtime/lib/object.cc index 2c5f526efd8..7d401554925 100644 --- a/runtime/lib/object.cc +++ b/runtime/lib/object.cc @@ -184,37 +184,6 @@ DEFINE_NATIVE_ENTRY(Type_getHashCode, 0, 1) { return Smi::New(hash_val); } -DEFINE_NATIVE_ENTRY(LibraryPrefix_invalidateDependentCode, 0, 1) { - const LibraryPrefix& prefix = - LibraryPrefix::CheckedHandle(zone, arguments->NativeArgAt(0)); - prefix.InvalidateDependentCode(); - return Bool::Get(true).raw(); -} - -DEFINE_NATIVE_ENTRY(LibraryPrefix_load, 0, 1) { - const LibraryPrefix& prefix = - LibraryPrefix::CheckedHandle(zone, arguments->NativeArgAt(0)); - bool hasCompleted = prefix.LoadLibrary(); - return Bool::Get(hasCompleted).raw(); -} - -DEFINE_NATIVE_ENTRY(LibraryPrefix_loadError, 0, 1) { - const LibraryPrefix& prefix = - LibraryPrefix::CheckedHandle(zone, arguments->NativeArgAt(0)); - // Currently all errors are Dart instances, e.g. I/O errors - // created by deferred loading code. LanguageErrors from - // failed loading or finalization attempts are propagated and result - // in the isolate's death. - const Instance& error = Instance::Handle(zone, prefix.LoadError()); - return error.raw(); -} - -DEFINE_NATIVE_ENTRY(LibraryPrefix_isLoaded, 0, 1) { - const LibraryPrefix& prefix = - LibraryPrefix::CheckedHandle(zone, arguments->NativeArgAt(0)); - return Bool::Get(prefix.is_loaded()).raw(); -} - DEFINE_NATIVE_ENTRY(Internal_inquireIs64Bit, 0, 0) { #if defined(ARCH_IS_64_BIT) return Bool::True().raw(); diff --git a/runtime/vm/bootstrap_natives.h b/runtime/vm/bootstrap_natives.h index 48fb3ef9765..efccf88e199 100644 --- a/runtime/vm/bootstrap_natives.h +++ b/runtime/vm/bootstrap_natives.h @@ -353,10 +353,6 @@ namespace dart { V(WeakProperty_getValue, 1) \ V(WeakProperty_setValue, 2) \ V(Uri_isWindowsPlatform, 0) \ - V(LibraryPrefix_load, 1) \ - V(LibraryPrefix_invalidateDependentCode, 1) \ - V(LibraryPrefix_loadError, 1) \ - V(LibraryPrefix_isLoaded, 1) \ V(UserTag_new, 2) \ V(UserTag_label, 1) \ V(UserTag_defaultTag, 0) \ diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc index 7beec45526c..086f7dbd710 100644 --- a/runtime/vm/clustered_snapshot.cc +++ b/runtime/vm/clustered_snapshot.cc @@ -2846,7 +2846,6 @@ class LibraryPrefixDeserializationCluster : public DeserializationCluster { ReadFromTo(prefix); prefix->ptr()->num_imports_ = d->Read(); prefix->ptr()->is_deferred_load_ = d->Read(); - prefix->ptr()->is_loaded_ = !prefix->ptr()->is_deferred_load_; } } }; diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc index 84eed1f6a9a..3e9c86eada8 100644 --- a/runtime/vm/compiler/aot/precompiler.cc +++ b/runtime/vm/compiler/aot/precompiler.cc @@ -2227,8 +2227,6 @@ void PrecompileParsedFunctionHelper::FinalizeCompilation( function.set_unoptimized_code(code); function.AttachCode(code); } - ASSERT(!parsed_function()->HasDeferredPrefixes()); - ASSERT(FLAG_load_deferred_eagerly); } // Return false if bailed out. diff --git a/runtime/vm/compiler/backend/flow_graph.cc b/runtime/vm/compiler/backend/flow_graph.cc index 43b6b14ec6f..c8838529b2f 100644 --- a/runtime/vm/compiler/backend/flow_graph.cc +++ b/runtime/vm/compiler/backend/flow_graph.cc @@ -54,7 +54,6 @@ FlowGraph::FlowGraph(const ParsedFunction& parsed_function, prologue_info_(prologue_info), loop_hierarchy_(nullptr), loop_invariant_loads_(nullptr), - deferred_prefixes_(parsed_function.deferred_prefixes()), captured_parameters_(new (zone()) BitVector(zone(), variable_count())), inlining_id_(-1), should_print_(FlowGraphPrinter::ShouldPrint(parsed_function.function())) { @@ -105,20 +104,6 @@ void FlowGraph::ReplaceCurrentInstruction(ForwardInstructionIterator* iterator, iterator->RemoveCurrentFromGraph(); } -void FlowGraph::AddToDeferredPrefixes( - ZoneGrowableArray* from) { - ZoneGrowableArray* to = deferred_prefixes(); - for (intptr_t i = 0; i < from->length(); i++) { - const LibraryPrefix* prefix = (*from)[i]; - for (intptr_t j = 0; j < to->length(); j++) { - if ((*to)[j]->raw() == prefix->raw()) { - return; - } - } - to->Add(prefix); - } -} - bool FlowGraph::ShouldReorderBlocks(const Function& function, bool is_optimized) { return is_optimized && FLAG_reorder_basic_blocks && diff --git a/runtime/vm/compiler/backend/flow_graph.h b/runtime/vm/compiler/backend/flow_graph.h index c138045c206..bbba0f184d8 100644 --- a/runtime/vm/compiler/backend/flow_graph.h +++ b/runtime/vm/compiler/backend/flow_graph.h @@ -341,12 +341,6 @@ class FlowGraph : public ZoneAllocated { bool IsCompiledForOsr() const { return graph_entry()->IsCompiledForOsr(); } - void AddToDeferredPrefixes(ZoneGrowableArray* from); - - ZoneGrowableArray* deferred_prefixes() const { - return deferred_prefixes_; - } - BitVector* captured_parameters() const { return captured_parameters_; } intptr_t inlining_id() const { return inlining_id_; } @@ -532,7 +526,6 @@ class FlowGraph : public ZoneAllocated { LoopHierarchy* loop_hierarchy_; ZoneGrowableArray* loop_invariant_loads_; - ZoneGrowableArray* deferred_prefixes_; DirectChainedHashMap constant_instr_pool_; BitVector* captured_parameters_; diff --git a/runtime/vm/compiler/backend/inliner.cc b/runtime/vm/compiler/backend/inliner.cc index 9300b6a2279..2a18c665efe 100644 --- a/runtime/vm/compiler/backend/inliner.cc +++ b/runtime/vm/compiler/backend/inliner.cc @@ -1240,10 +1240,6 @@ class CallSiteInliner : public ValueObject { caller_graph()->parsed_function().AddToGuardedFields( callee_guarded_fields[i]); } - // When inlined, we add the deferred prefixes of the callee to the - // caller's list of deferred prefixes. - caller_graph()->AddToDeferredPrefixes( - callee_graph->deferred_prefixes()); FlowGraphInliner::SetInliningId( callee_graph, diff --git a/runtime/vm/compiler/jit/compiler.cc b/runtime/vm/compiler/jit/compiler.cc index d8be990fce2..5bf7d0a6750 100644 --- a/runtime/vm/compiler/jit/compiler.cc +++ b/runtime/vm/compiler/jit/compiler.cc @@ -119,7 +119,6 @@ static void PrecompilationModeHandler(bool value) { // These flags are constants with PRODUCT and DART_PRECOMPILED_RUNTIME. FLAG_deoptimize_alot = false; // Used in some tests. FLAG_deoptimize_every = 0; // Used in some tests. - FLAG_load_deferred_eagerly = true; FLAG_use_osr = false; #endif } @@ -491,14 +490,6 @@ RawCode* CompileParsedFunctionHelper::FinalizeCompilation( function.SetUsageCounter(0); } } - if (parsed_function()->HasDeferredPrefixes()) { - ASSERT(!FLAG_load_deferred_eagerly); - ZoneGrowableArray* prefixes = - parsed_function()->deferred_prefixes(); - for (intptr_t i = 0; i < prefixes->length(); i++) { - (*prefixes)[i]->RegisterDependentCode(code); - } - } return code.raw(); } diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc index 0b2d49311a4..4b259aa46c3 100644 --- a/runtime/vm/dart_api_impl.cc +++ b/runtime/vm/dart_api_impl.cc @@ -1643,10 +1643,6 @@ Dart_CreateSnapshot(uint8_t** vm_snapshot_data_buffer, DARTSCOPE(Thread::Current()); API_TIMELINE_DURATION(T); Isolate* I = T->isolate(); - if (!FLAG_load_deferred_eagerly) { - return Api::NewError( - "Creating full snapshots requires --load_deferred_eagerly"); - } if (vm_snapshot_data_buffer != NULL && vm_snapshot_data_size == NULL) { RETURN_NULL_ERROR(vm_snapshot_data_size); } @@ -5403,7 +5399,6 @@ DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url) { DART_EXPORT Dart_Handle Dart_LibraryHandleError(Dart_Handle library_in, Dart_Handle error_in) { DARTSCOPE(Thread::Current()); - Isolate* I = T->isolate(); const Library& lib = Api::UnwrapLibraryHandle(Z, library_in); if (lib.IsNull()) { @@ -5415,15 +5410,6 @@ DART_EXPORT Dart_Handle Dart_LibraryHandleError(Dart_Handle library_in, } CHECK_CALLBACK_STATE(T); - const GrowableObjectArray& pending_deferred_loads = - GrowableObjectArray::Handle(Z, - I->object_store()->pending_deferred_loads()); - for (intptr_t i = 0; i < pending_deferred_loads.Length(); i++) { - if (pending_deferred_loads.At(i) == lib.raw()) { - lib.SetLoadError(err); - return Api::Null(); - } - } return error_in; } @@ -5514,9 +5500,6 @@ DART_EXPORT Dart_Handle Dart_FinalizeLoading(bool complete_futures) { // instead of freelists. BumpAllocateScope bump_allocate_scope(T); - // TODO(hausner): move the remaining code below (finalization and - // invoking of _completeDeferredLoads) into Isolate::DoneLoading(). - // Finalize all classes if needed. Dart_Handle state = Api::CheckAndFinalizePendingClasses(T); if (Api::IsError(state)) { @@ -5545,22 +5528,6 @@ DART_EXPORT Dart_Handle Dart_FinalizeLoading(bool complete_futures) { } #endif - if (complete_futures) { - const Library& corelib = Library::Handle(Z, Library::CoreLibrary()); - const String& function_name = - String::Handle(Z, String::New("_completeDeferredLoads")); - const Function& function = - Function::Handle(Z, corelib.LookupFunctionAllowPrivate(function_name)); - ASSERT(!function.IsNull()); - const Array& args = Array::empty_array(); - - const Object& res = - Object::Handle(Z, DartEntry::InvokeFunction(function, args)); - I->object_store()->clear_pending_deferred_loads(); - if (res.IsError() || res.IsUnhandledException()) { - return Api::NewHandle(T, res.raw()); - } - } return Api::Success(); } @@ -6171,7 +6138,6 @@ Dart_CreateAppAOTSnapshotAsAssembly(Dart_StreamingWriteCallback callback, "Isolate is not precompiled. " "Did you forget to call Dart_Precompile?"); } - ASSERT(FLAG_load_deferred_eagerly); CHECK_NULL(callback); TIMELINE_DURATION(T, Isolate, "WriteAppAOTSnapshot"); @@ -6307,7 +6273,6 @@ Dart_CreateAppAOTSnapshotAsBlobs(uint8_t** vm_snapshot_data_buffer, "Isolate is not precompiled. " "Did you forget to call Dart_Precompile?"); } - ASSERT(FLAG_load_deferred_eagerly); CHECK_NULL(vm_snapshot_data_buffer); CHECK_NULL(vm_snapshot_data_size); CHECK_NULL(vm_snapshot_instructions_buffer); @@ -6411,10 +6376,6 @@ DART_EXPORT Dart_Handle Dart_CreateCoreJITSnapshotAsBlobs( DARTSCOPE(Thread::Current()); API_TIMELINE_DURATION(T); Isolate* I = T->isolate(); - if (!FLAG_load_deferred_eagerly) { - return Api::NewError( - "Creating full snapshots requires --load_deferred_eagerly"); - } CHECK_NULL(vm_snapshot_data_buffer); CHECK_NULL(vm_snapshot_data_size); CHECK_NULL(vm_snapshot_instructions_buffer); @@ -6474,10 +6435,6 @@ Dart_CreateAppJITSnapshotAsBlobs(uint8_t** isolate_snapshot_data_buffer, DARTSCOPE(Thread::Current()); API_TIMELINE_DURATION(T); Isolate* I = T->isolate(); - if (!FLAG_load_deferred_eagerly) { - return Api::NewError( - "Creating full snapshots requires --load_deferred_eagerly"); - } CHECK_NULL(isolate_snapshot_data_buffer); CHECK_NULL(isolate_snapshot_data_size); CHECK_NULL(isolate_snapshot_instructions_buffer); diff --git a/runtime/vm/flag_list.h b/runtime/vm/flag_list.h index eb8434a4211..42d44cc59bb 100644 --- a/runtime/vm/flag_list.h +++ b/runtime/vm/flag_list.h @@ -116,8 +116,6 @@ constexpr bool kDartUseBytecode = false; P(interpret_irregexp, bool, USING_DBC, "Use irregexp bytecode interpreter") \ P(lazy_dispatchers, bool, true, "Generate dispatchers lazily") \ P(link_natives_lazily, bool, false, "Link native calls lazily") \ - C(load_deferred_eagerly, true, true, bool, false, \ - "Load deferred libraries eagerly.") \ R(log_marker_tasks, false, bool, false, \ "Log debugging information for old gen GC marking tasks.") \ P(marker_tasks, int, USING_MULTICORE ? 2 : 0, \ diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc index 6849a88c930..c341416d103 100644 --- a/runtime/vm/isolate.cc +++ b/runtime/vm/isolate.cc @@ -79,11 +79,6 @@ static void DeterministicModeHandler(bool value) { FLAG_concurrent_mark = false; // Timing dependent. FLAG_concurrent_sweep = false; // Timing dependent. FLAG_random_seed = 0x44617274; // "Dart" -#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) - FLAG_load_deferred_eagerly = true; -#else - COMPILE_ASSERT(FLAG_load_deferred_eagerly); -#endif } } diff --git a/runtime/vm/isolate_reload.cc b/runtime/vm/isolate_reload.cc index 5461f4581d3..640c3588ef6 100644 --- a/runtime/vm/isolate_reload.cc +++ b/runtime/vm/isolate_reload.cc @@ -726,7 +726,7 @@ void IsolateReloadContext::Reload(bool force_reload, // Ensure all functions on the stack have unoptimized code. EnsuredUnoptimizedCodeForStack(); // Deoptimize all code that had optimizing decisions that are dependent on - // assumptions from field guards or CHA or deferred library prefixes. + // assumptions from field guards or CHA. // TODO(johnmccutchan): Deoptimizing dependent code here (before the reload) // is paranoid. This likely can be moved to the commit phase. DeoptimizeDependentCode(); @@ -954,8 +954,6 @@ void IsolateReloadContext::DeoptimizeDependentCode() { } DeoptimizeTypeTestingStubs(); - - // TODO(johnmccutchan): Also call LibraryPrefix::InvalidateDependentCode. } void IsolateReloadContext::CheckpointClasses() { diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index 6d6de2ce623..4ba33447e25 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc @@ -9966,60 +9966,6 @@ void Library::SetLoaded() const { StoreNonPointer(&raw_ptr()->load_state_, RawLibrary::kLoaded); } -void Library::SetLoadError(const Instance& error) const { - // Should not be already successfully loaded or just allocated. - ASSERT(LoadInProgress() || LoadRequested() || LoadFailed()); - StoreNonPointer(&raw_ptr()->load_state_, RawLibrary::kLoadError); - StorePointer(&raw_ptr()->load_error_, error.raw()); -} - -// Traits for looking up Libraries by url in a hash set. -class LibraryUrlTraits { - public: - static const char* Name() { return "LibraryUrlTraits"; } - static bool ReportStats() { return false; } - - // Called when growing the table. - static bool IsMatch(const Object& a, const Object& b) { - ASSERT(a.IsLibrary() && b.IsLibrary()); - // Library objects are always canonical. - return a.raw() == b.raw(); - } - static uword Hash(const Object& key) { return Library::Cast(key).UrlHash(); } -}; -typedef UnorderedHashSet LibraryLoadErrorSet; - -RawInstance* Library::TransitiveLoadError() const { - if (LoadError() != Instance::null()) { - return LoadError(); - } - Thread* thread = Thread::Current(); - Isolate* isolate = thread->isolate(); - Zone* zone = thread->zone(); - ObjectStore* object_store = isolate->object_store(); - LibraryLoadErrorSet set(object_store->library_load_error_table()); - bool present = false; - if (set.GetOrNull(*this, &present) != Object::null()) { - object_store->set_library_load_error_table(set.Release()); - return Instance::null(); - } - // Ensure we don't repeatedly visit the same library again. - set.Insert(*this); - object_store->set_library_load_error_table(set.Release()); - intptr_t num_imp = num_imports(); - Library& lib = Library::Handle(zone); - Instance& error = Instance::Handle(zone); - for (intptr_t i = 0; i < num_imp; i++) { - HANDLESCOPE(thread); - lib = ImportLibraryAt(i); - error = lib.TransitiveLoadError(); - if (!error.IsNull()) { - break; - } - } - return error.raw(); -} - static RawString* MakeClassMetaName(Thread* thread, Zone* zone, const Class& cls) { @@ -11095,7 +11041,6 @@ RawLibrary* Library::NewLibraryHelper(const String& url, bool import_core_lib) { result.StorePointer(&result.raw_ptr()->imports_, Object::empty_array().raw()); result.StorePointer(&result.raw_ptr()->exports_, Object::empty_array().raw()); result.StorePointer(&result.raw_ptr()->loaded_scripts_, Array::null()); - result.StorePointer(&result.raw_ptr()->load_error_, Instance::null()); result.set_native_entry_resolver(NULL); result.set_native_entry_symbol_resolver(NULL); result.set_is_in_fullsnapshot(false); @@ -11746,49 +11691,6 @@ RawLibrary* LibraryPrefix::GetLibrary(int index) const { return Library::null(); } -RawInstance* LibraryPrefix::LoadError() const { - Thread* thread = Thread::Current(); - Isolate* isolate = thread->isolate(); - Zone* zone = thread->zone(); - ObjectStore* object_store = isolate->object_store(); - GrowableObjectArray& libs = - GrowableObjectArray::Handle(zone, object_store->libraries()); - ASSERT(!libs.IsNull()); - LibraryLoadErrorSet set(HashTables::New(libs.Length())); - object_store->set_library_load_error_table(set.Release()); - Library& lib = Library::Handle(zone); - Instance& error = Instance::Handle(zone); - for (int32_t i = 0; i < num_imports(); i++) { - lib = GetLibrary(i); - ASSERT(!lib.IsNull()); - HANDLESCOPE(thread); - error = lib.TransitiveLoadError(); - if (!error.IsNull()) { - break; - } - } - object_store->set_library_load_error_table(Object::empty_array()); - return error.raw(); -} - -bool LibraryPrefix::ContainsLibrary(const Library& library) const { - int32_t num_current_imports = num_imports(); - if (num_current_imports > 0) { - Library& lib = Library::Handle(); - const String& url = String::Handle(library.url()); - String& lib_url = String::Handle(); - for (int32_t i = 0; i < num_current_imports; i++) { - lib = GetLibrary(i); - ASSERT(!lib.IsNull()); - lib_url = lib.url(); - if (url.Equals(lib_url)) { - return true; - } - } - } - return false; -} - void LibraryPrefix::AddImport(const Namespace& import) const { intptr_t num_current_imports = num_imports(); @@ -11809,9 +11711,6 @@ void LibraryPrefix::AddImport(const Namespace& import) const { } RawObject* LibraryPrefix::LookupObject(const String& name) const { - if (!is_loaded() && !FLAG_load_deferred_eagerly) { - return Object::null(); - } Array& imports = Array::Handle(this->imports()); Object& obj = Object::Handle(); Namespace& import = Namespace::Handle(); @@ -11880,116 +11779,6 @@ RawClass* LibraryPrefix::LookupClass(const String& class_name) const { return Class::null(); } -void LibraryPrefix::set_is_loaded() const { - StoreNonPointer(&raw_ptr()->is_loaded_, true); -} - -bool LibraryPrefix::LoadLibrary() const { - // Non-deferred prefixes are loaded. - ASSERT(is_deferred_load() || is_loaded()); - if (is_loaded()) { - return true; // Load request has already completed. - } - ASSERT(is_deferred_load()); - ASSERT(num_imports() == 1); - if (Dart::vm_snapshot_kind() == Snapshot::kFullAOT) { - // The library list was tree-shaken away. - this->set_is_loaded(); - return true; - } - // This is a prefix for a deferred library. If the library is not loaded - // yet and isn't being loaded, call the library tag handler to schedule - // loading. Once all outstanding load requests have completed, the embedder - // will call the core library to: - // - invalidate dependent code of this prefix; - // - mark this prefixes as loaded; - // - complete the future associated with this prefix. - const Library& deferred_lib = Library::Handle(GetLibrary(0)); - if (deferred_lib.Loaded()) { - this->set_is_loaded(); - return true; - } else if (deferred_lib.LoadNotStarted()) { - Thread* thread = Thread::Current(); - Isolate* isolate = thread->isolate(); - Zone* zone = thread->zone(); - deferred_lib.SetLoadRequested(); - const GrowableObjectArray& pending_deferred_loads = - GrowableObjectArray::Handle( - isolate->object_store()->pending_deferred_loads()); - pending_deferred_loads.Add(deferred_lib); - const String& lib_url = String::Handle(zone, deferred_lib.url()); - const Object& obj = Object::Handle( - zone, isolate->CallTagHandler( - Dart_kImportTag, Library::Handle(zone, importer()), lib_url)); - if (obj.IsError()) { - Exceptions::PropagateError(Error::Cast(obj)); - } - } else { - // Another load request is in flight or previously failed. - ASSERT(deferred_lib.LoadRequested() || deferred_lib.LoadFailed()); - } - return false; // Load request not yet completed. -} - -RawArray* LibraryPrefix::dependent_code() const { - return raw_ptr()->dependent_code_; -} - -void LibraryPrefix::set_dependent_code(const Array& array) const { - StorePointer(&raw_ptr()->dependent_code_, array.raw()); -} - -class PrefixDependentArray : public WeakCodeReferences { - public: - explicit PrefixDependentArray(const LibraryPrefix& prefix) - : WeakCodeReferences(Array::Handle(prefix.dependent_code())), - prefix_(prefix) {} - - virtual void UpdateArrayTo(const Array& value) { - prefix_.set_dependent_code(value); - } - - virtual void ReportDeoptimization(const Code& code) { - // This gets called when the code object is on the stack - // while nuking code that depends on a prefix. We don't expect - // this to happen, so make sure we die loudly if we find - // ourselves here. - UNIMPLEMENTED(); - } - - virtual void ReportSwitchingCode(const Code& code) { - if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { - THR_Print("Prefix '%s': disabling %s code for %s function '%s'\n", - String::Handle(prefix_.name()).ToCString(), - code.is_optimized() ? "optimized" : "unoptimized", - code.IsDisabled() ? "'patched'" : "'unpatched'", - Function::Handle(code.function()).ToCString()); - } - } - - private: - const LibraryPrefix& prefix_; - DISALLOW_COPY_AND_ASSIGN(PrefixDependentArray); -}; - -void LibraryPrefix::RegisterDependentCode(const Code& code) const { - ASSERT(is_deferred_load()); - // In background compilation, a library can be loaded while we are compiling. - // The generated code will be rejected in that case, - ASSERT(!is_loaded() || Compiler::IsBackgroundCompilation()); - PrefixDependentArray a(*this); - a.Register(code); -} - -void LibraryPrefix::InvalidateDependentCode() const { - PrefixDependentArray a(*this); - if (FLAG_trace_deoptimization && a.HasCodes()) { - THR_Print("Deopt for lazy load (prefix %s)\n", ToCString()); - } - a.DisableCode(); - set_is_loaded(); -} - RawLibraryPrefix* LibraryPrefix::New() { RawObject* raw = Object::Allocate(LibraryPrefix::kClassId, LibraryPrefix::InstanceSize(), Heap::kOld); @@ -12005,7 +11794,6 @@ RawLibraryPrefix* LibraryPrefix::New(const String& name, result.set_num_imports(0); result.set_importer(importer); result.StoreNonPointer(&result.raw_ptr()->is_deferred_load_, deferred_load); - result.StoreNonPointer(&result.raw_ptr()->is_loaded_, !deferred_load); result.set_imports(Array::Handle(Array::New(kInitialSize))); result.AddImport(import); return result.raw(); diff --git a/runtime/vm/object.h b/runtime/vm/object.h index fafe3331bb5..c3770b0a0d6 100644 --- a/runtime/vm/object.h +++ b/runtime/vm/object.h @@ -4012,12 +4012,6 @@ class Library : public Object { void SetLoadInProgress() const; bool Loaded() const { return raw_ptr()->load_state_ == RawLibrary::kLoaded; } void SetLoaded() const; - bool LoadFailed() const { - return raw_ptr()->load_state_ == RawLibrary::kLoadError; - } - RawInstance* LoadError() const { return raw_ptr()->load_error_; } - void SetLoadError(const Instance& error) const; - RawInstance* TransitiveLoadError() const; static intptr_t InstanceSize() { return RoundedAllocationSize(sizeof(RawLibrary)); @@ -6515,27 +6509,12 @@ class LibraryPrefix : public Instance { intptr_t num_imports() const { return raw_ptr()->num_imports_; } RawLibrary* importer() const { return raw_ptr()->importer_; } - RawInstance* LoadError() const; - - bool ContainsLibrary(const Library& library) const; RawLibrary* GetLibrary(int index) const; void AddImport(const Namespace& import) const; RawObject* LookupObject(const String& name) const; RawClass* LookupClass(const String& class_name) const; bool is_deferred_load() const { return raw_ptr()->is_deferred_load_; } - bool is_loaded() const { return raw_ptr()->is_loaded_; } - bool LoadLibrary() const; - - // Return the list of code objects that were compiled when this - // prefix was not yet loaded. These code objects will be invalidated - // when the prefix is loaded. - RawArray* dependent_code() const; - void set_dependent_code(const Array& array) const; - - // Add the given code object to the list of dependent ones. - void RegisterDependentCode(const Code& code) const; - void InvalidateDependentCode() const; static intptr_t InstanceSize() { return RoundedAllocationSize(sizeof(RawLibraryPrefix)); @@ -6554,7 +6533,6 @@ class LibraryPrefix : public Instance { void set_imports(const Array& value) const; void set_num_imports(intptr_t value) const; void set_importer(const Library& value) const; - void set_is_loaded() const; static RawLibraryPrefix* New(); diff --git a/runtime/vm/object_reload.cc b/runtime/vm/object_reload.cc index d8cbadec2ff..6857b57057a 100644 --- a/runtime/vm/object_reload.cc +++ b/runtime/vm/object_reload.cc @@ -665,29 +665,6 @@ class InstanceSizeConflict : public ClassReasonForCancelling { } }; -class UnimplementedDeferredLibrary : public ReasonForCancelling { - public: - UnimplementedDeferredLibrary(Zone* zone, - const Library& from, - const Library& to, - const String& name) - : ReasonForCancelling(zone), from_(from), to_(to), name_(name) {} - - private: - const Library& from_; - const Library& to_; - const String& name_; - - RawString* ToString() { - const String& lib_url = String::Handle(to_.url()); - from_.ToCString(); - return String::NewFormatted( - "Reloading support for deferred loading has not yet been implemented:" - " library '%s' has deferred import '%s'", - lib_url.ToCString(), name_.ToCString()); - } -}; - // This is executed before iterating over the instances. void Class::CheckReload(const Class& replacement, IsolateReloadContext* context) const { @@ -822,20 +799,7 @@ bool Class::CanReloadPreFinalized(const Class& replacement, void Library::CheckReload(const Library& replacement, IsolateReloadContext* context) const { - // TODO(26878): If the replacement library uses deferred loading, - // reject it. We do not yet support reloading deferred libraries. - LibraryPrefix& prefix = LibraryPrefix::Handle(); - LibraryPrefixIterator it(replacement); - while (it.HasNext()) { - prefix = it.GetNext(); - if (prefix.is_deferred_load()) { - const String& prefix_name = String::Handle(prefix.name()); - context->AddReasonForCancelling( - new (context->zone()) UnimplementedDeferredLibrary( - context->zone(), *this, replacement, prefix_name)); - return; - } - } + // Currently no library properties will prevent a reload. } void CallSiteResetter::Reset(const ICData& ic) { diff --git a/runtime/vm/object_store.cc b/runtime/vm/object_store.cc index 0237cc08895..6dcf00a71a7 100644 --- a/runtime/vm/object_store.cc +++ b/runtime/vm/object_store.cc @@ -80,8 +80,6 @@ RawError* ObjectStore::PreallocateObjects() { ASSERT(this->out_of_memory() == Instance::null()); ASSERT(this->preallocated_stack_trace() == StackTrace::null()); - this->pending_deferred_loads_ = GrowableObjectArray::New(); - this->closure_functions_ = GrowableObjectArray::New(); this->resume_capabilities_ = GrowableObjectArray::New(); this->exit_listeners_ = GrowableObjectArray::New(); diff --git a/runtime/vm/object_store.h b/runtime/vm/object_store.h index 9c9cda56f66..77461f0997e 100644 --- a/runtime/vm/object_store.h +++ b/runtime/vm/object_store.h @@ -107,7 +107,6 @@ class ObjectPointerVisitor; RW(Array, libraries_map) \ RW(GrowableObjectArray, closure_functions) \ RW(GrowableObjectArray, pending_classes) \ - R_(GrowableObjectArray, pending_deferred_loads) \ R_(GrowableObjectArray, resume_capabilities) \ R_(GrowableObjectArray, exit_listeners) \ R_(GrowableObjectArray, error_listeners) \ @@ -127,7 +126,6 @@ class ObjectPointerVisitor; RW(Function, complete_on_async_return) \ RW(Class, async_star_stream_controller) \ RW(ObjectPool, global_object_pool) \ - RW(Array, library_load_error_table) \ RW(Array, unique_dynamic_targets) \ RW(GrowableObjectArray, megamorphic_cache_table) \ RW(Code, build_method_extractor_code) \ @@ -200,10 +198,6 @@ class ObjectStore { } } - void clear_pending_deferred_loads() { - pending_deferred_loads_ = GrowableObjectArray::New(); - } - void SetMegamorphicMissHandler(const Code& code, const Function& func) { // Hold onto the code so it is traced and not detached from the function. megamorphic_miss_code_ = code.raw(); @@ -243,7 +237,7 @@ class ObjectStore { RawObject** to_snapshot(Snapshot::Kind kind) { switch (kind) { case Snapshot::kFull: - return reinterpret_cast(&library_load_error_table_); + return reinterpret_cast(&global_object_pool_); case Snapshot::kFullJIT: case Snapshot::kFullAOT: return reinterpret_cast(&megamorphic_miss_function_); diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc index a91416ee5a0..ae99c877708 100644 --- a/runtime/vm/parser.cc +++ b/runtime/vm/parser.cc @@ -59,7 +59,6 @@ ParsedFunction::ParsedFunction(Thread* thread, const Function& function) expression_temp_var_(NULL), entry_points_temp_var_(NULL), finally_return_temp_var_(NULL), - deferred_prefixes_(new ZoneGrowableArray()), guarded_fields_(new ZoneGrowableArray()), default_parameter_values_(NULL), raw_type_arguments_var_(NULL), @@ -185,20 +184,6 @@ void ParsedFunction::SetRegExpCompileData( regexp_compile_data_ = regexp_compile_data; } -void ParsedFunction::AddDeferredPrefix(const LibraryPrefix& prefix) { - // 'deferred_prefixes_' are used to invalidate code, but no invalidation is - // needed if --load_deferred_eagerly. - ASSERT(!FLAG_load_deferred_eagerly); - ASSERT(prefix.is_deferred_load()); - ASSERT(!prefix.is_loaded()); - for (intptr_t i = 0; i < deferred_prefixes_->length(); i++) { - if ((*deferred_prefixes_)[i]->raw() == prefix.raw()) { - return; - } - } - deferred_prefixes_->Add(&LibraryPrefix::ZoneHandle(Z, prefix.raw())); -} - void ParsedFunction::AllocateVariables() { ASSERT(!function().IsIrregexpFunction()); LocalScope* scope = this->scope(); diff --git a/runtime/vm/parser.h b/runtime/vm/parser.h index 1841803adc5..f574ea61f1e 100644 --- a/runtime/vm/parser.h +++ b/runtime/vm/parser.h @@ -156,12 +156,6 @@ class ParsedFunction : public ZoneAllocated { LocalVariable* EnsureExpressionTemp(); LocalVariable* EnsureEntryPointsTemp(); - bool HasDeferredPrefixes() const { return deferred_prefixes_->length() != 0; } - ZoneGrowableArray* deferred_prefixes() const { - return deferred_prefixes_; - } - void AddDeferredPrefix(const LibraryPrefix& prefix); - ZoneGrowableArray* guarded_fields() const { return guarded_fields_; } @@ -263,7 +257,6 @@ class ParsedFunction : public ZoneAllocated { LocalVariable* expression_temp_var_; LocalVariable* entry_points_temp_var_; LocalVariable* finally_return_temp_var_; - ZoneGrowableArray* deferred_prefixes_; ZoneGrowableArray* guarded_fields_; ZoneGrowableArray* default_parameter_values_; diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h index afd1b45ff67..6980d6639ff 100644 --- a/runtime/vm/raw_object.h +++ b/runtime/vm/raw_object.h @@ -1205,7 +1205,6 @@ class RawLibrary : public RawObject { kLoadRequested, // Compiler or script requested load of library. kLoadInProgress, // Library is in the process of being loaded. kLoaded, // Library is loaded. - kLoadError, // Error occurred during load of the Library. }; RAW_HEAP_OBJECT_IMPLEMENTATION(Library); @@ -1220,12 +1219,11 @@ class RawLibrary : public RawObject { RawGrowableObjectArray* owned_scripts_; RawArray* imports_; // List of Namespaces imported without prefix. RawArray* exports_; // List of re-exported Namespaces. - RawInstance* load_error_; // Error iff load_state_ == kLoadError. RawExternalTypedData* kernel_data_; RawObject** to_snapshot(Snapshot::Kind kind) { switch (kind) { case Snapshot::kFullAOT: - return reinterpret_cast(&ptr()->load_error_); + return reinterpret_cast(&ptr()->exports_); case Snapshot::kFull: case Snapshot::kFullJIT: return reinterpret_cast(&ptr()->kernel_data_); @@ -1918,9 +1916,7 @@ class RawLibraryPrefix : public RawInstance { RawString* name_; // Library prefix name. RawLibrary* importer_; // Library which declares this prefix. RawArray* imports_; // Libraries imported with this prefix. - RawArray* dependent_code_; // Code that refers to deferred, unloaded - // library prefix. - VISIT_TO(RawObject*, dependent_code_) + VISIT_TO(RawObject*, imports_) RawObject** to_snapshot(Snapshot::Kind kind) { switch (kind) { case Snapshot::kFull: @@ -1938,7 +1934,6 @@ class RawLibraryPrefix : public RawInstance { } uint16_t num_imports_; // Number of library entries in libraries_. bool is_deferred_load_; - bool is_loaded_; }; class RawTypeArguments : public RawInstance { diff --git a/runtime/vm/raw_object_fields.cc b/runtime/vm/raw_object_fields.cc index f90a01d9bb0..3dc239b69ec 100644 --- a/runtime/vm/raw_object_fields.cc +++ b/runtime/vm/raw_object_fields.cc @@ -73,7 +73,6 @@ namespace dart { F(Library, owned_scripts_) \ F(Library, imports_) \ F(Library, exports_) \ - F(Library, load_error_) \ F(Library, kernel_data_) \ F(Library, resolved_names_) \ F(Library, exported_names_) \ @@ -138,7 +137,6 @@ namespace dart { F(LibraryPrefix, name_) \ F(LibraryPrefix, importer_) \ F(LibraryPrefix, imports_) \ - F(LibraryPrefix, dependent_code_) \ F(TypeArguments, instantiations_) \ F(TypeArguments, length_) \ F(TypeArguments, hash_) \ diff --git a/tests/language_2/language_2.status b/tests/language_2/language_2.status index 6e9a36b4926..dd3999734c7 100644 --- a/tests/language_2/language_2.status +++ b/tests/language_2/language_2.status @@ -73,42 +73,6 @@ function_type/*: Skip # Needs checked mode. built_in_identifier_type_annotation_test/set: Crash # Not supported by legacy VM front-end. [ $hot_reload || $hot_reload_rollback ] -cha_deopt1_test: Crash # Requires deferred libraries -cha_deopt2_test: Crash # Requires deferred libraries -cha_deopt3_test: Crash # Requires deferred libraries -conditional_import_string_test: Crash # Requires deferred libraries -conditional_import_test: Crash # Requires deferred libraries -deferred_call_empty_before_load_test: Crash # Requires deferred libraries -deferred_closurize_load_library_test: Crash # Requires deferred libraries -deferred_constant_list_test: Crash # Requires deferred libraries -deferred_constraints_constants_test: Crash # Requires deferred libraries -deferred_constraints_type_annotation_test: Crash # Requires deferred libraries -deferred_function_type_test: Crash # Requires deferred libraries -deferred_global_test: Crash # Requires deferred libraries -deferred_import_core_test: Crash # Requires deferred libraries -deferred_inheritance_constraints_test: Crash # Requires deferred libraries -deferred_inlined_test: Crash # Requires deferred libraries -deferred_load_constants_test: Crash # Requires deferred libraries -deferred_load_inval_code_test: Crash # Requires deferred libraries -deferred_load_library_wrong_args_test: Crash # Requires deferred libraries -deferred_mixin_test: Crash # Requires deferred libraries -deferred_no_such_method_test: Crash # Requires deferred libraries -deferred_not_loaded_check_test: Crash # Requires deferred libraries -deferred_only_constant_test: Crash # Requires deferred libraries -deferred_optimized_test: Crash # Requires deferred libraries -deferred_redirecting_factory_test: Crash # Requires deferred libraries -deferred_regression_22995_test: Crash # Requires deferred libraries -deferred_regression_28678_test: Crash # Requires deferred libraries -deferred_shadow_load_library_test: Crash # Requires deferred libraries -deferred_shared_and_unshared_classes_test: Crash # Requires deferred libraries -deferred_static_seperate_test: Crash # Requires deferred libraries -deferred_super_dependency_test: Pass, Crash # Requires deferred libraries -deferred_type_dependency_test: Crash # Requires deferred libraries -issue_1751477_test: Crash # Requires deferred libraries issue_22780_test/01: Pass, Crash # Issue 29094 -regress_22443_test: Crash # Requires deferred libraries -regress_23408_test: Crash # Requires deferred libraries -regress_28278_test: Crash # Requires deferred libraries static_closure_identical_test: Pass, Fail # Closure identity vm/optimized_stacktrace_test: Slow -vm/regress_27201_test: Pass, Crash # Requires deferred libraries