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

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

Issue 257053003: Always use the same json for null in the vm service. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: gen js Created 6 years, 7 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/coverage.h ('k') | runtime/vm/debugger.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) 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 149 }
150 150
151 Dart_FileOpenCallback file_open = Isolate::file_open_callback(); 151 Dart_FileOpenCallback file_open = Isolate::file_open_callback();
152 Dart_FileWriteCallback file_write = Isolate::file_write_callback(); 152 Dart_FileWriteCallback file_write = Isolate::file_write_callback();
153 Dart_FileCloseCallback file_close = Isolate::file_close_callback(); 153 Dart_FileCloseCallback file_close = Isolate::file_close_callback();
154 if ((file_open == NULL) || (file_write == NULL) || (file_close == NULL)) { 154 if ((file_open == NULL) || (file_write == NULL) || (file_close == NULL)) {
155 return; 155 return;
156 } 156 }
157 157
158 JSONStream stream; 158 JSONStream stream;
159 PrintToJSONStream(isolate, &stream); 159 PrintJSON(isolate, &stream);
160 160
161 const char* format = "%s/dart-cov-%" Pd "-%" Pd ".json"; 161 const char* format = "%s/dart-cov-%" Pd "-%" Pd ".json";
162 intptr_t pid = OS::ProcessId(); 162 intptr_t pid = OS::ProcessId();
163 intptr_t len = OS::SNPrint(NULL, 0, format, 163 intptr_t len = OS::SNPrint(NULL, 0, format,
164 FLAG_coverage_dir, pid, isolate->main_port()); 164 FLAG_coverage_dir, pid, isolate->main_port());
165 char* filename = Isolate::Current()->current_zone()->Alloc<char>(len + 1); 165 char* filename = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
166 OS::SNPrint(filename, len + 1, format, 166 OS::SNPrint(filename, len + 1, format,
167 FLAG_coverage_dir, pid, isolate->main_port()); 167 FLAG_coverage_dir, pid, isolate->main_port());
168 void* file = (*file_open)(filename, true); 168 void* file = (*file_open)(filename, true);
169 if (file == NULL) { 169 if (file == NULL) {
170 OS::Print("Failed to write coverage file: %s\n", filename); 170 OS::Print("Failed to write coverage file: %s\n", filename);
171 return; 171 return;
172 } 172 }
173 (*file_write)(stream.buffer()->buf(), stream.buffer()->length(), file); 173 (*file_write)(stream.buffer()->buf(), stream.buffer()->length(), file);
174 (*file_close)(file); 174 (*file_close)(file);
175 } 175 }
176 176
177 177
178 void CodeCoverage::PrintToJSONStream(Isolate* isolate, JSONStream* stream) { 178 void CodeCoverage::PrintJSON(Isolate* isolate, JSONStream* stream) {
179 const GrowableObjectArray& libs = GrowableObjectArray::Handle( 179 const GrowableObjectArray& libs = GrowableObjectArray::Handle(
180 isolate, isolate->object_store()->libraries()); 180 isolate, isolate->object_store()->libraries());
181 Library& lib = Library::Handle(); 181 Library& lib = Library::Handle();
182 Class& cls = Class::Handle(); 182 Class& cls = Class::Handle();
183 JSONObject coverage(stream); 183 JSONObject coverage(stream);
184 coverage.AddProperty("type", "CodeCoverage"); 184 coverage.AddProperty("type", "CodeCoverage");
185 coverage.AddProperty("id", "coverage"); 185 coverage.AddProperty("id", "coverage");
186 { 186 {
187 JSONArray jsarr(&coverage, "coverage"); 187 JSONArray jsarr(&coverage, "coverage");
188 for (int i = 0; i < libs.Length(); i++) { 188 for (int i = 0; i < libs.Length(); i++) {
189 lib ^= libs.At(i); 189 lib ^= libs.At(i);
190 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); 190 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate);
191 while (it.HasNext()) { 191 while (it.HasNext()) {
192 cls = it.GetNextClass(); 192 cls = it.GetNextClass();
193 if (cls.EnsureIsFinalized(isolate) == Error::null()) { 193 if (cls.EnsureIsFinalized(isolate) == Error::null()) {
194 // Only classes that have been finalized do have a meaningful list of 194 // Only classes that have been finalized do have a meaningful list of
195 // functions. 195 // functions.
196 PrintClass(cls, jsarr); 196 PrintClass(cls, jsarr);
197 } 197 }
198 } 198 }
199 } 199 }
200 } 200 }
201 } 201 }
202 202
203 203
204 } // namespace dart 204 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/coverage.h ('k') | runtime/vm/debugger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698