| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_FLOW_GRAPH_COMPILER_X64_H_ | 5 #ifndef VM_FLOW_GRAPH_COMPILER_X64_H_ |
| 6 #define VM_FLOW_GRAPH_COMPILER_X64_H_ | 6 #define VM_FLOW_GRAPH_COMPILER_X64_H_ |
| 7 | 7 |
| 8 #ifndef VM_FLOW_GRAPH_COMPILER_H_ | 8 #ifndef VM_FLOW_GRAPH_COMPILER_H_ |
| 9 #error Include flow_graph_compiler.h instead of flow_graph_compiler_x64.h. | 9 #error Include flow_graph_compiler.h instead of flow_graph_compiler_x64.h. |
| 10 #endif | 10 #endif |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 class Code; | 14 class Code; |
| 15 class DeoptimizationStub; | |
| 16 class FlowGraph; | 15 class FlowGraph; |
| 17 template <typename T> class GrowableArray; | 16 template <typename T> class GrowableArray; |
| 18 class ParsedFunction; | 17 class ParsedFunction; |
| 19 | 18 |
| 20 class FlowGraphCompiler : public ValueObject { | 19 class FlowGraphCompiler : public ValueObject { |
| 21 private: | 20 private: |
| 22 struct BlockInfo : public ZoneAllocated { | 21 struct BlockInfo : public ZoneAllocated { |
| 23 public: | 22 public: |
| 24 BlockInfo() : label() { } | 23 BlockInfo() : label() { } |
| 25 Label label; | 24 Label label; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 void SaveLiveRegisters(LocationSummary* locs); | 197 void SaveLiveRegisters(LocationSummary* locs); |
| 199 void RestoreLiveRegisters(LocationSummary* locs); | 198 void RestoreLiveRegisters(LocationSummary* locs); |
| 200 | 199 |
| 201 intptr_t CurrentTryIndex() const { | 200 intptr_t CurrentTryIndex() const { |
| 202 if (current_block_ == NULL) { | 201 if (current_block_ == NULL) { |
| 203 return CatchClauseNode::kInvalidTryIndex; | 202 return CatchClauseNode::kInvalidTryIndex; |
| 204 } | 203 } |
| 205 return current_block_->try_index(); | 204 return current_block_->try_index(); |
| 206 } | 205 } |
| 207 | 206 |
| 207 // Returns true if the generated code does not call other Dart code or |
| 208 // runtime. Only deoptimization is allowed to occur. Closures are not leaf. |
| 209 bool IsLeaf() const; |
| 210 |
| 208 private: | 211 private: |
| 209 friend class DeoptimizationStub; | |
| 210 | |
| 211 void GenerateDeferredCode(); | 212 void GenerateDeferredCode(); |
| 212 | 213 |
| 213 void EmitInstructionPrologue(Instruction* instr); | 214 void EmitInstructionPrologue(Instruction* instr); |
| 214 | 215 |
| 215 // Emit code to load a Value into register 'dst'. | 216 // Emit code to load a Value into register 'dst'. |
| 216 void LoadValue(Register dst, Value* value); | 217 void LoadValue(Register dst, Value* value); |
| 217 | 218 |
| 218 void EmitStaticCall(const Function& function, | 219 void EmitStaticCall(const Function& function, |
| 219 const Array& arguments_descriptor, | 220 const Array& arguments_descriptor, |
| 220 intptr_t argument_count, | 221 intptr_t argument_count, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 // Map a block number in a forward iteration into the block number in the | 280 // Map a block number in a forward iteration into the block number in the |
| 280 // corresponding reverse iteration. Used to obtain an index into | 281 // corresponding reverse iteration. Used to obtain an index into |
| 281 // block_order for reverse iterations. | 282 // block_order for reverse iterations. |
| 282 intptr_t reverse_index(intptr_t index) const { | 283 intptr_t reverse_index(intptr_t index) const { |
| 283 return block_order_.length() - index - 1; | 284 return block_order_.length() - index - 1; |
| 284 } | 285 } |
| 285 | 286 |
| 286 // Perform a greedy local register allocation. Consider all registers free. | 287 // Perform a greedy local register allocation. Consider all registers free. |
| 287 void AllocateRegistersLocally(Instruction* instr); | 288 void AllocateRegistersLocally(Instruction* instr); |
| 288 | 289 |
| 289 // Returns true if the generated code does not call other Dart code or | |
| 290 // runtime. Only deoptimization is allowed to occur. Closures are not leaf. | |
| 291 bool IsLeaf() const; | |
| 292 | |
| 293 class Assembler* assembler_; | 290 class Assembler* assembler_; |
| 294 const ParsedFunction& parsed_function_; | 291 const ParsedFunction& parsed_function_; |
| 295 const GrowableArray<BlockEntryInstr*>& block_order_; | 292 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 296 | 293 |
| 297 // Compiler specific per-block state. Indexed by postorder block number | 294 // Compiler specific per-block state. Indexed by postorder block number |
| 298 // for convenience. This is not the block's index in the block order, | 295 // for convenience. This is not the block's index in the block order, |
| 299 // which is reverse postorder. | 296 // which is reverse postorder. |
| 300 BlockEntryInstr* current_block_; | 297 BlockEntryInstr* current_block_; |
| 301 ExceptionHandlerList* exception_handlers_list_; | 298 ExceptionHandlerList* exception_handlers_list_; |
| 302 DescriptorList* pc_descriptors_list_; | 299 DescriptorList* pc_descriptors_list_; |
| 303 StackmapTableBuilder* stackmap_table_builder_; | 300 StackmapTableBuilder* stackmap_table_builder_; |
| 304 GrowableArray<BlockInfo*> block_info_; | 301 GrowableArray<BlockInfo*> block_info_; |
| 305 GrowableArray<DeoptimizationStub*> deopt_stubs_; | 302 GrowableArray<CompilerDeoptInfo*> deopt_infos_; |
| 306 GrowableArray<SlowPathCode*> slow_path_code_; | 303 GrowableArray<SlowPathCode*> slow_path_code_; |
| 307 const GrowableObjectArray& object_table_; | 304 const GrowableObjectArray& object_table_; |
| 308 const bool is_optimizing_; | 305 const bool is_optimizing_; |
| 309 const bool is_dart_leaf_; | 306 const bool is_dart_leaf_; |
| 310 | 307 |
| 311 const Bool& bool_true_; | 308 const Bool& bool_true_; |
| 312 const Bool& bool_false_; | 309 const Bool& bool_false_; |
| 313 const Class& double_class_; | 310 const Class& double_class_; |
| 314 | 311 |
| 315 ParallelMoveResolver parallel_move_resolver_; | 312 ParallelMoveResolver parallel_move_resolver_; |
| 316 | 313 |
| 317 // Currently instructions generate deopt stubs internally by | 314 // Currently instructions generate deopt stubs internally by |
| 318 // calling AddDeoptStub. To communicate deoptimization environment | 315 // calling AddDeoptStub. To communicate deoptimization environment |
| 319 // that should be used when deoptimizing we store it in this variable. | 316 // that should be used when deoptimizing we store it in this variable. |
| 320 // In future AddDeoptStub should be moved out of the instruction template. | 317 // In future AddDeoptStub should be moved out of the instruction template. |
| 321 Environment* pending_deoptimization_env_; | 318 Environment* pending_deoptimization_env_; |
| 322 | 319 |
| 323 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); | 320 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); |
| 324 }; | 321 }; |
| 325 | 322 |
| 326 } // namespace dart | 323 } // namespace dart |
| 327 | 324 |
| 328 #endif // VM_FLOW_GRAPH_COMPILER_X64_H_ | 325 #endif // VM_FLOW_GRAPH_COMPILER_X64_H_ |
| OLD | NEW |