OLD | NEW |
1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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_COVERAGE_H_ | 5 #ifndef V8_DEBUG_DEBUG_COVERAGE_H_ |
6 #define V8_DEBUG_DEBUG_COVERAGE_H_ | 6 #define V8_DEBUG_DEBUG_COVERAGE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "src/debug/debug-interface.h" | 10 #include "src/debug/debug-interface.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 struct CoverageScript { | 28 struct CoverageScript { |
29 // Initialize top-level function in case it has been garbage-collected. | 29 // Initialize top-level function in case it has been garbage-collected. |
30 CoverageScript(Isolate* isolate, Handle<Script> s) : script(s) {} | 30 CoverageScript(Isolate* isolate, Handle<Script> s) : script(s) {} |
31 Handle<Script> script; | 31 Handle<Script> script; |
32 // Functions are sorted by start position, from outer to inner function. | 32 // Functions are sorted by start position, from outer to inner function. |
33 std::vector<CoverageFunction> functions; | 33 std::vector<CoverageFunction> functions; |
34 }; | 34 }; |
35 | 35 |
36 class Coverage : public std::vector<CoverageScript> { | 36 class Coverage : public std::vector<CoverageScript> { |
37 public: | 37 public: |
38 // Allocate a new Coverage object and populate with result. | 38 // Collecting precise coverage only works if the modes kPreciseCount or |
39 // The ownership is transferred to the caller. | 39 // kPreciseBinary is selected. The invocation count is reset on collection. |
40 static Coverage* Collect(Isolate* isolate, bool reset_count); | 40 // In case of kPreciseCount, an updated count since last collection is |
| 41 // returned. In case of kPreciseBinary, a count of 1 is returned if a |
| 42 // function has been executed for the first time since last collection. |
| 43 static Coverage* CollectPrecise(Isolate* isolate); |
| 44 // Collecting best effort coverage always works, but may be imprecise |
| 45 // depending on selected mode. The invocation count is not reset. |
| 46 static Coverage* CollectBestEffort(Isolate* isolate); |
41 | 47 |
42 // Select code coverage mode. | 48 // Select code coverage mode. |
43 static void SelectMode(Isolate* isolate, debug::Coverage::Mode mode); | 49 static void SelectMode(Isolate* isolate, debug::Coverage::Mode mode); |
44 | 50 |
45 private: | 51 private: |
| 52 static Coverage* Collect(Isolate* isolate, |
| 53 v8::debug::Coverage::Mode collectionMode); |
| 54 |
46 Coverage() {} | 55 Coverage() {} |
47 }; | 56 }; |
48 | 57 |
49 } // namespace internal | 58 } // namespace internal |
50 } // namespace v8 | 59 } // namespace v8 |
51 | 60 |
52 #endif // V8_DEBUG_DEBUG_COVERAGE_H_ | 61 #endif // V8_DEBUG_DEBUG_COVERAGE_H_ |
OLD | NEW |