| 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 ParsedFunction; | 18 class ParsedFunction; |
| 19 | 19 |
| 20 class FlowGraphCompiler : public InstructionVisitor { | 20 class FlowGraphCompiler : public FlowGraphVisitor { |
| 21 public: | 21 public: |
| 22 FlowGraphCompiler(Assembler* assembler, | 22 FlowGraphCompiler(Assembler* assembler, |
| 23 const ParsedFunction& parsed_function, | 23 const ParsedFunction& parsed_function, |
| 24 const GrowableArray<BlockEntryInstr*>* blocks) | 24 const GrowableArray<BlockEntryInstr*>* blocks) |
| 25 : assembler_(assembler), | 25 : assembler_(assembler), |
| 26 parsed_function_(parsed_function), | 26 parsed_function_(parsed_function), |
| 27 blocks_(blocks), | 27 blocks_(blocks), |
| 28 pc_descriptors_list_(new CodeGenerator::DescriptorList()) { } | 28 pc_descriptors_list_(new CodeGenerator::DescriptorList()) { } |
| 29 | 29 |
| 30 virtual ~FlowGraphCompiler() { } | 30 virtual ~FlowGraphCompiler() { } |
| 31 | 31 |
| 32 void CompileGraph(); | 32 void CompileGraph(); |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 // Bail out of the flow graph compiler. Does not return to the caller. | 35 // Bail out of the flow graph compiler. Does not return to the caller. |
| 36 void Bailout(const char* reason); | 36 void Bailout(const char* reason); |
| 37 | 37 |
| 38 // Emit code to perform a computation. |
| 39 #define DECLARE_VISIT_COMPUTATION(ShortName, ClassName) \ |
| 40 virtual void Visit##ShortName(ClassName* comp) { UNREACHABLE(); } |
| 41 |
| 38 // Each visit function compiles a type of instruction. | 42 // Each visit function compiles a type of instruction. |
| 39 #define DECLARE_VISIT(type) \ | 43 #define DECLARE_VISIT_INSTRUCTION(ShortName) \ |
| 40 virtual void Visit##type(type##Instr* instr); | 44 virtual void Visit##ShortName(ShortName##Instr* instr); |
| 41 FOR_EACH_INSTRUCTION(DECLARE_VISIT) | 45 |
| 42 #undef DECLARE_VISIT | 46 FOR_EACH_COMPUTATION(DECLARE_VISIT_COMPUTATION) |
| 47 FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) |
| 48 |
| 49 #undef DECLARE_VISIT_COMPUTATION |
| 50 #undef DECLARE_VISIT_INSTRUCTION |
| 43 | 51 |
| 44 // Emit code to load a Value into register RAX. | 52 // Emit code to load a Value into register RAX. |
| 45 void LoadValue(Value* value); | 53 void LoadValue(Value* value); |
| 46 | 54 |
| 47 // Infrastructure copied from class CodeGenerator. | 55 // Infrastructure copied from class CodeGenerator. |
| 48 void GenerateCallRuntime(intptr_t node_id, | 56 void GenerateCallRuntime(intptr_t node_id, |
| 49 intptr_t token_index, | 57 intptr_t token_index, |
| 50 const RuntimeEntry& entry); | 58 const RuntimeEntry& entry); |
| 51 void AddCurrentDescriptor(PcDescriptors::Kind kind, | 59 void AddCurrentDescriptor(PcDescriptors::Kind kind, |
| 52 intptr_t node_id, | 60 intptr_t node_id, |
| 53 intptr_t token_index); | 61 intptr_t token_index); |
| 54 | 62 |
| 55 Assembler* assembler_; | 63 Assembler* assembler_; |
| 56 const ParsedFunction& parsed_function_; | 64 const ParsedFunction& parsed_function_; |
| 57 const GrowableArray<BlockEntryInstr*>* blocks_; | 65 const GrowableArray<BlockEntryInstr*>* blocks_; |
| 58 | 66 |
| 59 CodeGenerator::DescriptorList* pc_descriptors_list_; | 67 CodeGenerator::DescriptorList* pc_descriptors_list_; |
| 60 | 68 |
| 61 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); | 69 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); |
| 62 }; | 70 }; |
| 63 | 71 |
| 64 } // namespace dart | 72 } // namespace dart |
| 65 | 73 |
| 66 #endif // VM_FLOW_GRAPH_COMPILER_X64_H_ | 74 #endif // VM_FLOW_GRAPH_COMPILER_X64_H_ |
| OLD | NEW |