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 #include "src/debug/debug-coverage.h" | 5 #include "src/debug/debug-coverage.h" |
6 | 6 |
7 #include "src/base/hashmap.h" | 7 #include "src/base/hashmap.h" |
8 #include "src/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 if (reset_count) vector->clear_invocation_count(); | 87 if (reset_count) vector->clear_invocation_count(); |
88 counter_map.Add(shared, count); | 88 counter_map.Add(shared, count); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 // Iterate shared function infos of every script and build a mapping | 92 // Iterate shared function infos of every script and build a mapping |
93 // between source ranges and invocation counts. | 93 // between source ranges and invocation counts. |
94 Coverage* result = new Coverage(); | 94 Coverage* result = new Coverage(); |
95 Script::Iterator scripts(isolate); | 95 Script::Iterator scripts(isolate); |
96 while (Script* script = scripts.Next()) { | 96 while (Script* script = scripts.Next()) { |
97 // Dismiss non-user scripts. | 97 if (!script->IsUserJavaScript()) continue; |
98 if (script->type() != Script::TYPE_NORMAL) continue; | |
99 | 98 |
100 // Create and add new script data. | 99 // Create and add new script data. |
101 Handle<Script> script_handle(script, isolate); | 100 Handle<Script> script_handle(script, isolate); |
102 result->emplace_back(isolate, script_handle); | 101 result->emplace_back(isolate, script_handle); |
103 std::vector<CoverageFunction>* functions = &result->back().functions; | 102 std::vector<CoverageFunction>* functions = &result->back().functions; |
104 | 103 |
105 std::vector<SharedFunctionInfo*> sorted; | 104 std::vector<SharedFunctionInfo*> sorted; |
106 | 105 |
107 { | 106 { |
108 // Sort functions by start position, from outer to inner functions. | 107 // Sort functions by start position, from outer to inner functions. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 ArrayList::New(isolate, static_cast<int>(vectors.size())); | 148 ArrayList::New(isolate, static_cast<int>(vectors.size())); |
150 for (const auto& vector : vectors) list = ArrayList::Add(list, vector); | 149 for (const auto& vector : vectors) list = ArrayList::Add(list, vector); |
151 isolate->SetCodeCoverageList(*list); | 150 isolate->SetCodeCoverageList(*list); |
152 } else { | 151 } else { |
153 isolate->SetCodeCoverageList(isolate->heap()->undefined_value()); | 152 isolate->SetCodeCoverageList(isolate->heap()->undefined_value()); |
154 } | 153 } |
155 } | 154 } |
156 | 155 |
157 } // namespace internal | 156 } // namespace internal |
158 } // namespace v8 | 157 } // namespace v8 |
OLD | NEW |