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_CODE_EVENTS_H_ | 5 #ifndef V8_CODE_EVENTS_H_ |
6 #define V8_CODE_EVENTS_H_ | 6 #define V8_CODE_EVENTS_H_ |
7 | 7 |
8 #include <unordered_set> | 8 #include <unordered_set> |
9 | 9 |
10 #include "src/base/platform/mutex.h" | 10 #include "src/base/platform/mutex.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 int args_count) = 0; | 98 int args_count) = 0; |
99 virtual void CallbackEvent(Name* name, Address entry_point) = 0; | 99 virtual void CallbackEvent(Name* name, Address entry_point) = 0; |
100 virtual void GetterCallbackEvent(Name* name, Address entry_point) = 0; | 100 virtual void GetterCallbackEvent(Name* name, Address entry_point) = 0; |
101 virtual void SetterCallbackEvent(Name* name, Address entry_point) = 0; | 101 virtual void SetterCallbackEvent(Name* name, Address entry_point) = 0; |
102 virtual void RegExpCodeCreateEvent(AbstractCode* code, String* source) = 0; | 102 virtual void RegExpCodeCreateEvent(AbstractCode* code, String* source) = 0; |
103 virtual void CodeMoveEvent(AbstractCode* from, Address to) = 0; | 103 virtual void CodeMoveEvent(AbstractCode* from, Address to) = 0; |
104 virtual void SharedFunctionInfoMoveEvent(Address from, Address to) = 0; | 104 virtual void SharedFunctionInfoMoveEvent(Address from, Address to) = 0; |
105 virtual void CodeMovingGCEvent() = 0; | 105 virtual void CodeMovingGCEvent() = 0; |
106 virtual void CodeDisableOptEvent(AbstractCode* code, | 106 virtual void CodeDisableOptEvent(AbstractCode* code, |
107 SharedFunctionInfo* shared) = 0; | 107 SharedFunctionInfo* shared) = 0; |
108 virtual void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta) = 0; | 108 enum DeoptKind { kSoft, kLazy, kEager }; |
109 virtual void CodeDeoptEvent(DeoptKind kind, Code* code, Address pc, | |
Leszek Swirski
2017/03/21 14:28:39
nit: it would be neater if the Code was the first
| |
110 int fp_to_sp_delta) = 0; | |
109 }; | 111 }; |
110 | 112 |
111 class CodeEventDispatcher { | 113 class CodeEventDispatcher { |
112 public: | 114 public: |
113 using LogEventsAndTags = CodeEventListener::LogEventsAndTags; | 115 using LogEventsAndTags = CodeEventListener::LogEventsAndTags; |
114 | 116 |
115 CodeEventDispatcher() {} | 117 CodeEventDispatcher() {} |
116 | 118 |
117 bool AddListener(CodeEventListener* listener) { | 119 bool AddListener(CodeEventListener* listener) { |
118 base::LockGuard<base::Mutex> guard(&mutex_); | 120 base::LockGuard<base::Mutex> guard(&mutex_); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 void CodeMoveEvent(AbstractCode* from, Address to) { | 165 void CodeMoveEvent(AbstractCode* from, Address to) { |
164 CODE_EVENT_DISPATCH(CodeMoveEvent(from, to)); | 166 CODE_EVENT_DISPATCH(CodeMoveEvent(from, to)); |
165 } | 167 } |
166 void SharedFunctionInfoMoveEvent(Address from, Address to) { | 168 void SharedFunctionInfoMoveEvent(Address from, Address to) { |
167 CODE_EVENT_DISPATCH(SharedFunctionInfoMoveEvent(from, to)); | 169 CODE_EVENT_DISPATCH(SharedFunctionInfoMoveEvent(from, to)); |
168 } | 170 } |
169 void CodeMovingGCEvent() { CODE_EVENT_DISPATCH(CodeMovingGCEvent()); } | 171 void CodeMovingGCEvent() { CODE_EVENT_DISPATCH(CodeMovingGCEvent()); } |
170 void CodeDisableOptEvent(AbstractCode* code, SharedFunctionInfo* shared) { | 172 void CodeDisableOptEvent(AbstractCode* code, SharedFunctionInfo* shared) { |
171 CODE_EVENT_DISPATCH(CodeDisableOptEvent(code, shared)); | 173 CODE_EVENT_DISPATCH(CodeDisableOptEvent(code, shared)); |
172 } | 174 } |
173 void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta) { | 175 void CodeDeoptEvent(CodeEventListener::DeoptKind kind, Code* code, Address pc, |
174 CODE_EVENT_DISPATCH(CodeDeoptEvent(code, pc, fp_to_sp_delta)); | 176 int fp_to_sp_delta) { |
177 CODE_EVENT_DISPATCH(CodeDeoptEvent(kind, code, pc, fp_to_sp_delta)); | |
175 } | 178 } |
176 #undef CODE_EVENT_DISPATCH | 179 #undef CODE_EVENT_DISPATCH |
177 | 180 |
178 private: | 181 private: |
179 std::unordered_set<CodeEventListener*> listeners_; | 182 std::unordered_set<CodeEventListener*> listeners_; |
180 base::Mutex mutex_; | 183 base::Mutex mutex_; |
181 | 184 |
182 DISALLOW_COPY_AND_ASSIGN(CodeEventDispatcher); | 185 DISALLOW_COPY_AND_ASSIGN(CodeEventDispatcher); |
183 }; | 186 }; |
184 | 187 |
185 } // namespace internal | 188 } // namespace internal |
186 } // namespace v8 | 189 } // namespace v8 |
187 | 190 |
188 #endif // V8_CODE_EVENTS_H_ | 191 #endif // V8_CODE_EVENTS_H_ |
OLD | NEW |