| 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" |
| 11 #include "vm/object.h" | 11 #include "vm/object.h" |
| 12 #include "vm/profiler_service.h" |
| 12 #include "vm/token_position.h" | 13 #include "vm/token_position.h" |
| 13 | 14 |
| 14 namespace dart { | 15 namespace dart { |
| 15 | 16 |
| 16 // A SourceReport object is used to generate reports about the program | 17 // A SourceReport object is used to generate reports about the program |
| 17 // source code, with information associated with source token | 18 // source code, with information associated with source token |
| 18 // positions. There are multiple possible kinds of reports. | 19 // positions. There are multiple possible kinds of reports. |
| 19 class SourceReport { | 20 class SourceReport { |
| 20 public: | 21 public: |
| 21 enum ReportKind { | 22 enum ReportKind { |
| 22 kCallSites = 0x1, | 23 kCallSites = 0x1, |
| 23 kCoverage = 0x2, | 24 kCoverage = 0x2, |
| 24 kPossibleBreakpoints = 0x4, | 25 kPossibleBreakpoints = 0x4, |
| 26 kProfile = 0x8, |
| 25 }; | 27 }; |
| 26 | 28 |
| 29 static const char* kCallSitesStr; |
| 30 static const char* kCoverageStr; |
| 31 static const char* kPossibleBreakpointsStr; |
| 32 static const char* kProfileStr; |
| 33 |
| 27 enum CompileMode { | 34 enum CompileMode { |
| 28 kNoCompile, | 35 kNoCompile, |
| 29 kForceCompile | 36 kForceCompile |
| 30 }; | 37 }; |
| 31 | 38 |
| 32 // report_set is a bitvector indicating which reports to generate | 39 // report_set is a bitvector indicating which reports to generate |
| 33 // (e.g. kCallSites | kCoverage). | 40 // (e.g. kCallSites | kCoverage). |
| 34 explicit SourceReport(intptr_t report_set, | 41 explicit SourceReport(intptr_t report_set, |
| 35 CompileMode compile = kNoCompile); | 42 CompileMode compile = kNoCompile); |
| 36 | 43 |
| 37 // Generate a source report for (some subrange of) a script. | 44 // Generate a source report for (some subrange of) a script. |
| 38 // | 45 // |
| 39 // If script is null, then the report is generated for all scripts | 46 // If script is null, then the report is generated for all scripts |
| 40 // in the isolate. | 47 // in the isolate. |
| 41 void PrintJSON(JSONStream* js, const Script& script, | 48 void PrintJSON(JSONStream* js, const Script& script, |
| 42 TokenPosition start_pos = TokenPosition::kNoSource, | 49 TokenPosition start_pos = TokenPosition::kNoSource, |
| 43 TokenPosition end_pos = TokenPosition::kNoSource); | 50 TokenPosition end_pos = TokenPosition::kNoSource); |
| 44 | 51 |
| 45 private: | 52 private: |
| 46 void Init(Thread* thread, const Script* script, | 53 void Init(Thread* thread, const Script* script, |
| 47 TokenPosition start_pos, TokenPosition end_pos); | 54 TokenPosition start_pos, TokenPosition end_pos); |
| 48 | 55 |
| 49 Thread* thread() const { return thread_; } | 56 Thread* thread() const { return thread_; } |
| 50 Zone* zone() const { return thread_->zone(); } | 57 Zone* zone() const { return thread_->zone(); } |
| 58 Isolate* isolate() const { return thread_->isolate(); } |
| 51 | 59 |
| 52 bool IsReportRequested(ReportKind report_kind); | 60 bool IsReportRequested(ReportKind report_kind); |
| 53 bool ShouldSkipFunction(const Function& func); | 61 bool ShouldSkipFunction(const Function& func); |
| 54 intptr_t GetScriptIndex(const Script& script); | 62 intptr_t GetScriptIndex(const Script& script); |
| 55 bool ScriptIsLoadedByLibrary(const Script& script, const Library& lib); | 63 bool ScriptIsLoadedByLibrary(const Script& script, const Library& lib); |
| 56 | 64 |
| 57 void PrintCallSitesData(JSONObject* jsobj, | 65 void PrintCallSitesData(JSONObject* jsobj, |
| 58 const Function& func, const Code& code); | 66 const Function& func, const Code& code); |
| 59 void PrintCoverageData(JSONObject* jsobj, | 67 void PrintCoverageData(JSONObject* jsobj, |
| 60 const Function& func, const Code& code); | 68 const Function& func, const Code& code); |
| 61 void PrintPossibleBreakpointsData(JSONObject* jsobj, | 69 void PrintPossibleBreakpointsData(JSONObject* jsobj, |
| 62 const Function& func, const Code& code); | 70 const Function& func, const Code& code); |
| 71 void PrintProfileData(JSONObject* jsobj, ProfileFunction* profile_function); |
| 63 void PrintScriptTable(JSONArray* jsarr); | 72 void PrintScriptTable(JSONArray* jsarr); |
| 64 | 73 |
| 65 void VisitFunction(JSONArray* jsarr, const Function& func); | 74 void VisitFunction(JSONArray* jsarr, const Function& func); |
| 66 void VisitLibrary(JSONArray* jsarr, const Library& lib); | 75 void VisitLibrary(JSONArray* jsarr, const Library& lib); |
| 67 void VisitClosures(JSONArray* jsarr); | 76 void VisitClosures(JSONArray* jsarr); |
| 68 | 77 |
| 69 // An entry in the script table. | 78 // An entry in the script table. |
| 70 struct ScriptTableEntry { | 79 struct ScriptTableEntry { |
| 71 ScriptTableEntry() : key(NULL), index(-1), script(NULL) {} | 80 ScriptTableEntry() : key(NULL), index(-1), script(NULL) {} |
| 72 | 81 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 97 return kv->key->Equals(*key); | 106 return kv->key->Equals(*key); |
| 98 } | 107 } |
| 99 }; | 108 }; |
| 100 | 109 |
| 101 intptr_t report_set_; | 110 intptr_t report_set_; |
| 102 CompileMode compile_mode_; | 111 CompileMode compile_mode_; |
| 103 Thread* thread_; | 112 Thread* thread_; |
| 104 const Script* script_; | 113 const Script* script_; |
| 105 TokenPosition start_pos_; | 114 TokenPosition start_pos_; |
| 106 TokenPosition end_pos_; | 115 TokenPosition end_pos_; |
| 116 Profile profile_; |
| 107 GrowableArray<ScriptTableEntry> script_table_entries_; | 117 GrowableArray<ScriptTableEntry> script_table_entries_; |
| 108 DirectChainedHashMap<ScriptTableTrait> script_table_; | 118 DirectChainedHashMap<ScriptTableTrait> script_table_; |
| 109 intptr_t next_script_index_; | 119 intptr_t next_script_index_; |
| 110 }; | 120 }; |
| 111 | 121 |
| 112 } // namespace dart | 122 } // namespace dart |
| 113 | 123 |
| 114 #endif // VM_SOURCE_REPORT_H_ | 124 #endif // VM_SOURCE_REPORT_H_ |
| OLD | NEW |