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

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

Issue 50243004: Fix bug with guarded fields and deserialization. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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
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";
Ivan Posva 2013/11/01 04:50:05 Why not just s == null?
Florian Schneider 2013/11/01 10:39:27 I can't have an IC call here: it will introduce a
+ // 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);
Ivan Posva 2013/11/01 04:50:05 ditto
Florian Schneider 2013/11/01 10:39:27 Done.
+ 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);
Ivan Posva 2013/11/01 04:50:05 ditto
Florian Schneider 2013/11/01 10:39:27 Done.
+ 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();
}

Powered by Google App Engine
This is Rietveld 408576698