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

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

Issue 10389063: Implement PrimitiveOrNull types. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 } else if (expressionType.isExact()) { 541 } else if (expressionType.isExact()) {
542 return graph.addConstantBool(false); 542 return graph.addConstantBool(false);
543 } 543 }
544 } 544 }
545 } 545 }
546 return node; 546 return node;
547 } 547 }
548 548
549 HInstruction visitTypeConversion(HTypeConversion node) { 549 HInstruction visitTypeConversion(HTypeConversion node) {
550 HInstruction value = node.inputs[0]; 550 HInstruction value = node.inputs[0];
551 // If the union of the types is still the input type then 551 Type type = node.propagatedType.computeType(compiler);
552 // no conversion is required. 552 if (type.element === compiler.dynamicClass
553 HType combinedType = value.propagatedType.union(node.propagatedType); 553 || type.element === compiler.objectClass) {
554 return value;
555 }
556 HType combinedType = value.propagatedType.intersection(node.propagatedType);
554 return (combinedType == value.propagatedType) ? value : node; 557 return (combinedType == value.propagatedType) ? value : node;
555 } 558 }
556 559
557 HInstruction visitInvokeDynamicGetter(HInvokeDynamicGetter node) { 560 HInstruction visitInvokeDynamicGetter(HInvokeDynamicGetter node) {
558 HInstruction receiver = node.inputs[0]; 561 HInstruction receiver = node.inputs[0];
559 if (!receiver.propagatedType.isUseful()) return node; 562 if (!receiver.propagatedType.isUseful()) return node;
560 Type type = receiver.propagatedType.computeType(compiler); 563 Type type = receiver.propagatedType.computeType(compiler);
561 if (type === null) return node; 564 if (type === null) return node;
562 if (!compiler.world.isOnlyFields(type, node.name)) return node; 565 if (!compiler.world.isOnlyFields(type, node.name)) return node;
563 return new HFieldGet(node.name, node.inputs[0]); 566 return new HFieldGet(node.name, node.inputs[0]);
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 } 1071 }
1069 user.changeUse(input, newInput); 1072 user.changeUse(input, newInput);
1070 } 1073 }
1071 } 1074 }
1072 } 1075 }
1073 1076
1074 void visitIs(HIs instruction) { 1077 void visitIs(HIs instruction) {
1075 HInstruction input = instruction.expression; 1078 HInstruction input = instruction.expression;
1076 HType convertedType = 1079 HType convertedType =
1077 new HType.fromBoundedType(instruction.typeExpression, compiler); 1080 new HType.fromBoundedType(instruction.typeExpression, compiler);
1078 if (convertedType === null) return;
1079 1081
1080 List<HInstruction> ifUsers = <HInstruction>[]; 1082 List<HInstruction> ifUsers = <HInstruction>[];
1081 List<HInstruction> notIfUsers = <HInstruction>[]; 1083 List<HInstruction> notIfUsers = <HInstruction>[];
1082 1084
1083 for (HInstruction user in instruction.usedBy) { 1085 for (HInstruction user in instruction.usedBy) {
1084 if (user is HIf) { 1086 if (user is HIf) {
1085 ifUsers.add(user); 1087 ifUsers.add(user);
1086 } else if (user is HNot) { 1088 } else if (user is HNot) {
1087 for (HInstruction notUser in user.usedBy) { 1089 for (HInstruction notUser in user.usedBy) {
1088 if (notUser is HIf) notIfUsers.add(notUser); 1090 if (notUser is HIf) notIfUsers.add(notUser);
(...skipping 17 matching lines...) Expand all
1106 // the if block terminates. So any use of the instruction 1108 // the if block terminates. So any use of the instruction
1107 // after the join block should be changed to the new 1109 // after the join block should be changed to the new
1108 // instruction. 1110 // instruction.
1109 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType); 1111 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType);
1110 } 1112 }
1111 // TODO(ngeoffray): Also change uses for the then block on a HType 1113 // TODO(ngeoffray): Also change uses for the then block on a HType
1112 // that knows it is not of a specific Type. 1114 // that knows it is not of a specific Type.
1113 } 1115 }
1114 } 1116 }
1115 } 1117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698