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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/nodes.dart ('k') | no next file » | 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) 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 import "package:expect/expect.dart";
5 import 'compiler_helper.dart'; 6 import 'compiler_helper.dart';
6 7
7 const String FIB = r""" 8 const String FIB = r"""
8 fib(n) { 9 fib(n) {
9 if (n <= 1) return 1; 10 if (n <= 1) return 1;
10 return add(fib(n - 1), fib(n - 2)); 11 return add(fib(n - 1), fib(n - 2));
11 } 12 }
12 13
13 // We need this artificial add method because 14 // We need this artificial add method because
14 // our optimizer will actually add type checks 15 // our optimizer will actually add type checks
(...skipping 12 matching lines...) Expand all
27 var isLeaf = (bar() != null) && bar(); 28 var isLeaf = (bar() != null) && bar();
28 // Because we're using a local variable, the graph gets an empty 29 // Because we're using a local variable, the graph gets an empty
29 // block between the [isLeaf] phi and the next instruction that uses 30 // block between the [isLeaf] phi and the next instruction that uses
30 // it. The optimizer must take that new block into account in order 31 // it. The optimizer must take that new block into account in order
31 // to have the phi be generate at use uste. 32 // to have the phi be generate at use uste.
32 if (isLeaf) return null; 33 if (isLeaf) return null;
33 return true; 34 return true;
34 } 35 }
35 """; 36 """;
36 37
38 // Test that a synthesized [HTypeConversion] node added due to the is
39 // check is code motion invariant. No 'else' should be generated in
40 // this code snippet (the new [HTypeConversion] is put in the else
41 // branch, but the else branch dominates the rest of the code in this
42 // snippet).
43 const String TEST = r"""
44 foo(a) {
45 if (a is !int) throw a;
46 if (a < 0) throw a;
47 return a + a;
48 }
49 """;
50
37 main() { 51 main() {
38 // Make sure we don't introduce a new variable. 52 // Make sure we don't introduce a new variable.
39 RegExp regexp = new RegExp("var $anyIdentifier ="); 53 RegExp regexp = new RegExp("var $anyIdentifier =");
40 compileAndDoNotMatch(FIB, 'fib', regexp); 54 compileAndDoNotMatch(FIB, 'fib', regexp);
41 55
42 regexp = new RegExp("isLeaf"); 56 regexp = new RegExp("isLeaf");
43 compileAndDoNotMatch(BAR, 'bar', regexp); 57 compileAndDoNotMatch(BAR, 'bar', regexp);
58
59 String generated = compile(TEST, entry: 'foo');
60 Expect.isFalse(generated.contains('else'));
61 // Regression check to ensure that there is no floating variable
62 // expression.
63 Expect.isFalse(new RegExp('^[ ]*a;').hasMatch(generated));
44 } 64 }
OLDNEW
« 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