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

Side by Side Diff: lib/compiler/implementation/ssa/optimize.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 interface OptimizationPhase { 5 interface OptimizationPhase {
6 String get name(); 6 String get name();
7 void visitGraph(HGraph graph); 7 void visitGraph(HGraph graph);
8 } 8 }
9 9
10 class SsaOptimizerTask extends CompilerTask { 10 class SsaOptimizerTask extends CompilerTask {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 HInstruction visitInstruction(HInstruction node) { 148 HInstruction visitInstruction(HInstruction node) {
149 return node; 149 return node;
150 } 150 }
151 151
152 HInstruction visitBoolify(HBoolify node) { 152 HInstruction visitBoolify(HBoolify node) {
153 List<HInstruction> inputs = node.inputs; 153 List<HInstruction> inputs = node.inputs;
154 assert(inputs.length == 1); 154 assert(inputs.length == 1);
155 HInstruction input = inputs[0]; 155 HInstruction input = inputs[0];
156 if (input.isBoolean(types)) return input; 156 if (input.isBoolean(types)) return input;
157 // All values !== true are boolified to false. 157 // All values !== true are boolified to false.
158 Type type = types[input].computeType(compiler); 158 DartType type = types[input].computeType(compiler);
159 if (type !== null && type.element !== compiler.boolClass) { 159 if (type !== null && type.element !== compiler.boolClass) {
160 return graph.addConstantBool(false); 160 return graph.addConstantBool(false);
161 } 161 }
162 return node; 162 return node;
163 } 163 }
164 164
165 HInstruction visitNot(HNot node) { 165 HInstruction visitNot(HNot node) {
166 List<HInstruction> inputs = node.inputs; 166 List<HInstruction> inputs = node.inputs;
167 assert(inputs.length == 1); 167 assert(inputs.length == 1);
168 HInstruction input = inputs[0]; 168 HInstruction input = inputs[0];
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 HInstruction visitTypeGuard(HTypeGuard node) { 484 HInstruction visitTypeGuard(HTypeGuard node) {
485 HInstruction value = node.guarded; 485 HInstruction value = node.guarded;
486 // If the intersection of the types is still the incoming type then 486 // If the intersection of the types is still the incoming type then
487 // the incoming type was a subtype of the guarded type, and no check 487 // the incoming type was a subtype of the guarded type, and no check
488 // is required. 488 // is required.
489 HType combinedType = types[value].intersection(node.guardedType); 489 HType combinedType = types[value].intersection(node.guardedType);
490 return (combinedType == types[value]) ? value : node; 490 return (combinedType == types[value]) ? value : node;
491 } 491 }
492 492
493 HInstruction visitIs(HIs node) { 493 HInstruction visitIs(HIs node) {
494 Type type = node.typeExpression; 494 DartType type = node.typeExpression;
495 Element element = type.element; 495 Element element = type.element;
496 if (element.kind === ElementKind.TYPE_VARIABLE) { 496 if (element.kind === ElementKind.TYPE_VARIABLE) {
497 compiler.unimplemented("visitIs for type variables"); 497 compiler.unimplemented("visitIs for type variables");
498 } 498 }
499 499
500 HType expressionType = types[node.expression]; 500 HType expressionType = types[node.expression];
501 if (element === compiler.objectClass 501 if (element === compiler.objectClass
502 || element === compiler.dynamicClass) { 502 || element === compiler.dynamicClass) {
503 return graph.addConstantBool(true); 503 return graph.addConstantBool(true);
504 } else if (expressionType.isInteger()) { 504 } else if (expressionType.isInteger()) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 if (element === compiler.listClass 539 if (element === compiler.listClass
540 || Elements.isListSupertype(element, compiler)) { 540 || Elements.isListSupertype(element, compiler)) {
541 return graph.addConstantBool(true); 541 return graph.addConstantBool(true);
542 } else { 542 } else {
543 return graph.addConstantBool(false); 543 return graph.addConstantBool(false);
544 } 544 }
545 // TODO(karlklose): remove the hasTypeArguments check. 545 // TODO(karlklose): remove the hasTypeArguments check.
546 } else if (expressionType.isUseful() 546 } else if (expressionType.isUseful()
547 && !expressionType.canBeNull() 547 && !expressionType.canBeNull()
548 && !compiler.codegenWorld.rti.hasTypeArguments(type)) { 548 && !compiler.codegenWorld.rti.hasTypeArguments(type)) {
549 Type receiverType = expressionType.computeType(compiler); 549 DartType receiverType = expressionType.computeType(compiler);
550 if (receiverType !== null) { 550 if (receiverType !== null) {
551 if (compiler.types.isSubtype(receiverType, type)) { 551 if (compiler.types.isSubtype(receiverType, type)) {
552 return graph.addConstantBool(true); 552 return graph.addConstantBool(true);
553 } else if (expressionType.isExact()) { 553 } else if (expressionType.isExact()) {
554 return graph.addConstantBool(false); 554 return graph.addConstantBool(false);
555 } 555 }
556 } 556 }
557 } 557 }
558 return node; 558 return node;
559 } 559 }
560 560
561 HInstruction visitTypeConversion(HTypeConversion node) { 561 HInstruction visitTypeConversion(HTypeConversion node) {
562 HInstruction value = node.inputs[0]; 562 HInstruction value = node.inputs[0];
563 Type type = types[node].computeType(compiler); 563 DartType type = types[node].computeType(compiler);
564 if (type.element === compiler.dynamicClass 564 if (type.element === compiler.dynamicClass
565 || type.element === compiler.objectClass) { 565 || type.element === compiler.objectClass) {
566 return value; 566 return value;
567 } 567 }
568 HType combinedType = types[value].intersection(types[node]); 568 HType combinedType = types[value].intersection(types[node]);
569 return (combinedType == types[value]) ? value : node; 569 return (combinedType == types[value]) ? value : node;
570 } 570 }
571 571
572 Element findConcreteFieldForDynamicAccess(HInstruction receiver, 572 Element findConcreteFieldForDynamicAccess(HInstruction receiver,
573 Selector selector) { 573 Selector selector) {
574 HType receiverType = types[receiver]; 574 HType receiverType = types[receiver];
575 if (!receiverType.isUseful()) return null; 575 if (!receiverType.isUseful()) return null;
576 if (receiverType.canBeNull()) return null; 576 if (receiverType.canBeNull()) return null;
577 Type type = receiverType.computeType(compiler); 577 DartType type = receiverType.computeType(compiler);
578 if (type === null) return null; 578 if (type === null) return null;
579 return compiler.world.locateSingleField(type, selector); 579 return compiler.world.locateSingleField(type, selector);
580 } 580 }
581 581
582 HInstruction visitInvokeDynamicGetter(HInvokeDynamicGetter node) { 582 HInstruction visitInvokeDynamicGetter(HInvokeDynamicGetter node) {
583 Element field = 583 Element field =
584 findConcreteFieldForDynamicAccess(node.receiver, node.selector); 584 findConcreteFieldForDynamicAccess(node.receiver, node.selector);
585 if (field == null) return node; 585 if (field == null) return node;
586 586
587 Modifiers modifiers = field.modifiers; 587 Modifiers modifiers = field.modifiers;
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 // this type for the field is still a strong signal 1327 // this type for the field is still a strong signal
1328 // indicating the expected type of the field. 1328 // indicating the expected type of the field.
1329 types[field] = type; 1329 types[field] = type;
1330 } else { 1330 } else {
1331 // If there are no invoked setters we know the type of 1331 // If there are no invoked setters we know the type of
1332 // this field for sure. 1332 // this field for sure.
1333 field.guaranteedType = type; 1333 field.guaranteedType = type;
1334 } 1334 }
1335 } 1335 }
1336 } 1336 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698