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

Side by Side Diff: runtime/observatory/test/call_site_data_test.dart

Issue 1000933004: Display ICData entries at call sites, with links to the targets and guarded classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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/observatory/lib/src/service/object.dart ('k') | runtime/vm/coverage.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library call_site_data_test; 5 library call_site_data_test;
6 6
7 import 'package:observatory/service_io.dart'; 7 import 'package:observatory/service_io.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 import 'test_helper.dart'; 9 import 'test_helper.dart';
10 import 'dart:async'; 10 import 'dart:async';
(...skipping 30 matching lines...) Expand all
41 constructorCall() { 41 constructorCall() {
42 new Static(); 42 new Static();
43 return null; 43 return null;
44 } 44 }
45 topLevelMethod() => "TOP"; 45 topLevelMethod() => "TOP";
46 topLevelCall() { 46 topLevelCall() {
47 topLevelMethod(); 47 topLevelMethod();
48 return null; 48 return null;
49 } 49 }
50 50
51 class Super { bar() => "Super"; }
52 class Sub extends Super { bar() => super.bar(); }
53
51 script() { 54 script() {
52 for (int i = 0; i < 10; i++) monomorphic(new A()); 55 for (int i = 0; i < 10; i++) monomorphic(new A());
53 56
54 for (int i = 0; i < 10; i++) polymorphic(new A()); 57 for (int i = 0; i < 10; i++) polymorphic(new A());
55 for (int i = 0; i < 20; i++) polymorphic(new B()); 58 for (int i = 0; i < 20; i++) polymorphic(new B());
56 for (int i = 0; i < 30; i++) polymorphic(new C()); 59 for (int i = 0; i < 30; i++) polymorphic(new C());
57 60
58 for (int i = 0; i < 10; i++) megamorphic(new A()); 61 for (int i = 0; i < 10; i++) megamorphic(new A());
59 for (int i = 0; i < 20; i++) megamorphic(new B()); 62 for (int i = 0; i < 20; i++) megamorphic(new B());
60 for (int i = 0; i < 30; i++) megamorphic(new C()); 63 for (int i = 0; i < 30; i++) megamorphic(new C());
61 for (int i = 0; i < 40; i++) megamorphic(new D()); 64 for (int i = 0; i < 40; i++) megamorphic(new D());
62 for (int i = 0; i < 50; i++) megamorphic(new E()); 65 for (int i = 0; i < 50; i++) megamorphic(new E());
63 for (int i = 0; i < 60; i++) megamorphic(new F()); 66 for (int i = 0; i < 60; i++) megamorphic(new F());
64 for (int i = 0; i < 70; i++) megamorphic(new G()); 67 for (int i = 0; i < 70; i++) megamorphic(new G());
65 for (int i = 0; i < 80; i++) megamorphic(new H()); 68 for (int i = 0; i < 80; i++) megamorphic(new H());
66 69
67 for (int i = 0; i < 10; i++) staticCall(); 70 for (int i = 0; i < 10; i++) staticCall();
68 71
69 for (int i = 0; i < 10; i++) constructorCall(); 72 for (int i = 0; i < 10; i++) constructorCall();
70 73
71 for (int i = 0; i < 10; i++) topLevelCall(); 74 for (int i = 0; i < 10; i++) topLevelCall();
75
76 for (int i = 0; i < 15; i++) new Sub().bar();
72 } 77 }
73 78
74 79
75 Set<String> stringifyCacheEntries(Map callSite) { 80 Set<String> stringifyCacheEntries(Map callSite) {
76 return callSite['cacheEntries'].map((entry) { 81 return callSite['cacheEntries'].map((entry) {
77 return "${entry['receiverContainer']['name']}:${entry['count']}"; 82 return "${entry['receiverContainer']['name']}:${entry['count']}";
78 }).toSet(); 83 }).toSet();
79 } 84 }
80 85
86
87 testMonomorphic(Isolate isolate) async {
88 Library lib = await isolate.rootLib.load();
89 ServiceFunction func =
90 lib.functions.singleWhere((f) => f.name == 'monomorphic');
91 Map response = await isolate.invokeRpcNoUpgrade('getCallSiteData',
92 { 'targetId': func.id });
93 expect(response['type'], equals('CodeCoverage'));
94 Map callSite = response['coverage'].single['callSites'].single;
95 expect(callSite['name'], equals('foo'));
96 expect(stringifyCacheEntries(callSite),
97 equals(['A:10'].toSet()));
98 }
99
100 testPolymorphic(Isolate isolate) async {
101 Library lib = await isolate.rootLib.load();
102 ServiceFunction func =
103 lib.functions.singleWhere((f) => f.name == 'polymorphic');
104 Map response = await isolate.invokeRpcNoUpgrade('getCallSiteData',
105 { 'targetId': func.id });
106 expect(response['type'], equals('CodeCoverage'));
107 Map callSite = response['coverage'].single['callSites'].single;
108 expect(callSite['name'], equals('foo'));
109 expect(stringifyCacheEntries(callSite),
110 equals(['A:10', 'B:20', 'C:30'].toSet()));
111 }
112
113 testMegamorphic(Isolate isolate) async {
114 Library lib = await isolate.rootLib.load();
115 ServiceFunction func =
116 lib.functions.singleWhere((f) => f.name == 'megamorphic');
117 Map response = await isolate.invokeRpcNoUpgrade('getCallSiteData',
118 { 'targetId': func.id });
119 expect(response['type'], equals('CodeCoverage'));
120 Map callSite = response['coverage'].single['callSites'].single;
121 expect(callSite['name'], equals('foo'));
122 expect(stringifyCacheEntries(callSite),
123 equals(['A:10', 'B:20', 'C:30', 'D:40',
124 'E:50', 'F:60', 'G:70', 'H:80'].toSet()));
125 }
126
127 testStaticCall(Isolate isolate) async {
128 Library lib = await isolate.rootLib.load();
129 ServiceFunction func =
130 lib.functions.singleWhere((f) => f.name == 'staticCall');
131 Map response = await isolate.invokeRpcNoUpgrade('getCallSiteData',
132 { 'targetId': func.id });
133 expect(response['type'], equals('CodeCoverage'));
134 Map callSite = response['coverage'].single['callSites'].single;
135 expect(callSite['name'], equals('staticMethod'));
136 expect(stringifyCacheEntries(callSite),
137 equals(['Static:10'].toSet()));
138 }
139
140 testConstructorCall(Isolate isolate) async {
141 Library lib = await isolate.rootLib.load();
142 ServiceFunction func =
143 lib.functions.singleWhere((f) => f.name == 'constructorCall');
144 Map response = await isolate.invokeRpcNoUpgrade('getCallSiteData',
145 { 'targetId': func.id });
146 expect(response['type'], equals('CodeCoverage'));
147 Map callSite = response['coverage'].single['callSites'].single;
148 expect(callSite['name'], equals('Static.'));
149 expect(stringifyCacheEntries(callSite),
150 equals(['Static:10'].toSet()));
151 }
152
153 testTopLevelCall(Isolate isolate) async {
154 Library lib = await isolate.rootLib.load();
155 ServiceFunction func =
156 lib.functions.singleWhere((f) => f.name == 'topLevelCall');
157 Map response = await isolate.invokeRpcNoUpgrade('getCallSiteData',
158 { 'targetId': func.id });
159 expect(response['type'], equals('CodeCoverage'));
160 Map callSite = response['coverage'].single['callSites'].single;
161 expect(callSite['name'], equals('topLevelMethod'));
162 expect(stringifyCacheEntries(callSite),
163 equals(['call_site_data_test:10'].toSet()));
164 }
165
166 testSuperCall(Isolate isolate) async {
167 Library lib = await isolate.rootLib.load();
168 Class cls = await lib.classes.singleWhere((f) => f.name == 'Sub').load();
169 ServiceFunction func = cls.functions.singleWhere((f) => f.name == 'bar');
170 Map response = await isolate.invokeRpcNoUpgrade('getCallSiteData',
171 { 'targetId': func.id });
172 expect(response['type'], equals('CodeCoverage'));
173 Map callSite = response['coverage'].single['callSites'].single;
174 expect(callSite['name'], equals('bar'));
175 expect(stringifyCacheEntries(callSite),
176 equals(['Super:15'].toSet()));
177 }
178
81 var tests = [ 179 var tests = [
82 (Isolate isolate) { 180 testMonomorphic,
83 return isolate.rootLib.load().then((Library lib) { 181 testPolymorphic,
84 var monomorphic = lib.functions.singleWhere((f) => f.name == 'monomorphic'); 182 testMegamorphic,
85 var polymorphic = lib.functions.singleWhere((f) => f.name == 'polymorphic'); 183 testStaticCall,
86 var megamorphic = lib.functions.singleWhere((f) => f.name == 'megamorphic'); 184 testConstructorCall,
87 var staticCall = lib.functions.singleWhere((f) => f.name == 'staticCall'); 185 testTopLevelCall,
88 var constructorCall = lib.functions.singleWhere((f) => f.name == 'constructo rCall'); 186 testSuperCall ];
89 var topLevelCall = lib.functions.singleWhere((f) => f.name == 'topLevelCall' );
90
91 List tests = [];
92 tests.add(isolate.invokeRpcNoUpgrade('getCallSiteData',
93 { 'targetId': monomorphic.id })
94 .then((Map response) {
95 print("Monomorphic: $response");
96 expect(response['type'], equals('_CallSiteData'));
97 expect(response['function']['id'], equals(monomorphic.id));
98 expect(response['callSites'], isList);
99 expect(response['callSites'], hasLength(1));
100 Map callSite = response['callSites'].single;
101 expect(callSite['name'], equals('foo'));
102 // expect(callSite['deoptReasons'], equals(''));
103 expect(stringifyCacheEntries(callSite),
104 equals(['A:10'].toSet()));
105 }));
106
107 tests.add(isolate.invokeRpcNoUpgrade('getCallSiteData',
108 { 'targetId': polymorphic.id })
109 .then((Map response) {
110 print("Polymorphic: $response");
111 expect(response['type'], equals('_CallSiteData'));
112 expect(response['function']['id'], equals(polymorphic.id));
113 expect(response['callSites'], isList);
114 expect(response['callSites'], hasLength(1));
115 Map callSite = response['callSites'].single;
116 expect(callSite['name'], equals('foo'));
117 // expect(callSite['deoptReasons'], equals(''));
118 expect(stringifyCacheEntries(callSite),
119 equals(['A:10', 'B:20', 'C:30'].toSet()));
120 }));
121
122 tests.add(isolate.invokeRpcNoUpgrade('getCallSiteData',
123 { 'targetId': megamorphic.id })
124 .then((Map response) {
125 print("Megamorphic: $response");
126 expect(response['type'], equals('_CallSiteData'));
127 expect(response['function']['id'], equals(megamorphic.id));
128 expect(response['callSites'], isList);
129 expect(response['callSites'], hasLength(1));
130 Map callSite = response['callSites'].single;
131 expect(callSite['name'], equals('foo'));
132 // expect(callSite['deoptReasons'], equals(''));
133 expect(stringifyCacheEntries(callSite),
134 equals(['A:10', 'B:20', 'C:30', 'D:40',
135 'E:50', 'F:60', 'G:70', 'H:80'].toSet()));
136 }));
137
138 tests.add(isolate.invokeRpcNoUpgrade('getCallSiteData',
139 { 'targetId': staticCall.id })
140 .then((Map response) {
141 expect(response['type'], equals('_CallSiteData'));
142 expect(response['function']['id'], equals(staticCall.id));
143 expect(response['callSites'], isList);
144 expect(response['callSites'], hasLength(1));
145 Map callSite = response['callSites'].single;
146 expect(callSite['name'], equals('staticMethod'));
147 // expect(callSite['deoptReasons'], equals(''));
148 expect(stringifyCacheEntries(callSite),
149 equals(['Static:10'].toSet()));
150 }));
151
152 tests.add(isolate.invokeRpcNoUpgrade('getCallSiteData',
153 { 'targetId': constructorCall.id })
154 .then((Map response) {
155 expect(response['type'], equals('_CallSiteData'));
156 expect(response['function']['id'], equals(constructorCall.id ));
157 expect(response['callSites'], isList);
158 expect(response['callSites'], hasLength(1));
159 Map callSite = response['callSites'].single;
160 expect(callSite['name'], equals('Static.'));
161 // expect(callSite['deoptReasons'], equals(''));
162 expect(stringifyCacheEntries(callSite),
163 equals(['Static:10'].toSet()));
164 }));
165
166 tests.add(isolate.invokeRpcNoUpgrade('getCallSiteData',
167 { 'targetId': topLevelCall.id })
168 .then((Map response) {
169 expect(response['type'], equals('_CallSiteData'));
170 expect(response['function']['id'], equals(topLevelCall.id));
171 expect(response['callSites'], isList);
172 expect(response['callSites'], hasLength(1));
173 Map callSite = response['callSites'].single;
174 expect(callSite['name'], equals('topLevelMethod'));
175 // expect(callSite['deoptReasons'], equals(''));
176 expect(stringifyCacheEntries(callSite),
177 equals(['call_site_data_test:10'].toSet()));
178 }));
179
180 return Future.wait(tests);
181 });
182 },
183
184 ];
185 187
186 main(args) => runIsolateTests(args, tests, testeeBefore: script); 188 main(args) => runIsolateTests(args, tests, testeeBefore: script);
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/service/object.dart ('k') | runtime/vm/coverage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698