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

Side by Side Diff: runtime/vm/source_report.h

Issue 2038203002: Fix various nefarious problems with the script table used in source reports. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months 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
« no previous file with comments | « no previous file | runtime/vm/source_report.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/source_report.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698