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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects/debug-objects.cc
diff --git a/src/objects/debug-objects.cc b/src/objects/debug-objects.cc
index e790983e9ffa1f366b9e8a759149f6a43eaeaec2..bb0d2187c147e00f12e5446fce8f07952d86be60 100644
--- a/src/objects/debug-objects.cc
+++ b/src/objects/debug-objects.cc
@@ -165,6 +165,23 @@ Handle<Object> DebugInfo::FindBreakPointInfo(
return isolate->factory()->undefined_value();
}
+bool DebugInfo::HasCoverageInfo() const {
+ return (flags() & kHasCoverageInfo) != 0;
+}
+
+bool DebugInfo::ClearCoverageInfo() {
+ DCHECK(FLAG_block_coverage);
+ DCHECK(HasCoverageInfo());
+ Isolate* isolate = GetIsolate();
+
+ set_coverage_info(isolate->heap()->undefined_value());
+
+ int new_flags = flags() & ~kHasCoverageInfo;
+ set_flags(new_flags);
+
+ return new_flags == kNone;
+}
+
// Remove the specified break point object.
void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info,
Handle<Object> break_point_object) {
@@ -265,5 +282,49 @@ int BreakPointInfo::GetBreakPointCount() {
return FixedArray::cast(break_point_objects())->length();
}
+int CoverageInfo::SlotCount() const {
+ DCHECK(FLAG_block_coverage);
+ DCHECK_EQ(kFirstSlotIndex, length() % kSlotIndexCount);
+ return (length() - kFirstSlotIndex) / kSlotIndexCount;
+}
+
+int CoverageInfo::StartSourcePosition(int slot_index) const {
+ DCHECK(FLAG_block_coverage);
+ DCHECK_LT(slot_index, SlotCount());
+ const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
+ return Smi::cast(get(slot_start + kSlotStartSourcePositionIndex))->value();
+}
+
+int CoverageInfo::EndSourcePosition(int slot_index) const {
+ DCHECK(FLAG_block_coverage);
+ DCHECK_LT(slot_index, SlotCount());
+ const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
+ return Smi::cast(get(slot_start + kSlotEndSourcePositionIndex))->value();
+}
+
+int CoverageInfo::BlockCount(int slot_index) const {
+ DCHECK(FLAG_block_coverage);
+ DCHECK_LT(slot_index, SlotCount());
+ const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
+ return Smi::cast(get(slot_start + kSlotBlockCountIndex))->value();
+}
+
+void CoverageInfo::InitializeSlot(int slot_index, int from_pos, int to_pos) {
+ DCHECK(FLAG_block_coverage);
+ DCHECK_LT(slot_index, SlotCount());
+ const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
+ set(slot_start + kSlotStartSourcePositionIndex, Smi::FromInt(from_pos));
+ set(slot_start + kSlotEndSourcePositionIndex, Smi::FromInt(to_pos));
+ set(slot_start + kSlotBlockCountIndex, Smi::kZero);
+}
+
+void CoverageInfo::IncrementBlockCount(int slot_index) {
+ DCHECK(FLAG_block_coverage);
+ DCHECK_LT(slot_index, SlotCount());
+ const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
+ const int old_count = BlockCount(slot_index);
+ set(slot_start + kSlotBlockCountIndex, Smi::FromInt(old_count + 1));
+}
+
} // namespace internal
} // namespace v8
« 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