Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 4ff89f8

Browse files
johnniwinthercommit-bot@chromium.org
authored andcommitted
Move registrations on OutputUnitData to the impact transformer
Change-Id: I8060149b217d3222c7e784aafe9724e5ef6a7bde Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103530 Reviewed-by: Sigmund Cherem <[email protected]>
1 parent 7580e77 commit 4ff89f8

File tree

7 files changed

+73
-24
lines changed

7 files changed

+73
-24
lines changed

pkg/compiler/lib/src/deferred_load.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,9 +1456,9 @@ class OutputUnitData {
14561456

14571457
/// Registers that a constant is used in the same deferred output unit as
14581458
/// [field].
1459-
void registerConstantDeferredUse(
1460-
DeferredGlobalConstantValue constant, OutputUnit unit) {
1459+
void registerConstantDeferredUse(DeferredGlobalConstantValue constant) {
14611460
if (!isProgramSplit) return;
1461+
OutputUnit unit = constant.unit;
14621462
assert(
14631463
_constantToUnit[constant] == null || _constantToUnit[constant] == unit);
14641464
_constantToUnit[constant] = unit;

pkg/compiler/lib/src/js_backend/impact_transformer.dart

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ import '../common/codegen.dart' show CodegenImpact;
1313
import '../common/resolution.dart' show ResolutionImpact;
1414
import '../common_elements.dart' show ElementEnvironment;
1515
import '../constants/expressions.dart';
16+
import '../constants/values.dart';
1617
import '../elements/entities.dart';
1718
import '../elements/types.dart';
1819
import '../js_emitter/native_emitter.dart';
20+
import '../js_model/elements.dart';
1921
import '../native/enqueue.dart';
2022
import '../native/behavior.dart';
2123
import '../options.dart';
2224
import '../universe/feature.dart';
2325
import '../universe/selector.dart';
24-
import '../universe/use.dart'
25-
show StaticUse, StaticUseKind, TypeUse, TypeUseKind;
26+
import '../universe/use.dart';
2627
import '../universe/world_impact.dart' show TransformedWorldImpact, WorldImpact;
2728
import '../util/util.dart';
2829
import '../world.dart';
@@ -399,19 +400,57 @@ class CodegenImpactTransformer {
399400
}
400401
}
401402

403+
for (ConstantUse constantUse in impact.constantUses) {
404+
switch (constantUse.value.kind) {
405+
case ConstantValueKind.DEFERRED_GLOBAL:
406+
_closedWorld.outputUnitData
407+
.registerConstantDeferredUse(constantUse.value);
408+
break;
409+
default:
410+
break;
411+
}
412+
}
413+
402414
for (Pair<DartType, DartType> check
403415
in impact.typeVariableBoundsSubtypeChecks) {
404416
_rtiChecksBuilder.registerTypeVariableBoundsSubtypeCheck(
405417
check.a, check.b);
406418
}
407419

408420
for (StaticUse staticUse in impact.staticUses) {
409-
if (staticUse.kind == StaticUseKind.CALL_METHOD) {
410-
FunctionEntity callMethod = staticUse.element;
411-
if (_rtiNeed.methodNeedsSignature(callMethod)) {
412-
_impacts.computeSignature
413-
.registerImpact(transformed, _elementEnvironment);
414-
}
421+
switch (staticUse.kind) {
422+
case StaticUseKind.GENERATOR_BODY_INVOKE:
423+
JGeneratorBody generatorBody = staticUse.element;
424+
_closedWorld.outputUnitData
425+
.registerColocatedMembers(generatorBody.function, generatorBody);
426+
break;
427+
case StaticUseKind.CALL_METHOD:
428+
FunctionEntity callMethod = staticUse.element;
429+
if (_rtiNeed.methodNeedsSignature(callMethod)) {
430+
_impacts.computeSignature
431+
.registerImpact(transformed, _elementEnvironment);
432+
}
433+
break;
434+
case StaticUseKind.STATIC_TEAR_OFF:
435+
case StaticUseKind.INSTANCE_FIELD_GET:
436+
case StaticUseKind.INSTANCE_FIELD_SET:
437+
case StaticUseKind.SUPER_INVOKE:
438+
case StaticUseKind.STATIC_INVOKE:
439+
case StaticUseKind.SUPER_FIELD_SET:
440+
case StaticUseKind.SUPER_SETTER_SET:
441+
case StaticUseKind.STATIC_SET:
442+
case StaticUseKind.SUPER_TEAR_OFF:
443+
case StaticUseKind.SUPER_GET:
444+
case StaticUseKind.STATIC_GET:
445+
case StaticUseKind.FIELD_INIT:
446+
case StaticUseKind.FIELD_CONSTANT_INIT:
447+
case StaticUseKind.CONSTRUCTOR_INVOKE:
448+
case StaticUseKind.CONST_CONSTRUCTOR_INVOKE:
449+
case StaticUseKind.DIRECT_INVOKE:
450+
case StaticUseKind.INLINING:
451+
case StaticUseKind.CLOSURE:
452+
case StaticUseKind.CLOSURE_CALL:
453+
break;
415454
}
416455
}
417456

pkg/compiler/lib/src/ssa/builder_kernel.dart

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import '../common/names.dart';
1212
import '../common_elements.dart';
1313
import '../constants/constant_system.dart' as constant_system;
1414
import '../constants/values.dart';
15+
import '../deferred_load.dart';
1516
import '../dump_info.dart';
1617
import '../elements/entities.dart';
1718
import '../elements/jumps.dart';
@@ -1358,7 +1359,6 @@ class KernelSsaGraphBuilder extends ir.Visitor {
13581359
}
13591360

13601361
JGeneratorBody body = _elementMap.getGeneratorBody(function);
1361-
closedWorld.outputUnitData.registerColocatedMembers(function, body);
13621362
push(new HInvokeGeneratorBody(
13631363
body,
13641364
inputs,
@@ -1734,11 +1734,13 @@ class KernelSsaGraphBuilder extends ir.Visitor {
17341734
_sourceInformationBuilder.buildGet(node);
17351735
if (!closedWorld.outputUnitData
17361736
.hasOnlyNonDeferredImportPathsToConstant(targetElement, value)) {
1737+
OutputUnit outputUnit =
1738+
closedWorld.outputUnitData.outputUnitForConstant(value);
1739+
ConstantValue deferredConstant =
1740+
new DeferredGlobalConstantValue(value, outputUnit);
1741+
registry.registerConstantUse(new ConstantUse.deferred(deferredConstant));
17371742
stack.add(graph.addDeferredConstant(
1738-
value,
1739-
closedWorld.outputUnitData.outputUnitForConstant(value),
1740-
sourceInformation,
1741-
closedWorld));
1743+
deferredConstant, sourceInformation, closedWorld));
17421744
} else {
17431745
stack.add(graph.addConstant(value, closedWorld,
17441746
sourceInformation: sourceInformation));
@@ -3297,15 +3299,20 @@ class KernelSsaGraphBuilder extends ir.Visitor {
32973299
push(new HStatic(field, _typeInferenceMap.getInferredTypeOf(field),
32983300
sourceInformation));
32993301
} else if (fieldData.isEffectivelyConstant) {
3300-
var unit = closedWorld.outputUnitData.outputUnitForMember(field);
3302+
OutputUnit outputUnit =
3303+
closedWorld.outputUnitData.outputUnitForMember(field);
33013304
// TODO(sigmund): this is not equivalent to what the old FE does: if
33023305
// there is no prefix the old FE wouldn't treat this in any special
33033306
// way. Also, if the prefix points to a constant in the main output
33043307
// unit, the old FE would still generate a deferred wrapper here.
33053308
if (!closedWorld.outputUnitData
33063309
.hasOnlyNonDeferredImportPaths(targetElement, field)) {
3310+
ConstantValue deferredConstant = new DeferredGlobalConstantValue(
3311+
fieldData.initialValue, outputUnit);
3312+
registry
3313+
.registerConstantUse(new ConstantUse.deferred(deferredConstant));
33073314
stack.add(graph.addDeferredConstant(
3308-
fieldData.initialValue, unit, sourceInformation, closedWorld));
3315+
deferredConstant, sourceInformation, closedWorld));
33093316
} else {
33103317
stack.add(graph.addConstant(fieldData.initialValue, closedWorld,
33113318
sourceInformation: sourceInformation));

pkg/compiler/lib/src/ssa/nodes.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import '../closure.dart';
88
import '../common.dart';
99
import '../constants/constant_system.dart' as constant_system;
1010
import '../constants/values.dart';
11-
import '../deferred_load.dart' show OutputUnit;
1211
import '../elements/entities.dart';
1312
import '../elements/jumps.dart';
1413
import '../elements/types.dart';
@@ -283,11 +282,9 @@ class HGraph {
283282
return result;
284283
}
285284

286-
HConstant addDeferredConstant(ConstantValue constant, OutputUnit unit,
285+
HConstant addDeferredConstant(DeferredGlobalConstantValue constant,
287286
SourceInformation sourceInformation, JClosedWorld closedWorld) {
288-
ConstantValue wrapper = new DeferredGlobalConstantValue(constant, unit);
289-
closedWorld.outputUnitData.registerConstantDeferredUse(wrapper, unit);
290-
return addConstant(wrapper, closedWorld,
287+
return addConstant(constant, closedWorld,
291288
sourceInformation: sourceInformation);
292289
}
293290

pkg/compiler/lib/src/universe/codegen_world_builder.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ class CodegenWorldBuilderImpl extends WorldBuilderBase
345345
useSet.addAll(
346346
usage.invoke(Accesses.superAccess, staticUse.callStructure));
347347
break;
348+
case StaticUseKind.GENERATOR_BODY_INVOKE:
348349
case StaticUseKind.STATIC_INVOKE:
349350
registerStaticInvocation(staticUse);
350351
useSet.addAll(

pkg/compiler/lib/src/universe/resolution_world_builder.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ class ResolutionWorldBuilderImpl extends WorldBuilderBase
688688
break;
689689
case StaticUseKind.INLINING:
690690
case StaticUseKind.CALL_METHOD:
691+
case StaticUseKind.GENERATOR_BODY_INVOKE:
691692
failedAt(CURRENT_ELEMENT_SPANNABLE,
692693
"Static use ${staticUse.kind} is not supported during resolution.");
693694
}

pkg/compiler/lib/src/universe/use.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ enum StaticUseKind {
158158
CONST_CONSTRUCTOR_INVOKE,
159159
DIRECT_INVOKE,
160160
INLINING,
161+
GENERATOR_BODY_INVOKE,
161162
STATIC_INVOKE,
162163
STATIC_GET,
163164
STATIC_SET,
@@ -488,7 +489,7 @@ class StaticUse {
488489
/// Direct invocation of a generator (body) [element], as a static call or
489490
/// through a this or super constructor call.
490491
factory StaticUse.generatorBodyInvoke(FunctionEntity element) {
491-
return new StaticUse.internal(element, StaticUseKind.STATIC_INVOKE,
492+
return new StaticUse.internal(element, StaticUseKind.GENERATOR_BODY_INVOKE,
492493
callStructure: CallStructure.NO_ARGS);
493494
}
494495

@@ -901,9 +902,12 @@ class ConstantUse {
901902
/// Type constant used for registration of custom elements.
902903
ConstantUse.customElements(TypeConstantValue value) : this._(value);
903904

904-
/// Constant literal used on code.
905+
/// Constant literal used in code.
905906
ConstantUse.literal(ConstantValue value) : this._(value);
906907

908+
/// Deferred constant used in code.
909+
ConstantUse.deferred(DeferredGlobalConstantValue value) : this._(value);
910+
907911
@override
908912
bool operator ==(other) {
909913
if (identical(this, other)) return true;

0 commit comments

Comments
 (0)