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

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: remove hand written assembly stub 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
« runtime/vm/stub_code.cc ('K') | « 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 main() {
68 var a = new A(2);
69 var b = new B(2);
70 for (var i = 0; i < 2000; i++) {
71 Expect.equals(42, mono(a));
72 }
73
74 for (var i = 0; i < 2000; i++) {
75 Expect.equals(42, poly(a));
76 Expect.equals(-42, poly(b));
77 }
78
79 var c = new C<X>();
80 var x = new X();
81 for (var i = 0; i < 2000; i++) {
82 types(c, x);
83 }
84
85 var chaA = new ChaA("magicA");
86 for (var i = 0; i < 2000; i++) {
87 Expect.equals("A", cha(chaA));
88 }
89
90 var chaB = new ChaB("magicB");
91 for (var i = 0; i < 2000; i++) {
92 Expect.equals("B", cha(chaB));
93 }
94 }
95
OLDNEW
« runtime/vm/stub_code.cc ('K') | « runtime/vm/symbols.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698