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

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

Issue 10911007: Rename Type to DartType to avoid conflicts with the class Type in the core library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 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 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 } 1472 }
1473 } 1473 }
1474 push(jsPropertyCall(object, methodName, arguments), node); 1474 push(jsPropertyCall(object, methodName, arguments), node);
1475 } 1475 }
1476 1476
1477 Selector getOptimizedSelectorFor(HInvokeDynamic node, 1477 Selector getOptimizedSelectorFor(HInvokeDynamic node,
1478 Selector defaultSelector) { 1478 Selector defaultSelector) {
1479 // TODO(4434): For private members we need to use the untyped selector. 1479 // TODO(4434): For private members we need to use the untyped selector.
1480 if (defaultSelector.name.isPrivate()) return defaultSelector; 1480 if (defaultSelector.name.isPrivate()) return defaultSelector;
1481 HType receiverHType = types[node.inputs[0]]; 1481 HType receiverHType = types[node.inputs[0]];
1482 Type receiverType = receiverHType.computeType(compiler); 1482 DartType receiverType = receiverHType.computeType(compiler);
1483 if (receiverType !== null) { 1483 if (receiverType !== null) {
1484 return new TypedSelector(receiverType, defaultSelector); 1484 return new TypedSelector(receiverType, defaultSelector);
1485 } else { 1485 } else {
1486 return defaultSelector; 1486 return defaultSelector;
1487 } 1487 }
1488 } 1488 }
1489 1489
1490 visitInvokeDynamicSetter(HInvokeDynamicSetter node) { 1490 visitInvokeDynamicSetter(HInvokeDynamicSetter node) {
1491 use(node.receiver); 1491 use(node.receiver);
1492 Selector setter = node.selector; 1492 Selector setter = node.selector;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 push(jsPropertyCall(method, "call", visitArguments(node.inputs)), node); 1572 push(jsPropertyCall(method, "call", visitArguments(node.inputs)), node);
1573 } 1573 }
1574 world.registerStaticUse(superMethod); 1574 world.registerStaticUse(superMethod);
1575 } 1575 }
1576 1576
1577 visitFieldGet(HFieldGet node) { 1577 visitFieldGet(HFieldGet node) {
1578 String name = compiler.namer.getName(node.element); 1578 String name = compiler.namer.getName(node.element);
1579 use(node.receiver); 1579 use(node.receiver);
1580 push(new js.PropertyAccess.field(pop(), name), node); 1580 push(new js.PropertyAccess.field(pop(), name), node);
1581 HType receiverHType = types[node.receiver]; 1581 HType receiverHType = types[node.receiver];
1582 Type type = receiverHType.computeType(compiler); 1582 DartType type = receiverHType.computeType(compiler);
1583 if (type != null) { 1583 if (type != null) {
1584 world.registerFieldGetter( 1584 world.registerFieldGetter(
1585 node.element.name, node.element.getLibrary(), type); 1585 node.element.name, node.element.getLibrary(), type);
1586 } 1586 }
1587 } 1587 }
1588 1588
1589 // Determine if an instruction is a simple number computation 1589 // Determine if an instruction is a simple number computation
1590 // involving only things with guaranteed number types and a given 1590 // involving only things with guaranteed number types and a given
1591 // field. 1591 // field.
1592 bool isSimpleFieldNumberComputation(HInstruction value, HFieldSet node) { 1592 bool isSimpleFieldNumberComputation(HInstruction value, HFieldSet node) {
1593 if (value.guaranteedType.union(HType.NUMBER) == HType.NUMBER) return true; 1593 if (value.guaranteedType.union(HType.NUMBER) == HType.NUMBER) return true;
1594 if (value is HBinaryArithmetic) { 1594 if (value is HBinaryArithmetic) {
1595 return (isSimpleFieldNumberComputation(value.left, node) && 1595 return (isSimpleFieldNumberComputation(value.left, node) &&
1596 isSimpleFieldNumberComputation(value.right, node)); 1596 isSimpleFieldNumberComputation(value.right, node));
1597 } 1597 }
1598 if (value is HFieldGet) return value.element == node.element; 1598 if (value is HFieldGet) return value.element == node.element;
1599 return false; 1599 return false;
1600 } 1600 }
1601 1601
1602 visitFieldSet(HFieldSet node) { 1602 visitFieldSet(HFieldSet node) {
1603 if (work.element.isGenerativeConstructorBody() && 1603 if (work.element.isGenerativeConstructorBody() &&
1604 node.element.isMember() && 1604 node.element.isMember() &&
1605 node.value.hasGuaranteedType() && 1605 node.value.hasGuaranteedType() &&
1606 node.block.dominates(currentGraph.exit)) { 1606 node.block.dominates(currentGraph.exit)) {
1607 backend.updateFieldConstructorSetters(node.element, 1607 backend.updateFieldConstructorSetters(node.element,
1608 node.value.guaranteedType); 1608 node.value.guaranteedType);
1609 } 1609 }
1610 String name = compiler.namer.getName(node.element); 1610 String name = compiler.namer.getName(node.element);
1611 Type type = types[node.receiver].computeType(compiler); 1611 DartType type = types[node.receiver].computeType(compiler);
1612 if (type != null) { 1612 if (type != null) {
1613 if (!work.element.isGenerativeConstructorBody()) { 1613 if (!work.element.isGenerativeConstructorBody()) {
1614 world.registerFieldSetter( 1614 world.registerFieldSetter(
1615 node.element.name, node.element.getLibrary(), type); 1615 node.element.name, node.element.getLibrary(), type);
1616 } 1616 }
1617 // Determine the types seen so far for the field. If only number 1617 // Determine the types seen so far for the field. If only number
1618 // types have been seen and the value of the field set is a 1618 // types have been seen and the value of the field set is a
1619 // simple number computation only depending on that field, we 1619 // simple number computation only depending on that field, we
1620 // can safely keep the number type for the field. 1620 // can safely keep the number type for the field.
1621 HType fieldSettersType = backend.fieldSettersTypeSoFar(node.element); 1621 HType fieldSettersType = backend.fieldSettersTypeSoFar(node.element);
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 js.Expression objectTest = pop(); 2223 js.Expression objectTest = pop();
2224 checkArray(input, '==='); 2224 checkArray(input, '===');
2225 js.Expression arrayTest = pop(); 2225 js.Expression arrayTest = pop();
2226 checkType(input, element); 2226 checkType(input, element);
2227 push(new js.Binary('&&', 2227 push(new js.Binary('&&',
2228 objectTest, 2228 objectTest,
2229 new js.Binary('||', arrayTest, pop()))); 2229 new js.Binary('||', arrayTest, pop())));
2230 } 2230 }
2231 2231
2232 void visitIs(HIs node) { 2232 void visitIs(HIs node) {
2233 Type type = node.typeExpression; 2233 DartType type = node.typeExpression;
2234 Element element = type.element; 2234 Element element = type.element;
2235 if (element.kind === ElementKind.TYPE_VARIABLE) { 2235 if (element.kind === ElementKind.TYPE_VARIABLE) {
2236 compiler.unimplemented("visitIs for type variables", instruction: node); 2236 compiler.unimplemented("visitIs for type variables", instruction: node);
2237 } else if (element.kind === ElementKind.TYPEDEF) { 2237 } else if (element.kind === ElementKind.TYPEDEF) {
2238 compiler.unimplemented("visitIs for typedefs", instruction: node); 2238 compiler.unimplemented("visitIs for typedefs", instruction: node);
2239 } 2239 }
2240 LibraryElement coreLibrary = compiler.coreLibrary; 2240 LibraryElement coreLibrary = compiler.coreLibrary;
2241 ClassElement objectClass = compiler.objectClass; 2241 ClassElement objectClass = compiler.objectClass;
2242 HInstruction input = node.expression; 2242 HInstruction input = node.expression;
2243 2243
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 js.Expression objectTest = pop(); 2277 js.Expression objectTest = pop();
2278 checkType(input, element); 2278 checkType(input, element);
2279 push(new js.Binary('&&', objectTest, pop()), node); 2279 push(new js.Binary('&&', objectTest, pop()), node);
2280 } else { 2280 } else {
2281 checkType(input, element); 2281 checkType(input, element);
2282 attachLocationToLast(node); 2282 attachLocationToLast(node);
2283 } 2283 }
2284 if (node.hasTypeInfo()) { 2284 if (node.hasTypeInfo()) {
2285 InterfaceType interfaceType = type; 2285 InterfaceType interfaceType = type;
2286 ClassElement cls = type.element; 2286 ClassElement cls = type.element;
2287 Link<Type> arguments = interfaceType.arguments; 2287 Link<DartType> arguments = interfaceType.arguments;
2288 js.Expression result = pop(); 2288 js.Expression result = pop();
2289 for (TypeVariableType typeVariable in cls.typeVariables) { 2289 for (TypeVariableType typeVariable in cls.typeVariables) {
2290 use(node.typeInfoCall); 2290 use(node.typeInfoCall);
2291 // TODO(johnniwinther): Retrieve the type name properly and not through 2291 // TODO(johnniwinther): Retrieve the type name properly and not through
2292 // [toString]. Note: Two cases below [typeVariable] and 2292 // [toString]. Note: Two cases below [typeVariable] and
2293 // [arguments.head]. 2293 // [arguments.head].
2294 js.PropertyAccess field = 2294 js.PropertyAccess field =
2295 new js.PropertyAccess.field(pop(), typeVariable.toString()); 2295 new js.PropertyAccess.field(pop(), typeVariable.toString());
2296 js.Expression genericName = new js.LiteralString("'${arguments.head}'"); 2296 js.Expression genericName = new js.LiteralString("'${arguments.head}'");
2297 js.Binary eqTest = new js.Binary('===', field, genericName); 2297 js.Binary eqTest = new js.Binary('===', field, genericName);
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
2711 bool visitLoopInfo(HLoopBlockInformation info) { 2711 bool visitLoopInfo(HLoopBlockInformation info) {
2712 if (info.start.hasBailoutTargets()) return false; 2712 if (info.start.hasBailoutTargets()) return false;
2713 if (info.loopHeader.hasBailoutTargets()) return false; 2713 if (info.loopHeader.hasBailoutTargets()) return false;
2714 return super.visitLoopInfo(info); 2714 return super.visitLoopInfo(info);
2715 } 2715 }
2716 2716
2717 bool visitTryInfo(HTryBlockInformation info) => false; 2717 bool visitTryInfo(HTryBlockInformation info) => false;
2718 bool visitSequenceInfo(HStatementSequenceInformation info) => false; 2718 bool visitSequenceInfo(HStatementSequenceInformation info) => false;
2719 2719
2720 void visitTypeGuard(HTypeGuard node) { 2720 void visitTypeGuard(HTypeGuard node) {
2721 // Do nothing. Type guards are only used in the optimized version. 2721 // Do nothing. DartType guards are only used in the optimized version.
kasperl 2012/08/30 14:11:27 Undo this edit.
2722 } 2722 }
2723 2723
2724 void visitBailoutTarget(HBailoutTarget node) { 2724 void visitBailoutTarget(HBailoutTarget node) {
2725 if (!propagator.hasComplexBailoutTargets) return; 2725 if (!propagator.hasComplexBailoutTargets) return;
2726 2726
2727 js.Block nextBlock = new js.Block.empty(); 2727 js.Block nextBlock = new js.Block.empty();
2728 js.Case clause = new js.Case(new js.LiteralNumber('${node.state}'), 2728 js.Case clause = new js.Case(new js.LiteralNumber('${node.state}'),
2729 nextBlock); 2729 nextBlock);
2730 currentBailoutSwitch.cases.add(clause); 2730 currentBailoutSwitch.cases.add(clause);
2731 currentContainer = nextBlock; 2731 currentContainer = nextBlock;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2925 if (leftType.canBeNull() && rightType.canBeNull()) { 2925 if (leftType.canBeNull() && rightType.canBeNull()) {
2926 if (left.isConstantNull() || right.isConstantNull() || 2926 if (left.isConstantNull() || right.isConstantNull() ||
2927 (leftType.isPrimitive() && leftType == rightType)) { 2927 (leftType.isPrimitive() && leftType == rightType)) {
2928 return '=='; 2928 return '==';
2929 } 2929 }
2930 return null; 2930 return null;
2931 } else { 2931 } else {
2932 return '==='; 2932 return '===';
2933 } 2933 }
2934 } 2934 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698