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

Side by Side Diff: tests/compiler/dart2js/js_backend_cps_ir_gvn_test.dart

Issue 1537663002: dart2js: Initial implementation of inlining. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebaseline test expectations and fix a bug (typo). Created 5 years 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 // Test that the GVN optimization pass works as expected. 5 // Test that the GVN optimization pass works as expected.
6 6
7 library basic_tests; 7 library basic_tests;
8 8
9 import 'js_backend_cps_ir.dart'; 9 import 'js_backend_cps_ir.dart';
10 10
11 const List<TestEntry> tests = const [ 11 const List<TestEntry> tests = const [
12 const TestEntry.forMethod('function(foo)', r""" 12 const TestEntry(r"""
13 foo(x, list) { 13 foo(x, list) {
14 var sum = 0; 14 var sum = 0;
15 for (int k = 0; k < 10; k++) { 15 for (int k = 0; k < 10; k++) {
16 // Everything can be hoisted out up to the index access which is 16 // Everything can be hoisted out up to the index access which is
17 // blocked by the bounds check. 17 // blocked by the bounds check.
18 var a = x.left.left; 18 var a = x.left.left;
19 var b = x.left.right; 19 var b = x.left.right;
20 var c = x.right.left; 20 var c = x.right.left;
21 var d = x.right.right; 21 var d = x.right.right;
22 var i = a.value + c.value; 22 var i = a.value + c.value;
(...skipping 21 matching lines...) Expand all
44 var x1 = new Leaf(1); 44 var x1 = new Leaf(1);
45 var x2 = new Leaf(10); 45 var x2 = new Leaf(10);
46 var x3 = new Leaf(20); 46 var x3 = new Leaf(20);
47 var x4 = new Leaf(-10); 47 var x4 = new Leaf(-10);
48 var y1 = new Branch(x1, x2); 48 var y1 = new Branch(x1, x2);
49 var y2 = new Branch(x3, x4); 49 var y2 = new Branch(x3, x4);
50 var z = new Root(y1, y2); 50 var z = new Root(y1, y2);
51 print(foo(z, [1,2,3,4,5,6,7,8,9,10])); 51 print(foo(z, [1,2,3,4,5,6,7,8,9,10]));
52 } 52 }
53 """,r""" 53 """,r"""
54 function(x, list) { 54 function() {
55 var v0 = x.left, a = v0.left, b = v0.right, sum = 0, k = 0, c = (v0 = x.right) .left, d = v0.right, v1, v2, v3, i, v4; 55 var v0 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], sum = 0, k = 0, i, v1;
56 v0 = a.value; 56 for (; k < 10; sum = sum + (i + v0[v1]), k = k + 1) {
57 v1 = c.value; 57 i = 1 + 20;
58 v2 = b.value; 58 v1 = i * (10 + -10);
59 for (v3 = d.value; k < 10; sum = sum + (i + list[v4]), k = k + 1) { 59 if (v1 < 0 || v1 >= 10)
60 i = v0 + v1; 60 return H.ioore(v0, v1);
61 v4 = i * (v2 + v3);
62 if (v4 < 0 || v4 >= 10)
63 return H.ioore(list, v4);
64 } 61 }
65 return sum; 62 v0 = H.S(sum);
63 if (typeof dartPrint == "function")
64 dartPrint(v0);
65 else if (typeof console == "object" && typeof console.log != "undefined")
66 console.log(v0);
67 else if (!(typeof window == "object")) {
68 if (!(typeof print == "function"))
69 throw "Unable to print message: " + String(v0);
70 print(v0);
71 }
66 }"""), 72 }"""),
67 ]; 73 ];
68 74
69 void main() { 75 void main() {
70 runTests(tests); 76 runTests(tests);
71 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698