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

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

Issue 255843005: Avoid generating VariableUse nodes with non-identifier names (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_emitter/type_test_emitter.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 List<DartType> instantiatedTypes = node.instantiatedTypes; 1604 List<DartType> instantiatedTypes = node.instantiatedTypes;
1605 1605
1606 world.registerStaticUse(element); 1606 world.registerStaticUse(element);
1607 1607
1608 if (instantiatedTypes != null && !instantiatedTypes.isEmpty) { 1608 if (instantiatedTypes != null && !instantiatedTypes.isEmpty) {
1609 instantiatedTypes.forEach((type) { 1609 instantiatedTypes.forEach((type) {
1610 world.registerInstantiatedType(type, work.resolutionTree); 1610 world.registerInstantiatedType(type, work.resolutionTree);
1611 }); 1611 });
1612 } 1612 }
1613 1613
1614 push(new js.VariableUse(backend.namer.isolateAccess(node.element))); 1614 push(backend.namer.elementAccess(node.element));
1615 push(new js.Call(pop(), visitArguments(node.inputs, start: 0)), node); 1615 push(new js.Call(pop(), visitArguments(node.inputs, start: 0)), node);
1616 } 1616 }
1617 1617
1618 visitInvokeSuper(HInvokeSuper node) { 1618 visitInvokeSuper(HInvokeSuper node) {
1619 Element superMethod = node.element; 1619 Element superMethod = node.element;
1620 world.registerStaticUse(superMethod); 1620 world.registerStaticUse(superMethod);
1621 ClassElement superClass = superMethod.getEnclosingClass(); 1621 ClassElement superClass = superMethod.getEnclosingClass();
1622 if (superMethod.kind == ElementKind.FIELD) { 1622 if (superMethod.kind == ElementKind.FIELD) {
1623 String fieldName = backend.namer.instanceFieldPropertyName(superMethod); 1623 String fieldName = backend.namer.instanceFieldPropertyName(superMethod);
1624 use(node.inputs[0]); 1624 use(node.inputs[0]);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 interpolatedExpressions.add(pop()); 1736 interpolatedExpressions.add(pop());
1737 } 1737 }
1738 push(node.codeTemplate.instantiate(interpolatedExpressions)); 1738 push(node.codeTemplate.instantiate(interpolatedExpressions));
1739 } 1739 }
1740 1740
1741 // TODO(sra): Tell world.nativeEnqueuer about the types created here. 1741 // TODO(sra): Tell world.nativeEnqueuer about the types created here.
1742 registerForeignTypes(node); 1742 registerForeignTypes(node);
1743 } 1743 }
1744 1744
1745 visitForeignNew(HForeignNew node) { 1745 visitForeignNew(HForeignNew node) {
1746 String jsClassReference = backend.namer.isolateAccess(node.element); 1746 js.Expression jsClassReference = backend.namer.elementAccess(node.element);
1747 List<js.Expression> arguments = visitArguments(node.inputs, start: 0); 1747 List<js.Expression> arguments = visitArguments(node.inputs, start: 0);
1748 // TODO(floitsch): jsClassReference is an Access. We shouldn't treat it 1748 push(new js.New(jsClassReference, arguments), node);
1749 // as if it was a string.
1750 push(new js.New(new js.VariableUse(jsClassReference), arguments), node);
1751 registerForeignTypes(node); 1749 registerForeignTypes(node);
1752 if (node.instantiatedTypes == null) { 1750 if (node.instantiatedTypes == null) {
1753 return; 1751 return;
1754 } 1752 }
1755 node.instantiatedTypes.forEach((type) { 1753 node.instantiatedTypes.forEach((type) {
1756 world.registerInstantiatedType(type, work.resolutionTree); 1754 world.registerInstantiatedType(type, work.resolutionTree);
1757 }); 1755 });
1758 } 1756 }
1759 1757
1760 js.Expression newLiteralBool(bool value) { 1758 js.Expression newLiteralBool(bool value) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 thenBody = unwrapStatement(thenBody); 1974 thenBody = unwrapStatement(thenBody);
1977 pushStatement(new js.If.noElse(underOver, thenBody), node); 1975 pushStatement(new js.If.noElse(underOver, thenBody), node);
1978 } else { 1976 } else {
1979 generateThrowWithHelper('ioore', [node.array, node.index]); 1977 generateThrowWithHelper('ioore', [node.array, node.index]);
1980 } 1978 }
1981 } 1979 }
1982 1980
1983 void generateThrowWithHelper(String helperName, argument) { 1981 void generateThrowWithHelper(String helperName, argument) {
1984 Element helper = compiler.findHelper(helperName); 1982 Element helper = compiler.findHelper(helperName);
1985 world.registerStaticUse(helper); 1983 world.registerStaticUse(helper);
1986 js.VariableUse jsHelper = 1984 js.Expression jsHelper = backend.namer.elementAccess(helper);
1987 new js.VariableUse(backend.namer.isolateAccess(helper));
1988 List arguments = []; 1985 List arguments = [];
1989 var location; 1986 var location;
1990 if (argument is List) { 1987 if (argument is List) {
1991 location = argument[0]; 1988 location = argument[0];
1992 argument.forEach((instruction) { 1989 argument.forEach((instruction) {
1993 use(instruction); 1990 use(instruction);
1994 arguments.add(pop()); 1991 arguments.add(pop());
1995 }); 1992 });
1996 } else { 1993 } else {
1997 location = argument; 1994 location = argument;
(...skipping 12 matching lines...) Expand all
2010 } 2007 }
2011 } 2008 }
2012 2009
2013 visitThrowExpression(HThrowExpression node) { 2010 visitThrowExpression(HThrowExpression node) {
2014 HInstruction argument = node.inputs[0]; 2011 HInstruction argument = node.inputs[0];
2015 use(argument); 2012 use(argument);
2016 2013
2017 Element helper = compiler.findHelper("throwExpression"); 2014 Element helper = compiler.findHelper("throwExpression");
2018 world.registerStaticUse(helper); 2015 world.registerStaticUse(helper);
2019 2016
2020 js.VariableUse jsHelper = 2017 js.Expression jsHelper = backend.namer.elementAccess(helper);
2021 new js.VariableUse(backend.namer.isolateAccess(helper));
2022 js.Call value = new js.Call(jsHelper, [pop()]); 2018 js.Call value = new js.Call(jsHelper, [pop()]);
2023 value = attachLocation(value, argument); 2019 value = attachLocation(value, argument);
2024 push(value, node); 2020 push(value, node);
2025 } 2021 }
2026 2022
2027 void visitSwitch(HSwitch node) { 2023 void visitSwitch(HSwitch node) {
2028 // Switches are handled using [visitSwitchInfo]. 2024 // Switches are handled using [visitSwitchInfo].
2029 } 2025 }
2030 2026
2031 void visitStatic(HStatic node) { 2027 void visitStatic(HStatic node) {
2032 Element element = node.element; 2028 Element element = node.element;
2033 if (element.isFunction()) { 2029 if (element.isFunction()) {
2034 push(new js.VariableUse( 2030 push(backend.namer.isolateStaticClosureAccess(node.element));
2035 backend.namer.isolateStaticClosureAccess(node.element)));
2036 } else { 2031 } else {
2037 push(new js.VariableUse(backend.namer.isolateAccess(node.element))); 2032 push(backend.namer.elementAccess(node.element));
2038 } 2033 }
2039 world.registerStaticUse(element); 2034 world.registerStaticUse(element);
2040 } 2035 }
2041 2036
2042 void visitLazyStatic(HLazyStatic node) { 2037 void visitLazyStatic(HLazyStatic node) {
2043 Element element = node.element; 2038 Element element = node.element;
2044 world.registerStaticUse(element); 2039 world.registerStaticUse(element);
2045 String lazyGetter = backend.namer.isolateLazyInitializerAccess(element); 2040 js.Expression lazyGetter =
2046 js.VariableUse target = new js.VariableUse(lazyGetter); 2041 backend.namer.isolateLazyInitializerAccess(element);
2047 js.Call call = new js.Call(target, <js.Expression>[]); 2042 js.Call call = new js.Call(lazyGetter, <js.Expression>[]);
2048 push(call, node); 2043 push(call, node);
2049 } 2044 }
2050 2045
2051 void visitStaticStore(HStaticStore node) { 2046 void visitStaticStore(HStaticStore node) {
2052 world.registerStaticUse(node.element); 2047 world.registerStaticUse(node.element);
2053 js.Node variable = backend.namer.elementAccess(node.element); 2048 js.Node variable = backend.namer.elementAccess(node.element);
2054 use(node.inputs[0]); 2049 use(node.inputs[0]);
2055 push(new js.Assignment(variable, pop()), node); 2050 push(new js.Assignment(variable, pop()), node);
2056 } 2051 }
2057 2052
(...skipping 16 matching lines...) Expand all
2074 && node.usedBy[0] is HStringConcat 2069 && node.usedBy[0] is HStringConcat
2075 && node.usedBy[0].inputs[1] == node) { 2070 && node.usedBy[0].inputs[1] == node) {
2076 // The context is already <string> + value. 2071 // The context is already <string> + value.
2077 } else { 2072 } else {
2078 // Force an empty string for the first operand. 2073 // Force an empty string for the first operand.
2079 push(new js.Binary('+', js.string(""), pop()), node); 2074 push(new js.Binary('+', js.string(""), pop()), node);
2080 } 2075 }
2081 } else { 2076 } else {
2082 Element convertToString = backend.getStringInterpolationHelper(); 2077 Element convertToString = backend.getStringInterpolationHelper();
2083 world.registerStaticUse(convertToString); 2078 world.registerStaticUse(convertToString);
2084 js.VariableUse variableUse = 2079 js.Expression jsHelper = backend.namer.elementAccess(convertToString);
2085 new js.VariableUse(backend.namer.isolateAccess(convertToString));
2086 use(input); 2080 use(input);
2087 push(new js.Call(variableUse, <js.Expression>[pop()]), node); 2081 push(new js.Call(jsHelper, <js.Expression>[pop()]), node);
2088 } 2082 }
2089 } 2083 }
2090 2084
2091 void visitLiteralList(HLiteralList node) { 2085 void visitLiteralList(HLiteralList node) {
2092 world.registerInstantiatedClass( 2086 world.registerInstantiatedClass(
2093 compiler.listClass, work.resolutionTree); 2087 compiler.listClass, work.resolutionTree);
2094 generateArrayLiteral(node); 2088 generateArrayLiteral(node);
2095 } 2089 }
2096 2090
2097 void generateArrayLiteral(HLiteralList node) { 2091 void generateArrayLiteral(HLiteralList node) {
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
2681 js.PropertyAccess accessHelper(String name) { 2675 js.PropertyAccess accessHelper(String name) {
2682 Element helper = compiler.findHelper(name); 2676 Element helper = compiler.findHelper(name);
2683 if (helper == null) { 2677 if (helper == null) {
2684 // For mocked-up tests. 2678 // For mocked-up tests.
2685 return js.js('(void 0).$name'); 2679 return js.js('(void 0).$name');
2686 } 2680 }
2687 world.registerStaticUse(helper); 2681 world.registerStaticUse(helper);
2688 return backend.namer.elementAccess(helper); 2682 return backend.namer.elementAccess(helper);
2689 } 2683 }
2690 } 2684 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_emitter/type_test_emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698