OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
6 #define V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 6 #define V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
7 | 7 |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/interpreter/bytecode-array-builder.h" | 9 #include "src/interpreter/bytecode-array-builder.h" |
10 #include "src/interpreter/bytecode-label.h" | 10 #include "src/interpreter/bytecode-label.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 return builder()->register_allocator(); | 229 return builder()->register_allocator(); |
230 } | 230 } |
231 | 231 |
232 GlobalDeclarationsBuilder* globals_builder() { | 232 GlobalDeclarationsBuilder* globals_builder() { |
233 DCHECK_NOT_NULL(globals_builder_); | 233 DCHECK_NOT_NULL(globals_builder_); |
234 return globals_builder_; | 234 return globals_builder_; |
235 } | 235 } |
236 inline LanguageMode language_mode() const; | 236 inline LanguageMode language_mode() const; |
237 int feedback_index(FeedbackSlot slot) const; | 237 int feedback_index(FeedbackSlot slot) const; |
238 | 238 |
| 239 bool is_block_coverage() const; |
| 240 int AllocateBlockCoverageSlot(SourceRange range) { |
| 241 if (!is_block_coverage() || range.IsEmpty()) return -1; |
| 242 const int slot = static_cast<int>(block_coverage_slots_.size()); |
| 243 block_coverage_slots_.emplace_back(range); |
| 244 return slot; |
| 245 } |
| 246 void IncBlockCounter(SourceRange range) { |
| 247 if (is_block_coverage() && !range.IsEmpty()) { |
| 248 builder()->IncBlockCounter(AllocateBlockCoverageSlot(range)); |
| 249 } |
| 250 } |
| 251 |
239 Zone* zone_; | 252 Zone* zone_; |
240 BytecodeArrayBuilder* builder_; | 253 BytecodeArrayBuilder* builder_; |
241 CompilationInfo* info_; | 254 CompilationInfo* info_; |
242 const AstStringConstants* ast_string_constants_; | 255 const AstStringConstants* ast_string_constants_; |
243 DeclarationScope* closure_scope_; | 256 DeclarationScope* closure_scope_; |
244 Scope* current_scope_; | 257 Scope* current_scope_; |
245 | 258 |
246 GlobalDeclarationsBuilder* globals_builder_; | 259 GlobalDeclarationsBuilder* globals_builder_; |
247 ZoneVector<GlobalDeclarationsBuilder*> global_declarations_; | 260 ZoneVector<GlobalDeclarationsBuilder*> global_declarations_; |
248 ZoneVector<std::pair<FunctionLiteral*, size_t>> function_literals_; | 261 ZoneVector<std::pair<FunctionLiteral*, size_t>> function_literals_; |
249 ZoneVector<std::pair<NativeFunctionLiteral*, size_t>> | 262 ZoneVector<std::pair<NativeFunctionLiteral*, size_t>> |
250 native_function_literals_; | 263 native_function_literals_; |
251 ZoneVector<std::pair<ObjectLiteral*, size_t>> object_literals_; | 264 ZoneVector<std::pair<ObjectLiteral*, size_t>> object_literals_; |
252 ZoneVector<std::pair<ArrayLiteral*, size_t>> array_literals_; | 265 ZoneVector<std::pair<ArrayLiteral*, size_t>> array_literals_; |
253 | 266 |
| 267 // Contains source range information for allocated block coverage counter |
| 268 // slots. Slot i covers range block_coverage_slots_[i]. |
| 269 ZoneVector<SourceRange> block_coverage_slots_; |
| 270 |
254 ControlScope* execution_control_; | 271 ControlScope* execution_control_; |
255 ContextScope* execution_context_; | 272 ContextScope* execution_context_; |
256 ExpressionResultScope* execution_result_; | 273 ExpressionResultScope* execution_result_; |
257 | 274 |
258 BytecodeJumpTable* generator_jump_table_; | 275 BytecodeJumpTable* generator_jump_table_; |
259 Register generator_state_; | 276 Register generator_state_; |
260 int loop_depth_; | 277 int loop_depth_; |
261 }; | 278 }; |
262 | 279 |
263 } // namespace interpreter | 280 } // namespace interpreter |
264 } // namespace internal | 281 } // namespace internal |
265 } // namespace v8 | 282 } // namespace v8 |
266 | 283 |
267 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 284 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
OLD | NEW |