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/allocation.h" | |
11 #include "src/debug/debug-interface.h" | 10 #include "src/debug/debug-interface.h" |
12 #include "src/objects.h" | 11 #include "src/objects.h" |
13 | 12 |
14 namespace v8 { | 13 namespace v8 { |
15 namespace internal { | 14 namespace internal { |
16 | 15 |
17 // Forward declaration. | 16 // Forward declaration. |
18 class Isolate; | 17 class Isolate; |
19 | 18 |
20 class Coverage : public AllStatic { | 19 struct CoverageRange { |
20 CoverageRange(int s, int e, uint32_t c, Handle<String> n) | |
21 : start(s), end(e), count(c), name(n) {} | |
22 int start; | |
23 int end; | |
24 uint32_t count; | |
25 Handle<String> name; | |
26 std::vector<CoverageRange> inner; | |
27 }; | |
28 | |
29 struct CoverageScript { | |
30 // Initialize top-level function in case it has been garbage-collected. | |
31 CoverageScript(Isolate* isolate, Handle<Script> s, int source_length); | |
32 Handle<Script> script; | |
33 CoverageRange toplevel; | |
34 }; | |
35 | |
36 class Coverage : public std::vector<CoverageScript> { | |
kozy
2017/02/15 16:33:41
I think that std::vector has non-virtual destructo
Yang
2017/02/15 16:42:41
I'm not using any polymorphism here. The destructo
| |
21 public: | 37 public: |
22 struct Range { | 38 // Allocate a new Coverage object and populate with result. |
23 Range(int s, int e, uint32_t c) : start(s), end(e), count(c) {} | 39 // The ownership is transferred to the caller. |
24 int start; | 40 static Coverage* Collect(Isolate* isolate); |
25 int end; | |
26 uint32_t count; | |
27 std::vector<uint16_t> name; | |
28 std::vector<Range> inner; | |
29 }; | |
30 | |
31 struct ScriptData { | |
32 // Initialize top-level function in case it has been garbage-collected. | |
33 ScriptData(Handle<Script> s, int source_length) | |
34 : script(s), toplevel(0, source_length, 1) {} | |
35 Handle<Script> script; | |
36 Range toplevel; | |
37 }; | |
38 | |
39 V8_EXPORT_PRIVATE static std::vector<ScriptData> Collect(Isolate* isolate); | |
40 | 41 |
41 // Enable precise code coverage. This disables optimization and makes sure | 42 // Enable precise code coverage. This disables optimization and makes sure |
42 // invocation count is not affected by GC. | 43 // invocation count is not affected by GC. |
43 V8_EXPORT_PRIVATE static void EnablePrecise(Isolate* isolate); | 44 static void TogglePrecise(Isolate* isolate, bool enable); |
44 V8_EXPORT_PRIVATE static void DisablePrecise(Isolate* isolate); | 45 |
46 private: | |
47 Coverage() {} | |
45 }; | 48 }; |
46 | 49 |
47 } // namespace internal | 50 } // namespace internal |
48 } // namespace v8 | 51 } // namespace v8 |
49 | 52 |
50 #endif // V8_DEBUG_DEBUG_COVERAGE_H_ | 53 #endif // V8_DEBUG_DEBUG_COVERAGE_H_ |
OLD | NEW |