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

Unified Diff: tests/language/fast_method_extraction_test.dart

Issue 11642003: Create and cache method extraction stub in the ICData. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: ready for review. Created 8 years 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
« runtime/vm/flow_graph_optimizer.cc ('K') | « runtime/vm/stub_code_x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/fast_method_extraction_test.dart
diff --git a/tests/language/fast_method_extraction_test.dart b/tests/language/fast_method_extraction_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b20b99a82ef6565fce67d41ae622f1a94786325c
--- /dev/null
+++ b/tests/language/fast_method_extraction_test.dart
@@ -0,0 +1,82 @@
+// Copyright (c) 2012, 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.
+// Test that fast method extraction returns correct closure.
+
+class A {
+ var f;
+ A(this.f);
+ foo() => 40 + f;
+}
+
+class B {
+ var f;
+ B(this.f);
+ foo() => -40 - f;
+}
+
+class X { }
+
+class C<T> {
+ foo(v) => v is T;
+}
+
+class ChaA {
+ foo() => "A";
+
+ bar() => foo;
+}
+
+class ChaB extends ChaA {
+ foo() => "B";
+}
+
+mono(a) {
+ var f = a.foo;
+ return f();
+}
+
+poly(a) {
+ var f = a.foo;
+ return f();
+}
+
+types(a, b) {
+ var f = a.foo;
+ Expect.isTrue(f(b));
+}
+
+cha(a) {
+ var f = a.bar();
+ return f();
+}
+
+main() {
+ var a = new A(2);
+ var b = new B(2);
+ for (var i = 0; i < 2000; i++) {
+ Expect.equals(42, mono(a));
+ }
+
+ for (var i = 0; i < 2000; i++) {
+ Expect.equals(42, poly(a));
+ Expect.equals(-42, poly(b));
+ }
+
+ var c = new C<X>();
+ var x = new X();
+ for (var i = 0; i < 2000; i++) {
+ types(c, x);
+ }
+
+ var chaA = new ChaA();
+ for (var i = 0; i < 2000; i++) {
+ Expect.equals("A", cha(chaA));
+ }
+
+ var chaB = new ChaB();
+ for (var i = 0; i < 2000; i++) {
+ Expect.equals("B", cha(chaB));
+ }
+}
+
« runtime/vm/flow_graph_optimizer.cc ('K') | « runtime/vm/stub_code_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698