Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/objects/debug-objects.cc

Issue 2882973002: [coverage] Block coverage with support for IfStatements (Closed)
Patch Set: Address comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects/debug-objects.h ('k') | src/objects/debug-objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/objects/debug-objects.h" 5 #include "src/objects/debug-objects.h"
6 #include "src/objects/debug-objects-inl.h" 6 #include "src/objects/debug-objects-inl.h"
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 10
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 if (BreakPointInfo::HasBreakPointObject(break_point_info, 158 if (BreakPointInfo::HasBreakPointObject(break_point_info,
159 break_point_object)) { 159 break_point_object)) {
160 return break_point_info; 160 return break_point_info;
161 } 161 }
162 } 162 }
163 } 163 }
164 } 164 }
165 return isolate->factory()->undefined_value(); 165 return isolate->factory()->undefined_value();
166 } 166 }
167 167
168 bool DebugInfo::HasCoverageInfo() const {
169 return (flags() & kHasCoverageInfo) != 0;
170 }
171
172 bool DebugInfo::ClearCoverageInfo() {
173 DCHECK(FLAG_block_coverage);
174 DCHECK(HasCoverageInfo());
175 Isolate* isolate = GetIsolate();
176
177 set_coverage_info(isolate->heap()->undefined_value());
178
179 int new_flags = flags() & ~kHasCoverageInfo;
180 set_flags(new_flags);
181
182 return new_flags == kNone;
183 }
184
168 // Remove the specified break point object. 185 // Remove the specified break point object.
169 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info, 186 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info,
170 Handle<Object> break_point_object) { 187 Handle<Object> break_point_object) {
171 Isolate* isolate = break_point_info->GetIsolate(); 188 Isolate* isolate = break_point_info->GetIsolate();
172 // If there are no break points just ignore. 189 // If there are no break points just ignore.
173 if (break_point_info->break_point_objects()->IsUndefined(isolate)) return; 190 if (break_point_info->break_point_objects()->IsUndefined(isolate)) return;
174 // If there is a single break point clear it if it is the same. 191 // If there is a single break point clear it if it is the same.
175 if (!break_point_info->break_point_objects()->IsFixedArray()) { 192 if (!break_point_info->break_point_objects()->IsFixedArray()) {
176 if (break_point_info->break_point_objects() == *break_point_object) { 193 if (break_point_info->break_point_objects() == *break_point_object) {
177 break_point_info->set_break_point_objects( 194 break_point_info->set_break_point_objects(
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // Get the number of break points. 275 // Get the number of break points.
259 int BreakPointInfo::GetBreakPointCount() { 276 int BreakPointInfo::GetBreakPointCount() {
260 // No break point. 277 // No break point.
261 if (break_point_objects()->IsUndefined(GetIsolate())) return 0; 278 if (break_point_objects()->IsUndefined(GetIsolate())) return 0;
262 // Single break point. 279 // Single break point.
263 if (!break_point_objects()->IsFixedArray()) return 1; 280 if (!break_point_objects()->IsFixedArray()) return 1;
264 // Multiple break points. 281 // Multiple break points.
265 return FixedArray::cast(break_point_objects())->length(); 282 return FixedArray::cast(break_point_objects())->length();
266 } 283 }
267 284
285 int CoverageInfo::SlotCount() const {
286 DCHECK(FLAG_block_coverage);
287 DCHECK_EQ(kFirstSlotIndex, length() % kSlotIndexCount);
288 return (length() - kFirstSlotIndex) / kSlotIndexCount;
289 }
290
291 int CoverageInfo::StartSourcePosition(int slot_index) const {
292 DCHECK(FLAG_block_coverage);
293 DCHECK_LT(slot_index, SlotCount());
294 const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
295 return Smi::cast(get(slot_start + kSlotStartSourcePositionIndex))->value();
296 }
297
298 int CoverageInfo::EndSourcePosition(int slot_index) const {
299 DCHECK(FLAG_block_coverage);
300 DCHECK_LT(slot_index, SlotCount());
301 const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
302 return Smi::cast(get(slot_start + kSlotEndSourcePositionIndex))->value();
303 }
304
305 int CoverageInfo::BlockCount(int slot_index) const {
306 DCHECK(FLAG_block_coverage);
307 DCHECK_LT(slot_index, SlotCount());
308 const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
309 return Smi::cast(get(slot_start + kSlotBlockCountIndex))->value();
310 }
311
312 void CoverageInfo::InitializeSlot(int slot_index, int from_pos, int to_pos) {
313 DCHECK(FLAG_block_coverage);
314 DCHECK_LT(slot_index, SlotCount());
315 const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
316 set(slot_start + kSlotStartSourcePositionIndex, Smi::FromInt(from_pos));
317 set(slot_start + kSlotEndSourcePositionIndex, Smi::FromInt(to_pos));
318 set(slot_start + kSlotBlockCountIndex, Smi::kZero);
319 }
320
321 void CoverageInfo::IncrementBlockCount(int slot_index) {
322 DCHECK(FLAG_block_coverage);
323 DCHECK_LT(slot_index, SlotCount());
324 const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
325 const int old_count = BlockCount(slot_index);
326 set(slot_start + kSlotBlockCountIndex, Smi::FromInt(old_count + 1));
327 }
328
268 } // namespace internal 329 } // namespace internal
269 } // namespace v8 330 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects/debug-objects.h ('k') | src/objects/debug-objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698