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

Side by Side Diff: tests/language/load_to_load_forwarding_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
(Empty)
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
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.
5
6 import "package:expect/expect.dart";
7
8 class A {
9 var x, y;
10 A(this.x, this.y);
11 }
12
13 foo(a) {
14 var value1 = a.x;
15 var value2 = a.y;
16 for (var j = 1; j < 4; j++) {
17 value1 |= a.x << (j * 8);
18 a.y += 1;
19 a.x += 1;
20 value2 |= a.y << (j * 8);
21 }
22 return [value1, value2];
23 }
24
25 bar(a, mode) {
26 var value1 = a.x;
27 var value2 = a.y;
28 for (var j = 1; j < 4; j++) {
29 value1 |= a.x << (j * 8);
30 a.y += 1;
31 if (mode) a.x += 1;
32 a.x += 1;
33 value2 |= a.y << (j * 8);
34 }
35 return [value1, value2];
36 }
37
38 // Verify that immutable and mutable VM fields (array length in this case)
39 // are not confused by load forwarding even if the access the same offset
40 // in the object.
41 testImmutableVMFields(arr, immutable) {
42 if (immutable) {
43 return arr.length; // Immutable length load.
44 }
45
46 if (arr.length < 2) { // Mutable length load, should not be forwarded.
47 arr.add(null);
48 }
49
50 return arr.length;
51 }
52
53 main() {
54 final fixed = new List(10);
55 final growable = [];
56 testImmutableVMFields(fixed, true);
57 testImmutableVMFields(growable, false);
58 testImmutableVMFields(growable, false);
59
60 for (var i = 0; i < 2000; i++) {
61 Expect.listEquals([0x02010000, 0x03020100], foo(new A(0, 0)));
62 Expect.listEquals([0x02010000, 0x03020100], bar(new A(0, 0), false));
63 Expect.listEquals([0x04020000, 0x03020100], bar(new A(0, 0), true));
64 testImmutableVMFields(fixed, true);
65 }
66
67 Expect.equals(1, testImmutableVMFields([], false));
68 Expect.equals(2, testImmutableVMFields([1], false));
69 Expect.equals(2, testImmutableVMFields([1, 2], false));
70 Expect.equals(3, testImmutableVMFields([1, 2, 3], false));
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698