| 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 #include "vm/assembler.h" | 12 #include "vm/assembler.h" |
| 13 #include "vm/code_generator.h" | 13 #include "vm/code_generator.h" |
| 14 #include "vm/intermediate_language.h" | 14 #include "vm/intermediate_language.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 class Code; | 18 class Code; |
| 19 template <typename T> class GrowableArray; | 19 template <typename T> class GrowableArray; |
| 20 class ParsedFunction; | 20 class ParsedFunction; |
| 21 | 21 |
| 22 class FlowGraphCompiler : public FlowGraphVisitor { | 22 class FlowGraphCompiler : public FlowGraphVisitor { |
| 23 public: | 23 public: |
| 24 FlowGraphCompiler(Assembler* assembler, | 24 FlowGraphCompiler(Assembler* assembler, |
| 25 const ParsedFunction& parsed_function, | 25 const ParsedFunction& parsed_function, |
| 26 const GrowableArray<BlockEntryInstr*>* blocks); | 26 const GrowableArray<BlockEntryInstr*>& block_order); |
| 27 | 27 |
| 28 virtual ~FlowGraphCompiler(); | 28 virtual ~FlowGraphCompiler(); |
| 29 | 29 |
| 30 void CompileGraph(); | 30 void CompileGraph(); |
| 31 | 31 |
| 32 // Infrastructure copied from class CodeGenerator or stubbed out. | 32 // Infrastructure copied from class CodeGenerator or stubbed out. |
| 33 void FinalizePcDescriptors(const Code& code); | 33 void FinalizePcDescriptors(const Code& code); |
| 34 void FinalizeVarDescriptors(const Code& code); | 34 void FinalizeVarDescriptors(const Code& code); |
| 35 void FinalizeExceptionHandlers(const Code& code); | 35 void FinalizeExceptionHandlers(const Code& code); |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 struct BlockInfo : public ZoneAllocated { | 38 struct BlockInfo : public ZoneAllocated { |
| 39 public: | 39 public: |
| 40 BlockInfo() : label() { } | 40 BlockInfo() : label() { } |
| 41 | 41 |
| 42 Label label; | 42 Label label; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 BlockEntryInstr* current_block() const { return current_block_; } | 45 BlockEntryInstr* current_block() const { return current_block_; } |
| 46 | 46 |
| 47 // Bail out of the flow graph compiler. Does not return to the caller. | 47 // Bail out of the flow graph compiler. Does not return to the caller. |
| 48 void Bailout(const char* reason); | 48 void Bailout(const char* reason); |
| 49 | 49 |
| 50 virtual void VisitBlocks(const GrowableArray<BlockEntryInstr*>& blocks); | 50 virtual void VisitBlocks(); |
| 51 | 51 |
| 52 // Emit code to perform a computation, leaving its value in RAX. | 52 // Emit code to perform a computation, leaving its value in RAX. |
| 53 #define DECLARE_VISIT_COMPUTATION(ShortName, ClassName) \ | 53 #define DECLARE_VISIT_COMPUTATION(ShortName, ClassName) \ |
| 54 virtual void Visit##ShortName(ClassName* comp); | 54 virtual void Visit##ShortName(ClassName* comp); |
| 55 | 55 |
| 56 // Each visit function compiles a type of instruction. | 56 // Each visit function compiles a type of instruction. |
| 57 #define DECLARE_VISIT_INSTRUCTION(ShortName) \ | 57 #define DECLARE_VISIT_INSTRUCTION(ShortName) \ |
| 58 virtual void Visit##ShortName(ShortName##Instr* instr); | 58 virtual void Visit##ShortName(ShortName##Instr* instr); |
| 59 | 59 |
| 60 FOR_EACH_COMPUTATION(DECLARE_VISIT_COMPUTATION) | 60 FOR_EACH_COMPUTATION(DECLARE_VISIT_COMPUTATION) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 bool negate_result); | 96 bool negate_result); |
| 97 | 97 |
| 98 void GenerateInstantiatorTypeArguments(intptr_t token_index); | 98 void GenerateInstantiatorTypeArguments(intptr_t token_index); |
| 99 | 99 |
| 100 void CopyParameters(); | 100 void CopyParameters(); |
| 101 | 101 |
| 102 intptr_t StackSize() const; | 102 intptr_t StackSize() const; |
| 103 | 103 |
| 104 Assembler* assembler_; | 104 Assembler* assembler_; |
| 105 const ParsedFunction& parsed_function_; | 105 const ParsedFunction& parsed_function_; |
| 106 const GrowableArray<BlockEntryInstr*>* blocks_; | |
| 107 | 106 |
| 108 // Compiler specific per-block state. Indexed by block number, so not | 107 // Compiler specific per-block state. Indexed by postorder block number |
| 109 // necessarily the same order as the array of blocks. | 108 // for convenience. This is not the block's index in the block order, |
| 109 // which is reverse postorder. |
| 110 GrowableArray<BlockInfo*> block_info_; | 110 GrowableArray<BlockInfo*> block_info_; |
| 111 | 111 |
| 112 BlockEntryInstr* current_block_; | 112 BlockEntryInstr* current_block_; |
| 113 | 113 |
| 114 CodeGenerator::DescriptorList* pc_descriptors_list_; | 114 CodeGenerator::DescriptorList* pc_descriptors_list_; |
| 115 | 115 |
| 116 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); | 116 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 } // namespace dart | 119 } // namespace dart |
| 120 | 120 |
| 121 #endif // VM_FLOW_GRAPH_COMPILER_X64_H_ | 121 #endif // VM_FLOW_GRAPH_COMPILER_X64_H_ |
| OLD | NEW |