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