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

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

Issue 10139012: Refactor types in ssa nodes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 8 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 | « lib/compiler/implementation/ssa/nodes.dart ('k') | lib/compiler/implementation/ssa/ssa.dart » ('j') | 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) 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 return new HEquals(target, node.left, node.right); 334 return new HEquals(target, node.left, node.right);
335 } 335 }
336 } 336 }
337 337
338 // All other cases are dealt with by the [visitInvokeBinary]. 338 // All other cases are dealt with by the [visitInvokeBinary].
339 return visitInvokeBinary(node); 339 return visitInvokeBinary(node);
340 } 340 }
341 341
342 HInstruction visitTypeGuard(HTypeGuard node) { 342 HInstruction visitTypeGuard(HTypeGuard node) {
343 HInstruction value = node.guarded; 343 HInstruction value = node.guarded;
344 HType combinedType = value.propagatedType.combine(node.guardedType); 344 // If the union of the types is still the guarded type than the incoming
345 // type was a subtype of the guarded type, and no check is required.
346 HType combinedType = value.propagatedType.union(node.guardedType);
345 return (combinedType == value.propagatedType) ? value : node; 347 return (combinedType == value.propagatedType) ? value : node;
346 } 348 }
347 349
348 HInstruction visitIs(HIs node) { 350 HInstruction visitIs(HIs node) {
349 Type type = node.typeName; 351 Type type = node.typeName;
350 Element element = type.element; 352 Element element = type.element;
351 if (element.kind === ElementKind.TYPE_VARIABLE) { 353 if (element.kind === ElementKind.TYPE_VARIABLE) {
352 compiler.unimplemented("visitIs for type variables"); 354 compiler.unimplemented("visitIs for type variables");
353 } 355 }
354 356
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 return check; 445 return check;
444 } 446 }
445 447
446 HIntegerCheck insertIntegerCheck(HInstruction node, HInstruction value) { 448 HIntegerCheck insertIntegerCheck(HInstruction node, HInstruction value) {
447 HIntegerCheck check = new HIntegerCheck(value); 449 HIntegerCheck check = new HIntegerCheck(value);
448 node.block.addBefore(node, check); 450 node.block.addBefore(node, check);
449 return check; 451 return check;
450 } 452 }
451 453
452 void visitIndex(HIndex node) { 454 void visitIndex(HIndex node) {
453 if (!node.receiver.isStringOrArray()) return; 455 if (!node.receiver.isIndexablePrimitive()) return;
454 HInstruction index = node.index; 456 HInstruction index = node.index;
455 if (index is HBoundsCheck) return; 457 if (index is HBoundsCheck) return;
456 if (!node.index.isInteger()) { 458 if (!node.index.isInteger()) {
457 index = insertIntegerCheck(node, index); 459 index = insertIntegerCheck(node, index);
458 } 460 }
459 index = insertBoundsCheck(node, node.receiver, index); 461 index = insertBoundsCheck(node, node.receiver, index);
460 HIndex newInstruction = new HIndex(node.target, node.receiver, index); 462 HIndex newInstruction = new HIndex(node.target, node.receiver, index);
461 node.block.addBefore(node, newInstruction); 463 node.block.addBefore(node, newInstruction);
462 node.block.rewrite(node, newInstruction); 464 node.block.rewrite(node, newInstruction);
463 node.block.remove(node); 465 node.block.remove(node);
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 } 865 }
864 } 866 }
865 if (!canBeMoved) continue; 867 if (!canBeMoved) continue;
866 868
867 // This is safe because we are running after GVN. 869 // This is safe because we are running after GVN.
868 // TODO(ngeoffray): ensure GVN has been run. 870 // TODO(ngeoffray): ensure GVN has been run.
869 set_.add(current); 871 set_.add(current);
870 } 872 }
871 } 873 }
872 } 874 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/nodes.dart ('k') | lib/compiler/implementation/ssa/ssa.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698