| Index: lib/compiler/implementation/ssa/optimize.dart
|
| diff --git a/lib/compiler/implementation/ssa/optimize.dart b/lib/compiler/implementation/ssa/optimize.dart
|
| index 4faa8e9e2e4ae016ee5352b71ae07b34f8c7f2fd..736454c6883ac5bd1ba0b37a03be76f8886dd3cd 100644
|
| --- a/lib/compiler/implementation/ssa/optimize.dart
|
| +++ b/lib/compiler/implementation/ssa/optimize.dart
|
| @@ -23,15 +23,17 @@ class SsaOptimizerTask extends CompilerTask {
|
| }
|
|
|
| void optimize(WorkItem work, HGraph graph) {
|
| + FoldingOperations foldingOperations =
|
| + compiler.constantHandler.foldingOperations;
|
| measure(() {
|
| List<OptimizationPhase> phases = <OptimizationPhase>[
|
| // Run trivial constant folding first to optimize
|
| // some patterns useful for type conversion.
|
| - new SsaConstantFolder(backend, work),
|
| + new SsaConstantFolder(foldingOperations, backend, work),
|
| new SsaTypeConversionInserter(compiler),
|
| new SsaTypePropagator(compiler),
|
| new SsaCheckInserter(backend),
|
| - new SsaConstantFolder(backend, work),
|
| + new SsaConstantFolder(foldingOperations, backend, work),
|
| new SsaRedundantPhiEliminator(),
|
| new SsaDeadPhiEliminator(),
|
| new SsaGlobalValueNumberer(compiler),
|
| @@ -93,10 +95,11 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
|
| final String name = "SsaConstantFolder";
|
| final JavaScriptBackend backend;
|
| final WorkItem work;
|
| + final FoldingOperations foldingOperations;
|
| HGraph graph;
|
| Compiler get compiler() => backend.compiler;
|
|
|
| - SsaConstantFolder(this.backend, this.work);
|
| + SsaConstantFolder(this.foldingOperations, this.backend, this.work);
|
|
|
| void visitGraph(HGraph visitee) {
|
| graph = visitee;
|
| @@ -165,7 +168,7 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
|
| HInstruction visitInvokeUnary(HInvokeUnary node) {
|
| HInstruction operand = node.operand;
|
| if (operand is HConstant) {
|
| - UnaryOperation operation = node.operation;
|
| + UnaryOperation operation = node.operation(foldingOperations);
|
| HConstant receiver = operand;
|
| Constant folded = operation.fold(receiver.constant);
|
| if (folded !== null) return graph.addConstant(folded);
|
| @@ -319,8 +322,8 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
|
| HInstruction visitInvokeBinary(HInvokeBinary node) {
|
| HInstruction left = node.left;
|
| HInstruction right = node.right;
|
| + BinaryOperation operation = node.operation(foldingOperations);
|
| if (left is HConstant && right is HConstant) {
|
| - BinaryOperation operation = node.operation;
|
| HConstant op1 = left;
|
| HConstant op2 = right;
|
| Constant folded = operation.fold(op1.constant, op2.constant);
|
| @@ -328,10 +331,10 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
|
| }
|
|
|
| if (!left.canBePrimitive()
|
| - && node.operation.isUserDefinable()
|
| + && operation.isUserDefinable()
|
| // The equals operation is being optimized in visitEquals.
|
| - && node.operation !== const EqualsOperation()) {
|
| - Selector selector = new Selector.binaryOperator(node.operation.name);
|
| + && node is! HEquals) {
|
| + Selector selector = new Selector.binaryOperator(operation.name);
|
| return fromInterceptorToDynamicInvocation(node, selector);
|
| }
|
| return node;
|
|
|