| 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 int count, |
| 272 FrameStateBeforeAndAfter* states = nullptr); |
| 274 void RecordAfterState(Node* node, FrameStateBeforeAndAfter* states); | 273 void RecordAfterState(Node* node, FrameStateBeforeAndAfter* states); |
| 275 | 274 |
| 276 bool IsMarkedAsUnreachable() const; | 275 bool IsMarkedAsUnreachable() const; |
| 277 void MarkAsUnreachable(); | 276 void MarkAsUnreachable(); |
| 278 | 277 |
| 279 // Effect dependency tracked by this environment. | 278 // Effect dependency tracked by this environment. |
| 280 Node* GetEffectDependency() { return effect_dependency_; } | 279 Node* GetEffectDependency() { return effect_dependency_; } |
| 281 void UpdateEffectDependency(Node* dependency) { | 280 void UpdateEffectDependency(Node* dependency) { |
| 282 effect_dependency_ = dependency; | 281 effect_dependency_ = dependency; |
| 283 } | 282 } |
| 284 | 283 |
| 285 // Preserve a checkpoint of the environment for the IR graph. Any | 284 // Preserve a checkpoint of the environment for the IR graph. Any |
| 286 // further mutation of the environment will not affect checkpoints. | 285 // further mutation of the environment will not affect checkpoints. |
| 287 Node* Checkpoint(BailoutId ast_id, AccumulatorUpdateMode update_mode); | 286 Node* Checkpoint(BailoutId bytecode_offset, OutputFrameStateCombine combine); |
| 288 | 287 |
| 289 // Returns true if the state values are up to date with the current | 288 // Returns true if the state values are up to date with the current |
| 290 // environment. If update_mode is AccumulatorUpdateMode::kOutputInAccumulator | 289 // environment. |
| 291 // then accumulator state can be different from the environment. | 290 bool StateValuesAreUpToDate(int output_poke_offset, int output_poke_count); |
| 292 bool StateValuesAreUpToDate(AccumulatorUpdateMode update_mode); | |
| 293 | 291 |
| 294 // Control dependency tracked by this environment. | 292 // Control dependency tracked by this environment. |
| 295 Node* GetControlDependency() const { return control_dependency_; } | 293 Node* GetControlDependency() const { return control_dependency_; } |
| 296 void UpdateControlDependency(Node* dependency) { | 294 void UpdateControlDependency(Node* dependency) { |
| 297 control_dependency_ = dependency; | 295 control_dependency_ = dependency; |
| 298 } | 296 } |
| 299 | 297 |
| 300 Node* Context() const { return context_; } | 298 Node* Context() const { return context_; } |
| 301 void SetContext(Node* new_context) { context_ = new_context; } | 299 void SetContext(Node* new_context) { context_ = new_context; } |
| 302 | 300 |
| 303 Environment* CopyForConditional() const; | 301 Environment* CopyForConditional() const; |
| 304 Environment* CopyForLoop(); | 302 Environment* CopyForLoop(); |
| 305 void Merge(Environment* other); | 303 void Merge(Environment* other); |
| 306 | 304 |
| 307 private: | 305 private: |
| 308 explicit Environment(const Environment* copy); | 306 explicit Environment(const Environment* copy); |
| 309 void PrepareForLoop(); | 307 void PrepareForLoop(); |
| 308 bool StateValuesAreUpToDate(Node** state_values, int offset, int count, |
| 309 int output_poke_start, int output_poke_end); |
| 310 bool StateValuesRequireUpdate(Node** state_values, int offset, int count); | 310 bool StateValuesRequireUpdate(Node** state_values, int offset, int count); |
| 311 void UpdateStateValues(Node** state_values, int offset, int count); | 311 void UpdateStateValues(Node** state_values, int offset, int count); |
| 312 | 312 |
| 313 int RegisterToValuesIndex(interpreter::Register the_register) const; | 313 int RegisterToValuesIndex(interpreter::Register the_register) const; |
| 314 | 314 |
| 315 Zone* zone() const { return builder_->local_zone(); } | 315 Zone* zone() const { return builder_->local_zone(); } |
| 316 Graph* graph() const { return builder_->graph(); } | 316 Graph* graph() const { return builder_->graph(); } |
| 317 CommonOperatorBuilder* common() const { return builder_->common(); } | 317 CommonOperatorBuilder* common() const { return builder_->common(); } |
| 318 BytecodeGraphBuilder* builder() const { return builder_; } | 318 BytecodeGraphBuilder* builder() const { return builder_; } |
| 319 const NodeVector* values() const { return &values_; } | 319 const NodeVector* values() const { return &values_; } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 333 Node* accumulator_state_values_; | 333 Node* accumulator_state_values_; |
| 334 int register_base_; | 334 int register_base_; |
| 335 int accumulator_base_; | 335 int accumulator_base_; |
| 336 }; | 336 }; |
| 337 | 337 |
| 338 } // namespace compiler | 338 } // namespace compiler |
| 339 } // namespace internal | 339 } // namespace internal |
| 340 } // namespace v8 | 340 } // namespace v8 |
| 341 | 341 |
| 342 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ | 342 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ |
| OLD | NEW |