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_DEBUG_DEBUG_INTERFACE_H_ | 5 #ifndef V8_DEBUG_DEBUG_INTERFACE_H_ |
6 #define V8_DEBUG_DEBUG_INTERFACE_H_ | 6 #define V8_DEBUG_DEBUG_INTERFACE_H_ |
7 | 7 |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "include/v8-debug.h" | 10 #include "include/v8-debug.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 * Provide API layer between inspector and code coverage. | 214 * Provide API layer between inspector and code coverage. |
215 */ | 215 */ |
216 class V8_EXPORT_PRIVATE Coverage { | 216 class V8_EXPORT_PRIVATE Coverage { |
217 public: | 217 public: |
218 enum Mode { | 218 enum Mode { |
219 // Make use of existing information in feedback vectors on the heap. | 219 // Make use of existing information in feedback vectors on the heap. |
220 kBestEffort, | 220 kBestEffort, |
221 // Disable optimization and prevent feedback vectors from being garbage | 221 // Disable optimization and prevent feedback vectors from being garbage |
222 // collected in order to get precise invocation counts. | 222 // collected in order to get precise invocation counts. |
223 kPreciseCount, | 223 kPreciseCount, |
| 224 // We are only interested in a yes/no result for the function. Optimization |
| 225 // and garbage collection can be allowed once a function has been invoked. |
| 226 kPreciseBinary |
224 }; | 227 }; |
225 | 228 |
226 class ScriptData; // Forward declaration. | 229 class ScriptData; // Forward declaration. |
227 | 230 |
228 class V8_EXPORT_PRIVATE FunctionData { | 231 class V8_EXPORT_PRIVATE FunctionData { |
229 public: | 232 public: |
230 int StartOffset(); | 233 int StartOffset() const; |
231 int EndOffset(); | 234 int EndOffset() const; |
232 uint32_t Count(); | 235 uint32_t Count() const; |
233 MaybeLocal<String> Name(); | 236 MaybeLocal<String> Name() const; |
234 | 237 |
235 private: | 238 private: |
236 explicit FunctionData(i::CoverageFunction* function) | 239 explicit FunctionData(i::CoverageFunction* function) |
237 : function_(function) {} | 240 : function_(function) {} |
238 i::CoverageFunction* function_; | 241 i::CoverageFunction* function_; |
239 | 242 |
240 friend class v8::debug::Coverage::ScriptData; | 243 friend class v8::debug::Coverage::ScriptData; |
241 }; | 244 }; |
242 | 245 |
243 class V8_EXPORT_PRIVATE ScriptData { | 246 class V8_EXPORT_PRIVATE ScriptData { |
244 public: | 247 public: |
245 Local<debug::Script> GetScript(); | 248 Local<debug::Script> GetScript() const; |
246 size_t FunctionCount(); | 249 size_t FunctionCount() const; |
247 FunctionData GetFunctionData(size_t i); | 250 FunctionData GetFunctionData(size_t i) const; |
248 | 251 |
249 private: | 252 private: |
250 explicit ScriptData(i::CoverageScript* script) : script_(script) {} | 253 explicit ScriptData(i::CoverageScript* script) : script_(script) {} |
251 i::CoverageScript* script_; | 254 i::CoverageScript* script_; |
252 | 255 |
253 friend class v8::debug::Coverage; | 256 friend class v8::debug::Coverage; |
254 }; | 257 }; |
255 | 258 |
256 static Coverage Collect(Isolate* isolate, bool reset_count); | 259 static Coverage CollectPrecise(Isolate* isolate); |
| 260 static Coverage CollectBestEffort(Isolate* isolate); |
257 | 261 |
258 static void SelectMode(Isolate* isolate, Mode mode); | 262 static void SelectMode(Isolate* isolate, Mode mode); |
259 | 263 |
260 size_t ScriptCount(); | 264 size_t ScriptCount() const; |
261 ScriptData GetScriptData(size_t i); | 265 ScriptData GetScriptData(size_t i) const; |
262 bool IsEmpty() { return coverage_ == nullptr; } | 266 bool IsEmpty() const { return coverage_ == nullptr; } |
263 | 267 |
264 ~Coverage(); | 268 ~Coverage(); |
265 | 269 |
266 private: | 270 private: |
267 explicit Coverage(i::Coverage* coverage) : coverage_(coverage) {} | 271 explicit Coverage(i::Coverage* coverage) : coverage_(coverage) {} |
268 i::Coverage* coverage_; | 272 i::Coverage* coverage_; |
269 }; | 273 }; |
270 } // namespace debug | 274 } // namespace debug |
271 } // namespace v8 | 275 } // namespace v8 |
272 | 276 |
273 #endif // V8_DEBUG_DEBUG_INTERFACE_H_ | 277 #endif // V8_DEBUG_DEBUG_INTERFACE_H_ |
OLD | NEW |