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

Unified Diff: src/objects.cc

Issue 2882973002: [coverage] Block coverage with support for IfStatements (Closed)
Patch Set: Comment nit Created 3 years, 7 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
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 549137a08e710dbfa38f7d8e98647eadb45a11d5..0d756c9a681fb7856c9d162d58d6097508acc701 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -13657,6 +13657,7 @@ void SharedFunctionInfo::InitFromFunctionLiteral(
shared_info->set_needs_home_object(lit->scope()->NeedsHomeObject());
shared_info->set_asm_function(lit->scope()->asm_function());
shared_info->set_function_literal_id(lit->function_literal_id());
+ shared_info->set_coverage_info(Smi::kZero); // Set later on bytecode-gen.
// For lazy parsed functions, the following flags will be inaccurate since we
// don't have the information yet. They're set later in
@@ -19284,6 +19285,43 @@ int BreakPointInfo::GetBreakPointCount() {
return FixedArray::cast(break_point_objects())->length();
}
+int CoverageInfo::SlotCount() const {
+ DCHECK_EQ(kFirstSlotIndex, length() % kSlotIndexCount);
+ return (length() - kFirstSlotIndex) / kSlotIndexCount;
+}
+
+int CoverageInfo::FromSourcePosition(int slot_index) const {
+ DCHECK_LT(slot_index, SlotCount());
+ const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
+ return Smi::ToInt(get(slot_start + kSlotFromSourcePositionIndex));
+}
+
+int CoverageInfo::ToSourcePosition(int slot_index) const {
+ DCHECK_LT(slot_index, SlotCount());
+ const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
+ return Smi::ToInt(get(slot_start + kSlotToSourcePositionIndex));
+}
+
+int CoverageInfo::BlockCount(int slot_index) const {
+ DCHECK_LT(slot_index, SlotCount());
+ const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
+ return Smi::ToInt(get(slot_start + kSlotBlockCountIndex));
+}
+
+void CoverageInfo::InitializeSlot(int slot_index, int from_pos, int to_pos) {
+ DCHECK_LT(slot_index, SlotCount());
+ const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
+ set(slot_start + kSlotFromSourcePositionIndex, Smi::FromInt(from_pos));
+ set(slot_start + kSlotToSourcePositionIndex, Smi::FromInt(to_pos));
+ set(slot_start + kSlotBlockCountIndex, Smi::kZero);
+}
+
+void CoverageInfo::IncrementBlockCount(int slot_index) {
+ 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));
+}
// static
MaybeHandle<JSDate> JSDate::New(Handle<JSFunction> constructor,

Powered by Google App Engine
This is Rietveld 408576698