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

Unified Diff: tests/language/load_to_load_forwarding_test.dart

Issue 14935005: Implement a variation of scalar replacement for non-escaping allocations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comments Created 7 years, 7 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 | « tests/language/allocation_sinking_vm_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/load_to_load_forwarding_test.dart
diff --git a/tests/language/load_to_load_forwarding_test.dart b/tests/language/load_to_load_forwarding_test.dart
index 6c7d8b426747625c0e6549c1cb877203edd9fd0d..cade3c6e9af31a75ac7e96ce7aa0cac166560e7d 100644
--- a/tests/language/load_to_load_forwarding_test.dart
+++ b/tests/language/load_to_load_forwarding_test.dart
@@ -35,10 +35,37 @@ bar(a, mode) {
return [value1, value2];
}
+// Verify that immutable and mutable VM fields (array length in this case)
+// are not confused by load forwarding even if the access the same offset
+// in the object.
+testImmutableVMFields(arr, immutable) {
+ if (immutable) {
+ return arr.length; // Immutable length load.
+ }
+
+ if (arr.length < 2) { // Mutable length load, should not be forwarded.
+ arr.add(null);
+ }
+
+ return arr.length;
+}
+
main() {
+ final fixed = new List(10);
+ final growable = [];
+ testImmutableVMFields(fixed, true);
+ testImmutableVMFields(growable, false);
+ testImmutableVMFields(growable, false);
+
for (var i = 0; i < 2000; i++) {
Expect.listEquals([0x02010000, 0x03020100], foo(new A(0, 0)));
Expect.listEquals([0x02010000, 0x03020100], bar(new A(0, 0), false));
Expect.listEquals([0x04020000, 0x03020100], bar(new A(0, 0), true));
+ testImmutableVMFields(fixed, true);
}
+
+ Expect.equals(1, testImmutableVMFields([], false));
+ Expect.equals(2, testImmutableVMFields([1], false));
+ Expect.equals(2, testImmutableVMFields([1, 2], false));
+ Expect.equals(3, testImmutableVMFields([1, 2, 3], false));
}
« no previous file with comments | « tests/language/allocation_sinking_vm_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698