| Index: tests/language/vm/optimized_guarded_field_test.dart
|
| ===================================================================
|
| --- tests/language/vm/optimized_guarded_field_test.dart (revision 29540)
|
| +++ tests/language/vm/optimized_guarded_field_test.dart (working copy)
|
| @@ -17,6 +17,41 @@
|
|
|
| test(obj) => obj.foo == null ? "null" : "other";
|
|
|
| +
|
| +class C {
|
| + C(this.x, this.y);
|
| + final x;
|
| + final y;
|
| +}
|
| +
|
| +test_deopt(a, b) {
|
| + var c = new C(a, b);
|
| + return c.x + c.y;
|
| +}
|
| +
|
| +
|
| +create_error (x) {
|
| + return x as int;
|
| +}
|
| +
|
| +check_stacktrace(e) {
|
| + var s = e.stackTrace;
|
| + if (identical(s, null)) throw "FAIL";
|
| + // s should never be null.
|
| + return "OK";
|
| +}
|
| +
|
| +test_stacktrace() {
|
| + try {
|
| + create_error("bar");
|
| + } catch (e) {
|
| + Expect.equals("OK", check_stacktrace(e));
|
| + for (var i=0; i<20; i++) check_stacktrace(e);
|
| + Expect.equals("OK", check_stacktrace(e));
|
| + }
|
| +}
|
| +
|
| +
|
| main() {
|
| var a = new A();
|
| var b = new B();
|
| @@ -32,4 +67,13 @@
|
| a.foo = 123;
|
| Expect.equals("other", test(a));
|
| Expect.equals("null", test(b));
|
| +
|
| + // Test guarded fields with allocation sinking and deoptimization.
|
| + Expect.equals(43, test_deopt(42, 1));
|
| + for (var i = 0; i < 20; i++) test_deopt(42, 1);
|
| + Expect.equals(43, test_deopt(42, 1));
|
| + Expect.equals("aaabbb", test_deopt("aaa", "bbb"));
|
| +
|
| + // Regression test for fields initialized in native code (Error._stackTrace).
|
| + test_stacktrace();
|
| }
|
|
|