From c5c80648b942db137526eb21255fe66650223da1 Mon Sep 17 00:00:00 2001 From: Joshua Litt Date: Wed, 17 Mar 2021 17:27:44 +0000 Subject: [PATCH] [dart2js] Land accurate compute merging dependency algorithm. Change-Id: If47a670631c4c4d63b0fd834a01dc30275b416d8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191241 Reviewed-by: Sigmund Cherem Commit-Queue: Joshua Litt --- pkg/compiler/lib/src/deferred_load.dart | 7 - .../startup_emitter/fragment_merger.dart | 131 ++++++++++++++---- .../startup_emitter/model_emitter.dart | 17 ++- .../data/deferred_overlapping/main.dart | 18 ++- .../dont_inline_deferred_constants/main.dart | 22 ++- .../data/instantiation1/main.dart | 18 ++- .../data/instantiation2/main.dart | 18 ++- .../data/instantiation4/main.dart | 18 ++- .../data/instantiation5/main.dart | 18 ++- .../deferred_loading/data/lazy_types/lib.dart | 24 +--- .../data/lazy_types/libb.dart | 12 +- .../data/lazy_types/main.dart | 45 ++---- .../data/many_parts/libB.dart | 12 +- .../data/many_parts/main.dart | 76 +++++----- .../data/static_separate/main.dart | 18 ++- .../data/type_arguments/main.dart | 18 ++- 16 files changed, 292 insertions(+), 180 deletions(-) diff --git a/pkg/compiler/lib/src/deferred_load.dart b/pkg/compiler/lib/src/deferred_load.dart index 2a65eb6e63ce..dedd5025ca00 100644 --- a/pkg/compiler/lib/src/deferred_load.dart +++ b/pkg/compiler/lib/src/deferred_load.dart @@ -80,13 +80,6 @@ class OutputUnit implements Comparable { return name.compareTo(other.name); } - void merge(OutputUnit that) { - assert(this != that); - // We don't currently support merging code into the main output unit. - assert(!isMainOutput); - this.imports.addAll(that.imports); - } - @override String toString() => "OutputUnit($name, $imports)"; } diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_merger.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_merger.dart index 480255548a85..d9d65cc7ef5e 100644 --- a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_merger.dart +++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_merger.dart @@ -83,17 +83,20 @@ class PreFragment { this.lazyInitializers.addAll(that.lazyInitializers); this.nativeSupport.addAll(that.nativeSupport); this.successors.remove(that); + this.predecessors.remove(that); that.successors.forEach((fragment) { + if (fragment == this) return; + this.successors.add(fragment); fragment.predecessors.remove(that); fragment.predecessors.add(this); }); - this.successors.addAll(that.successors); - that.predecessors.remove(this); that.predecessors.forEach((fragment) { + if (fragment == this) return; + this.predecessors.add(fragment); fragment.successors.remove(that); fragment.successors.add(this); }); - this.predecessors.addAll(that.predecessors); + that.clearAll(); this.size += that.size; return this; } @@ -102,6 +105,7 @@ class PreFragment { Program program, Map fragmentMap) { FinalizedFragment finalizedFragment; var seedFragment = fragments.first; + var seedOutputUnit = seedFragment.outputUnit; // If we only have a single fragment, then wen just finalize it by itself. // Otherwise, we finalize an entire group of fragments into a single @@ -109,7 +113,7 @@ class PreFragment { if (fragments.length == 1) { finalizedFragment = FinalizedFragment( seedFragment.outputFileName, - seedFragment.outputUnit, + [seedOutputUnit], seedFragment.libraries, classPrototypes.first, closurePrototypes.first, @@ -122,21 +126,22 @@ class PreFragment { staticNonFinalFields.first, lazyInitializers.first, nativeSupport.first, - program.metadataTypesForOutputUnit(seedFragment.outputUnit)); + program.metadataTypesForOutputUnit(seedOutputUnit)); fragmentMap[seedFragment] = finalizedFragment; } else { + List outputUnits = [seedOutputUnit]; List libraries = []; for (var fragment in fragments) { - if (seedFragment.outputUnit != fragment.outputUnit) { - program.mergeOutputUnitMetadata( - seedFragment.outputUnit, fragment.outputUnit); - seedFragment.outputUnit.merge(fragment.outputUnit); + var fragmentOutputUnit = fragment.outputUnit; + if (seedOutputUnit != fragmentOutputUnit) { + program.mergeOutputUnitMetadata(seedOutputUnit, fragmentOutputUnit); + outputUnits.add(fragmentOutputUnit); } libraries.addAll(fragment.libraries); } finalizedFragment = FinalizedFragment( seedFragment.outputFileName, - seedFragment.outputUnit, + outputUnits, libraries, js.Block(classPrototypes), js.Block(closurePrototypes), @@ -149,7 +154,7 @@ class PreFragment { js.Block(staticNonFinalFields), js.Block(lazyInitializers), js.Block(nativeSupport), - program.metadataTypesForOutputUnit(seedFragment.outputUnit)); + program.metadataTypesForOutputUnit(seedOutputUnit)); for (var fragment in fragments) { fragmentMap[fragment] = finalizedFragment; } @@ -183,11 +188,31 @@ class PreFragment { } return "${outputUnitStrings.join('+')}"; } + + /// Clears all [PreFragment] data structure and zeros out the size. Should be + /// used only after merging to GC internal data structures. + void clearAll() { + fragments.clear(); + classPrototypes.clear(); + closurePrototypes.clear(); + inheritance.clear(); + methodAliases.clear(); + tearOffs.clear(); + constants.clear(); + typeRules.clear(); + variances.clear(); + staticNonFinalFields.clear(); + lazyInitializers.clear(); + nativeSupport.clear(); + successors.clear(); + predecessors.clear(); + size = 0; + } } class FinalizedFragment { final String outputFileName; - final OutputUnit outputUnit; + final List outputUnits; final List libraries; final js.Statement classPrototypes; final js.Statement closurePrototypes; @@ -204,7 +229,7 @@ class FinalizedFragment { FinalizedFragment( this.outputFileName, - this.outputUnit, + this.outputUnits, this.libraries, this.classPrototypes, this.closurePrototypes, @@ -247,6 +272,12 @@ class FinalizedFragment { isEmptyStatement(lazyInitializers) && isEmptyStatement(nativeSupport); } + + // The 'main' [OutputUnit] for this [FinalizedFragment]. + // TODO(joshualitt): Refactor this to more clearly disambiguate between + // [OutputUnits](units of deferred merging), fragments(units of emitted code), + // and files. + OutputUnit get canonicalOutputUnit => outputUnits.first; } class _Partition { @@ -261,6 +292,7 @@ class _Partition { class FragmentMerger { final CompilerOptions _options; + int totalSize = 0; FragmentMerger(this._options); @@ -284,16 +316,63 @@ class FragmentMerger { return loadMap; } - // Attaches predecessors to each PreFragment. We only care about - // direct predecessors. - static void attachDependencies(Map> programLoadMap, - Map fragmentMap) { - programLoadMap.forEach((loadId, fragments) { - for (int i = 0; i < fragments.length - 1; i++) { - var fragment = fragmentMap[fragments[i]]; - var nextFragment = fragmentMap[fragments[i + 1]]; - fragment.successors.add(nextFragment); - nextFragment.predecessors.add(fragment); + /// Given a list of OutputUnits sorted by their import entites, + /// returns a map of all the direct edges between output units. + Map> createDirectEdges( + List allOutputUnits) { + Map> backEdges = {}; + for (int i = 0; i < allOutputUnits.length; i++) { + var a = allOutputUnits[i]; + var aImports = a.imports; + for (int j = i + 1; j < allOutputUnits.length; j++) { + var b = allOutputUnits[j]; + if (b.imports.containsAll(aImports)) { + backEdges[b] ??= {}; + + // Remove transitive edges from nodes that will reach 'b' from the + // edge we just added. + // Note: Because we add edges in order (starting from the smallest + // sets) we always add transitive edges before the last direct edge. + backEdges[b].removeWhere((c) => aImports.containsAll(c.imports)); + + // Create an edge to denote that 'b' must be loaded before 'a'. + backEdges[b].add(a); + } + } + } + + Map> forwardEdges = {}; + backEdges.forEach((b, edges) { + for (var a in edges) { + (forwardEdges[a] ??= {}).add(b); + } + }); + return forwardEdges; + } + + /// Attachs predecessors and successors to each PreFragment. + void attachDependencies(Map fragmentMap, + List preDeferredFragments) { + // Create a map of OutputUnit to Fragment. + Map outputUnitMap = {}; + List allOutputUnits = []; + for (var preFragment in preDeferredFragments) { + var fragment = preFragment.fragments.single; + var outputUnit = fragment.outputUnit; + outputUnitMap[outputUnit] = fragment; + allOutputUnits.add(outputUnit); + totalSize += preFragment.size; + } + allOutputUnits.sort(); + + // Get a list of direct edges and then attach them to PreFragments. + var allEdges = createDirectEdges(allOutputUnits); + allEdges.forEach((outputUnit, edges) { + var predecessor = fragmentMap[outputUnitMap[outputUnit]]; + for (var edge in edges) { + var successor = fragmentMap[outputUnitMap[edge]]; + predecessor.successors.add(successor); + successor.predecessors.add(predecessor); } }); } @@ -315,12 +394,6 @@ class FragmentMerger { }); int desiredNumberOfFragment = _options.mergeFragmentsThreshold; - // TODO(joshualitt): Precalculate totalSize when computing dependencies. - int totalSize = 0; - for (var preFragment in preDeferredFragments) { - totalSize += preFragment.size; - } - int idealFragmentSize = (totalSize / desiredNumberOfFragment).ceil(); List<_Partition> partitions = []; void add(PreFragment next) { diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart index e12027bade57..943f80e78f76 100644 --- a/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart +++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart @@ -98,6 +98,7 @@ class ModelEmitter { final JClosedWorld _closedWorld; final ConstantOrdering _constantOrdering; final SourceInformationStrategy _sourceInformationStrategy; + final FragmentMerger fragmentMerger; // The full code that is written to each hunk part-file. final Map emittedOutputBuffers = {}; @@ -128,7 +129,8 @@ class ModelEmitter { this._sourceInformationStrategy, RecipeEncoder rtiRecipeEncoder, this._shouldGenerateSourceMap) - : _constantOrdering = new ConstantOrdering(_closedWorld.sorter) { + : _constantOrdering = new ConstantOrdering(_closedWorld.sorter), + fragmentMerger = FragmentMerger(_options) { this.constantEmitter = new ConstantEmitter( _options, _namer, @@ -227,12 +229,11 @@ class ModelEmitter { } }); - // Attach dependencies to each PreFragment. - FragmentMerger.attachDependencies(program.loadMap, preFragmentMap); - + // If we are going to merge, then we attach dependencies to each PreFragment + // and merge. if (shouldMergeFragments) { preDeferredFragments = _task.measureSubtask('merge fragments', () { - FragmentMerger fragmentMerger = FragmentMerger(_options); + fragmentMerger.attachDependencies(preFragmentMap, preDeferredFragments); return fragmentMerger.mergeFragments(preDeferredFragments); }); } @@ -252,7 +253,7 @@ class ModelEmitter { if (fragmentCode != null) { deferredFragmentsCode[finalizedFragment] = fragmentCode; } else { - omittedOutputUnits.add(finalizedFragment.outputUnit); + omittedOutputUnits.addAll(finalizedFragment.outputUnits); } } @@ -419,7 +420,9 @@ class ModelEmitter { hunkPrefix, deferredExtension, OutputType.jsPart), outputListeners); - emittedOutputBuffers[fragment.outputUnit] = output; + // TODO(joshualitt): This breaks dump_info when we merge, but fixing it will + // require updating the schema. + emittedOutputBuffers[fragment.canonicalOutputUnit] = output; // The [code] contains the function that must be invoked when the deferred // hunk is loaded. diff --git a/pkg/compiler/test/deferred_loading/data/deferred_overlapping/main.dart b/pkg/compiler/test/deferred_loading/data/deferred_overlapping/main.dart index d50cc2306a0b..58108e925c8f 100644 --- a/pkg/compiler/test/deferred_loading/data/deferred_overlapping/main.dart +++ b/pkg/compiler/test/deferred_loading/data/deferred_overlapping/main.dart @@ -2,11 +2,21 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/*library: +/*spec.library: output_units=[ - f1: {units: [1{lib1, lib2}], usedBy: [2, 3], needs: []}, - f2: {units: [2{lib1}], usedBy: [], needs: [1]}, - f3: {units: [3{lib2}], usedBy: [], needs: [1]}], + f1: {units: [1{lib1, lib2}], usedBy: [], needs: []}, + f2: {units: [2{lib1}], usedBy: [], needs: []}, + f3: {units: [3{lib2}], usedBy: [], needs: []}], + steps=[ + lib1=(f1, f2), + lib2=(f1, f3)] +*/ + +/*two-frag|three-frag.library: + output_units=[ + f1: {units: [1{lib1, lib2}], usedBy: [], needs: [2, 3]}, + f2: {units: [2{lib1}], usedBy: [1], needs: []}, + f3: {units: [3{lib2}], usedBy: [1], needs: []}], steps=[ lib1=(f1, f2), lib2=(f1, f3)] diff --git a/pkg/compiler/test/deferred_loading/data/dont_inline_deferred_constants/main.dart b/pkg/compiler/test/deferred_loading/data/dont_inline_deferred_constants/main.dart index d65299a2781f..db1d7a630290 100644 --- a/pkg/compiler/test/deferred_loading/data/dont_inline_deferred_constants/main.dart +++ b/pkg/compiler/test/deferred_loading/data/dont_inline_deferred_constants/main.dart @@ -2,11 +2,21 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/*spec|three-frag.library: +/*spec.library: output_units=[ - f1: {units: [2{lib1, lib2}], usedBy: [2, 3], needs: []}, - f2: {units: [1{lib1}], usedBy: [], needs: [1]}, - f3: {units: [3{lib2}], usedBy: [], needs: [1]}], + f1: {units: [2{lib1, lib2}], usedBy: [], needs: []}, + f2: {units: [1{lib1}], usedBy: [], needs: []}, + f3: {units: [3{lib2}], usedBy: [], needs: []}], + steps=[ + lib1=(f1, f2), + lib2=(f1, f3)] +*/ + +/*three-frag.library: + output_units=[ + f1: {units: [2{lib1, lib2}], usedBy: [], needs: [2, 3]}, + f2: {units: [1{lib1}], usedBy: [1], needs: []}, + f3: {units: [3{lib2}], usedBy: [1], needs: []}], steps=[ lib1=(f1, f2), lib2=(f1, f3)] @@ -14,8 +24,8 @@ /*two-frag.library: output_units=[ - f1: {units: [2{lib1, lib2}, 3{lib2}], usedBy: [2], needs: []}, - f2: {units: [1{lib1}], usedBy: [], needs: [1]}], + f1: {units: [2{lib1, lib2}, 3{lib2}], usedBy: [], needs: [2]}, + f2: {units: [1{lib1}], usedBy: [1], needs: []}], steps=[ lib1=(f1, f2), lib2=(f1)] diff --git a/pkg/compiler/test/deferred_loading/data/instantiation1/main.dart b/pkg/compiler/test/deferred_loading/data/instantiation1/main.dart index ce147941bd9f..4642e97a6872 100644 --- a/pkg/compiler/test/deferred_loading/data/instantiation1/main.dart +++ b/pkg/compiler/test/deferred_loading/data/instantiation1/main.dart @@ -2,11 +2,21 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/*library: +/*spec.library: output_units=[ - f1: {units: [2{b, c}], usedBy: [2, 3], needs: []}, - f2: {units: [1{b}], usedBy: [], needs: [1]}, - f3: {units: [3{c}], usedBy: [], needs: [1]}], + f1: {units: [2{b, c}], usedBy: [], needs: []}, + f2: {units: [1{b}], usedBy: [], needs: []}, + f3: {units: [3{c}], usedBy: [], needs: []}], + steps=[ + b=(f1, f2), + c=(f1, f3)] +*/ + +/*two-frag|three-frag.library: + output_units=[ + f1: {units: [2{b, c}], usedBy: [], needs: [2, 3]}, + f2: {units: [1{b}], usedBy: [1], needs: []}, + f3: {units: [3{c}], usedBy: [1], needs: []}], steps=[ b=(f1, f2), c=(f1, f3)] diff --git a/pkg/compiler/test/deferred_loading/data/instantiation2/main.dart b/pkg/compiler/test/deferred_loading/data/instantiation2/main.dart index 0aba5e2f697d..4f5bd6872bb8 100644 --- a/pkg/compiler/test/deferred_loading/data/instantiation2/main.dart +++ b/pkg/compiler/test/deferred_loading/data/instantiation2/main.dart @@ -2,11 +2,21 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/*library: +/*spec.library: output_units=[ - f1: {units: [1{b, c}], usedBy: [2, 3], needs: []}, - f2: {units: [2{b}], usedBy: [], needs: [1]}, - f3: {units: [3{c}], usedBy: [], needs: [1]}], + f1: {units: [1{b, c}], usedBy: [], needs: []}, + f2: {units: [2{b}], usedBy: [], needs: []}, + f3: {units: [3{c}], usedBy: [], needs: []}], + steps=[ + b=(f1, f2), + c=(f1, f3)] +*/ + +/*two-frag|three-frag.library: + output_units=[ + f1: {units: [1{b, c}], usedBy: [], needs: [2, 3]}, + f2: {units: [2{b}], usedBy: [1], needs: []}, + f3: {units: [3{c}], usedBy: [1], needs: []}], steps=[ b=(f1, f2), c=(f1, f3)] diff --git a/pkg/compiler/test/deferred_loading/data/instantiation4/main.dart b/pkg/compiler/test/deferred_loading/data/instantiation4/main.dart index 16295210fedf..f972fc5f998e 100644 --- a/pkg/compiler/test/deferred_loading/data/instantiation4/main.dart +++ b/pkg/compiler/test/deferred_loading/data/instantiation4/main.dart @@ -2,11 +2,21 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/*library: +/*spec.library: output_units=[ - f1: {units: [2{b, c}], usedBy: [2, 3], needs: []}, - f2: {units: [1{b}], usedBy: [], needs: [1]}, - f3: {units: [3{c}], usedBy: [], needs: [1]}], + f1: {units: [2{b, c}], usedBy: [], needs: []}, + f2: {units: [1{b}], usedBy: [], needs: []}, + f3: {units: [3{c}], usedBy: [], needs: []}], + steps=[ + b=(f1, f2), + c=(f1, f3)] +*/ + +/*two-frag|three-frag.library: + output_units=[ + f1: {units: [2{b, c}], usedBy: [], needs: [2, 3]}, + f2: {units: [1{b}], usedBy: [1], needs: []}, + f3: {units: [3{c}], usedBy: [1], needs: []}], steps=[ b=(f1, f2), c=(f1, f3)] diff --git a/pkg/compiler/test/deferred_loading/data/instantiation5/main.dart b/pkg/compiler/test/deferred_loading/data/instantiation5/main.dart index 768282f5afc5..f9dd67dee776 100644 --- a/pkg/compiler/test/deferred_loading/data/instantiation5/main.dart +++ b/pkg/compiler/test/deferred_loading/data/instantiation5/main.dart @@ -2,11 +2,21 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/*library: +/*spec.library: output_units=[ - f1: {units: [1{b, c}], usedBy: [2, 3], needs: []}, - f2: {units: [2{b}], usedBy: [], needs: [1]}, - f3: {units: [3{c}], usedBy: [], needs: [1]}], + f1: {units: [1{b, c}], usedBy: [], needs: []}, + f2: {units: [2{b}], usedBy: [], needs: []}, + f3: {units: [3{c}], usedBy: [], needs: []}], + steps=[ + b=(f1, f2), + c=(f1, f3)] +*/ + +/*two-frag|three-frag.library: + output_units=[ + f1: {units: [1{b, c}], usedBy: [], needs: [2, 3]}, + f2: {units: [2{b}], usedBy: [1], needs: []}, + f3: {units: [3{c}], usedBy: [1], needs: []}], steps=[ b=(f1, f2), c=(f1, f3)] diff --git a/pkg/compiler/test/deferred_loading/data/lazy_types/lib.dart b/pkg/compiler/test/deferred_loading/data/lazy_types/lib.dart index 120b83cd745b..4cd9f1537109 100644 --- a/pkg/compiler/test/deferred_loading/data/lazy_types/lib.dart +++ b/pkg/compiler/test/deferred_loading/data/lazy_types/lib.dart @@ -4,25 +4,18 @@ // @dart = 2.7 -/*spec|three-frag.class: Foo: +/*class: Foo: class_unit=1{libB}, type_unit=3{libA, libB, libC} */ -/*two-frag.class: Foo: - class_unit=1{libB, libA}, - type_unit=3{libA, libB, libC} -*/ class Foo { - /*spec|three-frag.member: Foo.x:member_unit=1{libB}*/ - /*two-frag.member: Foo.x:member_unit=1{libB, libA}*/ + /*member: Foo.x:member_unit=1{libB}*/ int x; - /*spec|three-frag.member: Foo.:member_unit=1{libB}*/ - /*two-frag.member: Foo.:member_unit=1{libB, libA}*/ + /*member: Foo.:member_unit=1{libB}*/ Foo() { x = DateTime.now().millisecond; } - /*spec|three-frag.member: Foo.method:member_unit=1{libB}*/ - /*two-frag.member: Foo.method:member_unit=1{libB, libA}*/ + /*member: Foo.method:member_unit=1{libB}*/ int method() => x; } @@ -31,8 +24,7 @@ bool isFoo(o) { return o is Foo; } -/*spec|three-frag.member: callFooMethod:member_unit=1{libB}*/ -/*two-frag.member: callFooMethod:member_unit=1{libB, libA}*/ +/*member: callFooMethod:member_unit=1{libB}*/ int callFooMethod() { return Foo().method(); } @@ -64,14 +56,10 @@ class Boo implements Aoo {} /*member: Coo.:member_unit=2{libC}*/ class Coo {} -/*spec|three-frag.class: Doo: +/*class: Doo: class_unit=2{libC}, type_unit=5{libB, libC} */ -/*two-frag.class: Doo: - class_unit=2{libC}, - type_unit=5{libB, libC, libA} -*/ /*member: Doo.:member_unit=2{libC}*/ class Doo extends Coo with Boo {} diff --git a/pkg/compiler/test/deferred_loading/data/lazy_types/libb.dart b/pkg/compiler/test/deferred_loading/data/lazy_types/libb.dart index 7c98f968e08b..20c24234ea5e 100644 --- a/pkg/compiler/test/deferred_loading/data/lazy_types/libb.dart +++ b/pkg/compiler/test/deferred_loading/data/lazy_types/libb.dart @@ -6,18 +6,14 @@ import 'lib.dart' as lib; -/*spec|three-frag.member: callFooMethod:member_unit=1{libB}*/ -/*two-frag.member: callFooMethod:member_unit=1{libB, libA}*/ +/*member: callFooMethod:member_unit=1{libB}*/ int callFooMethod() => lib.callFooMethod(); -/*spec|three-frag.member: isFoo:member_unit=1{libB}*/ -/*two-frag.member: isFoo:member_unit=1{libB, libA}*/ +/*member: isFoo:member_unit=1{libB}*/ bool isFoo(o) => lib.isFoo(o); -/*spec|three-frag.member: isFunFunFoo:member_unit=1{libB}*/ -/*two-frag.member: isFunFunFoo:member_unit=1{libB, libA}*/ +/*member: isFunFunFoo:member_unit=1{libB}*/ bool isFunFunFoo(o) => lib.isFunFunFoo(o); -/*spec|three-frag.member: isDooFunFunFoo:member_unit=1{libB}*/ -/*two-frag.member: isDooFunFunFoo:member_unit=1{libB, libA}*/ +/*member: isDooFunFunFoo:member_unit=1{libB}*/ bool isDooFunFunFoo(o) => o is lib.Doo; diff --git a/pkg/compiler/test/deferred_loading/data/lazy_types/main.dart b/pkg/compiler/test/deferred_loading/data/lazy_types/main.dart index 6e80197b0824..15e802220e97 100644 --- a/pkg/compiler/test/deferred_loading/data/lazy_types/main.dart +++ b/pkg/compiler/test/deferred_loading/data/lazy_types/main.dart @@ -4,12 +4,12 @@ /*spec.library: output_units=[ - f1: {units: [3{libA, libB, libC}], usedBy: [2, 4], needs: []}, - f2: {units: [4{libA, libC}], usedBy: [3, 6], needs: [1, 4]}, - f3: {units: [6{libA}], usedBy: [], needs: [2]}, - f4: {units: [5{libB, libC}], usedBy: [5, 2], needs: [1]}, - f5: {units: [1{libB}], usedBy: [], needs: [4]}, - f6: {units: [2{libC}], usedBy: [], needs: [2]}], + f1: {units: [3{libA, libB, libC}], usedBy: [], needs: []}, + f2: {units: [4{libA, libC}], usedBy: [], needs: []}, + f3: {units: [6{libA}], usedBy: [], needs: []}, + f4: {units: [5{libB, libC}], usedBy: [], needs: []}, + f5: {units: [1{libB}], usedBy: [], needs: []}, + f6: {units: [2{libC}], usedBy: [], needs: []}], steps=[ libA=(f1, f2, f3), libB=(f1, f4, f5), @@ -18,9 +18,9 @@ /*two-frag.library: output_units=[ - f1: {units: [3{libA, libB, libC}], usedBy: [2], needs: []}, - f2: {units: [5{libB, libC, libA}, 4{libA, libC}, 2{libC}], usedBy: [3], needs: [1]}, - f3: {units: [1{libB, libA}, 6{libA}], usedBy: [], needs: [2]}], + f1: {units: [3{libA, libB, libC}], usedBy: [], needs: [2]}, + f2: {units: [5{libB, libC}, 4{libA, libC}, 2{libC}], usedBy: [1], needs: [3]}, + f3: {units: [1{libB}, 6{libA}], usedBy: [2], needs: []}], steps=[ libA=(f1, f2, f3), libB=(f1, f2, f3), @@ -29,10 +29,10 @@ /*three-frag.library: output_units=[ - f1: {units: [3{libA, libB, libC}, 5{libB, libC}, 4{libA, libC}], usedBy: [3, 2, 4], needs: []}, - f2: {units: [6{libA}], usedBy: [], needs: [1]}, - f3: {units: [1{libB}], usedBy: [], needs: [1]}, - f4: {units: [2{libC}], usedBy: [], needs: [1]}], + f1: {units: [3{libA, libB, libC}, 5{libB, libC}, 4{libA, libC}], usedBy: [], needs: [4, 3, 2]}, + f2: {units: [6{libA}], usedBy: [1], needs: []}, + f3: {units: [1{libB}], usedBy: [1], needs: []}, + f4: {units: [2{libC}], usedBy: [1], needs: []}], steps=[ libA=(f1, f2), libB=(f1, f3), @@ -45,7 +45,7 @@ import 'liba.dart' deferred as libA; import 'libb.dart' deferred as libB; import 'libc.dart' deferred as libC; -/*spec|three-frag.member: foo: +/*member: foo: constants=[ FunctionConstant(callFooMethod)=1{libB}, FunctionConstant(createB2)=2{libC}, @@ -62,23 +62,6 @@ import 'libc.dart' deferred as libC; FunctionConstant(isMega)=6{libA}], member_unit=main{} */ -/*two-frag.member: foo: - constants=[ - FunctionConstant(callFooMethod)=1{libB, libA}, - FunctionConstant(createB2)=2{libC}, - FunctionConstant(createC3)=2{libC}, - FunctionConstant(createD3)=2{libC}, - FunctionConstant(createDooFunFunFoo)=2{libC}, - FunctionConstant(isDooFunFunFoo)=1{libB, libA}, - FunctionConstant(isFoo)=1{libB, libA}, - FunctionConstant(isFoo)=2{libC}, - FunctionConstant(isFoo)=6{libA}, - FunctionConstant(isFunFunFoo)=1{libB, libA}, - FunctionConstant(isFunFunFoo)=2{libC}, - FunctionConstant(isFunFunFoo)=6{libA}, - FunctionConstant(isMega)=6{libA}], - member_unit=main{} -*/ void foo() async { await libA.loadLibrary(); await libB.loadLibrary(); diff --git a/pkg/compiler/test/deferred_loading/data/many_parts/libB.dart b/pkg/compiler/test/deferred_loading/data/many_parts/libB.dart index 64e287e5bbca..7f86fc1cd037 100644 --- a/pkg/compiler/test/deferred_loading/data/many_parts/libB.dart +++ b/pkg/compiler/test/deferred_loading/data/many_parts/libB.dart @@ -35,13 +35,11 @@ f_010_01(Set u, int b) => v(u, '01001', b); f_010_11(Set u, int b) => v(u, '01011', b); @pragma('dart2js:noInline') -/*spec|three-frag.member: f_011_01:member_unit=8{b1, b3, b4}*/ -/*two-frag.member: f_011_01:member_unit=8{b1, b3, b4, b2, b5}*/ +/*member: f_011_01:member_unit=8{b1, b3, b4}*/ f_011_01(Set u, int b) => v(u, '01101', b); @pragma('dart2js:noInline') -/*spec|two-frag.member: f_011_11:member_unit=9{b1, b2, b3, b4}*/ -/*three-frag.member: f_011_11:member_unit=9{b1, b2, b3, b4, b5}*/ +/*member: f_011_11:member_unit=9{b1, b2, b3, b4}*/ f_011_11(Set u, int b) => v(u, '01111', b); @pragma('dart2js:noInline') @@ -105,8 +103,7 @@ f_101_10(Set u, int b) => v(u, '10110', b); f_110_10(Set u, int b) => v(u, '11010', b); @pragma('dart2js:noInline') -/*spec.member: f_111_10:member_unit=24{b2, b3, b4, b5}*/ -/*two-frag|three-frag.member: f_111_10:member_unit=24{b2, b3, b4, b5, b1}*/ +/*member: f_111_10:member_unit=24{b2, b3, b4, b5}*/ f_111_10(Set u, int b) => v(u, '11110', b); @pragma('dart2js:noInline') @@ -114,8 +111,7 @@ f_111_10(Set u, int b) => v(u, '11110', b); f_001_00(Set u, int b) => v(u, '00100', b); @pragma('dart2js:noInline') -/*spec|two-frag.member: f_011_00:member_unit=26{b3, b4}*/ -/*three-frag.member: f_011_00:member_unit=26{b3, b4, b2, b5, b1}*/ +/*member: f_011_00:member_unit=26{b3, b4}*/ f_011_00(Set u, int b) => v(u, '01100', b); @pragma('dart2js:noInline') diff --git a/pkg/compiler/test/deferred_loading/data/many_parts/main.dart b/pkg/compiler/test/deferred_loading/data/many_parts/main.dart index 6f86ab91fcf0..6cd9224377b9 100644 --- a/pkg/compiler/test/deferred_loading/data/many_parts/main.dart +++ b/pkg/compiler/test/deferred_loading/data/many_parts/main.dart @@ -4,37 +4,37 @@ /*spec.library: output_units=[ - f10: {units: [7{b1, b2, b4}], usedBy: [11, 29], needs: [9, 8]}, - f11: {units: [5{b1, b2, b3}], usedBy: [12, 21, 26], needs: [10, 8]}, - f12: {units: [10{b1, b5}], usedBy: [13, 31], needs: [11, 21]}, - f13: {units: [6{b1, b4}], usedBy: [14, 30], needs: [12, 22]}, - f14: {units: [4{b1, b3}], usedBy: [15, 28], needs: [13, 23]}, - f15: {units: [3{b1, b2}], usedBy: [16, 24], needs: [14, 23]}, - f16: {units: [2{b1}], usedBy: [], needs: [15]}, - f17: {units: [24{b2, b3, b4, b5}], usedBy: [3, 2], needs: [1]}, - f18: {units: [23{b2, b4, b5}], usedBy: [19, 20], needs: [5, 25]}, - f19: {units: [22{b2, b3, b5}], usedBy: [20, 6], needs: [18, 25]}, - f1: {units: [1{b1, b2, b3, b4, b5}], usedBy: [2, 17], needs: []}, - f20: {units: [20{b2, b3, b4}], usedBy: [9, 7, 6], needs: [19, 18]}, - f21: {units: [21{b2, b5}], usedBy: [22, 12], needs: [11, 26]}, - f22: {units: [19{b2, b4}], usedBy: [23, 13], needs: [21, 27]}, - f23: {units: [18{b2, b3}], usedBy: [15, 14], needs: [22, 27]}, - f24: {units: [17{b2}], usedBy: [], needs: [15]}, - f25: {units: [28{b3, b4, b5}], usedBy: [19, 18], needs: [5, 4]}, - f26: {units: [27{b3, b5}], usedBy: [27, 21], needs: [11, 29]}, - f27: {units: [26{b3, b4}], usedBy: [23, 22], needs: [26, 29]}, - f28: {units: [25{b3}], usedBy: [], needs: [14]}, - f29: {units: [30{b4, b5}], usedBy: [27, 26], needs: [10, 9]}, - f2: {units: [16{b1, b3, b4, b5}], usedBy: [3, 4], needs: [1, 17]}, - f30: {units: [29{b4}], usedBy: [], needs: [13]}, - f31: {units: [31{b5}], usedBy: [], needs: [12]}, - f3: {units: [15{b1, b2, b4, b5}], usedBy: [4, 5], needs: [2, 17]}, - f4: {units: [13{b1, b2, b3, b5}], usedBy: [5, 25], needs: [3, 2]}, - f5: {units: [9{b1, b2, b3, b4}], usedBy: [6, 18, 25], needs: [4, 3]}, - f6: {units: [14{b1, b4, b5}], usedBy: [7, 8], needs: [5, 20, 19]}, - f7: {units: [12{b1, b3, b5}], usedBy: [8, 9], needs: [6, 20]}, - f8: {units: [8{b1, b3, b4}], usedBy: [9, 11, 10], needs: [7, 6]}, - f9: {units: [11{b1, b2, b5}], usedBy: [10, 29], needs: [8, 20, 7]}], + f10: {units: [7{b1, b2, b4}], usedBy: [], needs: []}, + f11: {units: [5{b1, b2, b3}], usedBy: [], needs: []}, + f12: {units: [10{b1, b5}], usedBy: [], needs: []}, + f13: {units: [6{b1, b4}], usedBy: [], needs: []}, + f14: {units: [4{b1, b3}], usedBy: [], needs: []}, + f15: {units: [3{b1, b2}], usedBy: [], needs: []}, + f16: {units: [2{b1}], usedBy: [], needs: []}, + f17: {units: [24{b2, b3, b4, b5}], usedBy: [], needs: []}, + f18: {units: [23{b2, b4, b5}], usedBy: [], needs: []}, + f19: {units: [22{b2, b3, b5}], usedBy: [], needs: []}, + f1: {units: [1{b1, b2, b3, b4, b5}], usedBy: [], needs: []}, + f20: {units: [20{b2, b3, b4}], usedBy: [], needs: []}, + f21: {units: [21{b2, b5}], usedBy: [], needs: []}, + f22: {units: [19{b2, b4}], usedBy: [], needs: []}, + f23: {units: [18{b2, b3}], usedBy: [], needs: []}, + f24: {units: [17{b2}], usedBy: [], needs: []}, + f25: {units: [28{b3, b4, b5}], usedBy: [], needs: []}, + f26: {units: [27{b3, b5}], usedBy: [], needs: []}, + f27: {units: [26{b3, b4}], usedBy: [], needs: []}, + f28: {units: [25{b3}], usedBy: [], needs: []}, + f29: {units: [30{b4, b5}], usedBy: [], needs: []}, + f2: {units: [16{b1, b3, b4, b5}], usedBy: [], needs: []}, + f30: {units: [29{b4}], usedBy: [], needs: []}, + f31: {units: [31{b5}], usedBy: [], needs: []}, + f3: {units: [15{b1, b2, b4, b5}], usedBy: [], needs: []}, + f4: {units: [13{b1, b2, b3, b5}], usedBy: [], needs: []}, + f5: {units: [9{b1, b2, b3, b4}], usedBy: [], needs: []}, + f6: {units: [14{b1, b4, b5}], usedBy: [], needs: []}, + f7: {units: [12{b1, b3, b5}], usedBy: [], needs: []}, + f8: {units: [8{b1, b3, b4}], usedBy: [], needs: []}, + f9: {units: [11{b1, b2, b5}], usedBy: [], needs: []}], steps=[ b1=(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16), b2=(f1, f17, f3, f4, f5, f18, f19, f20, f9, f10, f11, f21, f22, f23, f15, f24), @@ -45,10 +45,10 @@ /*three-frag.library: output_units=[ - f1: {units: [1{b1, b2, b3, b4, b5}], usedBy: [2], needs: []}, - f2: {units: [24{b2, b3, b4, b5, b1}, 16{b1, b3, b4, b5}, 15{b1, b2, b4, b5}, 13{b1, b2, b3, b5}], usedBy: [3], needs: [1]}, - f3: {units: [9{b1, b2, b3, b4, b5}, 28{b3, b4, b5}, 23{b2, b4, b5}, 22{b2, b3, b5}, 20{b2, b3, b4}, 14{b1, b4, b5}, 12{b1, b3, b5}, 8{b1, b3, b4}, 11{b1, b2, b5}, 7{b1, b2, b4}, 5{b1, b2, b3}, 30{b4, b5}, 27{b3, b5}], usedBy: [4], needs: [2]}, - f4: {units: [26{b3, b4, b2, b5, b1}, 21{b2, b5}, 19{b2, b4}, 18{b2, b3}, 10{b1, b5}, 6{b1, b4}, 4{b1, b3}, 3{b1, b2}, 31{b5}, 29{b4}, 25{b3}, 17{b2}, 2{b1}], usedBy: [], needs: [3]}], + f1: {units: [1{b1, b2, b3, b4, b5}], usedBy: [], needs: [3, 2]}, + f2: {units: [24{b2, b3, b4, b5}, 16{b1, b3, b4, b5}, 15{b1, b2, b4, b5}, 13{b1, b2, b3, b5}], usedBy: [1], needs: [3]}, + f3: {units: [9{b1, b2, b3, b4}, 28{b3, b4, b5}, 23{b2, b4, b5}, 22{b2, b3, b5}, 20{b2, b3, b4}, 14{b1, b4, b5}, 12{b1, b3, b5}, 8{b1, b3, b4}, 11{b1, b2, b5}, 7{b1, b2, b4}, 5{b1, b2, b3}, 30{b4, b5}, 27{b3, b5}], usedBy: [1, 2], needs: [4]}, + f4: {units: [26{b3, b4}, 21{b2, b5}, 19{b2, b4}, 18{b2, b3}, 10{b1, b5}, 6{b1, b4}, 4{b1, b3}, 3{b1, b2}, 31{b5}, 29{b4}, 25{b3}, 17{b2}, 2{b1}], usedBy: [3], needs: []}], steps=[ b1=(f1, f2, f3, f4), b2=(f1, f2, f3, f4), @@ -59,9 +59,9 @@ /*two-frag.library: output_units=[ - f1: {units: [1{b1, b2, b3, b4, b5}], usedBy: [2], needs: []}, - f2: {units: [24{b2, b3, b4, b5, b1}, 16{b1, b3, b4, b5}, 15{b1, b2, b4, b5}, 13{b1, b2, b3, b5}, 9{b1, b2, b3, b4}, 28{b3, b4, b5}, 23{b2, b4, b5}, 22{b2, b3, b5}, 20{b2, b3, b4}, 14{b1, b4, b5}, 12{b1, b3, b5}], usedBy: [3], needs: [1]}, - f3: {units: [8{b1, b3, b4, b2, b5}, 11{b1, b2, b5}, 7{b1, b2, b4}, 5{b1, b2, b3}, 30{b4, b5}, 27{b3, b5}, 26{b3, b4}, 21{b2, b5}, 19{b2, b4}, 18{b2, b3}, 10{b1, b5}, 6{b1, b4}, 4{b1, b3}, 3{b1, b2}, 31{b5}, 29{b4}, 25{b3}, 17{b2}, 2{b1}], usedBy: [], needs: [2]}], + f1: {units: [1{b1, b2, b3, b4, b5}], usedBy: [], needs: [2]}, + f2: {units: [24{b2, b3, b4, b5}, 16{b1, b3, b4, b5}, 15{b1, b2, b4, b5}, 13{b1, b2, b3, b5}, 9{b1, b2, b3, b4}, 28{b3, b4, b5}, 23{b2, b4, b5}, 22{b2, b3, b5}, 20{b2, b3, b4}, 14{b1, b4, b5}, 12{b1, b3, b5}], usedBy: [1], needs: [3]}, + f3: {units: [8{b1, b3, b4}, 11{b1, b2, b5}, 7{b1, b2, b4}, 5{b1, b2, b3}, 30{b4, b5}, 27{b3, b5}, 26{b3, b4}, 21{b2, b5}, 19{b2, b4}, 18{b2, b3}, 10{b1, b5}, 6{b1, b4}, 4{b1, b3}, 3{b1, b2}, 31{b5}, 29{b4}, 25{b3}, 17{b2}, 2{b1}], usedBy: [2], needs: []}], steps=[ b1=(f1, f2, f3), b2=(f1, f2, f3), diff --git a/pkg/compiler/test/deferred_loading/data/static_separate/main.dart b/pkg/compiler/test/deferred_loading/data/static_separate/main.dart index 9c8dd2f4a849..a4f5f5a2ca22 100644 --- a/pkg/compiler/test/deferred_loading/data/static_separate/main.dart +++ b/pkg/compiler/test/deferred_loading/data/static_separate/main.dart @@ -2,11 +2,21 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/*library: +/*spec.library: output_units=[ - f1: {units: [2{lib1, lib2}], usedBy: [2, 3], needs: []}, - f2: {units: [1{lib1}], usedBy: [], needs: [1]}, - f3: {units: [3{lib2}], usedBy: [], needs: [1]}], + f1: {units: [2{lib1, lib2}], usedBy: [], needs: []}, + f2: {units: [1{lib1}], usedBy: [], needs: []}, + f3: {units: [3{lib2}], usedBy: [], needs: []}], + steps=[ + lib1=(f1, f2), + lib2=(f1, f3)] +*/ + +/*two-frag|three-frag.library: + output_units=[ + f1: {units: [2{lib1, lib2}], usedBy: [], needs: [2, 3]}, + f2: {units: [1{lib1}], usedBy: [1], needs: []}, + f3: {units: [3{lib2}], usedBy: [1], needs: []}], steps=[ lib1=(f1, f2), lib2=(f1, f3)] diff --git a/pkg/compiler/test/deferred_loading/data/type_arguments/main.dart b/pkg/compiler/test/deferred_loading/data/type_arguments/main.dart index 42fed699432a..13f5f038ebb7 100644 --- a/pkg/compiler/test/deferred_loading/data/type_arguments/main.dart +++ b/pkg/compiler/test/deferred_loading/data/type_arguments/main.dart @@ -2,11 +2,21 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/*library: +/*spec.library: output_units=[ - f1: {units: [3{lib1, lib3}], usedBy: [2, 3], needs: []}, - f2: {units: [1{lib1}], usedBy: [], needs: [1]}, - f3: {units: [2{lib3}], usedBy: [], needs: [1]}], + f1: {units: [3{lib1, lib3}], usedBy: [], needs: []}, + f2: {units: [1{lib1}], usedBy: [], needs: []}, + f3: {units: [2{lib3}], usedBy: [], needs: []}], + steps=[ + lib1=(f1, f2), + lib3=(f1, f3)] +*/ + +/*two-frag|three-frag.library: + output_units=[ + f1: {units: [3{lib1, lib3}], usedBy: [], needs: [2, 3]}, + f2: {units: [1{lib1}], usedBy: [1], needs: []}, + f3: {units: [2{lib3}], usedBy: [1], needs: []}], steps=[ lib1=(f1, f2), lib3=(f1, f3)]