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

Unified Diff: tests/language/vm/optimized_guarded_field_isolates_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_isolates_test.dart
===================================================================
--- tests/language/vm/optimized_guarded_field_isolates_test.dart (revision 0)
+++ tests/language/vm/optimized_guarded_field_isolates_test.dart (revision 0)
@@ -0,0 +1,70 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// VMOptions=--optimization_counter_threshold=100
+
+// Test field type tracking and field list-length tracking in the presence of
+// multiple isolates.
+
+import "dart:isolate";
+import "package:expect/expect.dart";
+
+class A {
+ A(this.a);
+ var a;
+}
+
+class B extends A {
+ B(a, this.b) : super(a) { }
+
+ var b;
+}
+
+f1(SendPort send_port) {
+ send_port.send(new B("foo", "bar"));
+}
+
+test_b(B obj) => obj.a + obj.b;
+
+test_field_type() {
+ var receive_port = new ReceivePort();
+ Future<Isolate> isolate = Isolate.spawn(f1, receive_port.sendPort);
+ B b = new B(1, 2);
+ for (var i = 0; i < 200; i++) test_b(b);
Ivan Posva 2013/11/01 04:50:05 { test_b(b); }
Florian Schneider 2013/11/01 10:39:27 Done.
+ Expect.equals(3, test_b(b));
+ Future<B> item = receive_port.first;
+ item.then((B value) {
+ Expect.equals("foobar", test_b(value));
+ receive_port.close();
+ });
+}
+
+class C {
+ C(this.list);
+ final List list;
+}
+
+f2(SendPort send_port) {
+ send_port.send(new C(new List(1)));
+}
+
+test_c(C obj) => obj.list[9999];
+
+test_list_length() {
+ var receive_port = new ReceivePort();
+ Future<Isolate> isolate = Isolate.spawn(f2, receive_port.sendPort);
+ List list = new List(10000);
Ivan Posva 2013/11/01 04:50:05 Where is list being used?
+ C c = new C(new List(10000));
+ for (var i = 0; i < 200; i++) test_c(c);
Ivan Posva 2013/11/01 04:50:05 ditto: { test_c(c); }
+ Expect.equals(null, test_c(c));
+ Future<C> item = receive_port.first;
+ item.then((C value) {
+ Expect.throws(() => test_c(value), (e) => e is RangeError);
+ receive_port.close();
+ });
+}
+
+main() {
+ test_field_type();
+ test_list_length();
+}

Powered by Google App Engine
This is Rietveld 408576698