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

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: lazyly inject extractors as getters into class Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/symbols.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 final magic;
26 ChaA(magic) : this.magic = magic;
27
28 foo() {
29 Expect.isTrue(this is ChaA);
30 Expect.equals("magicA", magic);
31 return "A";
32 }
33
34 bar() => foo;
35 }
36
37 class ChaB extends ChaA {
38 ChaB(magic) : super(magic);
39
40 foo() {
41 Expect.isTrue(this is ChaB);
42 Expect.equals("magicB", magic);
43 return "B";
44 }
45 }
46
47 mono(a) {
48 var f = a.foo;
49 return f();
50 }
51
52 poly(a) {
53 var f = a.foo;
54 return f();
55 }
56
57 types(a, b) {
58 var f = a.foo;
59 Expect.isTrue(f(b));
60 }
61
62 cha(a) {
63 var f = a.bar();
64 return f();
65 }
66
67 extractFromNull() {
68 var f = (null).toString;
69 Expect.equals("null", f());
70 }
71
72 main() {
73 var a = new A(2);
74 var b = new B(2);
75 for (var i = 0; i < 10000; i++) {
76 Expect.equals(42, mono(a));
77 }
78
79 for (var i = 0; i < 10000; i++) {
80 Expect.equals(42, poly(a));
81 Expect.equals(-42, poly(b));
82 }
83
84 var c = new C<X>();
85 var x = new X();
86 for (var i = 0; i < 10000; i++) {
87 types(c, x);
88 }
89
90 var chaA = new ChaA("magicA");
91 for (var i = 0; i < 10000; i++) {
92 Expect.equals("A", cha(chaA));
93 }
94
95 var chaB = new ChaB("magicB");
96 for (var i = 0; i < 10000; i++) {
97 Expect.equals("B", cha(chaB));
98 }
99
100 for (var i = 0; i < 10000; i++) {
101 extractFromNull();
102 }
103 }
104
OLDNEW
« no previous file with comments | « runtime/vm/symbols.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698