OLD | NEW |
---|---|
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_PROFILER_PROFILER_LISTENER_H_ | 5 #ifndef V8_PROFILER_PROFILER_LISTENER_H_ |
6 #define V8_PROFILER_PROFILER_LISTENER_H_ | 6 #define V8_PROFILER_PROFILER_LISTENER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "src/code-events.h" | 10 #include "src/code-events.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 } | 72 } |
73 const char* GetFunctionName(const char* name) { | 73 const char* GetFunctionName(const char* name) { |
74 return function_and_resource_names_.GetFunctionName(name); | 74 return function_and_resource_names_.GetFunctionName(name); |
75 } | 75 } |
76 | 76 |
77 private: | 77 private: |
78 void RecordInliningInfo(CodeEntry* entry, AbstractCode* abstract_code); | 78 void RecordInliningInfo(CodeEntry* entry, AbstractCode* abstract_code); |
79 void RecordDeoptInlinedFrames(CodeEntry* entry, AbstractCode* abstract_code); | 79 void RecordDeoptInlinedFrames(CodeEntry* entry, AbstractCode* abstract_code); |
80 Name* InferScriptName(Name* name, SharedFunctionInfo* info); | 80 Name* InferScriptName(Name* name, SharedFunctionInfo* info); |
81 V8_INLINE void DispatchCodeEvent(const CodeEventsContainer& evt_rec) { | 81 V8_INLINE void DispatchCodeEvent(const CodeEventsContainer& evt_rec) { |
82 if (observers_.empty()) return; | |
83 base::LockGuard<base::Mutex> guard(&mutex_); | |
jochen (gone - plz use gerrit)
2016/09/09 13:21:09
shouldn't you lock before checking observers_?
alph
2016/09/09 21:03:30
I'd like to have a fast path if there're no observ
| |
82 for (auto observer : observers_) { | 84 for (auto observer : observers_) { |
83 observer->CodeEventHandler(evt_rec); | 85 observer->CodeEventHandler(evt_rec); |
84 } | 86 } |
85 } | 87 } |
86 | 88 |
87 StringsStorage function_and_resource_names_; | 89 StringsStorage function_and_resource_names_; |
88 std::vector<CodeEntry*> code_entries_; | 90 std::vector<CodeEntry*> code_entries_; |
89 std::vector<CodeEventObserver*> observers_; | 91 std::vector<CodeEventObserver*> observers_; |
92 base::Mutex mutex_; | |
90 | 93 |
91 DISALLOW_COPY_AND_ASSIGN(ProfilerListener); | 94 DISALLOW_COPY_AND_ASSIGN(ProfilerListener); |
92 }; | 95 }; |
93 | 96 |
94 } // namespace internal | 97 } // namespace internal |
95 } // namespace v8 | 98 } // namespace v8 |
96 | 99 |
97 #endif // V8_PROFILER_PROFILER_LISTENER_H_ | 100 #endif // V8_PROFILER_PROFILER_LISTENER_H_ |
OLD | NEW |