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

Unified Diff: src/interpreter/bytecode-generator.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/interpreter/bytecode-generator.h
diff --git a/src/interpreter/bytecode-generator.h b/src/interpreter/bytecode-generator.h
index cfea60e3e356dda92bdee662f0d6cff0d6ac5f7a..b95d3f38457b393df4054f3ac18ac4a194a5ea41 100644
--- a/src/interpreter/bytecode-generator.h
+++ b/src/interpreter/bytecode-generator.h
@@ -221,6 +221,18 @@ 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) {
+ 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()) {
+ builder()->IncBlockCounter(AllocateBlockCoverageSlot(range));
+ }
+ }
rmcilroy 2017/05/18 14:17:59 How about factoring this out into a small helper c
+
Zone* zone_;
BytecodeArrayBuilder* builder_;
CompilationInfo* info_;
@@ -236,6 +248,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