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

Unified Diff: src/interpreter/bytecode-generator.h

Issue 2882973002: [coverage] Block coverage with support for IfStatements (Closed)
Patch Set: Rebase 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/interpreter/bytecode-generator.h
diff --git a/src/interpreter/bytecode-generator.h b/src/interpreter/bytecode-generator.h
index 579365952b9fae9bd4fc51e4c902c0b8bd0c4133..55c6fc1342da0d82ce0c2545880077aacbfb71a4 100644
--- a/src/interpreter/bytecode-generator.h
+++ b/src/interpreter/bytecode-generator.h
@@ -236,6 +236,19 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
inline LanguageMode language_mode() const;
int feedback_index(FeedbackSlot slot) const;
+ bool is_block_coverage() const;
+ int AllocateBlockCoverageSlot(SourceRange range) {
+ if (!is_block_coverage() || range.IsEmpty()) return -1;
+ const int slot = static_cast<int>(block_coverage_slots_.size());
+ block_coverage_slots_.emplace_back(range);
+ return slot;
+ }
+ void IncBlockCounter(SourceRange range) {
+ if (is_block_coverage() && !range.IsEmpty()) {
+ builder()->IncBlockCounter(AllocateBlockCoverageSlot(range));
+ }
+ }
+
Zone* zone_;
BytecodeArrayBuilder* builder_;
CompilationInfo* info_;
@@ -251,6 +264,10 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
ZoneVector<std::pair<ObjectLiteral*, size_t>> object_literals_;
ZoneVector<std::pair<ArrayLiteral*, size_t>> array_literals_;
+ // Contains source range information for allocated block coverage counter
+ // slots. Slot i covers range block_coverage_slots_[i].
+ ZoneVector<SourceRange> block_coverage_slots_;
+
ControlScope* execution_control_;
ContextScope* execution_context_;
ExpressionResultScope* execution_result_;

Powered by Google App Engine
This is Rietveld 408576698