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

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: tweaks Created 5 years 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
(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 all scripts in an isolate.
34 void PrintJSON(JSONStream* js);
35
36 // Generate a source report for (some subrange of) a script.
37 void PrintJSONForScript(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() {
64 key = NULL;
Cutch 2015/12/17 21:31:07 use initializer list syntax instead.. : key(NULL).
turnidge 2015/12/17 21:48:01 Done.
65 index = -1;
66 script = NULL;
67 }
68
69 const String* key;
70 intptr_t index;
71 const Script* script;
72 };
73
74 // Needed for DirectChainedHashMap.
75 struct ScriptTableTrait {
76 typedef ScriptTableEntry* Value;
77 typedef const String* Key;
78 typedef ScriptTableEntry* Pair;
79
80 static Key KeyOf(Pair kv) {
81 return kv->key;
82 }
83
84 static Value ValueOf(Pair kv) {
85 return kv;
86 }
87
88 static inline intptr_t Hashcode(Key key) {
89 return key->Hash();
90 }
91
92 static inline bool IsKeyEqual(Pair kv, Key key) {
93 return kv->key->Equals(*key);
94 }
95 };
96
97 ReportKind report_kind_;
98 CompileMode compile_mode_;
99 Thread* thread_;
100 const Script* script_;
101 intptr_t start_pos_;
102 intptr_t end_pos_;
103 GrowableArray<ScriptTableEntry> script_table_entries_;
104 DirectChainedHashMap<ScriptTableTrait> script_table_;
105 intptr_t next_script_index_;
106 };
107
108 } // namespace dart
109
110 #endif // VM_SOURCE_REPORT_H_
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/source_report.cc » ('j') | runtime/vm/source_report.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698