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

Commit 7a29495

Browse files
johnniwinthercommit-bot@chromium.org
authored andcommitted
Handle ConstantExpression in ssa and kernel impact
The ssa builder now also fails if we have any unhandled nodes. Change-Id: Ieaaa6a86edcc3ead0a46c70c2e513c1fe581aee8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97102 Commit-Queue: Johnni Winther <[email protected]> Reviewed-by: Sigmund Cherem <[email protected]>
1 parent 7a90563 commit 7a29495

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

pkg/compiler/lib/src/kernel/kernel_impact.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,9 +785,8 @@ abstract class KernelImpactRegistryMixin implements ImpactRegistry {
785785

786786
@override
787787
void registerConstant(ir.ConstantExpression node) {
788-
// ignore: unused_local_variable
789788
ConstantValue value = elementMap.getConstantValue(node);
790-
// TODO(johnniwinther,fishythefish): Register the constant.
789+
impactBuilder.registerConstantUse(new ConstantUse.literal(value));
791790
}
792791

793792
@override

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

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,29 +1436,8 @@ class KernelSsaGraphBuilder extends ir.Visitor
14361436
}
14371437

14381438
@override
1439-
void defaultExpression(ir.Expression expression) {
1440-
// TODO(johnniwinther): We should make this an internal error.
1441-
_trap('Unhandled ir.${expression.runtimeType} $expression');
1442-
}
1443-
1444-
@override
1445-
void defaultStatement(ir.Statement statement) {
1446-
// TODO(johnniwinther): We should make this an internal error.
1447-
_trap('Unhandled ir.${statement.runtimeType} $statement');
1448-
pop();
1449-
}
1450-
1451-
void _trap(String message) {
1452-
HInstruction nullValue = graph.addConstantNull(closedWorld);
1453-
HInstruction errorMessage = graph.addConstantString(message, closedWorld);
1454-
HInstruction trap = new HForeignCode(
1455-
js.js.parseForeignJS("#.#"),
1456-
abstractValueDomain.dynamicType,
1457-
<HInstruction>[nullValue, errorMessage]);
1458-
trap.sideEffects
1459-
..setAllSideEffects()
1460-
..setDependsOnSomething();
1461-
push(trap);
1439+
void defaultNode(ir.Node node) {
1440+
throw new UnsupportedError("Unhandled node $node (${node.runtimeType})");
14621441
}
14631442

14641443
/// Returns the current source element. This is used by the type builder.
@@ -1545,6 +1524,12 @@ class KernelSsaGraphBuilder extends ir.Visitor
15451524
}
15461525
}
15471526

1527+
@override
1528+
void visitConstantExpression(ir.ConstantExpression node) {
1529+
stack.add(
1530+
graph.addConstant(_elementMap.getConstantValue(node), closedWorld));
1531+
}
1532+
15481533
/// Returns true if the [type] is a valid return type for an asynchronous
15491534
/// function.
15501535
///

0 commit comments

Comments
 (0)