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