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_; |