OLD | NEW |
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 #ifndef VM_SOURCE_REPORT_H_ | 5 #ifndef VM_SOURCE_REPORT_H_ |
6 #define VM_SOURCE_REPORT_H_ | 6 #define VM_SOURCE_REPORT_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
10 #include "vm/hash_map.h" | 10 #include "vm/hash_map.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 enum CompileMode { | 34 enum CompileMode { |
35 kNoCompile, | 35 kNoCompile, |
36 kForceCompile | 36 kForceCompile |
37 }; | 37 }; |
38 | 38 |
39 // report_set is a bitvector indicating which reports to generate | 39 // report_set is a bitvector indicating which reports to generate |
40 // (e.g. kCallSites | kCoverage). | 40 // (e.g. kCallSites | kCoverage). |
41 explicit SourceReport(intptr_t report_set, | 41 explicit SourceReport(intptr_t report_set, |
42 CompileMode compile = kNoCompile); | 42 CompileMode compile = kNoCompile); |
| 43 ~SourceReport(); |
43 | 44 |
44 // Generate a source report for (some subrange of) a script. | 45 // Generate a source report for (some subrange of) a script. |
45 // | 46 // |
46 // If script is null, then the report is generated for all scripts | 47 // If script is null, then the report is generated for all scripts |
47 // in the isolate. | 48 // in the isolate. |
48 void PrintJSON(JSONStream* js, const Script& script, | 49 void PrintJSON(JSONStream* js, const Script& script, |
49 TokenPosition start_pos = TokenPosition::kNoSource, | 50 TokenPosition start_pos = TokenPosition::kNoSource, |
50 TokenPosition end_pos = TokenPosition::kNoSource); | 51 TokenPosition end_pos = TokenPosition::kNoSource); |
51 | 52 |
52 private: | 53 private: |
| 54 void ClearScriptTable(); |
53 void Init(Thread* thread, const Script* script, | 55 void Init(Thread* thread, const Script* script, |
54 TokenPosition start_pos, TokenPosition end_pos); | 56 TokenPosition start_pos, TokenPosition end_pos); |
55 | 57 |
56 Thread* thread() const { return thread_; } | 58 Thread* thread() const { return thread_; } |
57 Zone* zone() const { return thread_->zone(); } | 59 Zone* zone() const { return thread_->zone(); } |
58 Isolate* isolate() const { return thread_->isolate(); } | 60 Isolate* isolate() const { return thread_->isolate(); } |
59 | 61 |
60 bool IsReportRequested(ReportKind report_kind); | 62 bool IsReportRequested(ReportKind report_kind); |
61 bool ShouldSkipFunction(const Function& func); | 63 bool ShouldSkipFunction(const Function& func); |
62 intptr_t GetScriptIndex(const Script& script); | 64 intptr_t GetScriptIndex(const Script& script); |
63 bool ScriptIsLoadedByLibrary(const Script& script, const Library& lib); | 65 bool ScriptIsLoadedByLibrary(const Script& script, const Library& lib); |
64 | 66 |
65 void PrintCallSitesData(JSONObject* jsobj, | 67 void PrintCallSitesData(JSONObject* jsobj, |
66 const Function& func, const Code& code); | 68 const Function& func, const Code& code); |
67 void PrintCoverageData(JSONObject* jsobj, | 69 void PrintCoverageData(JSONObject* jsobj, |
68 const Function& func, const Code& code); | 70 const Function& func, const Code& code); |
69 void PrintPossibleBreakpointsData(JSONObject* jsobj, | 71 void PrintPossibleBreakpointsData(JSONObject* jsobj, |
70 const Function& func, const Code& code); | 72 const Function& func, const Code& code); |
71 void PrintProfileData(JSONObject* jsobj, ProfileFunction* profile_function); | 73 void PrintProfileData(JSONObject* jsobj, ProfileFunction* profile_function); |
| 74 #if defined(DEBUG) |
| 75 void VerifyScriptTable(); |
| 76 #endif |
72 void PrintScriptTable(JSONArray* jsarr); | 77 void PrintScriptTable(JSONArray* jsarr); |
73 | 78 |
74 void VisitFunction(JSONArray* jsarr, const Function& func); | 79 void VisitFunction(JSONArray* jsarr, const Function& func); |
75 void VisitLibrary(JSONArray* jsarr, const Library& lib); | 80 void VisitLibrary(JSONArray* jsarr, const Library& lib); |
76 void VisitClosures(JSONArray* jsarr); | 81 void VisitClosures(JSONArray* jsarr); |
77 | 82 |
78 // An entry in the script table. | 83 // An entry in the script table. |
79 struct ScriptTableEntry { | 84 struct ScriptTableEntry { |
80 ScriptTableEntry() : key(NULL), index(-1), script(NULL) {} | 85 ScriptTableEntry() : key(NULL), index(-1), script(NULL) {} |
81 | 86 |
(...skipping 25 matching lines...) Expand all Loading... |
107 } | 112 } |
108 }; | 113 }; |
109 | 114 |
110 intptr_t report_set_; | 115 intptr_t report_set_; |
111 CompileMode compile_mode_; | 116 CompileMode compile_mode_; |
112 Thread* thread_; | 117 Thread* thread_; |
113 const Script* script_; | 118 const Script* script_; |
114 TokenPosition start_pos_; | 119 TokenPosition start_pos_; |
115 TokenPosition end_pos_; | 120 TokenPosition end_pos_; |
116 Profile profile_; | 121 Profile profile_; |
117 GrowableArray<ScriptTableEntry> script_table_entries_; | 122 GrowableArray<ScriptTableEntry*> script_table_entries_; |
118 DirectChainedHashMap<ScriptTableTrait> script_table_; | 123 DirectChainedHashMap<ScriptTableTrait> script_table_; |
119 intptr_t next_script_index_; | 124 intptr_t next_script_index_; |
120 }; | 125 }; |
121 | 126 |
122 } // namespace dart | 127 } // namespace dart |
123 | 128 |
124 #endif // VM_SOURCE_REPORT_H_ | 129 #endif // VM_SOURCE_REPORT_H_ |
OLD | NEW |