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

Unified Diff: tests/compiler/dart2js/generate_at_use_site_test.dart

Issue 16510003: Make [HTypeConversion] with NO_CHECK code motion invariant to ensure no code is generated for it. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/nodes.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/generate_at_use_site_test.dart
===================================================================
--- tests/compiler/dart2js/generate_at_use_site_test.dart (revision 23847)
+++ tests/compiler/dart2js/generate_at_use_site_test.dart (working copy)
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String FIB = r"""
@@ -34,6 +35,19 @@
}
""";
+// Test that a synthesized [HTypeConversion] node added due to the is
+// check is code motion invariant. No 'else' should be generated in
+// this code snippet (the new [HTypeConversion] is put in the else
+// branch, but the else branch dominates the rest of the code in this
+// snippet).
+const String TEST = r"""
+foo(a) {
+ if (a is !int) throw a;
+ if (a < 0) throw a;
+ return a + a;
+}
+""";
+
main() {
// Make sure we don't introduce a new variable.
RegExp regexp = new RegExp("var $anyIdentifier =");
@@ -41,4 +55,10 @@
regexp = new RegExp("isLeaf");
compileAndDoNotMatch(BAR, 'bar', regexp);
+
+ String generated = compile(TEST, entry: 'foo');
+ Expect.isFalse(generated.contains('else'));
+ // Regression check to ensure that there is no floating variable
+ // expression.
+ Expect.isFalse(new RegExp('^[ ]*a;').hasMatch(generated));
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/nodes.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698