| 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_IA32_H_ | 5 #ifndef VM_FLOW_GRAPH_COMPILER_IA32_H_ |
| 6 #define VM_FLOW_GRAPH_COMPILER_IA32_H_ | 6 #define VM_FLOW_GRAPH_COMPILER_IA32_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_ia32.h. | 9 #error Include flow_graph_compiler.h instead of flow_graph_compiler_ia32.h. |
| 10 #endif | 10 #endif |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 struct BlockInfo : public ZoneAllocated { | 22 struct BlockInfo : public ZoneAllocated { |
| 23 public: | 23 public: |
| 24 BlockInfo() : label() { } | 24 BlockInfo() : label() { } |
| 25 Label label; | 25 Label label; |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 public: | 28 public: |
| 29 FlowGraphCompiler(Assembler* assembler, | 29 FlowGraphCompiler(Assembler* assembler, |
| 30 const FlowGraph& flow_graph, | 30 const FlowGraph& flow_graph, |
| 31 bool is_optimizing, | 31 bool is_optimizing, |
| 32 bool is_ssa, | |
| 33 bool is_leaf); | 32 bool is_leaf); |
| 34 | 33 |
| 35 ~FlowGraphCompiler(); | 34 ~FlowGraphCompiler(); |
| 36 | 35 |
| 37 // Accessors. | 36 // Accessors. |
| 38 Assembler* assembler() const { return assembler_; } | 37 Assembler* assembler() const { return assembler_; } |
| 39 const ParsedFunction& parsed_function() const { return parsed_function_; } | 38 const ParsedFunction& parsed_function() const { return parsed_function_; } |
| 40 const GrowableArray<BlockEntryInstr*>& block_order() const { | 39 const GrowableArray<BlockEntryInstr*>& block_order() const { |
| 41 return block_order_; | 40 return block_order_; |
| 42 } | 41 } |
| 43 DescriptorList* pc_descriptors_list() const { | 42 DescriptorList* pc_descriptors_list() const { |
| 44 return pc_descriptors_list_; | 43 return pc_descriptors_list_; |
| 45 } | 44 } |
| 46 const GrowableObjectArray& object_table() { | 45 const GrowableObjectArray& object_table() { |
| 47 return object_table_; | 46 return object_table_; |
| 48 } | 47 } |
| 49 BlockEntryInstr* current_block() const { return current_block_; } | 48 BlockEntryInstr* current_block() const { return current_block_; } |
| 50 void set_current_block(BlockEntryInstr* value) { | 49 void set_current_block(BlockEntryInstr* value) { |
| 51 current_block_ = value; | 50 current_block_ = value; |
| 52 } | 51 } |
| 53 static bool CanOptimize(); | 52 static bool CanOptimize(); |
| 54 bool is_optimizing() const { return is_optimizing_; } | 53 bool is_optimizing() const { return is_optimizing_; } |
| 55 | 54 |
| 56 bool is_ssa() const { return is_ssa_; } | |
| 57 | |
| 58 const GrowableArray<BlockInfo*>& block_info() const { return block_info_; } | 55 const GrowableArray<BlockInfo*>& block_info() const { return block_info_; } |
| 59 ParallelMoveResolver* parallel_move_resolver() { | 56 ParallelMoveResolver* parallel_move_resolver() { |
| 60 return ¶llel_move_resolver_; | 57 return ¶llel_move_resolver_; |
| 61 } | 58 } |
| 62 | 59 |
| 63 // Constructor is lighweight, major initialization work should occur here. | 60 // Constructor is lighweight, major initialization work should occur here. |
| 64 // This makes it easier to measure time spent in the compiler. | 61 // This makes it easier to measure time spent in the compiler. |
| 65 void InitCompiler(); | 62 void InitCompiler(); |
| 66 | 63 |
| 67 void CompileGraph(); | 64 void CompileGraph(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 // the block order and if it is the given block. | 176 // the block order and if it is the given block. |
| 180 bool IsNextBlock(BlockEntryInstr* block_entry) const; | 177 bool IsNextBlock(BlockEntryInstr* block_entry) const; |
| 181 | 178 |
| 182 void AddExceptionHandler(intptr_t try_index, intptr_t pc_offset); | 179 void AddExceptionHandler(intptr_t try_index, intptr_t pc_offset); |
| 183 void AddCurrentDescriptor(PcDescriptors::Kind kind, | 180 void AddCurrentDescriptor(PcDescriptors::Kind kind, |
| 184 intptr_t deopt_id, | 181 intptr_t deopt_id, |
| 185 intptr_t token_pos, | 182 intptr_t token_pos, |
| 186 intptr_t try_index); | 183 intptr_t try_index); |
| 187 Label* AddDeoptStub(intptr_t deopt_id, | 184 Label* AddDeoptStub(intptr_t deopt_id, |
| 188 intptr_t try_index_, | 185 intptr_t try_index_, |
| 189 DeoptReasonId reason, | 186 DeoptReasonId reason); |
| 190 Register reg1 = kNoRegister, | |
| 191 Register reg2 = kNoRegister, | |
| 192 Register reg3 = kNoRegister); | |
| 193 | 187 |
| 194 void AddSlowPathCode(SlowPathCode* slow_path); | 188 void AddSlowPathCode(SlowPathCode* slow_path); |
| 195 | 189 |
| 196 void FinalizeExceptionHandlers(const Code& code); | 190 void FinalizeExceptionHandlers(const Code& code); |
| 197 void FinalizePcDescriptors(const Code& code); | 191 void FinalizePcDescriptors(const Code& code); |
| 198 void FinalizeDeoptInfo(const Code& code); | 192 void FinalizeDeoptInfo(const Code& code); |
| 199 void FinalizeStackmaps(const Code& code); | 193 void FinalizeStackmaps(const Code& code); |
| 200 void FinalizeVarDescriptors(const Code& code); | 194 void FinalizeVarDescriptors(const Code& code); |
| 201 void FinalizeComments(const Code& code); | 195 void FinalizeComments(const Code& code); |
| 202 | 196 |
| 203 const Bool& bool_true() const { return bool_true_; } | 197 const Bool& bool_true() const { return bool_true_; } |
| 204 const Bool& bool_false() const { return bool_false_; } | 198 const Bool& bool_false() const { return bool_false_; } |
| 205 const Class& double_class() const { return double_class_; } | 199 const Class& double_class() const { return double_class_; } |
| 206 | 200 |
| 207 FrameRegisterAllocator* frame_register_allocator() { | |
| 208 return &frame_register_allocator_; | |
| 209 } | |
| 210 | |
| 211 void SaveLiveRegisters(LocationSummary* locs); | 201 void SaveLiveRegisters(LocationSummary* locs); |
| 212 void RestoreLiveRegisters(LocationSummary* locs); | 202 void RestoreLiveRegisters(LocationSummary* locs); |
| 213 | 203 |
| 214 // Returns true if the compiled function has a finally clause. | 204 // Returns true if the compiled function has a finally clause. |
| 215 bool HasFinally() const; | 205 bool HasFinally() const; |
| 216 | 206 |
| 217 static const int kLocalsOffsetFromFP = (-1 * kWordSize); | 207 static const int kLocalsOffsetFromFP = (-1 * kWordSize); |
| 218 | 208 |
| 219 private: | 209 private: |
| 220 friend class DeoptimizationStub; | 210 friend class DeoptimizationStub; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 Label* is_instance_lbl, | 269 Label* is_instance_lbl, |
| 280 Label* is_not_instance_lbl); | 270 Label* is_not_instance_lbl); |
| 281 | 271 |
| 282 void GenerateBoolToJump(Register bool_reg, Label* is_true, Label* is_false); | 272 void GenerateBoolToJump(Register bool_reg, Label* is_true, Label* is_false); |
| 283 | 273 |
| 284 void CopyParameters(); | 274 void CopyParameters(); |
| 285 | 275 |
| 286 void GenerateInlinedGetter(intptr_t offset); | 276 void GenerateInlinedGetter(intptr_t offset); |
| 287 void GenerateInlinedSetter(intptr_t offset); | 277 void GenerateInlinedSetter(intptr_t offset); |
| 288 | 278 |
| 279 // Perform a greedy local register allocation. Consider all registers free. |
| 280 void AllocateRegistersLocally(Instruction* instr); |
| 281 |
| 289 // Map a block number in a forward iteration into the block number in the | 282 // Map a block number in a forward iteration into the block number in the |
| 290 // corresponding reverse iteration. Used to obtain an index into | 283 // corresponding reverse iteration. Used to obtain an index into |
| 291 // block_order for reverse iterations. | 284 // block_order for reverse iterations. |
| 292 intptr_t reverse_index(intptr_t index) const { | 285 intptr_t reverse_index(intptr_t index) const { |
| 293 return block_order_.length() - index - 1; | 286 return block_order_.length() - index - 1; |
| 294 } | 287 } |
| 295 | 288 |
| 296 // Returns true if the generated code does not call other Dart code or | 289 // Returns true if the generated code does not call other Dart code or |
| 297 // runtime. Only deoptimization is allowed to occur. Closures are not leaf. | 290 // runtime. Only deoptimization is allowed to occur. Closures are not leaf. |
| 298 bool IsLeaf() const; | 291 bool IsLeaf() const; |
| 299 | 292 |
| 300 class Assembler* assembler_; | 293 class Assembler* assembler_; |
| 301 const ParsedFunction& parsed_function_; | 294 const ParsedFunction& parsed_function_; |
| 302 const GrowableArray<BlockEntryInstr*>& block_order_; | 295 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 303 | 296 |
| 304 // Compiler specific per-block state. Indexed by postorder block number | 297 // Compiler specific per-block state. Indexed by postorder block number |
| 305 // for convenience. This is not the block's index in the block order, | 298 // for convenience. This is not the block's index in the block order, |
| 306 // which is reverse postorder. | 299 // which is reverse postorder. |
| 307 BlockEntryInstr* current_block_; | 300 BlockEntryInstr* current_block_; |
| 308 ExceptionHandlerList* exception_handlers_list_; | 301 ExceptionHandlerList* exception_handlers_list_; |
| 309 DescriptorList* pc_descriptors_list_; | 302 DescriptorList* pc_descriptors_list_; |
| 310 StackmapTableBuilder* stackmap_table_builder_; | 303 StackmapTableBuilder* stackmap_table_builder_; |
| 311 GrowableArray<BlockInfo*> block_info_; | 304 GrowableArray<BlockInfo*> block_info_; |
| 312 GrowableArray<DeoptimizationStub*> deopt_stubs_; | 305 GrowableArray<DeoptimizationStub*> deopt_stubs_; |
| 313 GrowableArray<SlowPathCode*> slow_path_code_; | 306 GrowableArray<SlowPathCode*> slow_path_code_; |
| 314 const GrowableObjectArray& object_table_; | 307 const GrowableObjectArray& object_table_; |
| 315 const bool is_optimizing_; | 308 const bool is_optimizing_; |
| 316 const bool is_ssa_; | |
| 317 const bool is_dart_leaf_; | 309 const bool is_dart_leaf_; |
| 318 | 310 |
| 319 const Bool& bool_true_; | 311 const Bool& bool_true_; |
| 320 const Bool& bool_false_; | 312 const Bool& bool_false_; |
| 321 const Class& double_class_; | 313 const Class& double_class_; |
| 322 | 314 |
| 323 FrameRegisterAllocator frame_register_allocator_; | |
| 324 ParallelMoveResolver parallel_move_resolver_; | 315 ParallelMoveResolver parallel_move_resolver_; |
| 325 | 316 |
| 326 // Currently instructions generate deopt stubs internally by | 317 // Currently instructions generate deopt stubs internally by |
| 327 // calling AddDeoptStub. To communicate deoptimization environment | 318 // calling AddDeoptStub. To communicate deoptimization environment |
| 328 // that should be used when deoptimizing we store it in this variable. | 319 // that should be used when deoptimizing we store it in this variable. |
| 329 // In future AddDeoptStub should be moved out of the instruction template. | 320 // In future AddDeoptStub should be moved out of the instruction template. |
| 330 Environment* pending_deoptimization_env_; | 321 Environment* pending_deoptimization_env_; |
| 331 | 322 |
| 332 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); | 323 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); |
| 333 }; | 324 }; |
| 334 | 325 |
| 335 } // namespace dart | 326 } // namespace dart |
| 336 | 327 |
| 337 #endif // VM_FLOW_GRAPH_COMPILER_IA32_H_ | 328 #endif // VM_FLOW_GRAPH_COMPILER_IA32_H_ |
| OLD | NEW |