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

Side by Side Diff: runtime/vm/coverage.cc

Issue 1436243005: Collect closure functions in isolate (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #include "vm/coverage.h" 5 #include "vm/coverage.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 184 }
185 if (!filter->ShouldOutputCoverageFor(lib, script, cls, function)) { 185 if (!filter->ShouldOutputCoverageFor(lib, script, cls, function)) {
186 i++; 186 i++;
187 continue; 187 continue;
188 } 188 }
189 CompileAndAdd(function, hits_or_sites, pos_to_line, as_call_sites); 189 CompileAndAdd(function, hits_or_sites, pos_to_line, as_call_sites);
190 i++; 190 i++;
191 } 191 }
192 } 192 }
193 193
194 GrowableObjectArray& closures = 194 const GrowableObjectArray& closures = GrowableObjectArray::Handle(
195 GrowableObjectArray::Handle(cls.closures()); 195 thread->isolate()->object_store()->closure_functions());
196 if (!closures.IsNull()) { 196 pos_to_line.Clear();
197 i = 0; 197 // We need to keep rechecking the length of the closures array, as handling
198 pos_to_line.Clear(); 198 // a closure potentially adds new entries to the end.
199 // We need to keep rechecking the length of the closures array, as handling 199 i = 0;
200 // a closure potentially adds new entries to the end. 200 while (i < closures.Length()) {
201 HANDLESCOPE(thread);
202 function ^= closures.At(i);
203 if (function.Owner() != cls.raw()) {
204 i++;
205 continue;
206 }
207 script = function.script();
208 saved_url = script.url();
209 if (!filter->ShouldOutputCoverageFor(lib, script, cls, function)) {
210 i++;
211 continue;
212 }
213 ComputeTokenPosToLineNumberMap(script, &pos_to_line);
214 JSONObject jsobj(&jsarr);
215 jsobj.AddProperty("source", saved_url.ToCString());
216 jsobj.AddProperty("script", script);
217 JSONArray hits_or_sites(&jsobj, as_call_sites ? "callSites" : "hits");
218
219 // We stay within this loop while we are seeing functions from the same
220 // source URI.
201 while (i < closures.Length()) { 221 while (i < closures.Length()) {
202 HANDLESCOPE(thread);
203 function ^= closures.At(i); 222 function ^= closures.At(i);
204 script = function.script(); 223 script = function.script();
205 saved_url = script.url(); 224 url = script.url();
206 if (!filter->ShouldOutputCoverageFor(lib, script, cls, function)) { 225 if (!url.Equals(saved_url)) {
207 i++; 226 pos_to_line.Clear();
208 continue; 227 break;
209 } 228 }
210 ComputeTokenPosToLineNumberMap(script, &pos_to_line); 229 CompileAndAdd(function, hits_or_sites, pos_to_line, as_call_sites);
211 JSONObject jsobj(&jsarr); 230 i++;
212 jsobj.AddProperty("source", saved_url.ToCString());
213 jsobj.AddProperty("script", script);
214 JSONArray hits_or_sites(&jsobj, as_call_sites ? "callSites" : "hits");
215
216 // We stay within this loop while we are seeing functions from the same
217 // source URI.
218 while (i < closures.Length()) {
219 function ^= closures.At(i);
220 script = function.script();
221 url = script.url();
222 if (!url.Equals(saved_url)) {
223 pos_to_line.Clear();
224 break;
225 }
226 CompileAndAdd(function, hits_or_sites, pos_to_line, as_call_sites);
227 i++;
228 }
229 } 231 }
230 } 232 }
231 } 233 }
232 234
233 235
234 void CodeCoverage::Write(Thread* thread) { 236 void CodeCoverage::Write(Thread* thread) {
235 if (FLAG_coverage_dir == NULL) { 237 if (FLAG_coverage_dir == NULL) {
236 return; 238 return;
237 } 239 }
238 240
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 cls = it.GetNextClass(); 286 cls = it.GetNextClass();
285 ASSERT(!cls.IsNull()); 287 ASSERT(!cls.IsNull());
286 PrintClass(lib, cls, jsarr, filter, as_call_sites); 288 PrintClass(lib, cls, jsarr, filter, as_call_sites);
287 } 289 }
288 } 290 }
289 } 291 }
290 } 292 }
291 293
292 294
293 } // namespace dart 295 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler_stats.cc ('k') | runtime/vm/debugger.cc » ('j') | runtime/vm/debugger.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698