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

Unified Diff: src/objects.h

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.h
diff --git a/src/objects.h b/src/objects.h
index ca84064c420e34a04e5ba5f8cebbd5221dfdce9e..7cc3aad41774234bfe82e64bb2fc4fca0fb68dca 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -998,6 +998,7 @@ template <class C> inline bool Is(Object* obj);
V(ConstantElementsPair) \
V(Constructor) \
V(Context) \
+ V(CoverageInfo) \
V(DeoptimizationInputData) \
V(DeoptimizationOutputData) \
V(DependentCode) \
@@ -1574,6 +1575,10 @@ class Smi: public Object {
public:
// Returns the integer value.
inline int value() const { return Internals::SmiValue(this); }
+
+ // Casts o to a Smi and returns its value.
+ static inline int ToInt(Object* o);
rmcilroy 2017/05/18 14:17:59 Is this worth adding rather than just Smi::cast(o)
jgruber 2017/05/22 09:43:32 Smi::cast(o)->value() Smi::ToInt(o) I think the l
rmcilroy 2017/05/22 11:08:46 Acknowledged.
+
inline Smi* ToUint32Smi() {
if (value() <= 0) return Smi::kZero;
return Smi::FromInt(static_cast<uint32_t>(value()));
@@ -5999,6 +6004,11 @@ class SharedFunctionInfo: public HeapObject {
// [debug info]: Debug information.
DECL_ACCESSORS(debug_info, Object)
+ // A function has coverage info if block coverage has been enabled and the
+ // function is user JS.
+ inline bool HasCoverageInfo() const;
+ DECL_ACCESSORS(coverage_info, Object)
+
// Bit field containing various information collected for debugging.
// This field is either stored on the kDebugInfo slot or inside the
// debug info struct.
@@ -6266,7 +6276,9 @@ class SharedFunctionInfo: public HeapObject {
kInstanceClassNameOffset + kPointerSize;
static const int kScriptOffset = kFunctionDataOffset + kPointerSize;
static const int kDebugInfoOffset = kScriptOffset + kPointerSize;
- static const int kFunctionIdentifierOffset = kDebugInfoOffset + kPointerSize;
+ static const int kCoverageInfoOffset = kDebugInfoOffset + kPointerSize;
rmcilroy 2017/05/18 14:17:59 I don't think we want to add this as a field to SF
jgruber 2017/05/22 09:43:32 Ack. I discussed this with Benedikt a while ago, a
+ static const int kFunctionIdentifierOffset =
+ kCoverageInfoOffset + kPointerSize;
static const int kFeedbackMetadataOffset =
kFunctionIdentifierOffset + kPointerSize;
static const int kFunctionLiteralIdOffset =
@@ -10049,6 +10061,41 @@ class DebugInfo: public Struct {
DISALLOW_IMPLICIT_CONSTRUCTORS(DebugInfo);
};
+// Holds information related to block code coverage.
+// More information at go/v8-designdoc-block-code-coverage.
+class CoverageInfo : public FixedArray {
marja 2017/05/18 11:30:17 Please put this in a different file than objects.h
jgruber 2017/05/22 09:43:32 Ack, thought so myself after uploading this CL. I'
+ public:
+ int SlotCount() const;
+
+ int FromSourcePosition(int slot_index) const;
+ int ToSourcePosition(int slot_index) const;
+ int BlockCount(int slot_index) const;
+
+ void InitializeSlot(int slot_index, int from_pos, int to_pos);
+ void IncrementBlockCount(int slot_index);
+
+ static int FixedArrayLengthForSlotCount(int slot_count) {
+ return slot_count * kSlotIndexCount + kFirstSlotIndex;
+ }
+
+ DECLARE_CAST(CoverageInfo)
+
+ private:
+ static int FirstIndexForSlot(int slot_index) {
+ return kFirstSlotIndex + slot_index * kSlotIndexCount;
+ }
+
+ static const int kFirstSlotIndex = 0;
+
+ // Each slot is assigned a group of indices starting at kFirstSlotIndex.
+ // Within this group, semantics are as follows:
+ static const int kSlotFromSourcePositionIndex = 0;
+ static const int kSlotToSourcePositionIndex = 1;
+ static const int kSlotBlockCountIndex = 2;
+ static const int kSlotIndexCount = 3;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(CoverageInfo);
+};
// The BreakPointInfo class holds information for break points set in a
// function. The DebugInfo object holds a BreakPointInfo object for each code

Powered by Google App Engine
This is Rietveld 408576698