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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4 // Test that fast method extraction returns correct closure.
5
6 class A {
7 var f;
8 A(this.f);
9 foo() => 40 + f;
10 }
11
12 class B {
13 var f;
14 B(this.f);
15 foo() => -40 - f;
16 }
17
18 class X { }
19
20 class C<T> {
21 foo(v) => v is T;
22 }
23
24 class ChaA {
25 foo() => "A";
26
27 bar() => foo;
28 }
29
30 class ChaB extends ChaA {
31 foo() => "B";
32 }
33
34 mono(a) {
35 var f = a.foo;
36 return f();
37 }
38
39 poly(a) {
40 var f = a.foo;
41 return f();
42 }
43
44 types(a, b) {
45 var f = a.foo;
46 Expect.isTrue(f(b));
47 }
48
49 cha(a) {
50 var f = a.bar();
51 return f();
52 }
53
54 main() {
55 var a = new A(2);
56 var b = new B(2);
57 for (var i = 0; i < 2000; i++) {
58 Expect.equals(42, mono(a));
59 }
60
61 for (var i = 0; i < 2000; i++) {
62 Expect.equals(42, poly(a));
63 Expect.equals(-42, poly(b));
64 }
65
66 var c = new C<X>();
67 var x = new X();
68 for (var i = 0; i < 2000; i++) {
69 types(c, x);
70 }
71
72 var chaA = new ChaA();
73 for (var i = 0; i < 2000; i++) {
74 Expect.equals("A", cha(chaA));
75 }
76
77 var chaB = new ChaB();
78 for (var i = 0; i < 2000; i++) {
79 Expect.equals("B", cha(chaB));
80 }
81 }
82
OLDNEW
« 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