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

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

Issue 1401643002: Remove isolate parameter when allocating handles (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Sync Created 5 years, 2 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
« no previous file with comments | « runtime/vm/coverage.h ('k') | runtime/vm/coverage_test.cc » ('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) 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 break; 224 break;
225 } 225 }
226 CompileAndAdd(function, hits_or_sites, pos_to_line, as_call_sites); 226 CompileAndAdd(function, hits_or_sites, pos_to_line, as_call_sites);
227 i++; 227 i++;
228 } 228 }
229 } 229 }
230 } 230 }
231 } 231 }
232 232
233 233
234 void CodeCoverage::Write(Isolate* isolate) { 234 void CodeCoverage::Write(Thread* thread) {
235 if (FLAG_coverage_dir == NULL) { 235 if (FLAG_coverage_dir == NULL) {
236 return; 236 return;
237 } 237 }
238 238
239 Dart_FileOpenCallback file_open = Isolate::file_open_callback(); 239 Dart_FileOpenCallback file_open = Isolate::file_open_callback();
240 Dart_FileWriteCallback file_write = Isolate::file_write_callback(); 240 Dart_FileWriteCallback file_write = Isolate::file_write_callback();
241 Dart_FileCloseCallback file_close = Isolate::file_close_callback(); 241 Dart_FileCloseCallback file_close = Isolate::file_close_callback();
242 if ((file_open == NULL) || (file_write == NULL) || (file_close == NULL)) { 242 if ((file_open == NULL) || (file_write == NULL) || (file_close == NULL)) {
243 return; 243 return;
244 } 244 }
245 245
246 JSONStream stream; 246 JSONStream stream;
247 PrintJSON(isolate, &stream, NULL, false); 247 PrintJSON(thread, &stream, NULL, false);
248 248
249 intptr_t pid = OS::ProcessId(); 249 intptr_t pid = OS::ProcessId();
250 char* filename = OS::SCreate(Thread::Current()->zone(), 250 char* filename = OS::SCreate(thread->zone(),
251 "%s/dart-cov-%" Pd "-%" Pd64 ".json", 251 "%s/dart-cov-%" Pd "-%" Pd64 ".json",
252 FLAG_coverage_dir, pid, isolate->main_port()); 252 FLAG_coverage_dir, pid, thread->isolate()->main_port());
253 void* file = (*file_open)(filename, true); 253 void* file = (*file_open)(filename, true);
254 if (file == NULL) { 254 if (file == NULL) {
255 OS::Print("Failed to write coverage file: %s\n", filename); 255 OS::Print("Failed to write coverage file: %s\n", filename);
256 return; 256 return;
257 } 257 }
258 (*file_write)(stream.buffer()->buf(), stream.buffer()->length(), file); 258 (*file_write)(stream.buffer()->buf(), stream.buffer()->length(), file);
259 (*file_close)(file); 259 (*file_close)(file);
260 } 260 }
261 261
262 262
263 void CodeCoverage::PrintJSON(Isolate* isolate, 263 void CodeCoverage::PrintJSON(Thread* thread,
264 JSONStream* stream, 264 JSONStream* stream,
265 CoverageFilter* filter, 265 CoverageFilter* filter,
266 bool as_call_sites) { 266 bool as_call_sites) {
267 CoverageFilterAll default_filter; 267 CoverageFilterAll default_filter;
268 if (filter == NULL) { 268 if (filter == NULL) {
269 filter = &default_filter; 269 filter = &default_filter;
270 } 270 }
271 const GrowableObjectArray& libs = GrowableObjectArray::Handle( 271 const GrowableObjectArray& libs = GrowableObjectArray::Handle(
272 isolate, isolate->object_store()->libraries()); 272 thread->zone(),
273 thread->isolate()->object_store()->libraries());
273 Library& lib = Library::Handle(); 274 Library& lib = Library::Handle();
274 Class& cls = Class::Handle(); 275 Class& cls = Class::Handle();
275 JSONObject coverage(stream); 276 JSONObject coverage(stream);
276 coverage.AddProperty("type", "CodeCoverage"); 277 coverage.AddProperty("type", "CodeCoverage");
277 { 278 {
278 JSONArray jsarr(&coverage, "coverage"); 279 JSONArray jsarr(&coverage, "coverage");
279 for (int i = 0; i < libs.Length(); i++) { 280 for (int i = 0; i < libs.Length(); i++) {
280 lib ^= libs.At(i); 281 lib ^= libs.At(i);
281 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); 282 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate);
282 while (it.HasNext()) { 283 while (it.HasNext()) {
283 cls = it.GetNextClass(); 284 cls = it.GetNextClass();
284 ASSERT(!cls.IsNull()); 285 ASSERT(!cls.IsNull());
285 PrintClass(lib, cls, jsarr, filter, as_call_sites); 286 PrintClass(lib, cls, jsarr, filter, as_call_sites);
286 } 287 }
287 } 288 }
288 } 289 }
289 } 290 }
290 291
291 292
292 } // namespace dart 293 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/coverage.h ('k') | runtime/vm/coverage_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698