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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 return builder()->register_allocator(); | 214 return builder()->register_allocator(); |
215 } | 215 } |
216 | 216 |
217 GlobalDeclarationsBuilder* globals_builder() { | 217 GlobalDeclarationsBuilder* globals_builder() { |
218 DCHECK_NOT_NULL(globals_builder_); | 218 DCHECK_NOT_NULL(globals_builder_); |
219 return globals_builder_; | 219 return globals_builder_; |
220 } | 220 } |
221 inline LanguageMode language_mode() const; | 221 inline LanguageMode language_mode() const; |
222 int feedback_index(FeedbackSlot slot) const; | 222 int feedback_index(FeedbackSlot slot) const; |
223 | 223 |
224 bool is_block_coverage() const; | |
225 int AllocateBlockCoverageSlot(SourceRange range) { | |
226 const int slot = static_cast<int>(block_coverage_slots_.size()); | |
227 block_coverage_slots_.emplace_back(range); | |
228 return slot; | |
229 } | |
230 void IncBlockCounter(SourceRange range) { | |
231 if (is_block_coverage()) { | |
232 builder()->IncBlockCounter(AllocateBlockCoverageSlot(range)); | |
233 } | |
234 } | |
rmcilroy
2017/05/18 14:17:59
How about factoring this out into a small helper c
| |
235 | |
224 Zone* zone_; | 236 Zone* zone_; |
225 BytecodeArrayBuilder* builder_; | 237 BytecodeArrayBuilder* builder_; |
226 CompilationInfo* info_; | 238 CompilationInfo* info_; |
227 const AstStringConstants* ast_string_constants_; | 239 const AstStringConstants* ast_string_constants_; |
228 DeclarationScope* closure_scope_; | 240 DeclarationScope* closure_scope_; |
229 Scope* current_scope_; | 241 Scope* current_scope_; |
230 | 242 |
231 GlobalDeclarationsBuilder* globals_builder_; | 243 GlobalDeclarationsBuilder* globals_builder_; |
232 ZoneVector<GlobalDeclarationsBuilder*> global_declarations_; | 244 ZoneVector<GlobalDeclarationsBuilder*> global_declarations_; |
233 ZoneVector<std::pair<FunctionLiteral*, size_t>> function_literals_; | 245 ZoneVector<std::pair<FunctionLiteral*, size_t>> function_literals_; |
234 ZoneVector<std::pair<NativeFunctionLiteral*, size_t>> | 246 ZoneVector<std::pair<NativeFunctionLiteral*, size_t>> |
235 native_function_literals_; | 247 native_function_literals_; |
236 ZoneVector<std::pair<ObjectLiteral*, size_t>> object_literals_; | 248 ZoneVector<std::pair<ObjectLiteral*, size_t>> object_literals_; |
237 ZoneVector<std::pair<ArrayLiteral*, size_t>> array_literals_; | 249 ZoneVector<std::pair<ArrayLiteral*, size_t>> array_literals_; |
238 | 250 |
251 // Contains source range information for allocated block coverage counter | |
252 // slots. Slot i covers range block_coverage_slots_[i]. | |
253 ZoneVector<SourceRange> block_coverage_slots_; | |
254 | |
239 ControlScope* execution_control_; | 255 ControlScope* execution_control_; |
240 ContextScope* execution_context_; | 256 ContextScope* execution_context_; |
241 ExpressionResultScope* execution_result_; | 257 ExpressionResultScope* execution_result_; |
242 | 258 |
243 BytecodeJumpTable* generator_jump_table_; | 259 BytecodeJumpTable* generator_jump_table_; |
244 Register generator_state_; | 260 Register generator_state_; |
245 int loop_depth_; | 261 int loop_depth_; |
246 }; | 262 }; |
247 | 263 |
248 } // namespace interpreter | 264 } // namespace interpreter |
249 } // namespace internal | 265 } // namespace internal |
250 } // namespace v8 | 266 } // namespace v8 |
251 | 267 |
252 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 268 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
OLD | NEW |