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

Unified Diff: lib/compiler/implementation/ssa/builder.dart

Issue 10910092: Improvements for checked mode: check when intializing fields, and when assigning to fields. (Closed) Base URL: http://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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/builder.dart
===================================================================
--- lib/compiler/implementation/ssa/builder.dart (revision 11954)
+++ lib/compiler/implementation/ssa/builder.dart (working copy)
@@ -1213,7 +1213,8 @@
includeBackendMembers: true,
includeSuperMembers: true,
f: (ClassElement enclosingClass, Element member) {
- constructorArguments.add(fieldValues[member]);
+ constructorArguments.add(
+ potentiallyCheckType(fieldValues[member], member));
});
HForeignNew newObject = new HForeignNew(classElement, constructorArguments);
@@ -1355,35 +1356,12 @@
HInstruction potentiallyCheckType(HInstruction original,
Element sourceElement) {
if (!compiler.enableTypeAssertions) return original;
- return convertType(original, sourceElement,
- HTypeConversion.CHECKED_MODE_CHECK);
+ HInstruction other = original.convertType(
+ compiler, sourceElement, HTypeConversion.CHECKED_MODE_CHECK);
+ if (other != original) add(other);
+ return other;
}
- HInstruction convertType(HInstruction original,
- Element sourceElement,
- int kind) {
- DartType type = sourceElement.computeType(compiler);
- if (type === null) return original;
- if (type.element === compiler.dynamicClass) return original;
- if (type.element === compiler.objectClass) return original;
-
- // If the original can't be null, type conversion also can't produce null.
- bool canBeNull = original.guaranteedType.canBeNull();
- HType convertedType =
- new HType.fromBoundedType(type, compiler, canBeNull);
-
- // No need to convert if we know the instruction has
- // [convertedType] as a bound.
- if (original.guaranteedType == convertedType) {
- return original;
- }
-
- HInstruction instruction =
- new HTypeConversion(convertedType, original, kind);
- add(instruction);
- return instruction;
- }
-
HGraph closeFunction() {
// TODO(kasperl): Make this goto an implicit return.
if (!isAborted()) close(new HGoto()).addSuccessor(graph.exit);
@@ -2211,8 +2189,9 @@
Node argument = node.arguments.head;
TypeAnnotation typeAnnotation = argument.asTypeAnnotation();
DartType type = elements.getType(typeAnnotation);
- HInstruction converted = convertType(expression, type.element,
- HTypeConversion.CAST_TYPE_CHECK);
+ HInstruction converted = expression.convertType(
+ compiler, type.element, HTypeConversion.CAST_TYPE_CHECK);
+ if (converted != expression) add(converted);
stack.add(converted);
} else {
visit(node.receiver);
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698