Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart

Issue 15988003: Fix issue 9228, by nopt doing some optimizations in checked mode. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 part of ssa; 5 part of ssa;
6 6
7 class SsaCodeGeneratorTask extends CompilerTask { 7 class SsaCodeGeneratorTask extends CompilerTask {
8 8
9 final JavaScriptBackend backend; 9 final JavaScriptBackend backend;
10 10
(...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 push(node.codeAst, node); 1755 push(node.codeAst, node);
1756 } 1756 }
1757 } 1757 }
1758 1758
1759 registerForeignType(node.instructionType); 1759 registerForeignType(node.instructionType);
1760 // TODO(sra): Tell world.nativeEnqueuer about the types created here. 1760 // TODO(sra): Tell world.nativeEnqueuer about the types created here.
1761 } 1761 }
1762 1762
1763 visitForeignNew(HForeignNew node) { 1763 visitForeignNew(HForeignNew node) {
1764 String jsClassReference = backend.namer.isolateAccess(node.element); 1764 String jsClassReference = backend.namer.isolateAccess(node.element);
1765 List<HInstruction> inputs = node.inputs; 1765 List<js.Expression> arguments = visitArguments(node.inputs, start: 0);
1766 // We can't use 'visitArguments', since our arguments start at input[0].
1767 List<js.Expression> arguments = <js.Expression>[];
1768 for (int i = 0; i < inputs.length; i++) {
1769 use(inputs[i]);
1770 arguments.add(pop());
1771 }
1772 // TODO(floitsch): jsClassReference is an Access. We shouldn't treat it 1766 // TODO(floitsch): jsClassReference is an Access. We shouldn't treat it
1773 // as if it was a string. 1767 // as if it was a string.
1774 push(new js.New(new js.VariableUse(jsClassReference), arguments), node); 1768 push(new js.New(new js.VariableUse(jsClassReference), arguments), node);
1775 registerForeignType(node.instructionType); 1769 registerForeignType(node.instructionType);
1776 } 1770 }
1777 1771
1778 js.Expression newLiteralBool(bool value) { 1772 js.Expression newLiteralBool(bool value) {
1779 if (compiler.enableMinification) { 1773 if (compiler.enableMinification) {
1780 // Use !0 for true, !1 for false. 1774 // Use !0 for true, !1 for false.
1781 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1")); 1775 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1"));
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 } else { 1983 } else {
1990 generateThrowWithHelper('ioore', node.index); 1984 generateThrowWithHelper('ioore', node.index);
1991 } 1985 }
1992 } 1986 }
1993 1987
1994 void generateThrowWithHelper(String helperName, HInstruction argument) { 1988 void generateThrowWithHelper(String helperName, HInstruction argument) {
1995 Element helper = compiler.findHelper(new SourceString(helperName)); 1989 Element helper = compiler.findHelper(new SourceString(helperName));
1996 world.registerStaticUse(helper); 1990 world.registerStaticUse(helper);
1997 js.VariableUse jsHelper = 1991 js.VariableUse jsHelper =
1998 new js.VariableUse(backend.namer.isolateAccess(helper)); 1992 new js.VariableUse(backend.namer.isolateAccess(helper));
1999 js.Call value = new js.Call(jsHelper, visitArguments([null, argument])); 1993 use(argument);
1994 js.Call value = new js.Call(jsHelper, [pop()]);
2000 attachLocation(value, argument); 1995 attachLocation(value, argument);
2001 // BUG(4906): Using throw here adds to the size of the generated code 1996 // BUG(4906): Using throw here adds to the size of the generated code
2002 // but it has the advantage of explicitly telling the JS engine that 1997 // but it has the advantage of explicitly telling the JS engine that
2003 // this code path will terminate abruptly. Needs more work. 1998 // this code path will terminate abruptly. Needs more work.
2004 pushStatement(new js.Throw(value)); 1999 pushStatement(new js.Throw(value));
2005 } 2000 }
2006 2001
2007 visitThrowExpression(HThrowExpression node) { 2002 visitThrowExpression(HThrowExpression node) {
2008 HInstruction argument = node.inputs[0]; 2003 HInstruction argument = node.inputs[0];
2009 use(argument); 2004 use(argument);
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
3041 if (leftType.canBeNull() && rightType.canBeNull()) { 3036 if (leftType.canBeNull() && rightType.canBeNull()) {
3042 if (left.isConstantNull() || right.isConstantNull() || 3037 if (left.isConstantNull() || right.isConstantNull() ||
3043 (leftType.isPrimitive() && leftType == rightType)) { 3038 (leftType.isPrimitive() && leftType == rightType)) {
3044 return '=='; 3039 return '==';
3045 } 3040 }
3046 return null; 3041 return null;
3047 } else { 3042 } else {
3048 return '==='; 3043 return '===';
3049 } 3044 }
3050 } 3045 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698