OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 class SsaCodeGeneratorTask extends CompilerTask { | 5 class SsaCodeGeneratorTask extends CompilerTask { |
6 | 6 |
7 final JavaScriptBackend backend; | 7 final JavaScriptBackend backend; |
8 | 8 |
9 SsaCodeGeneratorTask(JavaScriptBackend backend) | 9 SsaCodeGeneratorTask(JavaScriptBackend backend) |
10 : this.backend = backend, | 10 : this.backend = backend, |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 attachLocation(expression, instruction); | 344 attachLocation(expression, instruction); |
345 } | 345 } |
346 expressionStack.add(expression); | 346 expressionStack.add(expression); |
347 } | 347 } |
348 | 348 |
349 js.Expression pop() { | 349 js.Expression pop() { |
350 return expressionStack.removeLast(); | 350 return expressionStack.removeLast(); |
351 } | 351 } |
352 | 352 |
353 attachLocationToLast(HInstruction instruction) { | 353 attachLocationToLast(HInstruction instruction) { |
354 attachLocation(expressionStack.last(), instruction); | 354 attachLocation(expressionStack.last, instruction); |
355 } | 355 } |
356 | 356 |
357 js.Node attachLocation(js.Node jsNode, HInstruction instruction) { | 357 js.Node attachLocation(js.Node jsNode, HInstruction instruction) { |
358 jsNode.sourcePosition = instruction.sourcePosition; | 358 jsNode.sourcePosition = instruction.sourcePosition; |
359 return jsNode; | 359 return jsNode; |
360 } | 360 } |
361 | 361 |
362 js.Node attachLocationRange(js.Node jsNode, | 362 js.Node attachLocationRange(js.Node jsNode, |
363 SourceFileLocation sourcePosition, | 363 SourceFileLocation sourcePosition, |
364 SourceFileLocation endSourcePosition) { | 364 SourceFileLocation endSourcePosition) { |
(...skipping 2321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2686 String label = 'L${labelId++}'; | 2686 String label = 'L${labelId++}'; |
2687 labels.addLast(label); | 2687 labels.addLast(label); |
2688 return label; | 2688 return label; |
2689 } | 2689 } |
2690 | 2690 |
2691 String popLabel() { | 2691 String popLabel() { |
2692 return labels.removeLast(); | 2692 return labels.removeLast(); |
2693 } | 2693 } |
2694 | 2694 |
2695 String currentLabel() { | 2695 String currentLabel() { |
2696 return labels.last(); | 2696 return labels.last; |
2697 } | 2697 } |
2698 | 2698 |
2699 js.VariableUse generateStateUse() | 2699 js.VariableUse generateStateUse() |
2700 => new js.VariableUse(variableNames.stateName); | 2700 => new js.VariableUse(variableNames.stateName); |
2701 | 2701 |
2702 HBasicBlock beginGraph(HGraph graph) { | 2702 HBasicBlock beginGraph(HGraph graph) { |
2703 propagator = new SsaBailoutPropagator(compiler, generateAtUseSite); | 2703 propagator = new SsaBailoutPropagator(compiler, generateAtUseSite); |
2704 propagator.visitGraph(graph); | 2704 propagator.visitGraph(graph); |
2705 // TODO(ngeoffray): We could avoid generating the state at the | 2705 // TODO(ngeoffray): We could avoid generating the state at the |
2706 // call site for non-complex bailout methods. | 2706 // call site for non-complex bailout methods. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2815 i++; | 2815 i++; |
2816 } | 2816 } |
2817 setupBlock.statements.add(new js.Break(null)); | 2817 setupBlock.statements.add(new js.Break(null)); |
2818 js.Case setupClause = | 2818 js.Case setupClause = |
2819 new js.Case(new js.LiteralNumber('${node.state}'), setupBlock); | 2819 new js.Case(new js.LiteralNumber('${node.state}'), setupBlock); |
2820 (setup as js.Switch).cases.add(setupClause); | 2820 (setup as js.Switch).cases.add(setupClause); |
2821 } | 2821 } |
2822 | 2822 |
2823 void startBailoutCase(List<HBailoutTarget> bailouts1, | 2823 void startBailoutCase(List<HBailoutTarget> bailouts1, |
2824 [List<HBailoutTarget> bailouts2 = const []]) { | 2824 [List<HBailoutTarget> bailouts2 = const []]) { |
2825 if (!defaultClauseUsedInBailoutStack.last() && | 2825 if (!defaultClauseUsedInBailoutStack.last && |
2826 bailouts1.length + bailouts2.length >= 2) { | 2826 bailouts1.length + bailouts2.length >= 2) { |
2827 currentContainer = new js.Block.empty(); | 2827 currentContainer = new js.Block.empty(); |
2828 currentBailoutSwitch.cases.add(new js.Default(currentContainer)); | 2828 currentBailoutSwitch.cases.add(new js.Default(currentContainer)); |
2829 int len = defaultClauseUsedInBailoutStack.length; | 2829 int len = defaultClauseUsedInBailoutStack.length; |
2830 defaultClauseUsedInBailoutStack[len - 1] = true; | 2830 defaultClauseUsedInBailoutStack[len - 1] = true; |
2831 } else { | 2831 } else { |
2832 _handleBailoutCase(bailouts1); | 2832 _handleBailoutCase(bailouts1); |
2833 _handleBailoutCase(bailouts2); | 2833 _handleBailoutCase(bailouts2); |
2834 currentContainer = currentBailoutSwitch.cases.last().body; | 2834 currentContainer = currentBailoutSwitch.cases.last.body; |
2835 } | 2835 } |
2836 } | 2836 } |
2837 | 2837 |
2838 void _handleBailoutCase(List<HBailoutTarget> targets) { | 2838 void _handleBailoutCase(List<HBailoutTarget> targets) { |
2839 for (int i = 0, len = targets.length; i < len; i++) { | 2839 for (int i = 0, len = targets.length; i < len; i++) { |
2840 js.LiteralNumber expr = new js.LiteralNumber('${targets[i].state}'); | 2840 js.LiteralNumber expr = new js.LiteralNumber('${targets[i].state}'); |
2841 currentBailoutSwitch.cases.add(new js.Case(expr, new js.Block.empty())); | 2841 currentBailoutSwitch.cases.add(new js.Case(expr, new js.Block.empty())); |
2842 } | 2842 } |
2843 } | 2843 } |
2844 | 2844 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2990 if (leftType.canBeNull() && rightType.canBeNull()) { | 2990 if (leftType.canBeNull() && rightType.canBeNull()) { |
2991 if (left.isConstantNull() || right.isConstantNull() || | 2991 if (left.isConstantNull() || right.isConstantNull() || |
2992 (leftType.isPrimitive() && leftType == rightType)) { | 2992 (leftType.isPrimitive() && leftType == rightType)) { |
2993 return '=='; | 2993 return '=='; |
2994 } | 2994 } |
2995 return null; | 2995 return null; |
2996 } else { | 2996 } else { |
2997 return '==='; | 2997 return '==='; |
2998 } | 2998 } |
2999 } | 2999 } |
OLD | NEW |