| 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" | 10 #include "src/allocation.h" |
| 11 #include "src/debug/debug-interface.h" |
| 12 #include "src/objects.h" |
| 11 | 13 |
| 12 namespace v8 { | 14 namespace v8 { |
| 13 namespace internal { | 15 namespace internal { |
| 14 | 16 |
| 15 // Forward declaration. | 17 // Forward declaration. |
| 16 class Isolate; | 18 class Isolate; |
| 17 | 19 |
| 18 class Coverage : public AllStatic { | 20 class Coverage : public AllStatic { |
| 19 public: | 21 public: |
| 20 struct RangeEntry { | 22 struct Range { |
| 21 int end_position; | 23 Range(int s, int e, uint32_t c) : start(s), end(e), count(c) {} |
| 24 int start; |
| 25 int end; |
| 22 uint32_t count; | 26 uint32_t count; |
| 27 std::vector<uint16_t> name; |
| 28 std::vector<Range> inner; |
| 23 }; | 29 }; |
| 24 | 30 |
| 25 struct ScriptData { | 31 struct ScriptData { |
| 26 ScriptData(int s, std::vector<RangeEntry> e) | 32 // Initialize top-level function in case it has been garbage-collected. |
| 27 : script_id(s), entries(std::move(e)) {} | 33 ScriptData(Handle<Script> s, int source_length) |
| 28 int script_id; | 34 : script(s), toplevel(0, source_length, 1) {} |
| 29 std::vector<RangeEntry> entries; | 35 Handle<Script> script; |
| 36 Range toplevel; |
| 30 }; | 37 }; |
| 31 | 38 |
| 32 static std::vector<ScriptData> Collect(Isolate* isolate); | 39 static std::vector<ScriptData> Collect(Isolate* isolate); |
| 33 | 40 |
| 34 // Enable precise code coverage. This disables optimization and makes sure | 41 // Enable precise code coverage. This disables optimization and makes sure |
| 35 // invocation count is not affected by GC. | 42 // invocation count is not affected by GC. |
| 36 static void EnablePrecise(Isolate* isolate); | 43 static void EnablePrecise(Isolate* isolate); |
| 37 static void DisablePrecise(Isolate* isolate); | 44 static void DisablePrecise(Isolate* isolate); |
| 38 }; | 45 }; |
| 39 | 46 |
| 40 } // namespace internal | 47 } // namespace internal |
| 41 } // namespace v8 | 48 } // namespace v8 |
| 42 | 49 |
| 43 #endif // V8_DEBUG_DEBUG_COVERAGE_H_ | 50 #endif // V8_DEBUG_DEBUG_COVERAGE_H_ |
| OLD | NEW |