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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 void BuildConditionalJump(Node* condition); | 168 void BuildConditionalJump(Node* condition); |
169 void BuildJumpIfEqual(Node* comperand); | 169 void BuildJumpIfEqual(Node* comperand); |
170 void BuildJumpIfToBooleanEqual(Node* boolean_comperand); | 170 void BuildJumpIfToBooleanEqual(Node* boolean_comperand); |
171 | 171 |
172 // Constructing merge and loop headers. | 172 // Constructing merge and loop headers. |
173 void MergeEnvironmentsOfBackwardBranches(int source_offset, | 173 void MergeEnvironmentsOfBackwardBranches(int source_offset, |
174 int target_offset); | 174 int target_offset); |
175 void MergeEnvironmentsOfForwardBranches(int source_offset); | 175 void MergeEnvironmentsOfForwardBranches(int source_offset); |
176 void BuildLoopHeaderForBackwardBranches(int source_offset); | 176 void BuildLoopHeaderForBackwardBranches(int source_offset); |
177 | 177 |
| 178 // Simulates entry and exit of exception handlers. |
| 179 void EnterAndExitExceptionHandlers(int current_offset); |
| 180 |
178 // Attaches a frame state to |node| for the entry to the function. | 181 // Attaches a frame state to |node| for the entry to the function. |
179 void PrepareEntryFrameState(Node* node); | 182 void PrepareEntryFrameState(Node* node); |
180 | 183 |
181 // Growth increment for the temporary buffer used to construct input lists to | 184 // Growth increment for the temporary buffer used to construct input lists to |
182 // new nodes. | 185 // new nodes. |
183 static const int kInputBufferSizeIncrement = 64; | 186 static const int kInputBufferSizeIncrement = 64; |
184 | 187 |
| 188 // An abstract representation for an exception handler that is being |
| 189 // entered and exited while the graph builder is iterating over the |
| 190 // underlying bytecode. The exception handlers within the bytecode are |
| 191 // well scoped, hence will form a stack during iteration. |
| 192 struct ExceptionHandler { |
| 193 int start_offset_; // Start offset of the handled area in the bytecode. |
| 194 int end_offset_; // End offset of the handled area in the bytecode. |
| 195 int handler_offset_; // Handler entry offset within the bytecode. |
| 196 }; |
| 197 |
185 // Field accessors | 198 // Field accessors |
186 CommonOperatorBuilder* common() const { return jsgraph_->common(); } | 199 CommonOperatorBuilder* common() const { return jsgraph_->common(); } |
187 Zone* graph_zone() const { return graph()->zone(); } | 200 Zone* graph_zone() const { return graph()->zone(); } |
188 CompilationInfo* info() const { return info_; } | 201 CompilationInfo* info() const { return info_; } |
189 JSGraph* jsgraph() const { return jsgraph_; } | 202 JSGraph* jsgraph() const { return jsgraph_; } |
190 JSOperatorBuilder* javascript() const { return jsgraph_->javascript(); } | 203 JSOperatorBuilder* javascript() const { return jsgraph_->javascript(); } |
191 Zone* local_zone() const { return local_zone_; } | 204 Zone* local_zone() const { return local_zone_; } |
192 const Handle<BytecodeArray>& bytecode_array() const { | 205 const Handle<BytecodeArray>& bytecode_array() const { |
193 return bytecode_array_; | 206 return bytecode_array_; |
194 } | 207 } |
| 208 const Handle<HandlerTable>& exception_handler_table() const { |
| 209 return exception_handler_table_; |
| 210 } |
195 const FrameStateFunctionInfo* frame_state_function_info() const { | 211 const FrameStateFunctionInfo* frame_state_function_info() const { |
196 return frame_state_function_info_; | 212 return frame_state_function_info_; |
197 } | 213 } |
198 | 214 |
199 LanguageMode language_mode() const { | 215 LanguageMode language_mode() const { |
200 // TODO(mythria): Don't rely on parse information to get language mode. | 216 // TODO(mythria): Don't rely on parse information to get language mode. |
201 return info()->language_mode(); | 217 return info()->language_mode(); |
202 } | 218 } |
203 | 219 |
204 const interpreter::BytecodeArrayIterator* bytecode_iterator() const { | 220 const interpreter::BytecodeArrayIterator* bytecode_iterator() const { |
205 return bytecode_iterator_; | 221 return bytecode_iterator_; |
206 } | 222 } |
207 | 223 |
208 void set_bytecode_iterator( | 224 void set_bytecode_iterator( |
209 const interpreter::BytecodeArrayIterator* bytecode_iterator) { | 225 const interpreter::BytecodeArrayIterator* bytecode_iterator) { |
210 bytecode_iterator_ = bytecode_iterator; | 226 bytecode_iterator_ = bytecode_iterator; |
211 } | 227 } |
212 | 228 |
213 const BytecodeBranchAnalysis* branch_analysis() const { | 229 const BytecodeBranchAnalysis* branch_analysis() const { |
214 return branch_analysis_; | 230 return branch_analysis_; |
215 } | 231 } |
216 | 232 |
217 void set_branch_analysis(const BytecodeBranchAnalysis* branch_analysis) { | 233 void set_branch_analysis(BytecodeBranchAnalysis* branch_analysis) { |
218 branch_analysis_ = branch_analysis; | 234 branch_analysis_ = branch_analysis; |
219 } | 235 } |
220 | 236 |
221 #define DECLARE_VISIT_BYTECODE(name, ...) \ | 237 #define DECLARE_VISIT_BYTECODE(name, ...) \ |
222 void Visit##name(const interpreter::BytecodeArrayIterator& iterator); | 238 void Visit##name(const interpreter::BytecodeArrayIterator& iterator); |
223 BYTECODE_LIST(DECLARE_VISIT_BYTECODE) | 239 BYTECODE_LIST(DECLARE_VISIT_BYTECODE) |
224 #undef DECLARE_VISIT_BYTECODE | 240 #undef DECLARE_VISIT_BYTECODE |
225 | 241 |
226 Zone* local_zone_; | 242 Zone* local_zone_; |
227 CompilationInfo* info_; | 243 CompilationInfo* info_; |
228 JSGraph* jsgraph_; | 244 JSGraph* jsgraph_; |
229 Handle<BytecodeArray> bytecode_array_; | 245 Handle<BytecodeArray> bytecode_array_; |
| 246 Handle<HandlerTable> exception_handler_table_; |
230 const FrameStateFunctionInfo* frame_state_function_info_; | 247 const FrameStateFunctionInfo* frame_state_function_info_; |
231 const interpreter::BytecodeArrayIterator* bytecode_iterator_; | 248 const interpreter::BytecodeArrayIterator* bytecode_iterator_; |
232 const BytecodeBranchAnalysis* branch_analysis_; | 249 BytecodeBranchAnalysis* branch_analysis_; // TODO(mstarzinger): Make const. |
233 Environment* environment_; | 250 Environment* environment_; |
234 | 251 |
235 | |
236 // Merge environments are snapshots of the environment at a particular | 252 // Merge environments are snapshots of the environment at a particular |
237 // bytecode offset to be merged into a later environment. | 253 // bytecode offset to be merged into a later environment. |
238 ZoneMap<int, Environment*> merge_environments_; | 254 ZoneMap<int, Environment*> merge_environments_; |
239 | 255 |
240 // Loop header environments are environments created for bytecodes | 256 // Loop header environments are environments created for bytecodes |
241 // where it is known there are back branches, ie a loop header. | 257 // where it is known there are back branches, ie a loop header. |
242 ZoneMap<int, Environment*> loop_header_environments_; | 258 ZoneMap<int, Environment*> loop_header_environments_; |
243 | 259 |
| 260 // Exception handlers currently entered by the iteration. |
| 261 ZoneStack<ExceptionHandler> exception_handlers_; |
| 262 int current_exception_handler_; |
| 263 |
244 // Temporary storage for building node input lists. | 264 // Temporary storage for building node input lists. |
245 int input_buffer_size_; | 265 int input_buffer_size_; |
246 Node** input_buffer_; | 266 Node** input_buffer_; |
247 | 267 |
248 // Nodes representing values in the activation record. | 268 // Nodes representing values in the activation record. |
249 SetOncePointer<Node> function_context_; | 269 SetOncePointer<Node> function_context_; |
250 SetOncePointer<Node> function_closure_; | 270 SetOncePointer<Node> function_closure_; |
251 SetOncePointer<Node> new_target_; | 271 SetOncePointer<Node> new_target_; |
252 | 272 |
253 // Optimization to cache loaded feedback vector. | 273 // Optimization to cache loaded feedback vector. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 Node* accumulator_state_values_; | 362 Node* accumulator_state_values_; |
343 int register_base_; | 363 int register_base_; |
344 int accumulator_base_; | 364 int accumulator_base_; |
345 }; | 365 }; |
346 | 366 |
347 } // namespace compiler | 367 } // namespace compiler |
348 } // namespace internal | 368 } // namespace internal |
349 } // namespace v8 | 369 } // namespace v8 |
350 | 370 |
351 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ | 371 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ |
OLD | NEW |