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

Unified Diff: tests/language/vm/allocation_sinking_vm_test.dart

Issue 395943003: Support allocation sinking for compound objects. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: improve tests Created 6 years, 5 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 | « runtime/vm/intermediate_language.cc ('k') | tests/language/vm/load_to_load_forwarding_vm_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/vm/allocation_sinking_vm_test.dart
diff --git a/tests/language/vm/allocation_sinking_vm_test.dart b/tests/language/vm/allocation_sinking_vm_test.dart
index 619235a6186d882f8e79db5e5da0434499808c7f..55b5f351e7c1e5e1570f34ea99611c020a0c84ad 100644
--- a/tests/language/vm/allocation_sinking_vm_test.dart
+++ b/tests/language/vm/allocation_sinking_vm_test.dart
@@ -163,6 +163,111 @@ testVMField() {
Expect.equals(84, test_vm_field());
}
+class CompoundA {
+ var b;
+ CompoundA(this.b);
+}
+
+class CompoundB {
+ var c;
+ CompoundB(this.c);
+}
+
+class CompoundC {
+ var d;
+ var root;
+ CompoundC(this.d);
+}
+
+class NoopSink {
+ const NoopSink();
+ call(val) { }
+}
+
+testCompound1() {
+ f(d, [sink = const NoopSink()]) {
+ var c = new CompoundC(d);
+ var a = new CompoundA(new CompoundB(c));
+ sink(a);
+ return c.d;
+ }
+
+ Expect.equals(0.1, f(0.1));
+ for (var i = 0; i < 100; i++) f(0.1);
+ Expect.equals(0.1, f(0.1));
+ Expect.equals(0.1, f(0.1, (val) {
+ Expect.isTrue(val is CompoundA);
+ Expect.isTrue(val.b is CompoundB);
+ Expect.isTrue(val.b.c is CompoundC);
+ Expect.isNull(val.b.c.root);
+ Expect.equals(0.1, val.b.c.d);
+ }));
+}
+
+
+testCompound2() {
+ f(d, [sink = const NoopSink()]) {
+ var c = new CompoundC(d);
+ var a = new CompoundA(new CompoundB(c));
+ c.root = a;
+ sink(a);
+ return c.d;
+ }
+
+ Expect.equals(0.1, f(0.1));
+ for (var i = 0; i < 100; i++) f(0.1);
+ Expect.equals(0.1, f(0.1));
+ Expect.equals(0.1, f(0.1, (val) {
+ Expect.isTrue(val is CompoundA);
+ Expect.isTrue(val.b is CompoundB);
+ Expect.isTrue(val.b.c is CompoundC);
+ Expect.equals(val, val.b.c.root);
+ Expect.equals(0.1, val.b.c.d);
+ }));
+}
+
+
+testCompound3() {
+ f(d, [sink = const NoopSink()]) {
+ var c = new CompoundC(d);
+ c.root = c;
+ sink(c);
+ return c.d;
+ }
+
+ Expect.equals(0.1, f(0.1));
+ for (var i = 0; i < 100; i++) f(0.1);
+ Expect.equals(0.1, f(0.1));
+ Expect.equals(0.1, f(0.1, (val) {
+ Expect.isTrue(val is CompoundC);
+ Expect.equals(val, val.root);
+ Expect.equals(0.1, val.d);
+ }));
+}
+
+
+testCompound4() {
+ f(d, [sink = const NoopSink()]) {
+ var c = new CompoundC(d);
+ c.root = c;
+ for (var i = 0; i < 10; i++) {
+ c.d += 1.0;
+ }
+ sink(c);
+ return c.d - 1.0 * 10;
+ }
+
+ Expect.equals(1.0, f(1.0));
+ for (var i = 0; i < 100; i++) f(1.0);
+ Expect.equals(1.0, f(1.0));
+ Expect.equals(1.0, f(1.0, (val) {
+ Expect.isTrue(val is CompoundC);
+ Expect.equals(val, val.root);
+ Expect.equals(11.0, val.d);
+ }));
+}
+
+
main() {
var c = new C(new Point(0.1, 0.2));
@@ -220,4 +325,8 @@ main() {
testFinalField();
testVMField();
+ testCompound1();
+ testCompound2();
+ testCompound3();
+ testCompound4();
}
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | tests/language/vm/load_to_load_forwarding_vm_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698