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

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

Issue 1533653003: Add SourceReport, a class for generating Dart source-level reports. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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/object.cc ('k') | runtime/vm/source_report.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef VM_SOURCE_REPORT_H_
6 #define VM_SOURCE_REPORT_H_
7
8 #include "vm/allocation.h"
9 #include "vm/flags.h"
10 #include "vm/hash_map.h"
11 #include "vm/object.h"
12
13 namespace dart {
14
15 // A SourceReport object is used to generate reports about the program
16 // source code, with information associated with source token
17 // positions. There are multiple possible kinds of reports.
18 class SourceReport {
19 public:
20 enum ReportKind {
21 kCallSites,
22 kCoverage,
23 };
24
25 enum CompileMode {
26 kNoCompile,
27 kForceCompile
28 };
29
30 explicit SourceReport(ReportKind report_kind,
31 CompileMode compile = kNoCompile);
32
33 // Generate a source report for (some subrange of) a script.
34 //
35 // If script is null, then the report is generated for all scripts
36 // in the isolate.
37 void PrintJSON(JSONStream* js, const Script& script,
38 intptr_t start_pos = -1, intptr_t end_pos = -1);
39
40 private:
41 void Init(Thread* thread, const Script* script,
42 intptr_t start_pos, intptr_t end_pos);
43
44 Thread* thread() const { return thread_; }
45 Zone* zone() const { return thread_->zone(); }
46
47 bool ShouldSkipFunction(const Function& func);
48 intptr_t GetScriptIndex(const Script& script);
49 bool ScriptIsLoadedByLibrary(const Script& script, const Library& lib);
50
51 void PrintCallSitesData(JSONObject* jsobj,
52 const Function& func, const Code& code);
53 void PrintCoverageData(JSONObject* jsobj,
54 const Function& func, const Code& code);
55 void PrintScriptTable(JSONArray* jsarr);
56
57 void VisitFunction(JSONArray* jsarr, const Function& func);
58 void VisitLibrary(JSONArray* jsarr, const Library& lib);
59 void VisitClosures(JSONArray* jsarr);
60
61 // An entry in the script table.
62 struct ScriptTableEntry {
63 ScriptTableEntry() : key(NULL), index(-1), script(NULL) {}
64
65 const String* key;
66 intptr_t index;
67 const Script* script;
68 };
69
70 // Needed for DirectChainedHashMap.
71 struct ScriptTableTrait {
72 typedef ScriptTableEntry* Value;
73 typedef const String* Key;
74 typedef ScriptTableEntry* Pair;
75
76 static Key KeyOf(Pair kv) {
77 return kv->key;
78 }
79
80 static Value ValueOf(Pair kv) {
81 return kv;
82 }
83
84 static inline intptr_t Hashcode(Key key) {
85 return key->Hash();
86 }
87
88 static inline bool IsKeyEqual(Pair kv, Key key) {
89 return kv->key->Equals(*key);
90 }
91 };
92
93 ReportKind report_kind_;
94 CompileMode compile_mode_;
95 Thread* thread_;
96 const Script* script_;
97 intptr_t start_pos_;
98 intptr_t end_pos_;
99 GrowableArray<ScriptTableEntry> script_table_entries_;
100 DirectChainedHashMap<ScriptTableTrait> script_table_;
101 intptr_t next_script_index_;
102 };
103
104 } // namespace dart
105
106 #endif // VM_SOURCE_REPORT_H_
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/source_report.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698