Changes that slipped through rebasing
Change-Id: I7d40fe0c5bc360fb154d3490e134125265ab366d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103132
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
diff --git a/pkg/compiler/lib/src/constants/values.dart b/pkg/compiler/lib/src/constants/values.dart
index c10956f..67b4c3f 100644
--- a/pkg/compiler/lib/src/constants/values.dart
+++ b/pkg/compiler/lib/src/constants/values.dart
@@ -27,7 +27,8 @@
TYPE,
INTERCEPTOR,
JS_NAME,
- ABSTRACT_VALUE,
+ DUMMY_INTERCEPTOR,
+ UNREACHABLE,
INSTANTIATION,
DEFERRED_GLOBAL,
NON_CONSTANT,
@@ -50,8 +51,10 @@
R visitType(covariant TypeConstantValue constant, covariant A arg);
R visitInterceptor(
covariant InterceptorConstantValue constant, covariant A arg);
- R visitAbstractValue(
- covariant AbstractValueConstantValue constant, covariant A arg);
+ R visitDummyInterceptor(
+ covariant DummyInterceptorConstantValue constant, covariant A arg);
+ R visitUnreachable(
+ covariant UnreachableConstantValue constant, covariant A arg);
R visitJsName(covariant JsNameConstantValue constant, covariant A arg);
R visitDeferredGlobal(
covariant DeferredGlobalConstantValue constant, covariant A arg);
@@ -850,19 +853,19 @@
String toStructuredText() => 'JsNameConstant(${name})';
}
-/// An abstract value as a constant value. This is only used during code
-/// generation.
-class AbstractValueConstantValue extends ConstantValue {
+/// A constant used as the dummy interceptor value for intercepted calls with
+/// a known non-interceptor target.
+class DummyInterceptorConstantValue extends ConstantValue {
final AbstractValue abstractValue;
- AbstractValueConstantValue(this.abstractValue);
+ DummyInterceptorConstantValue(this.abstractValue);
@override
bool get isDummy => true;
@override
bool operator ==(other) {
- return other is AbstractValueConstantValue &&
+ return other is DummyInterceptorConstantValue &&
abstractValue == other.abstractValue;
}
@@ -874,20 +877,49 @@
@override
accept(ConstantValueVisitor visitor, arg) {
- return visitor.visitAbstractValue(this, arg);
+ return visitor.visitDummyInterceptor(this, arg);
}
@override
DartType getType(CommonElements types) => types.dynamicType;
@override
- ConstantValueKind get kind => ConstantValueKind.ABSTRACT_VALUE;
+ ConstantValueKind get kind => ConstantValueKind.DUMMY_INTERCEPTOR;
@override
- String toDartText() => 'abstract_value($abstractValue)';
+ String toDartText() => 'dummy_interceptor($abstractValue)';
@override
- String toStructuredText() => 'AbstractValueConstant($abstractValue)';
+ String toStructuredText() => 'DummyInterceptorConstant($abstractValue)';
+}
+
+// A constant with an empty type used in [HInstruction]s of an expression
+// in an unreachable context.
+class UnreachableConstantValue extends ConstantValue {
+ const UnreachableConstantValue();
+
+ @override
+ bool get isDummy => true;
+
+ @override
+ List<ConstantValue> getDependencies() => const <ConstantValue>[];
+
+ @override
+ accept(ConstantValueVisitor visitor, arg) {
+ return visitor.visitUnreachable(this, arg);
+ }
+
+ @override
+ DartType getType(CommonElements types) => types.dynamicType;
+
+ @override
+ ConstantValueKind get kind => ConstantValueKind.UNREACHABLE;
+
+ @override
+ String toDartText() => 'unreachable()';
+
+ @override
+ String toStructuredText() => 'UnreachableConstant()';
}
class ConstructedConstantValue extends ObjectConstantValue {
diff --git a/pkg/compiler/lib/src/inferrer/typemasks/constants.dart b/pkg/compiler/lib/src/inferrer/typemasks/constants.dart
index a453382..0994564 100644
--- a/pkg/compiler/lib/src/inferrer/typemasks/constants.dart
+++ b/pkg/compiler/lib/src/inferrer/typemasks/constants.dart
@@ -48,12 +48,18 @@
}
@override
- TypeMask visitAbstractValue(
- AbstractValueConstantValue constant, JClosedWorld closedWorld) {
+ TypeMask visitDummyInterceptor(
+ DummyInterceptorConstantValue constant, JClosedWorld closedWorld) {
return constant.abstractValue;
}
@override
+ TypeMask visitUnreachable(
+ UnreachableConstantValue constant, JClosedWorld closedWorld) {
+ return closedWorld.abstractValueDomain.emptyType;
+ }
+
+ @override
TypeMask visitJsName(JsNameConstantValue constant, JClosedWorld closedWorld) {
return closedWorld.abstractValueDomain.stringType;
}
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index 79a1ada..b4e5034 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -594,7 +594,6 @@
_codegenImpactTransformer.transformCodegenImpact(result.impact);
compiler.dumpInfoTask.registerImpact(member, worldImpact);
result.applyModularState(_namer, emitterTask.emitter);
- //print('$member:$result');
return worldImpact;
}
diff --git a/pkg/compiler/lib/src/js_backend/constant_emitter.dart b/pkg/compiler/lib/src/js_backend/constant_emitter.dart
index 96bc202..06ec784 100644
--- a/pkg/compiler/lib/src/js_backend/constant_emitter.dart
+++ b/pkg/compiler/lib/src/js_backend/constant_emitter.dart
@@ -144,12 +144,17 @@
}
@override
- jsAst.Expression visitAbstractValue(AbstractValueConstantValue constant,
+ jsAst.Expression visitDummyInterceptor(DummyInterceptorConstantValue constant,
[_]) {
return new jsAst.LiteralNumber('0');
}
@override
+ jsAst.Expression visitUnreachable(UnreachableConstantValue constant, [_]) {
+ return new jsAst.LiteralNumber('0');
+ }
+
+ @override
jsAst.Expression visitJsName(JsNameConstantValue constant, [_]) {
return constant.name;
}
diff --git a/pkg/compiler/lib/src/js_backend/interceptor_data.dart b/pkg/compiler/lib/src/js_backend/interceptor_data.dart
index b63dae7..cc38bab 100644
--- a/pkg/compiler/lib/src/js_backend/interceptor_data.dart
+++ b/pkg/compiler/lib/src/js_backend/interceptor_data.dart
@@ -388,8 +388,8 @@
String key = suffixForGetInterceptor(_commonElements, _nativeData, classes);
Map<String, OneShotInterceptor> interceptors =
_oneShotInterceptors[selector] ??= {};
- OneShotInterceptor interceptor = interceptors.putIfAbsent(
- key, () => new OneShotInterceptor(key, selector));
+ OneShotInterceptor interceptor =
+ interceptors[key] ??= new OneShotInterceptor(key, selector);
interceptor.classes.addAll(classes);
registerSpecializedGetInterceptor(classes, namer);
return namer.nameForGetOneShotInterceptor(selector, classes);
diff --git a/pkg/compiler/lib/src/js_backend/namer.dart b/pkg/compiler/lib/src/js_backend/namer.dart
index ee53198..c230130 100644
--- a/pkg/compiler/lib/src/js_backend/namer.dart
+++ b/pkg/compiler/lib/src/js_backend/namer.dart
@@ -1884,8 +1884,13 @@
}
@override
- void visitAbstractValue(AbstractValueConstantValue constant, [_]) {
- add('dummy_receiver');
+ void visitDummyInterceptor(DummyInterceptorConstantValue constant, [_]) {
+ add('dummy_interceptor');
+ }
+
+ @override
+ void visitUnreachable(UnreachableConstantValue constant, [_]) {
+ add('unreachable');
}
@override
@@ -2012,10 +2017,18 @@
}
@override
- int visitAbstractValue(AbstractValueConstantValue constant, [_]) {
+ int visitDummyInterceptor(DummyInterceptorConstantValue constant, [_]) {
throw failedAt(
NO_LOCATION_SPANNABLE,
- 'AbstractValueConstantValue should never be named and '
+ 'DummyInterceptorConstantValue should never be named and '
+ 'never be subconstant');
+ }
+
+ @override
+ int visitUnreachable(UnreachableConstantValue constant, [_]) {
+ throw failedAt(
+ NO_LOCATION_SPANNABLE,
+ 'UnreachableConstantValue should never be named and '
'never be subconstant');
}
diff --git a/pkg/compiler/lib/src/js_backend/namer_names.dart b/pkg/compiler/lib/src/js_backend/namer_names.dart
index f74a30a..f405dc0 100644
--- a/pkg/compiler/lib/src/js_backend/namer_names.dart
+++ b/pkg/compiler/lib/src/js_backend/namer_names.dart
@@ -212,7 +212,7 @@
@override
String get name {
assert(isFinalized, "TokenName($key) has not been finalized.");
- return _name ?? key;
+ return _name;
}
@override
diff --git a/pkg/compiler/lib/src/js_emitter/constant_ordering.dart b/pkg/compiler/lib/src/js_emitter/constant_ordering.dart
index fb1a792..f205845 100644
--- a/pkg/compiler/lib/src/js_emitter/constant_ordering.dart
+++ b/pkg/compiler/lib/src/js_emitter/constant_ordering.dart
@@ -31,7 +31,7 @@
int compareValues(ConstantValue a, ConstantValue b) {
if (identical(a, b)) return 0;
- int r = _KindVisitor.kind(a).compareTo(_KindVisitor.kind(b));
+ int r = a.kind.index.compareTo(b.kind.index);
if (r != 0) return r;
return a.accept(this, b);
}
@@ -168,8 +168,14 @@
}
@override
- int visitAbstractValue(
- AbstractValueConstantValue a, AbstractValueConstantValue b) {
+ int visitDummyInterceptor(
+ DummyInterceptorConstantValue a, DummyInterceptorConstantValue b) {
+ // Never emitted.
+ return 0;
+ }
+
+ @override
+ int visitUnreachable(UnreachableConstantValue a, UnreachableConstantValue b) {
// Never emitted.
return 0;
}
@@ -197,66 +203,6 @@
}
}
-class _KindVisitor implements ConstantValueVisitor<int, Null> {
- const _KindVisitor();
-
- static const int FUNCTION = 1;
- static const int NULL = 2;
- static const int INT = 3;
- static const int DOUBLE = 4;
- static const int BOOL = 5;
- static const int STRING = 6;
- static const int LIST = 7;
- static const int SET = 8;
- static const int MAP = 9;
- static const int CONSTRUCTED = 10;
- static const int TYPE = 11;
- static const int INTERCEPTOR = 12;
- static const int ABSTRACT_VALUE = 13;
- static const int JS_NAME = 14;
- static const int DEFERRED_GLOBAL = 15;
- static const int NONCONSTANT = 16;
- static const int INSTANTIATION = 17;
-
- static int kind(ConstantValue constant) =>
- constant.accept(const _KindVisitor(), null);
-
- @override
- int visitFunction(FunctionConstantValue a, _) => FUNCTION;
- @override
- int visitNull(NullConstantValue a, _) => NULL;
- @override
- int visitNonConstant(NonConstantValue a, _) => NONCONSTANT;
- @override
- int visitInt(IntConstantValue a, _) => INT;
- @override
- int visitDouble(DoubleConstantValue a, _) => DOUBLE;
- @override
- int visitBool(BoolConstantValue a, _) => BOOL;
- @override
- int visitString(StringConstantValue a, _) => STRING;
- @override
- int visitList(ListConstantValue a, _) => LIST;
- @override
- int visitSet(SetConstantValue a, _) => SET;
- @override
- int visitMap(MapConstantValue a, _) => MAP;
- @override
- int visitConstructed(ConstructedConstantValue a, _) => CONSTRUCTED;
- @override
- int visitType(TypeConstantValue a, _) => TYPE;
- @override
- int visitInterceptor(InterceptorConstantValue a, _) => INTERCEPTOR;
- @override
- int visitAbstractValue(AbstractValueConstantValue a, _) => ABSTRACT_VALUE;
- @override
- int visitJsName(JsNameConstantValue a, _) => JS_NAME;
- @override
- int visitDeferredGlobal(DeferredGlobalConstantValue a, _) => DEFERRED_GLOBAL;
- @override
- int visitInstantiation(InstantiationConstantValue a, _) => INSTANTIATION;
-}
-
/// Visitor for distinguishing types by kind.
class _DartTypeKindVisitor extends DartTypeVisitor<int, Null> {
const _DartTypeKindVisitor();
diff --git a/pkg/compiler/lib/src/js_model/js_world_builder.dart b/pkg/compiler/lib/src/js_model/js_world_builder.dart
index b3a59d2..fa4c4d9 100644
--- a/pkg/compiler/lib/src/js_model/js_world_builder.dart
+++ b/pkg/compiler/lib/src/js_model/js_world_builder.dart
@@ -846,7 +846,11 @@
@override
ConstantValue visitString(StringConstantValue constant, _) => constant;
@override
- ConstantValue visitAbstractValue(AbstractValueConstantValue constant, _) =>
+ ConstantValue visitDummyInterceptor(
+ DummyInterceptorConstantValue constant, _) =>
+ constant;
+ @override
+ ConstantValue visitUnreachable(UnreachableConstantValue constant, _) =>
constant;
@override
ConstantValue visitJsName(JsNameConstantValue constant, _) => constant;
diff --git a/pkg/compiler/lib/src/serialization/abstract_sink.dart b/pkg/compiler/lib/src/serialization/abstract_sink.dart
index ac9d487..66909c3 100644
--- a/pkg/compiler/lib/src/serialization/abstract_sink.dart
+++ b/pkg/compiler/lib/src/serialization/abstract_sink.dart
@@ -450,10 +450,12 @@
writeConstant(constant.referenced);
writeOutputUnitReference(constant.unit);
break;
- case ConstantValueKind.ABSTRACT_VALUE:
- AbstractValueConstantValue constant = value;
+ case ConstantValueKind.DUMMY_INTERCEPTOR:
+ DummyInterceptorConstantValue constant = value;
writeAbstractValue(constant.abstractValue);
break;
+ case ConstantValueKind.UNREACHABLE:
+ break;
case ConstantValueKind.JS_NAME:
JsNameConstantValue constant = value;
writeJsNode(constant.name);
diff --git a/pkg/compiler/lib/src/serialization/abstract_source.dart b/pkg/compiler/lib/src/serialization/abstract_source.dart
index 87cb765..f10276c 100644
--- a/pkg/compiler/lib/src/serialization/abstract_source.dart
+++ b/pkg/compiler/lib/src/serialization/abstract_source.dart
@@ -510,9 +510,11 @@
ConstantValue constant = readConstant();
OutputUnit unit = readOutputUnitReference();
return new DeferredGlobalConstantValue(constant, unit);
- case ConstantValueKind.ABSTRACT_VALUE:
+ case ConstantValueKind.DUMMY_INTERCEPTOR:
AbstractValue abstractValue = readAbstractValue();
- return new AbstractValueConstantValue(abstractValue);
+ return new DummyInterceptorConstantValue(abstractValue);
+ case ConstantValueKind.UNREACHABLE:
+ return const UnreachableConstantValue();
case ConstantValueKind.JS_NAME:
js.LiteralString name = readJsNode();
return new JsNameConstantValue(name);
diff --git a/pkg/compiler/lib/src/ssa/codegen.dart b/pkg/compiler/lib/src/ssa/codegen.dart
index 47d0de0..9a19e55 100644
--- a/pkg/compiler/lib/src/ssa/codegen.dart
+++ b/pkg/compiler/lib/src/ssa/codegen.dart
@@ -628,6 +628,9 @@
js.Expression generateExpressionAssignment(String variableName,
js.Expression value, SourceInformation sourceInformation) {
+ // TODO(johnniwinther): Introduce a DeferredVariableUse to handle this
+ // in the SSA codegen or let the JS printer handle it fully and remove it
+ // here.
if (value is js.Binary) {
js.Binary binary = value;
String op = binary.op;
diff --git a/pkg/compiler/lib/src/ssa/codegen_helpers.dart b/pkg/compiler/lib/src/ssa/codegen_helpers.dart
index bc388f2..b84e1f8 100644
--- a/pkg/compiler/lib/src/ssa/codegen_helpers.dart
+++ b/pkg/compiler/lib/src/ssa/codegen_helpers.dart
@@ -191,7 +191,7 @@
!_interceptorData.isInterceptedMixinSelector(
selector, mask, _closedWorld)) {
ConstantValue constant =
- new AbstractValueConstantValue(receiverArgument.instructionType);
+ new DummyInterceptorConstantValue(receiverArgument.instructionType);
HConstant dummy = graph.addConstant(constant, _closedWorld);
receiverArgument.usedBy.remove(node);
node.inputs[1] = dummy;
diff --git a/pkg/compiler/lib/src/ssa/nodes.dart b/pkg/compiler/lib/src/ssa/nodes.dart
index a893874..573404b 100644
--- a/pkg/compiler/lib/src/ssa/nodes.dart
+++ b/pkg/compiler/lib/src/ssa/nodes.dart
@@ -326,10 +326,7 @@
HConstant addConstantUnreachable(JClosedWorld closedWorld) {
// A constant with an empty type used as the HInstruction of an expression
// in an unreachable context.
- return addConstant(
- new AbstractValueConstantValue(
- closedWorld.abstractValueDomain.emptyType),
- closedWorld);
+ return addConstant(const UnreachableConstantValue(), closedWorld);
}
void finalize(AbstractValueDomain domain) {
diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart
index 91a06794f..c9f34cc 100644
--- a/pkg/compiler/lib/src/ssa/optimize.dart
+++ b/pkg/compiler/lib/src/ssa/optimize.dart
@@ -1955,8 +1955,7 @@
HInstruction get zapInstruction {
if (zapInstructionCache == null) {
// A constant with no type does not pollute types at phi nodes.
- ConstantValue constant =
- new AbstractValueConstantValue(_abstractValueDomain.emptyType);
+ ConstantValue constant = const UnreachableConstantValue();
zapInstructionCache = analyzer.graph.addConstant(constant, closedWorld);
}
return zapInstructionCache;