| 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 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 // A SourceReport object is used to generate reports about the program | 15 // A SourceReport object is used to generate reports about the program |
| 16 // source code, with information associated with source token | 16 // source code, with information associated with source token |
| 17 // positions. There are multiple possible kinds of reports. | 17 // positions. There are multiple possible kinds of reports. |
| 18 class SourceReport { | 18 class SourceReport { |
| 19 public: | 19 public: |
| 20 enum ReportKind { | 20 enum ReportKind { |
| 21 kCallSites, | 21 kCallSites = 0x1, |
| 22 kCoverage, | 22 kCoverage = 0x2, |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 enum CompileMode { | 25 enum CompileMode { |
| 26 kNoCompile, | 26 kNoCompile, |
| 27 kForceCompile | 27 kForceCompile |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 explicit SourceReport(ReportKind report_kind, | 30 // report_set is a bitvector indicating which reports to generate |
| 31 // (e.g. kCallSites | kCoverage). |
| 32 explicit SourceReport(intptr_t report_set, |
| 31 CompileMode compile = kNoCompile); | 33 CompileMode compile = kNoCompile); |
| 32 | 34 |
| 33 // Generate a source report for (some subrange of) a script. | 35 // Generate a source report for (some subrange of) a script. |
| 34 // | 36 // |
| 35 // If script is null, then the report is generated for all scripts | 37 // If script is null, then the report is generated for all scripts |
| 36 // in the isolate. | 38 // in the isolate. |
| 37 void PrintJSON(JSONStream* js, const Script& script, | 39 void PrintJSON(JSONStream* js, const Script& script, |
| 38 intptr_t start_pos = -1, intptr_t end_pos = -1); | 40 intptr_t start_pos = -1, intptr_t end_pos = -1); |
| 39 | 41 |
| 40 private: | 42 private: |
| 41 void Init(Thread* thread, const Script* script, | 43 void Init(Thread* thread, const Script* script, |
| 42 intptr_t start_pos, intptr_t end_pos); | 44 intptr_t start_pos, intptr_t end_pos); |
| 43 | 45 |
| 44 Thread* thread() const { return thread_; } | 46 Thread* thread() const { return thread_; } |
| 45 Zone* zone() const { return thread_->zone(); } | 47 Zone* zone() const { return thread_->zone(); } |
| 46 | 48 |
| 49 bool IsReportRequested(ReportKind report_kind); |
| 47 bool ShouldSkipFunction(const Function& func); | 50 bool ShouldSkipFunction(const Function& func); |
| 48 intptr_t GetScriptIndex(const Script& script); | 51 intptr_t GetScriptIndex(const Script& script); |
| 49 bool ScriptIsLoadedByLibrary(const Script& script, const Library& lib); | 52 bool ScriptIsLoadedByLibrary(const Script& script, const Library& lib); |
| 50 | 53 |
| 51 void PrintCallSitesData(JSONObject* jsobj, | 54 void PrintCallSitesData(JSONObject* jsobj, |
| 52 const Function& func, const Code& code); | 55 const Function& func, const Code& code); |
| 53 void PrintCoverageData(JSONObject* jsobj, | 56 void PrintCoverageData(JSONObject* jsobj, |
| 54 const Function& func, const Code& code); | 57 const Function& func, const Code& code); |
| 55 void PrintScriptTable(JSONArray* jsarr); | 58 void PrintScriptTable(JSONArray* jsarr); |
| 56 | 59 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 83 | 86 |
| 84 static inline intptr_t Hashcode(Key key) { | 87 static inline intptr_t Hashcode(Key key) { |
| 85 return key->Hash(); | 88 return key->Hash(); |
| 86 } | 89 } |
| 87 | 90 |
| 88 static inline bool IsKeyEqual(Pair kv, Key key) { | 91 static inline bool IsKeyEqual(Pair kv, Key key) { |
| 89 return kv->key->Equals(*key); | 92 return kv->key->Equals(*key); |
| 90 } | 93 } |
| 91 }; | 94 }; |
| 92 | 95 |
| 93 ReportKind report_kind_; | 96 intptr_t report_set_; |
| 94 CompileMode compile_mode_; | 97 CompileMode compile_mode_; |
| 95 Thread* thread_; | 98 Thread* thread_; |
| 96 const Script* script_; | 99 const Script* script_; |
| 97 intptr_t start_pos_; | 100 intptr_t start_pos_; |
| 98 intptr_t end_pos_; | 101 intptr_t end_pos_; |
| 99 GrowableArray<ScriptTableEntry> script_table_entries_; | 102 GrowableArray<ScriptTableEntry> script_table_entries_; |
| 100 DirectChainedHashMap<ScriptTableTrait> script_table_; | 103 DirectChainedHashMap<ScriptTableTrait> script_table_; |
| 101 intptr_t next_script_index_; | 104 intptr_t next_script_index_; |
| 102 }; | 105 }; |
| 103 | 106 |
| 104 } // namespace dart | 107 } // namespace dart |
| 105 | 108 |
| 106 #endif // VM_SOURCE_REPORT_H_ | 109 #endif // VM_SOURCE_REPORT_H_ |
| OLD | NEW |