| 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); | |
| 33 void VisitBytecodes(); | 32 void VisitBytecodes(); |
| 34 | 33 |
| 35 // Get or create the node that represents the outer function closure. | 34 // Get or create the node that represents the outer function closure. |
| 36 Node* GetFunctionClosure(); | 35 Node* GetFunctionClosure(); |
| 37 | 36 |
| 38 // Get or create the node that represents the outer function context. | 37 // Get or create the node that represents the outer function context. |
| 39 Node* GetFunctionContext(); | 38 Node* GetFunctionContext(); |
| 40 | 39 |
| 41 // Get or create the node that represents the incoming new target value. | 40 // Get or create the node that represents the incoming new target value. |
| 42 Node* GetNewTarget(); | 41 Node* GetNewTarget(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 void MergeIntoSuccessorEnvironment(int target_offset); | 153 void MergeIntoSuccessorEnvironment(int target_offset); |
| 155 void BuildLoopHeaderEnvironment(int current_offset); | 154 void BuildLoopHeaderEnvironment(int current_offset); |
| 156 void SwitchToMergeEnvironment(int current_offset); | 155 void SwitchToMergeEnvironment(int current_offset); |
| 157 | 156 |
| 158 // Simulates control flow that exits the function body. | 157 // Simulates control flow that exits the function body. |
| 159 void MergeControlToLeaveFunction(Node* exit); | 158 void MergeControlToLeaveFunction(Node* exit); |
| 160 | 159 |
| 161 // Simulates entry and exit of exception handlers. | 160 // Simulates entry and exit of exception handlers. |
| 162 void EnterAndExitExceptionHandlers(int current_offset); | 161 void EnterAndExitExceptionHandlers(int current_offset); |
| 163 | 162 |
| 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 | 163 // Growth increment for the temporary buffer used to construct input lists to |
| 168 // new nodes. | 164 // new nodes. |
| 169 static const int kInputBufferSizeIncrement = 64; | 165 static const int kInputBufferSizeIncrement = 64; |
| 170 | 166 |
| 171 // An abstract representation for an exception handler that is being | 167 // An abstract representation for an exception handler that is being |
| 172 // entered and exited while the graph builder is iterating over the | 168 // entered and exited while the graph builder is iterating over the |
| 173 // underlying bytecode. The exception handlers within the bytecode are | 169 // underlying bytecode. The exception handlers within the bytecode are |
| 174 // well scoped, hence will form a stack during iteration. | 170 // well scoped, hence will form a stack during iteration. |
| 175 struct ExceptionHandler { | 171 struct ExceptionHandler { |
| 176 int start_offset_; // Start offset of the handled area in the bytecode. | 172 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_; | 253 ZoneVector<Node*> exit_controls_; |
| 258 | 254 |
| 259 DISALLOW_COPY_AND_ASSIGN(BytecodeGraphBuilder); | 255 DISALLOW_COPY_AND_ASSIGN(BytecodeGraphBuilder); |
| 260 }; | 256 }; |
| 261 | 257 |
| 262 } // namespace compiler | 258 } // namespace compiler |
| 263 } // namespace internal | 259 } // namespace internal |
| 264 } // namespace v8 | 260 } // namespace v8 |
| 265 | 261 |
| 266 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ | 262 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ |
| OLD | NEW |