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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 static v8::Local<debug::GeneratorObject> Cast(v8::Local<v8::Value> value); | 210 static v8::Local<debug::GeneratorObject> Cast(v8::Local<v8::Value> value); |
211 }; | 211 }; |
212 | 212 |
213 /* | 213 /* |
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 // Only return a yes/no result. Optimization and GC are not affected. |
| 221 // Collecting best effort coverage does not reset counters. |
220 kBestEffort, | 222 kBestEffort, |
221 // Disable optimization and prevent feedback vectors from being garbage | 223 // Disable optimization and prevent feedback vectors from being garbage |
222 // collected in order to get precise invocation counts. | 224 // collected in order to preserve precise invocation counts. Collecting |
| 225 // precise count coverage resets counters to get incremental updates. |
223 kPreciseCount, | 226 kPreciseCount, |
| 227 // We are only interested in a yes/no result for the function. Optimization |
| 228 // and GC can be allowed once a function has been invoked. Collecting |
| 229 // precise binary coverage resets counters for incremental updates. |
| 230 kPreciseBinary |
224 }; | 231 }; |
225 | 232 |
226 class ScriptData; // Forward declaration. | 233 class ScriptData; // Forward declaration. |
227 | 234 |
228 class V8_EXPORT_PRIVATE FunctionData { | 235 class V8_EXPORT_PRIVATE FunctionData { |
229 public: | 236 public: |
230 int StartOffset(); | 237 int StartOffset() const; |
231 int EndOffset(); | 238 int EndOffset() const; |
232 uint32_t Count(); | 239 uint32_t Count() const; |
233 MaybeLocal<String> Name(); | 240 MaybeLocal<String> Name() const; |
234 | 241 |
235 private: | 242 private: |
236 explicit FunctionData(i::CoverageFunction* function) | 243 explicit FunctionData(i::CoverageFunction* function) |
237 : function_(function) {} | 244 : function_(function) {} |
238 i::CoverageFunction* function_; | 245 i::CoverageFunction* function_; |
239 | 246 |
240 friend class v8::debug::Coverage::ScriptData; | 247 friend class v8::debug::Coverage::ScriptData; |
241 }; | 248 }; |
242 | 249 |
243 class V8_EXPORT_PRIVATE ScriptData { | 250 class V8_EXPORT_PRIVATE ScriptData { |
244 public: | 251 public: |
245 Local<debug::Script> GetScript(); | 252 Local<debug::Script> GetScript() const; |
246 size_t FunctionCount(); | 253 size_t FunctionCount() const; |
247 FunctionData GetFunctionData(size_t i); | 254 FunctionData GetFunctionData(size_t i) const; |
248 | 255 |
249 private: | 256 private: |
250 explicit ScriptData(i::CoverageScript* script) : script_(script) {} | 257 explicit ScriptData(i::CoverageScript* script) : script_(script) {} |
251 i::CoverageScript* script_; | 258 i::CoverageScript* script_; |
252 | 259 |
253 friend class v8::debug::Coverage; | 260 friend class v8::debug::Coverage; |
254 }; | 261 }; |
255 | 262 |
256 static Coverage Collect(Isolate* isolate, bool reset_count); | 263 static Coverage CollectPrecise(Isolate* isolate); |
| 264 static Coverage CollectBestEffort(Isolate* isolate); |
257 | 265 |
258 static void SelectMode(Isolate* isolate, Mode mode); | 266 static void SelectMode(Isolate* isolate, Mode mode); |
259 | 267 |
260 size_t ScriptCount(); | 268 size_t ScriptCount() const; |
261 ScriptData GetScriptData(size_t i); | 269 ScriptData GetScriptData(size_t i) const; |
262 bool IsEmpty() { return coverage_ == nullptr; } | 270 bool IsEmpty() const { return coverage_ == nullptr; } |
263 | 271 |
264 ~Coverage(); | 272 ~Coverage(); |
265 | 273 |
266 private: | 274 private: |
267 explicit Coverage(i::Coverage* coverage) : coverage_(coverage) {} | 275 explicit Coverage(i::Coverage* coverage) : coverage_(coverage) {} |
268 i::Coverage* coverage_; | 276 i::Coverage* coverage_; |
269 }; | 277 }; |
270 } // namespace debug | 278 } // namespace debug |
271 } // namespace v8 | 279 } // namespace v8 |
272 | 280 |
273 #endif // V8_DEBUG_DEBUG_INTERFACE_H_ | 281 #endif // V8_DEBUG_DEBUG_INTERFACE_H_ |
OLD | NEW |