Skip to content

Commit 6355939

Browse files
committed
Version 1.20.0-dev.9.0
Merge commit '0f0bd64ca42c2eab15c4a07a8aaffde130646fff' into dev
2 parents 2f49ace + 0f0bd64 commit 6355939

40 files changed

+600
-347
lines changed

pkg/compiler/lib/src/common/backend_api.dart

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ abstract class Backend extends Target {
6464
return const SourceInformationStrategy();
6565
}
6666

67+
/// Common classes used by the backend.
68+
BackendClasses get backendClasses;
69+
6770
/// Interface for serialization of backend specific data.
6871
BackendSerialization get serialization => const BackendSerialization();
6972

@@ -182,34 +185,6 @@ abstract class Backend extends Target {
182185

183186
void registerConstSymbol(String name) {}
184187

185-
bool isNullImplementation(ClassElement cls) {
186-
return cls == compiler.coreClasses.nullClass;
187-
}
188-
189-
ClassElement get intImplementation => compiler.coreClasses.intClass;
190-
ClassElement get doubleImplementation => compiler.coreClasses.doubleClass;
191-
ClassElement get numImplementation => compiler.coreClasses.numClass;
192-
ClassElement get stringImplementation => compiler.coreClasses.stringClass;
193-
ClassElement get listImplementation => compiler.coreClasses.listClass;
194-
ClassElement get growableListImplementation => compiler.coreClasses.listClass;
195-
ClassElement get fixedListImplementation => compiler.coreClasses.listClass;
196-
ClassElement get constListImplementation => compiler.coreClasses.listClass;
197-
ClassElement get mapImplementation => compiler.coreClasses.mapClass;
198-
ClassElement get constMapImplementation => compiler.coreClasses.mapClass;
199-
ClassElement get functionImplementation => compiler.coreClasses.functionClass;
200-
ClassElement get typeImplementation => compiler.coreClasses.typeClass;
201-
ClassElement get boolImplementation => compiler.coreClasses.boolClass;
202-
ClassElement get nullImplementation => compiler.coreClasses.nullClass;
203-
ClassElement get uint32Implementation => compiler.coreClasses.intClass;
204-
ClassElement get uint31Implementation => compiler.coreClasses.intClass;
205-
ClassElement get positiveIntImplementation => compiler.coreClasses.intClass;
206-
ClassElement get syncStarIterableImplementation =>
207-
compiler.coreClasses.iterableClass;
208-
ClassElement get asyncFutureImplementation =>
209-
compiler.coreClasses.futureClass;
210-
ClassElement get asyncStarStreamImplementation =>
211-
compiler.coreClasses.streamClass;
212-
213188
ClassElement defaultSuperclass(ClassElement element) {
214189
return compiler.coreClasses.objectClass;
215190
}
@@ -411,3 +386,27 @@ class BackendSerialization {
411386
SerializerPlugin get serializer => const SerializerPlugin();
412387
DeserializerPlugin get deserializer => const DeserializerPlugin();
413388
}
389+
390+
/// Interface providing access to core classes used by the backend.
391+
abstract class BackendClasses {
392+
ClassElement get intImplementation;
393+
ClassElement get doubleImplementation;
394+
ClassElement get numImplementation;
395+
ClassElement get stringImplementation;
396+
ClassElement get listImplementation;
397+
ClassElement get growableListImplementation;
398+
ClassElement get fixedListImplementation;
399+
ClassElement get constListImplementation;
400+
ClassElement get mapImplementation;
401+
ClassElement get constMapImplementation;
402+
ClassElement get functionImplementation;
403+
ClassElement get typeImplementation;
404+
ClassElement get boolImplementation;
405+
ClassElement get nullImplementation;
406+
ClassElement get uint32Implementation;
407+
ClassElement get uint31Implementation;
408+
ClassElement get positiveIntImplementation;
409+
ClassElement get syncStarIterableImplementation;
410+
ClassElement get asyncFutureImplementation;
411+
ClassElement get asyncStarStreamImplementation;
412+
}

pkg/compiler/lib/src/compiler.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -850,12 +850,16 @@ abstract class Compiler implements LibraryLoaderListener {
850850
mainMethod.computeType(resolution);
851851
if (mainMethod.functionSignature.parameterCount != 0) {
852852
// The first argument could be a list of strings.
853-
backend.listImplementation.ensureResolved(resolution);
853+
backend.backendClasses.listImplementation
854+
.ensureResolved(resolution);
854855
backend.registerInstantiatedType(
855-
backend.listImplementation.rawType, world, globalDependencies);
856-
backend.stringImplementation.ensureResolved(resolution);
856+
backend.backendClasses.listImplementation.rawType,
857+
world,
858+
globalDependencies);
859+
backend.backendClasses.stringImplementation
860+
.ensureResolved(resolution);
857861
backend.registerInstantiatedType(
858-
backend.stringImplementation.rawType,
862+
backend.backendClasses.stringImplementation.rawType,
859863
world,
860864
globalDependencies);
861865

pkg/compiler/lib/src/constant_system_dart.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,10 @@ class DartConstantSystem extends ConstantSystem {
446446
// TODO(johnniwinther): Change the `Type` type to
447447
// `compiler.coreTypes.typeType` and check the backend specific value in
448448
// [checkConstMapKeysDontOverrideEquals] in 'members.dart'.
449-
return new TypeConstantValue(type,
450-
compiler.backend.typeImplementation.computeType(compiler.resolution));
449+
return new TypeConstantValue(
450+
type,
451+
compiler.backend.backendClasses.typeImplementation
452+
.computeType(compiler.resolution));
451453
}
452454

453455
@override

pkg/compiler/lib/src/inferrer/node_tracer.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ abstract class TracerVisitor<T extends TypeInformation>
333333
*/
334334
bool isParameterOfListAddingMethod(Element element) {
335335
if (!element.isRegularParameter) return false;
336-
if (element.enclosingClass != compiler.backend.listImplementation) {
336+
if (element.enclosingClass !=
337+
compiler.backend.backendClasses.listImplementation) {
337338
return false;
338339
}
339340
Element method = element.enclosingElement;
@@ -349,7 +350,8 @@ abstract class TracerVisitor<T extends TypeInformation>
349350
*/
350351
bool isParameterOfMapAddingMethod(Element element) {
351352
if (!element.isRegularParameter) return false;
352-
if (element.enclosingClass != compiler.backend.mapImplementation) {
353+
if (element.enclosingClass !=
354+
compiler.backend.backendClasses.mapImplementation) {
353355
return false;
354356
}
355357
Element method = element.enclosingElement;

pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ class SimpleTypeInferrerVisitor<T>
13521352
// In erroneous code the number of arguments in the selector might not
13531353
// match the function element.
13541354
// TODO(polux): return nonNullEmpty and check it doesn't break anything
1355-
if (!selector.applies(target, compiler.backend) ||
1355+
if (!selector.applies(target) ||
13561356
(mask != null &&
13571357
!mask.canHit(target, selector, compiler.closedWorld))) {
13581358
return types.dynamicType;

pkg/compiler/lib/src/inferrer/type_graph_nodes.dart

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import '../types/masks.dart'
2424
ValueTypeMask;
2525
import '../universe/selector.dart' show Selector;
2626
import '../util/util.dart' show ImmutableEmptySet, Setlet;
27-
import '../world.dart' show ClassWorld;
27+
import '../world.dart' show ClosedWorld;
2828
import 'debug.dart' as debug;
2929
import 'inferrer_visitor.dart' show ArgumentsTypes;
3030
import 'type_graph_inferrer.dart'
@@ -867,26 +867,27 @@ class DynamicCallSiteTypeInformation extends CallSiteTypeInformation {
867867
*/
868868
TypeInformation handleIntrisifiedSelector(
869869
Selector selector, TypeMask mask, TypeGraphInferrerEngine inferrer) {
870-
ClassWorld classWorld = inferrer.closedWorld;
871-
if (!classWorld.backend.intImplementation.isResolved) return null;
870+
ClosedWorld closedWorld = inferrer.closedWorld;
871+
if (!closedWorld.backendClasses.intImplementation.isResolved) return null;
872872
if (mask == null) return null;
873-
if (!mask.containsOnlyInt(classWorld)) {
873+
if (!mask.containsOnlyInt(closedWorld)) {
874874
return null;
875875
}
876876
if (!selector.isCall && !selector.isOperator) return null;
877877
if (!arguments.named.isEmpty) return null;
878878
if (arguments.positional.length > 1) return null;
879879

880-
ClassElement uint31Implementation = classWorld.backend.uint31Implementation;
881-
bool isInt(info) => info.type.containsOnlyInt(classWorld);
880+
ClassElement uint31Implementation =
881+
closedWorld.backendClasses.uint31Implementation;
882+
bool isInt(info) => info.type.containsOnlyInt(closedWorld);
882883
bool isEmpty(info) => info.type.isEmpty;
883884
bool isUInt31(info) {
884-
return info.type.satisfies(uint31Implementation, classWorld);
885+
return info.type.satisfies(uint31Implementation, closedWorld);
885886
}
886887

887888
bool isPositiveInt(info) {
888-
return info.type
889-
.satisfies(classWorld.backend.positiveIntImplementation, classWorld);
889+
return info.type.satisfies(
890+
closedWorld.backendClasses.positiveIntImplementation, closedWorld);
890891
}
891892

892893
TypeInformation tryLater() => inferrer.types.nonNullEmptyType;

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

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames;
1111
import '../closure.dart';
1212
import '../common.dart';
1313
import '../common/backend_api.dart'
14-
show Backend, ImpactTransformer, ForeignResolver, NativeRegistry;
14+
show
15+
Backend,
16+
BackendClasses,
17+
ImpactTransformer,
18+
ForeignResolver,
19+
NativeRegistry;
1520
import '../common/codegen.dart' show CodegenImpact, CodegenWorkItem;
1621
import '../common/names.dart' show Identifiers, Selectors, Uris;
1722
import '../common/registry.dart' show Registry;
@@ -591,6 +596,7 @@ class JavaScriptBackend extends Backend {
591596

592597
final BackendHelpers helpers;
593598
final BackendImpacts impacts;
599+
BackendClasses backendClasses;
594600

595601
final JSFrontendAccess frontend;
596602

@@ -630,6 +636,7 @@ class JavaScriptBackend extends Backend {
630636
functionCompiler =
631637
new SsaFunctionCompiler(this, sourceInformationStrategy, useKernel);
632638
serialization = new JavaScriptBackendSerialization(this);
639+
backendClasses = new JavaScriptBackendClasses(helpers);
633640
}
634641

635642
ConstantSystem get constantSystem => constants.constantSystem;
@@ -925,7 +932,7 @@ class JavaScriptBackend extends Backend {
925932
if (elements == null) return false;
926933
if (elements.isEmpty) return false;
927934
return elements.any((element) {
928-
return selector.applies(element, this) &&
935+
return selector.applies(element) &&
929936
(mask == null ||
930937
mask.canHit(element, selector, compiler.closedWorld));
931938
});
@@ -1121,7 +1128,7 @@ class JavaScriptBackend extends Backend {
11211128
registerBackendUse(helpers.createRuntimeType);
11221129
}
11231130
impactBuilder.registerTypeUse(
1124-
new TypeUse.instantiation(typeImplementation.rawType));
1131+
new TypeUse.instantiation(backendClasses.typeImplementation.rawType));
11251132
}
11261133
lookupMapAnalysis.registerConstantKey(constant);
11271134
}
@@ -1139,7 +1146,7 @@ class JavaScriptBackend extends Backend {
11391146
helpers.setRuntimeTypeInfo,
11401147
null));
11411148
}
1142-
if (type.element == typeImplementation) {
1149+
if (type.element == backendClasses.typeImplementation) {
11431150
// If we use a type literal in a constant, the compile time
11441151
// constant emitter will generate a call to the createRuntimeType
11451152
// helper so we register a use of that.
@@ -1897,30 +1904,6 @@ class JavaScriptBackend extends Backend {
18971904
return compiler.closedWorld.hasOnlySubclasses(classElement);
18981905
}
18991906

1900-
bool isNullImplementation(ClassElement cls) {
1901-
return cls == helpers.jsNullClass;
1902-
}
1903-
1904-
ClassElement get intImplementation => helpers.jsIntClass;
1905-
ClassElement get uint32Implementation => helpers.jsUInt32Class;
1906-
ClassElement get uint31Implementation => helpers.jsUInt31Class;
1907-
ClassElement get positiveIntImplementation => helpers.jsPositiveIntClass;
1908-
ClassElement get doubleImplementation => helpers.jsDoubleClass;
1909-
ClassElement get numImplementation => helpers.jsNumberClass;
1910-
ClassElement get stringImplementation => helpers.jsStringClass;
1911-
ClassElement get listImplementation => helpers.jsArrayClass;
1912-
ClassElement get constListImplementation => helpers.jsUnmodifiableArrayClass;
1913-
ClassElement get fixedListImplementation => helpers.jsFixedArrayClass;
1914-
ClassElement get growableListImplementation => helpers.jsExtendableArrayClass;
1915-
ClassElement get mapImplementation => helpers.mapLiteralClass;
1916-
ClassElement get constMapImplementation => helpers.constMapLiteralClass;
1917-
ClassElement get typeImplementation => helpers.typeLiteralClass;
1918-
ClassElement get boolImplementation => helpers.jsBoolClass;
1919-
ClassElement get nullImplementation => helpers.jsNullClass;
1920-
ClassElement get syncStarIterableImplementation => helpers.syncStarIterable;
1921-
ClassElement get asyncFutureImplementation => helpers.futureImplementation;
1922-
ClassElement get asyncStarStreamImplementation => helpers.controllerStream;
1923-
19241907
void registerStaticUse(Element element, Enqueuer enqueuer) {
19251908
if (element == helpers.disableTreeShakingMarker) {
19261909
isTreeShakingDisabled = true;
@@ -3257,3 +3240,30 @@ class JavaScriptImpactStrategy extends ImpactStrategy {
32573240
}
32583241
}
32593242
}
3243+
3244+
class JavaScriptBackendClasses implements BackendClasses {
3245+
final BackendHelpers helpers;
3246+
3247+
JavaScriptBackendClasses(this.helpers);
3248+
3249+
ClassElement get intImplementation => helpers.jsIntClass;
3250+
ClassElement get uint32Implementation => helpers.jsUInt32Class;
3251+
ClassElement get uint31Implementation => helpers.jsUInt31Class;
3252+
ClassElement get positiveIntImplementation => helpers.jsPositiveIntClass;
3253+
ClassElement get doubleImplementation => helpers.jsDoubleClass;
3254+
ClassElement get numImplementation => helpers.jsNumberClass;
3255+
ClassElement get stringImplementation => helpers.jsStringClass;
3256+
ClassElement get listImplementation => helpers.jsArrayClass;
3257+
ClassElement get constListImplementation => helpers.jsUnmodifiableArrayClass;
3258+
ClassElement get fixedListImplementation => helpers.jsFixedArrayClass;
3259+
ClassElement get growableListImplementation => helpers.jsExtendableArrayClass;
3260+
ClassElement get mapImplementation => helpers.mapLiteralClass;
3261+
ClassElement get constMapImplementation => helpers.constMapLiteralClass;
3262+
ClassElement get typeImplementation => helpers.typeLiteralClass;
3263+
ClassElement get boolImplementation => helpers.jsBoolClass;
3264+
ClassElement get nullImplementation => helpers.jsNullClass;
3265+
ClassElement get syncStarIterableImplementation => helpers.syncStarIterable;
3266+
ClassElement get asyncFutureImplementation => helpers.futureImplementation;
3267+
ClassElement get asyncStarStreamImplementation => helpers.controllerStream;
3268+
ClassElement get functionImplementation => helpers.coreClasses.functionClass;
3269+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ class BackendImpacts {
446446
BackendImpact get typeLiteral {
447447
if (_typeLiteral == null) {
448448
_typeLiteral = new BackendImpact(
449-
instantiatedClasses: [backend.typeImplementation],
449+
instantiatedClasses: [backend.backendClasses.typeImplementation],
450450
staticUses: [helpers.createRuntimeType]);
451451
}
452452
return _typeLiteral;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,10 @@ class JavaScriptConstantSystem extends ConstantSystem {
265265

266266
@override
267267
ConstantValue createType(Compiler compiler, DartType type) {
268-
return new TypeConstantValue(type,
269-
compiler.backend.typeImplementation.computeType(compiler.resolution));
268+
return new TypeConstantValue(
269+
type,
270+
compiler.backend.backendClasses.typeImplementation
271+
.computeType(compiler.resolution));
270272
}
271273

272274
// Integer checks report true for -0.0, INFINITY, and -INFINITY. At

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class CodegenEnqueuer implements Enqueuer {
8888

8989
Registry get mirrorDependencies => _compiler.mirrorDependencies;
9090

91-
ClassWorld get _world => _compiler.closedWorld;
91+
ClosedWorld get _world => _compiler.closedWorld;
9292

9393
bool get queueIsEmpty => queue.isEmpty;
9494

0 commit comments

Comments
 (0)