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

Side by Side Diff: tests/language/load_to_load_forwarding_vm_test.dart

Issue 16430002: Ensure that all phis inserted by load optimizer have consistent representation. (Closed) Base URL: https://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
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 // Test correctness of side effects tracking used by load to load forwarding. 4 // Test correctness of side effects tracking used by load to load forwarding.
5 5
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 import "dart:typed_data";
7 8
8 class A { 9 class A {
9 var x, y; 10 var x, y;
10 A(this.x, this.y); 11 A(this.x, this.y);
11 } 12 }
12 13
13 foo(a) { 14 foo(a) {
14 var value1 = a.x; 15 var value1 = a.x;
15 var value2 = a.y; 16 var value2 = a.y;
16 for (var j = 1; j < 4; j++) { 17 for (var j = 1; j < 4; j++) {
(...skipping 26 matching lines...) Expand all
43 return arr.length; // Immutable length load. 44 return arr.length; // Immutable length load.
44 } 45 }
45 46
46 if (arr.length < 2) { // Mutable length load, should not be forwarded. 47 if (arr.length < 2) { // Mutable length load, should not be forwarded.
47 arr.add(null); 48 arr.add(null);
48 } 49 }
49 50
50 return arr.length; 51 return arr.length;
51 } 52 }
52 53
54
55 testPhiRepresentation(f, arr) {
56 if (f) {
57 arr[0] = arr[0] + arr[1];
58 } else {
59 arr[0] = arr[0] - arr[1];
60 }
61 return arr[0];
62 }
63
64
65 testPhiConvertions(f, arr) {
66 if (f) {
67 arr[0] = arr[1];
68 } else {
69 arr[0] = arr[2];
70 }
71 return arr[0];
72 }
73
53 main() { 74 main() {
54 final fixed = new List(10); 75 final fixed = new List(10);
55 final growable = []; 76 final growable = [];
56 testImmutableVMFields(fixed, true); 77 testImmutableVMFields(fixed, true);
57 testImmutableVMFields(growable, false); 78 testImmutableVMFields(growable, false);
58 testImmutableVMFields(growable, false); 79 testImmutableVMFields(growable, false);
59 80
81 final f64List = new Float64List(2);
82 testPhiRepresentation(true, f64List);
83 testPhiRepresentation(false, f64List);
84
60 for (var i = 0; i < 2000; i++) { 85 for (var i = 0; i < 2000; i++) {
61 Expect.listEquals([0x02010000, 0x03020100], foo(new A(0, 0))); 86 Expect.listEquals([0x02010000, 0x03020100], foo(new A(0, 0)));
62 Expect.listEquals([0x02010000, 0x03020100], bar(new A(0, 0), false)); 87 Expect.listEquals([0x02010000, 0x03020100], bar(new A(0, 0), false));
63 Expect.listEquals([0x04020000, 0x03020100], bar(new A(0, 0), true)); 88 Expect.listEquals([0x04020000, 0x03020100], bar(new A(0, 0), true));
64 testImmutableVMFields(fixed, true); 89 testImmutableVMFields(fixed, true);
90 testPhiRepresentation(true, f64List);
65 } 91 }
66 92
67 Expect.equals(1, testImmutableVMFields([], false)); 93 Expect.equals(1, testImmutableVMFields([], false));
68 Expect.equals(2, testImmutableVMFields([1], false)); 94 Expect.equals(2, testImmutableVMFields([1], false));
69 Expect.equals(2, testImmutableVMFields([1, 2], false)); 95 Expect.equals(2, testImmutableVMFields([1, 2], false));
70 Expect.equals(3, testImmutableVMFields([1, 2, 3], false)); 96 Expect.equals(3, testImmutableVMFields([1, 2, 3], false));
71 } 97
98 final u32List = new Uint32List(3);
99 u32List[0] = 0;
100 u32List[1] = 0x3FFFFFFF;
101 u32List[2] = 0x7FFFFFFF;
102
103 for (var i = 0; i < 4000; i++) {
104 testPhiConvertions(true, u32List);
105 testPhiConvertions(false, u32List);
106 }
107 }
OLDNEW
« runtime/vm/flow_graph_optimizer.cc ('K') | « tests/language/load_to_load_forwarding_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698