| 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 |
| 11 | 11 |
| 12 #include "vm/assembler.h" |
| 13 #include "vm/assembler_macros.h" |
| 14 #include "vm/code_descriptors.h" |
| 15 #include "vm/code_generator.h" |
| 12 #include "vm/intermediate_language.h" | 16 #include "vm/intermediate_language.h" |
| 13 | 17 |
| 14 namespace dart { | 18 namespace dart { |
| 15 | 19 |
| 16 class Assembler; | 20 class Assembler; |
| 17 class Code; | 21 class Code; |
| 22 class DeoptimizationStub; |
| 18 template <typename T> class GrowableArray; | 23 template <typename T> class GrowableArray; |
| 19 class ParsedFunction; | 24 class ParsedFunction; |
| 25 class StackMapBuilder; |
| 20 | 26 |
| 21 // Stubbed out implementation of graph compiler, bails out immediately if | 27 // Stubbed out implementation of graph compiler, bails out immediately if |
| 22 // CompileGraph is called. The rest of the public API is UNIMPLEMENTED. | 28 // CompileGraph is called. The rest of the public API is UNIMPLEMENTED. |
| 23 class FlowGraphCompiler : public FlowGraphVisitor { | 29 class FlowGraphCompiler : public FlowGraphVisitor { |
| 24 public: | 30 public: |
| 25 FlowGraphCompiler(Assembler* assembler, | 31 FlowGraphCompiler(Assembler* assembler, |
| 26 const ParsedFunction& parsed_function, | 32 const ParsedFunction& parsed_function, |
| 27 const GrowableArray<BlockEntryInstr*>& blocks, | 33 const GrowableArray<BlockEntryInstr*>& block_order, |
| 28 bool is_optimizing) | 34 bool is_optimizing); |
| 29 : FlowGraphVisitor(blocks), | |
| 30 parsed_function_(parsed_function), | |
| 31 is_optimizing_(is_optimizing) { | |
| 32 } | |
| 33 | 35 |
| 34 virtual ~FlowGraphCompiler() { } | 36 virtual ~FlowGraphCompiler(); |
| 35 | 37 |
| 36 void CompileGraph(); | 38 void CompileGraph(); |
| 37 | 39 |
| 38 // Infrastructure copied from class CodeGenerator or stubbed out. | 40 // Infrastructure copied from class CodeGenerator or stubbed out. |
| 39 void FinalizePcDescriptors(const Code& code); | 41 void FinalizePcDescriptors(const Code& code); |
| 40 void FinalizeStackmaps(const Code& code); | 42 void FinalizeStackmaps(const Code& code); |
| 41 void FinalizeVarDescriptors(const Code& code); | 43 void FinalizeVarDescriptors(const Code& code); |
| 42 void FinalizeExceptionHandlers(const Code& code); | 44 void FinalizeExceptionHandlers(const Code& code); |
| 43 void FinalizeComments(const Code& code); | 45 void FinalizeComments(const Code& code); |
| 44 | 46 |
| 47 Assembler* assembler() const { return assembler_; } |
| 48 |
| 45 private: | 49 private: |
| 50 friend class DeoptimizationStub; |
| 51 |
| 46 // Bail out of the flow graph compiler. Does not return to the caller. | 52 // Bail out of the flow graph compiler. Does not return to the caller. |
| 47 void Bailout(const char* reason); | 53 void Bailout(const char* reason); |
| 48 | 54 |
| 55 virtual void VisitBlocks(); |
| 56 |
| 57 BlockEntryInstr* current_block() const { return current_block_; } |
| 58 |
| 59 // Constructor is lighweight, major initialization work should occur here. |
| 60 // This makes it easier to measure time spent in the compiler. |
| 61 void InitCompiler(); |
| 62 |
| 63 struct BlockInfo : public ZoneAllocated { |
| 64 public: |
| 65 BlockInfo() : label() { } |
| 66 |
| 67 Label label; |
| 68 }; |
| 69 |
| 70 void GenerateCallRuntime(intptr_t cid, |
| 71 intptr_t token_index, |
| 72 intptr_t try_index, |
| 73 const RuntimeEntry& entry); |
| 74 void AddCurrentDescriptor(PcDescriptors::Kind kind, |
| 75 intptr_t cid, |
| 76 intptr_t token_index, |
| 77 intptr_t try_index); |
| 78 void CopyParameters(); |
| 79 void EmitInstructionPrologue(Instruction* instr); |
| 80 |
| 81 intptr_t StackSize() const; |
| 82 |
| 83 bool CanOptimize(); |
| 84 bool TryIntrinsify(); |
| 85 void IntrinsifyGetter(); |
| 86 void IntrinsifySetter(); |
| 87 |
| 88 void GenerateDeferredCode(); |
| 89 void EmitComment(Instruction* instr); |
| 90 void BailoutOnInstruction(Instruction* instr); |
| 91 |
| 92 Assembler* assembler_; |
| 49 const ParsedFunction& parsed_function_; | 93 const ParsedFunction& parsed_function_; |
| 94 |
| 95 // Compiler specific per-block state. Indexed by postorder block number |
| 96 // for convenience. This is not the block's index in the block order, |
| 97 // which is reverse postorder. |
| 98 GrowableArray<BlockInfo*> block_info_; |
| 99 BlockEntryInstr* current_block_; |
| 100 DescriptorList* pc_descriptors_list_; |
| 101 StackmapBuilder* stackmap_builder_; |
| 102 ExceptionHandlerList* exception_handlers_list_; |
| 103 GrowableArray<DeoptimizationStub*> deopt_stubs_; |
| 50 const bool is_optimizing_; | 104 const bool is_optimizing_; |
| 51 | 105 |
| 52 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); | 106 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); |
| 53 }; | 107 }; |
| 54 | 108 |
| 55 } // namespace dart | 109 } // namespace dart |
| 56 | 110 |
| 57 #endif // VM_FLOW_GRAPH_COMPILER_IA32_H_ | 111 #endif // VM_FLOW_GRAPH_COMPILER_IA32_H_ |
| OLD | NEW |