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/frames-inl.h" | 9 #include "src/frames-inl.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 case v8::debug::Coverage::kPreciseCount: | 152 case v8::debug::Coverage::kPreciseCount: |
153 break; | 153 break; |
154 case v8::debug::Coverage::kPreciseBinary: | 154 case v8::debug::Coverage::kPreciseBinary: |
155 count = info->has_reported_binary_coverage() ? 0 : 1; | 155 count = info->has_reported_binary_coverage() ? 0 : 1; |
156 info->set_has_reported_binary_coverage(true); | 156 info->set_has_reported_binary_coverage(true); |
157 break; | 157 break; |
158 case v8::debug::Coverage::kBestEffort: | 158 case v8::debug::Coverage::kBestEffort: |
159 count = 1; | 159 count = 1; |
160 break; | 160 break; |
161 } | 161 } |
162 } else if (nesting.empty() || functions->at(nesting.back()).count == 0) { | |
163 // Only include a function range if it has a non-0 count, or | |
164 // if it is directly nested inside a function with non-0 count. | |
165 continue; | |
166 } | 162 } |
167 Handle<String> name(info->DebugName(), isolate); | 163 // Only include a function range if it has a non-0 count, or |
168 nesting.push_back(functions->size()); | 164 // if it is directly nested inside a function with non-0 count. |
169 functions->emplace_back(start, end, count, name); | 165 if (count != 0 || |
| 166 (!nesting.empty() && functions->at(nesting.back()).count != 0)) { |
| 167 Handle<String> name(info->DebugName(), isolate); |
| 168 nesting.push_back(functions->size()); |
| 169 functions->emplace_back(start, end, count, name); |
| 170 } |
170 } | 171 } |
171 | 172 |
172 // Remove entries for scripts that have no coverage. | 173 // Remove entries for scripts that have no coverage. |
173 if (functions->empty()) result->pop_back(); | 174 if (functions->empty()) result->pop_back(); |
174 } | 175 } |
175 return result; | 176 return result; |
176 } | 177 } |
177 | 178 |
178 void Coverage::SelectMode(Isolate* isolate, debug::Coverage::Mode mode) { | 179 void Coverage::SelectMode(Isolate* isolate, debug::Coverage::Mode mode) { |
179 switch (mode) { | 180 switch (mode) { |
(...skipping 29 matching lines...) Expand all Loading... |
209 for (const auto& vector : vectors) list = ArrayList::Add(list, vector); | 210 for (const auto& vector : vectors) list = ArrayList::Add(list, vector); |
210 isolate->SetCodeCoverageList(*list); | 211 isolate->SetCodeCoverageList(*list); |
211 break; | 212 break; |
212 } | 213 } |
213 } | 214 } |
214 isolate->set_code_coverage_mode(mode); | 215 isolate->set_code_coverage_mode(mode); |
215 } | 216 } |
216 | 217 |
217 } // namespace internal | 218 } // namespace internal |
218 } // namespace v8 | 219 } // namespace v8 |
OLD | NEW |