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

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

Issue 304153014: Remove element from DynamicType. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix infinite loop. Created 6 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 abstract class OptimizationPhase { 7 abstract class OptimizationPhase {
8 String get name; 8 String get name;
9 void visitGraph(HGraph graph); 9 void visitGraph(HGraph graph);
10 } 10 }
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 simplifyCondition(node.elseBlock, condition, isNegated); 570 simplifyCondition(node.elseBlock, condition, isNegated);
571 return node; 571 return node;
572 } 572 }
573 573
574 HInstruction visitIs(HIs node) { 574 HInstruction visitIs(HIs node) {
575 DartType type = node.typeExpression; 575 DartType type = node.typeExpression;
576 Element element = type.element; 576 Element element = type.element;
577 577
578 if (!node.isRawCheck) { 578 if (!node.isRawCheck) {
579 return node; 579 return node;
580 } else if (element.isTypedef) { 580 } else if (type.isTypedef) {
581 return node; 581 return node;
582 } else if (element == compiler.functionClass) { 582 } else if (element == compiler.functionClass) {
583 return node; 583 return node;
584 } 584 }
585 585
586 if (element == compiler.objectClass || type.treatAsDynamic) { 586 if (element == compiler.objectClass || type.treatAsDynamic) {
587 return graph.addConstantBool(true, compiler); 587 return graph.addConstantBool(true, compiler);
588 } 588 }
589 589
590 HInstruction expression = node.expression; 590 HInstruction expression = node.expression;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 return graph.addConstantBool(false, compiler); 639 return graph.addConstantBool(false, compiler);
640 } 640 }
641 } 641 }
642 return node; 642 return node;
643 } 643 }
644 644
645 HInstruction visitTypeConversion(HTypeConversion node) { 645 HInstruction visitTypeConversion(HTypeConversion node) {
646 HInstruction value = node.inputs[0]; 646 HInstruction value = node.inputs[0];
647 DartType type = node.typeExpression; 647 DartType type = node.typeExpression;
648 if (type != null) { 648 if (type != null) {
649 if (type.kind == TypeKind.MALFORMED_TYPE) { 649 if (type.isMalformed) {
650 // Malformed types are treated as dynamic statically, but should 650 // Malformed types are treated as dynamic statically, but should
651 // throw a type error at runtime. 651 // throw a type error at runtime.
652 return node; 652 return node;
653 } 653 }
654 if (!type.treatAsRaw || type.kind == TypeKind.TYPE_VARIABLE) { 654 if (!type.treatAsRaw || type.isTypeVariable) {
655 return node; 655 return node;
656 } 656 }
657 if (type.kind == TypeKind.FUNCTION) { 657 if (type.isFunctionType) {
658 // TODO(johnniwinther): Optimize function type conversions. 658 // TODO(johnniwinther): Optimize function type conversions.
659 return node; 659 return node;
660 } 660 }
661 } 661 }
662 return removeIfCheckAlwaysSucceeds(node, node.checkedType); 662 return removeIfCheckAlwaysSucceeds(node, node.checkedType);
663 } 663 }
664 664
665 HInstruction visitTypeKnown(HTypeKnown node) { 665 HInstruction visitTypeKnown(HTypeKnown node) {
666 return removeIfCheckAlwaysSucceeds(node, node.knownType); 666 return removeIfCheckAlwaysSucceeds(node, node.knownType);
667 } 667 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 HInstruction receiver = node.getDartReceiver(compiler); 763 HInstruction receiver = node.getDartReceiver(compiler);
764 VariableElement field = 764 VariableElement field =
765 findConcreteFieldForDynamicAccess(receiver, node.selector); 765 findConcreteFieldForDynamicAccess(receiver, node.selector);
766 if (field == null || !field.isAssignable) return node; 766 if (field == null || !field.isAssignable) return node;
767 // Use [:node.inputs.last:] in case the call follows the 767 // Use [:node.inputs.last:] in case the call follows the
768 // interceptor calling convention, but is not a call on an 768 // interceptor calling convention, but is not a call on an
769 // interceptor. 769 // interceptor.
770 HInstruction value = node.inputs.last; 770 HInstruction value = node.inputs.last;
771 if (compiler.enableTypeAssertions) { 771 if (compiler.enableTypeAssertions) {
772 DartType type = field.type; 772 DartType type = field.type;
773 if (!type.treatAsRaw || type.kind == TypeKind.TYPE_VARIABLE) { 773 if (!type.treatAsRaw || type.isTypeVariable) {
774 // We cannot generate the correct type representation here, so don't 774 // We cannot generate the correct type representation here, so don't
775 // inline this access. 775 // inline this access.
776 return node; 776 return node;
777 } 777 }
778 HInstruction other = value.convertType( 778 HInstruction other = value.convertType(
779 compiler, 779 compiler,
780 type, 780 type,
781 HTypeConversion.CHECKED_MODE_CHECK); 781 HTypeConversion.CHECKED_MODE_CHECK);
782 if (other != value) { 782 if (other != value) {
783 node.block.addBefore(node, other); 783 node.block.addBefore(node, other);
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2115 2115
2116 keyedValues.forEach((receiver, values) { 2116 keyedValues.forEach((receiver, values) {
2117 result.keyedValues[receiver] = 2117 result.keyedValues[receiver] =
2118 new Map<HInstruction, HInstruction>.from(values); 2118 new Map<HInstruction, HInstruction>.from(values);
2119 }); 2119 });
2120 2120
2121 result.nonEscapingReceivers.addAll(nonEscapingReceivers); 2121 result.nonEscapingReceivers.addAll(nonEscapingReceivers);
2122 return result; 2122 return result;
2123 } 2123 }
2124 } 2124 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/nodes.dart ('k') | sdk/lib/_internal/compiler/implementation/typechecker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698