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_COMPILER_BYTECODE_GRAPH_BUILDER_H_ | 5 #ifndef V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ |
6 #define V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ | 6 #define V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ |
7 | 7 |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/compiler/bytecode-branch-analysis.h" | 9 #include "src/compiler/bytecode-branch-analysis.h" |
10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 public: | 21 public: |
22 BytecodeGraphBuilder(Zone* local_zone, CompilationInfo* info, | 22 BytecodeGraphBuilder(Zone* local_zone, CompilationInfo* info, |
23 JSGraph* jsgraph); | 23 JSGraph* jsgraph); |
24 | 24 |
25 // Creates a graph by visiting bytecodes. | 25 // Creates a graph by visiting bytecodes. |
26 bool CreateGraph(bool stack_check = true); | 26 bool CreateGraph(bool stack_check = true); |
27 | 27 |
28 Graph* graph() const { return jsgraph_->graph(); } | 28 Graph* graph() const { return jsgraph_->graph(); } |
29 | 29 |
30 private: | 30 private: |
31 enum class AccumulatorUpdateMode { | |
32 kOutputIgnored, | |
33 kOutputInAccumulator, | |
34 }; | |
35 | |
36 class Environment; | 31 class Environment; |
37 class FrameStateBeforeAndAfter; | 32 class FrameStateBeforeAndAfter; |
38 | 33 |
39 void CreateGraphBody(bool stack_check); | 34 void CreateGraphBody(bool stack_check); |
40 void VisitBytecodes(); | 35 void VisitBytecodes(); |
41 | 36 |
42 Node* LoadAccumulator(Node* value); | 37 Node* LoadAccumulator(Node* value); |
43 | 38 |
44 // Get or create the node that represents the outer function closure. | 39 // Get or create the node that represents the outer function closure. |
45 Node* GetFunctionClosure(); | 40 Node* GetFunctionClosure(); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 251 |
257 | 252 |
258 class BytecodeGraphBuilder::Environment : public ZoneObject { | 253 class BytecodeGraphBuilder::Environment : public ZoneObject { |
259 public: | 254 public: |
260 Environment(BytecodeGraphBuilder* builder, int register_count, | 255 Environment(BytecodeGraphBuilder* builder, int register_count, |
261 int parameter_count, Node* control_dependency, Node* context); | 256 int parameter_count, Node* control_dependency, Node* context); |
262 | 257 |
263 int parameter_count() const { return parameter_count_; } | 258 int parameter_count() const { return parameter_count_; } |
264 int register_count() const { return register_count_; } | 259 int register_count() const { return register_count_; } |
265 | 260 |
266 void BindRegister(interpreter::Register the_register, Node* node); | 261 Node* LookupAccumulator() const; |
267 Node* LookupRegister(interpreter::Register the_register) const; | 262 Node* LookupRegister(interpreter::Register the_register) const; |
| 263 |
268 void ExchangeRegisters(interpreter::Register reg0, | 264 void ExchangeRegisters(interpreter::Register reg0, |
269 interpreter::Register reg1); | 265 interpreter::Register reg1); |
270 | 266 |
271 void BindAccumulator(Node* node, FrameStateBeforeAndAfter* states = nullptr); | 267 void BindAccumulator(Node* node, FrameStateBeforeAndAfter* states = nullptr); |
272 Node* LookupAccumulator() const; | 268 void BindRegister(interpreter::Register the_register, Node* node, |
273 | 269 FrameStateBeforeAndAfter* states = nullptr); |
| 270 void BindRegistersToProjections(interpreter::Register first_reg, Node* node, |
| 271 FrameStateBeforeAndAfter* states = nullptr); |
274 void RecordAfterState(Node* node, FrameStateBeforeAndAfter* states); | 272 void RecordAfterState(Node* node, FrameStateBeforeAndAfter* states); |
275 | 273 |
276 bool IsMarkedAsUnreachable() const; | 274 bool IsMarkedAsUnreachable() const; |
277 void MarkAsUnreachable(); | 275 void MarkAsUnreachable(); |
278 | 276 |
279 // Effect dependency tracked by this environment. | 277 // Effect dependency tracked by this environment. |
280 Node* GetEffectDependency() { return effect_dependency_; } | 278 Node* GetEffectDependency() { return effect_dependency_; } |
281 void UpdateEffectDependency(Node* dependency) { | 279 void UpdateEffectDependency(Node* dependency) { |
282 effect_dependency_ = dependency; | 280 effect_dependency_ = dependency; |
283 } | 281 } |
284 | 282 |
285 // Preserve a checkpoint of the environment for the IR graph. Any | 283 // Preserve a checkpoint of the environment for the IR graph. Any |
286 // further mutation of the environment will not affect checkpoints. | 284 // further mutation of the environment will not affect checkpoints. |
287 Node* Checkpoint(BailoutId ast_id, AccumulatorUpdateMode update_mode); | 285 Node* Checkpoint(BailoutId bytecode_offset, OutputFrameStateCombine combine); |
288 | 286 |
289 // Returns true if the state values are up to date with the current | 287 // Returns true if the state values are up to date with the current |
290 // environment. If update_mode is AccumulatorUpdateMode::kOutputInAccumulator | 288 // environment. |
291 // then accumulator state can be different from the environment. | 289 bool StateValuesAreUpToDate(int output_poke_offset, int output_poke_count); |
292 bool StateValuesAreUpToDate(AccumulatorUpdateMode update_mode); | |
293 | 290 |
294 // Control dependency tracked by this environment. | 291 // Control dependency tracked by this environment. |
295 Node* GetControlDependency() const { return control_dependency_; } | 292 Node* GetControlDependency() const { return control_dependency_; } |
296 void UpdateControlDependency(Node* dependency) { | 293 void UpdateControlDependency(Node* dependency) { |
297 control_dependency_ = dependency; | 294 control_dependency_ = dependency; |
298 } | 295 } |
299 | 296 |
300 Node* Context() const { return context_; } | 297 Node* Context() const { return context_; } |
301 void SetContext(Node* new_context) { context_ = new_context; } | 298 void SetContext(Node* new_context) { context_ = new_context; } |
302 | 299 |
303 Environment* CopyForConditional() const; | 300 Environment* CopyForConditional() const; |
304 Environment* CopyForLoop(); | 301 Environment* CopyForLoop(); |
305 void Merge(Environment* other); | 302 void Merge(Environment* other); |
306 | 303 |
307 private: | 304 private: |
308 explicit Environment(const Environment* copy); | 305 explicit Environment(const Environment* copy); |
309 void PrepareForLoop(); | 306 void PrepareForLoop(); |
| 307 bool StateValuesAreUpToDate(Node** state_values, int offset, int count, |
| 308 int output_poke_start, int output_poke_end); |
310 bool StateValuesRequireUpdate(Node** state_values, int offset, int count); | 309 bool StateValuesRequireUpdate(Node** state_values, int offset, int count); |
311 void UpdateStateValues(Node** state_values, int offset, int count); | 310 void UpdateStateValues(Node** state_values, int offset, int count); |
312 | 311 |
313 int RegisterToValuesIndex(interpreter::Register the_register) const; | 312 int RegisterToValuesIndex(interpreter::Register the_register) const; |
314 | 313 |
315 Zone* zone() const { return builder_->local_zone(); } | 314 Zone* zone() const { return builder_->local_zone(); } |
316 Graph* graph() const { return builder_->graph(); } | 315 Graph* graph() const { return builder_->graph(); } |
317 CommonOperatorBuilder* common() const { return builder_->common(); } | 316 CommonOperatorBuilder* common() const { return builder_->common(); } |
318 BytecodeGraphBuilder* builder() const { return builder_; } | 317 BytecodeGraphBuilder* builder() const { return builder_; } |
319 const NodeVector* values() const { return &values_; } | 318 const NodeVector* values() const { return &values_; } |
(...skipping 13 matching lines...) Expand all Loading... |
333 Node* accumulator_state_values_; | 332 Node* accumulator_state_values_; |
334 int register_base_; | 333 int register_base_; |
335 int accumulator_base_; | 334 int accumulator_base_; |
336 }; | 335 }; |
337 | 336 |
338 } // namespace compiler | 337 } // namespace compiler |
339 } // namespace internal | 338 } // namespace internal |
340 } // namespace v8 | 339 } // namespace v8 |
341 | 340 |
342 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ | 341 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ |
OLD | NEW |