| 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" |
| 11 #include "src/interpreter/bytecode-array-iterator.h" | 11 #include "src/interpreter/bytecode-array-iterator.h" |
| 12 #include "src/interpreter/bytecodes.h" | 12 #include "src/interpreter/bytecodes.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 namespace compiler { | 16 namespace compiler { |
| 17 | 17 |
| 18 // The BytecodeGraphBuilder produces a high-level IR graph based on | 18 // The BytecodeGraphBuilder produces a high-level IR graph based on |
| 19 // interpreter bytecodes. | 19 // interpreter bytecodes. |
| 20 class BytecodeGraphBuilder { | 20 class BytecodeGraphBuilder { |
| 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(); |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 class Environment; | 29 class Environment; |
| 30 class FrameStateBeforeAndAfter; | 30 class FrameStateBeforeAndAfter; |
| 31 | 31 |
| 32 void CreateGraphBody(bool stack_check); | 32 void CreateGraphBody(); |
| 33 void VisitBytecodes(); | 33 void VisitBytecodes(); |
| 34 | 34 |
| 35 // Get or create the node that represents the outer function closure. | 35 // Get or create the node that represents the outer function closure. |
| 36 Node* GetFunctionClosure(); | 36 Node* GetFunctionClosure(); |
| 37 | 37 |
| 38 // Get or create the node that represents the outer function context. | 38 // Get or create the node that represents the outer function context. |
| 39 Node* GetFunctionContext(); | 39 Node* GetFunctionContext(); |
| 40 | 40 |
| 41 // Get or create the node that represents the incoming new target value. | 41 // Get or create the node that represents the incoming new target value. |
| 42 Node* GetNewTarget(); | 42 Node* GetNewTarget(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 void MergeIntoSuccessorEnvironment(int target_offset); | 154 void MergeIntoSuccessorEnvironment(int target_offset); |
| 155 void BuildLoopHeaderEnvironment(int current_offset); | 155 void BuildLoopHeaderEnvironment(int current_offset); |
| 156 void SwitchToMergeEnvironment(int current_offset); | 156 void SwitchToMergeEnvironment(int current_offset); |
| 157 | 157 |
| 158 // Simulates control flow that exits the function body. | 158 // Simulates control flow that exits the function body. |
| 159 void MergeControlToLeaveFunction(Node* exit); | 159 void MergeControlToLeaveFunction(Node* exit); |
| 160 | 160 |
| 161 // Simulates entry and exit of exception handlers. | 161 // Simulates entry and exit of exception handlers. |
| 162 void EnterAndExitExceptionHandlers(int current_offset); | 162 void EnterAndExitExceptionHandlers(int current_offset); |
| 163 | 163 |
| 164 // Attaches a frame state to |node| for the entry to the function. | |
| 165 void PrepareEntryFrameState(Node* node); | |
| 166 | |
| 167 // Growth increment for the temporary buffer used to construct input lists to | 164 // Growth increment for the temporary buffer used to construct input lists to |
| 168 // new nodes. | 165 // new nodes. |
| 169 static const int kInputBufferSizeIncrement = 64; | 166 static const int kInputBufferSizeIncrement = 64; |
| 170 | 167 |
| 171 // An abstract representation for an exception handler that is being | 168 // An abstract representation for an exception handler that is being |
| 172 // entered and exited while the graph builder is iterating over the | 169 // entered and exited while the graph builder is iterating over the |
| 173 // underlying bytecode. The exception handlers within the bytecode are | 170 // underlying bytecode. The exception handlers within the bytecode are |
| 174 // well scoped, hence will form a stack during iteration. | 171 // well scoped, hence will form a stack during iteration. |
| 175 struct ExceptionHandler { | 172 struct ExceptionHandler { |
| 176 int start_offset_; // Start offset of the handled area in the bytecode. | 173 int start_offset_; // Start offset of the handled area in the bytecode. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 ZoneVector<Node*> exit_controls_; | 254 ZoneVector<Node*> exit_controls_; |
| 258 | 255 |
| 259 DISALLOW_COPY_AND_ASSIGN(BytecodeGraphBuilder); | 256 DISALLOW_COPY_AND_ASSIGN(BytecodeGraphBuilder); |
| 260 }; | 257 }; |
| 261 | 258 |
| 262 } // namespace compiler | 259 } // namespace compiler |
| 263 } // namespace internal | 260 } // namespace internal |
| 264 } // namespace v8 | 261 } // namespace v8 |
| 265 | 262 |
| 266 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ | 263 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ |
| OLD | NEW |