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

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

Issue 1566793002: Expose the new _getSourceReport api in the service protocol. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code rev Created 4 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
« no previous file with comments | « runtime/vm/source_report.h ('k') | runtime/vm/source_report_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) 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 #include "vm/source_report.h" 5 #include "vm/source_report.h"
6 6
7 #include "vm/compiler.h" 7 #include "vm/compiler.h"
8 #include "vm/object.h" 8 #include "vm/object.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 SourceReport::SourceReport(ReportKind report_kind, CompileMode compile_mode) 13 SourceReport::SourceReport(intptr_t report_set, CompileMode compile_mode)
14 : report_kind_(report_kind), 14 : report_set_(report_set),
15 compile_mode_(compile_mode), 15 compile_mode_(compile_mode),
16 thread_(NULL), 16 thread_(NULL),
17 script_(NULL), 17 script_(NULL),
18 start_pos_(-1), 18 start_pos_(-1),
19 end_pos_(-1), 19 end_pos_(-1),
20 next_script_index_(0) { 20 next_script_index_(0) {
21 } 21 }
22 22
23 23
24 void SourceReport::Init(Thread* thread, 24 void SourceReport::Init(Thread* thread,
25 const Script* script, 25 const Script* script,
26 intptr_t start_pos, 26 intptr_t start_pos,
27 intptr_t end_pos) { 27 intptr_t end_pos) {
28 thread_ = thread; 28 thread_ = thread;
29 script_ = script; 29 script_ = script;
30 start_pos_ = start_pos; 30 start_pos_ = start_pos;
31 end_pos_ = end_pos; 31 end_pos_ = end_pos;
32 script_table_entries_.Clear(); 32 script_table_entries_.Clear();
33 script_table_.Clear(); 33 script_table_.Clear();
34 next_script_index_ = 0; 34 next_script_index_ = 0;
35 } 35 }
36 36
37 37
38 bool SourceReport::IsReportRequested(ReportKind report_kind) {
39 return (report_set_ & report_kind) != 0;
40 }
41
42
38 bool SourceReport::ShouldSkipFunction(const Function& func) { 43 bool SourceReport::ShouldSkipFunction(const Function& func) {
39 if (script_ != NULL && !script_->IsNull()) { 44 if (script_ != NULL && !script_->IsNull()) {
40 if (func.script() != script_->raw()) { 45 if (func.script() != script_->raw()) {
41 // The function is from the wrong script. 46 // The function is from the wrong script.
42 return true; 47 return true;
43 } 48 }
44 if (((start_pos_ > 0) && (func.end_token_pos() < start_pos_)) || 49 if (((start_pos_ > 0) && (func.end_token_pos() < start_pos_)) ||
45 ((end_pos_ > 0) && (func.token_pos() > end_pos_))) { 50 ((end_pos_ > 0) && (func.token_pos() > end_pos_))) {
46 // The function does not intersect with the requested token range. 51 // The function does not intersect with the requested token range.
47 return true; 52 return true;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 243 }
239 } 244 }
240 ASSERT(!code.IsNull()); 245 ASSERT(!code.IsNull());
241 246
242 JSONObject range(jsarr); 247 JSONObject range(jsarr);
243 range.AddProperty("scriptIndex", GetScriptIndex(script)); 248 range.AddProperty("scriptIndex", GetScriptIndex(script));
244 range.AddProperty("startPos", begin_pos); 249 range.AddProperty("startPos", begin_pos);
245 range.AddProperty("endPos", end_pos); 250 range.AddProperty("endPos", end_pos);
246 range.AddProperty("compiled", true); 251 range.AddProperty("compiled", true);
247 252
248 if (report_kind_ == kCallSites) { 253 if (IsReportRequested(kCallSites)) {
249 PrintCallSitesData(&range, func, code); 254 PrintCallSitesData(&range, func, code);
250 } else if (report_kind_ == kCoverage) { 255 }
256 if (IsReportRequested(kCoverage)) {
251 PrintCoverageData(&range, func, code); 257 PrintCoverageData(&range, func, code);
252 } 258 }
253 } 259 }
254 260
255 261
256 void SourceReport::VisitLibrary(JSONArray* jsarr, const Library& lib) { 262 void SourceReport::VisitLibrary(JSONArray* jsarr, const Library& lib) {
257 Class& cls = Class::Handle(zone()); 263 Class& cls = Class::Handle(zone());
258 Array& functions = Array::Handle(zone()); 264 Array& functions = Array::Handle(zone());
259 Function& func = Function::Handle(zone()); 265 Function& func = Function::Handle(zone());
260 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); 266 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 VisitClosures(&ranges); 315 VisitClosures(&ranges);
310 } 316 }
311 317
312 // Print the script table. 318 // Print the script table.
313 JSONArray scripts(&report, "scripts"); 319 JSONArray scripts(&report, "scripts");
314 PrintScriptTable(&scripts); 320 PrintScriptTable(&scripts);
315 } 321 }
316 322
317 323
318 } // namespace dart 324 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/source_report.h ('k') | runtime/vm/source_report_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698