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

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

Issue 19097003: Support new malformed types semantics. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix unittests. Created 7 years, 4 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 Element element = type.element; 533 Element element = type.element;
534 534
535 if (!node.isRawCheck) { 535 if (!node.isRawCheck) {
536 return node; 536 return node;
537 } else if (element.isTypedef()) { 537 } else if (element.isTypedef()) {
538 return node; 538 return node;
539 } else if (element == compiler.functionClass) { 539 } else if (element == compiler.functionClass) {
540 return node; 540 return node;
541 } 541 }
542 542
543 if (element == compiler.objectClass || element == compiler.dynamicClass) { 543 if (element == compiler.objectClass || type.treatAsDynamic) {
544 return graph.addConstantBool(true, compiler); 544 return graph.addConstantBool(true, compiler);
545 } 545 }
546 546
547 HType expressionType = node.expression.instructionType; 547 HType expressionType = node.expression.instructionType;
548 if (expressionType.isInteger()) { 548 if (expressionType.isInteger()) {
549 if (identical(element, compiler.intClass) 549 if (identical(element, compiler.intClass)
550 || identical(element, compiler.numClass) 550 || identical(element, compiler.numClass)
551 || Elements.isNumberOrStringSupertype(element, compiler)) { 551 || Elements.isNumberOrStringSupertype(element, compiler)) {
552 return graph.addConstantBool(true, compiler); 552 return graph.addConstantBool(true, compiler);
553 } else if (identical(element, compiler.doubleClass)) { 553 } else if (identical(element, compiler.doubleClass)) {
(...skipping 20 matching lines...) Expand all
574 if (identical(element, compiler.numClass)) { 574 if (identical(element, compiler.numClass)) {
575 return graph.addConstantBool(true, compiler); 575 return graph.addConstantBool(true, compiler);
576 } else { 576 } else {
577 // We cannot just return false, because the expression may be of 577 // We cannot just return false, because the expression may be of
578 // type int or double. 578 // type int or double.
579 } 579 }
580 // We need the [:hasTypeArguments:] check because we don't have 580 // We need the [:hasTypeArguments:] check because we don't have
581 // the notion of generics in the backend. For example, [:this:] in 581 // the notion of generics in the backend. For example, [:this:] in
582 // a class [:A<T>:], is currently always considered to have the 582 // a class [:A<T>:], is currently always considered to have the
583 // raw type. 583 // raw type.
584 } else if (!RuntimeTypes.hasTypeArguments(type) && !type.isMalformed) { 584 } else if (!RuntimeTypes.hasTypeArguments(type)) {
585 TypeMask expressionMask = expressionType.computeMask(compiler); 585 TypeMask expressionMask = expressionType.computeMask(compiler);
586 TypeMask typeMask = new TypeMask.nonNullSubtype(type); 586 TypeMask typeMask = new TypeMask.nonNullSubtype(type);
587 if (expressionMask.union(typeMask, compiler) == typeMask) { 587 if (expressionMask.union(typeMask, compiler) == typeMask) {
588 return graph.addConstantBool(true, compiler); 588 return graph.addConstantBool(true, compiler);
589 } else if (expressionMask.intersection(typeMask, compiler).isEmpty) { 589 } else if (expressionMask.intersection(typeMask, compiler).isEmpty) {
590 return graph.addConstantBool(false, compiler); 590 return graph.addConstantBool(false, compiler);
591 } 591 }
592 } 592 }
593 return node; 593 return node;
594 } 594 }
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 // that knows it is not of a specific Type. 1338 // that knows it is not of a specific Type.
1339 } 1339 }
1340 1340
1341 for (HIf ifUser in notIfUsers) { 1341 for (HIf ifUser in notIfUsers) {
1342 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); 1342 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType);
1343 // TODO(ngeoffray): Also change uses for the then block on a HType 1343 // TODO(ngeoffray): Also change uses for the then block on a HType
1344 // that knows it is not of a specific Type. 1344 // that knows it is not of a specific Type.
1345 } 1345 }
1346 } 1346 }
1347 } 1347 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/nodes.dart ('k') | sdk/lib/_internal/compiler/implementation/ssa/types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698