| 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 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 class AbstractType; | |
| 15 class Assembler; | |
| 16 class Code; | 14 class Code; |
| 17 class DeoptimizationStub; | 15 class DeoptimizationStub; |
| 18 class FlowGraphCompiler; | |
| 19 template <typename T> class GrowableArray; | 16 template <typename T> class GrowableArray; |
| 20 class ParsedFunction; | 17 class ParsedFunction; |
| 21 class StackMapBuilder; | |
| 22 | 18 |
| 23 | |
| 24 // Stubbed out implementation of graph compiler, bails out immediately if | |
| 25 // CompileGraph is called. The rest of the public API is UNIMPLEMENTED. | |
| 26 class FlowGraphCompiler : public ValueObject { | 19 class FlowGraphCompiler : public ValueObject { |
| 27 private: | 20 private: |
| 28 struct BlockInfo : public ZoneAllocated { | 21 struct BlockInfo : public ZoneAllocated { |
| 29 public: | 22 public: |
| 30 BlockInfo() : label() { } | 23 BlockInfo() : label() { } |
| 31 Label label; | 24 Label label; |
| 32 }; | 25 }; |
| 33 | 26 |
| 34 public: | 27 public: |
| 35 FlowGraphCompiler(Assembler* assembler, | 28 FlowGraphCompiler(Assembler* assembler, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 66 |
| 74 // Returns 'true' if code generation for this function is complete, i.e., | 67 // Returns 'true' if code generation for this function is complete, i.e., |
| 75 // no fall-through to regular code is needed. | 68 // no fall-through to regular code is needed. |
| 76 bool TryIntrinsify(); | 69 bool TryIntrinsify(); |
| 77 | 70 |
| 78 void GenerateCallRuntime(intptr_t cid, | 71 void GenerateCallRuntime(intptr_t cid, |
| 79 intptr_t token_pos, | 72 intptr_t token_pos, |
| 80 intptr_t try_index, | 73 intptr_t try_index, |
| 81 const RuntimeEntry& entry); | 74 const RuntimeEntry& entry); |
| 82 | 75 |
| 83 // Returns pc-offset (in bytes) of the pc after the call, can be used to emit | |
| 84 // pc-descriptor information. | |
| 85 intptr_t EmitStaticCall(const Function& function, | |
| 86 const Array& arguments_descriptor, | |
| 87 intptr_t argument_count); | |
| 88 | |
| 89 void GenerateCall(intptr_t token_pos, | 76 void GenerateCall(intptr_t token_pos, |
| 90 intptr_t try_index, | 77 intptr_t try_index, |
| 91 const ExternalLabel* label, | 78 const ExternalLabel* label, |
| 92 PcDescriptors::Kind kind); | 79 PcDescriptors::Kind kind); |
| 93 void GenerateInstanceOf(intptr_t cid, | 80 |
| 94 intptr_t token_pos, | |
| 95 intptr_t try_index, | |
| 96 const AbstractType& type, | |
| 97 bool negate_result); | |
| 98 void GenerateAssertAssignable(intptr_t cid, | 81 void GenerateAssertAssignable(intptr_t cid, |
| 99 intptr_t token_pos, | 82 intptr_t token_pos, |
| 100 intptr_t try_index, | 83 intptr_t try_index, |
| 101 const AbstractType& dst_type, | 84 const AbstractType& dst_type, |
| 102 const String& dst_name); | 85 const String& dst_name); |
| 103 | 86 |
| 87 void GenerateInstanceOf(intptr_t cid, |
| 88 intptr_t token_pos, |
| 89 intptr_t try_index, |
| 90 const AbstractType& type, |
| 91 bool negate_result); |
| 92 |
| 104 void GenerateInstanceCall(intptr_t cid, | 93 void GenerateInstanceCall(intptr_t cid, |
| 105 intptr_t token_pos, | 94 intptr_t token_pos, |
| 106 intptr_t try_index, | 95 intptr_t try_index, |
| 107 const String& function_name, | 96 const String& function_name, |
| 108 intptr_t argument_count, | 97 intptr_t argument_count, |
| 109 const Array& argument_names, | 98 const Array& argument_names, |
| 110 intptr_t checked_argument_count); | 99 intptr_t checked_argument_count); |
| 111 | 100 |
| 112 void GenerateStaticCall(intptr_t cid, | 101 void GenerateStaticCall(intptr_t cid, |
| 113 intptr_t token_pos, | 102 intptr_t token_pos, |
| 114 intptr_t try_index, | 103 intptr_t try_index, |
| 115 const Function& function, | 104 const Function& function, |
| 116 intptr_t argument_count, | 105 intptr_t argument_count, |
| 117 const Array& argument_names); | 106 const Array& argument_names); |
| 118 | 107 |
| 119 void GenerateInlinedMathSqrt(Label* done); | 108 void GenerateInlinedMathSqrt(Label* done); |
| 120 | 109 |
| 121 void GenerateNumberTypeCheck(Register kClassIdReg, | 110 void GenerateNumberTypeCheck(Register kClassIdReg, |
| 122 const AbstractType& type, | 111 const AbstractType& type, |
| 123 Label* is_instance_lbl, | 112 Label* is_instance_lbl, |
| 124 Label* is_not_instance_lbl); | 113 Label* is_not_instance_lbl); |
| 125 void GenerateStringTypeCheck(Register kClassIdReg, | 114 void GenerateStringTypeCheck(Register kClassIdReg, |
| 126 Label* is_instance_lbl, | 115 Label* is_instance_lbl, |
| 127 Label* is_not_instance_lbl); | 116 Label* is_not_instance_lbl); |
| 128 void GenerateListTypeCheck(Register kClassIdReg, | 117 void GenerateListTypeCheck(Register kClassIdReg, |
| 129 Label* is_instance_lbl); | 118 Label* is_instance_lbl); |
| 130 | 119 |
| 120 void EmitComment(Instruction* instr); |
| 121 |
| 122 void EmitClassChecksNoSmi(const ICData& ic_data, |
| 123 Register instance_reg, |
| 124 Register temp_reg, |
| 125 Label* deopt); |
| 126 |
| 131 // Returns pc-offset (in bytes) of the pc after the call, can be used to emit | 127 // Returns pc-offset (in bytes) of the pc after the call, can be used to emit |
| 132 // pc-descriptor information. | 128 // pc-descriptor information. |
| 133 intptr_t EmitInstanceCall(ExternalLabel* target_label, | 129 intptr_t EmitInstanceCall(ExternalLabel* target_label, |
| 134 const ICData& ic_data, | 130 const ICData& ic_data, |
| 135 const Array& arguments_descriptor, | 131 const Array& arguments_descriptor, |
| 136 intptr_t argument_count); | 132 intptr_t argument_count); |
| 137 | 133 |
| 138 void EmitLoadIndexedGeneric(LoadIndexedComp* comp); | 134 void EmitLoadIndexedGeneric(LoadIndexedComp* comp); |
| 139 | |
| 140 void EmitComment(Instruction* instr); | |
| 141 | |
| 142 void EmitClassChecksNoSmi(const ICData& ic_data, | |
| 143 Register instance_reg, | |
| 144 Register temp_reg, | |
| 145 Label* deopt); | |
| 146 void EmitTestAndCall(const ICData& ic_data, | 135 void EmitTestAndCall(const ICData& ic_data, |
| 147 Register class_id_reg, | 136 Register class_id_reg, |
| 148 intptr_t arg_count, | 137 intptr_t arg_count, |
| 149 const Array& arg_names, | 138 const Array& arg_names, |
| 150 Label* deopt, | 139 Label* deopt, |
| 151 Label* done, | 140 Label* done, |
| 152 intptr_t cid, | 141 intptr_t cid, |
| 153 intptr_t token_index, | 142 intptr_t token_index, |
| 154 intptr_t try_index); | 143 intptr_t try_index); |
| 155 | 144 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 174 Register reg1 = kNoRegister, | 163 Register reg1 = kNoRegister, |
| 175 Register reg2 = kNoRegister, | 164 Register reg2 = kNoRegister, |
| 176 Register reg3 = kNoRegister); | 165 Register reg3 = kNoRegister); |
| 177 | 166 |
| 178 void FinalizeExceptionHandlers(const Code& code); | 167 void FinalizeExceptionHandlers(const Code& code); |
| 179 void FinalizePcDescriptors(const Code& code); | 168 void FinalizePcDescriptors(const Code& code); |
| 180 void FinalizeStackmaps(const Code& code); | 169 void FinalizeStackmaps(const Code& code); |
| 181 void FinalizeVarDescriptors(const Code& code); | 170 void FinalizeVarDescriptors(const Code& code); |
| 182 void FinalizeComments(const Code& code); | 171 void FinalizeComments(const Code& code); |
| 183 | 172 |
| 173 const Bool& bool_true() const { return bool_true_; } |
| 174 const Bool& bool_false() const { return bool_false_; } |
| 175 const Class& double_class() const { return double_class_; } |
| 176 |
| 184 FrameRegisterAllocator* frame_register_allocator() { | 177 FrameRegisterAllocator* frame_register_allocator() { |
| 185 return &frame_register_allocator_; | 178 return &frame_register_allocator_; |
| 186 } | 179 } |
| 187 | 180 |
| 188 static const int kLocalsOffsetFromFP = (-1 * kWordSize); | 181 static const int kLocalsOffsetFromFP = (-1 * kWordSize); |
| 189 | 182 |
| 190 const Bool& bool_true() const { return bool_true_; } | |
| 191 const Bool& bool_false() const { return bool_false_; } | |
| 192 const Class& double_class() const { return double_class_; } | |
| 193 | |
| 194 private: | 183 private: |
| 195 friend class DeoptimizationStub; | 184 friend class DeoptimizationStub; |
| 196 | 185 |
| 197 void GenerateDeferredCode(); | 186 void GenerateDeferredCode(); |
| 198 | 187 |
| 199 void CopyParameters(); | |
| 200 void EmitInstructionPrologue(Instruction* instr); | 188 void EmitInstructionPrologue(Instruction* instr); |
| 201 | 189 |
| 202 void GenerateInlinedGetter(intptr_t offset); | 190 // Emit code to load a Value into register 'dst'. |
| 203 void GenerateInlinedSetter(intptr_t offset); | 191 void LoadValue(Register dst, Value* value); |
| 192 |
| 193 // Returns pc-offset (in bytes) of the pc after the call, can be used to emit |
| 194 // pc-descriptor information. |
| 195 intptr_t EmitStaticCall(const Function& function, |
| 196 const Array& arguments_descriptor, |
| 197 intptr_t argument_count); |
| 198 |
| 199 // Type checking helper methods. |
| 200 void CheckClassIds(Register class_id_reg, |
| 201 const GrowableArray<intptr_t>& class_ids, |
| 202 Label* is_instance_lbl, |
| 203 Label* is_not_instance_lbl); |
| 204 | 204 |
| 205 RawSubtypeTestCache* GenerateInlineInstanceof(intptr_t cid, | 205 RawSubtypeTestCache* GenerateInlineInstanceof(intptr_t cid, |
| 206 intptr_t token_pos, | 206 intptr_t token_pos, |
| 207 const AbstractType& type, | 207 const AbstractType& type, |
| 208 Label* is_instance_lbl, | 208 Label* is_instance_lbl, |
| 209 Label* is_not_instance_lbl); | 209 Label* is_not_instance_lbl); |
| 210 | 210 |
| 211 RawSubtypeTestCache* GenerateInstantiatedTypeWithArgumentsTest( | 211 RawSubtypeTestCache* GenerateInstantiatedTypeWithArgumentsTest( |
| 212 intptr_t cid, | 212 intptr_t cid, |
| 213 intptr_t token_pos, | 213 intptr_t token_pos, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 243 | 243 |
| 244 RawSubtypeTestCache* GenerateCallSubtypeTestStub(TypeTestStubKind test_kind, | 244 RawSubtypeTestCache* GenerateCallSubtypeTestStub(TypeTestStubKind test_kind, |
| 245 Register instance_reg, | 245 Register instance_reg, |
| 246 Register type_arguments_reg, | 246 Register type_arguments_reg, |
| 247 Register temp_reg, | 247 Register temp_reg, |
| 248 Label* is_instance_lbl, | 248 Label* is_instance_lbl, |
| 249 Label* is_not_instance_lbl); | 249 Label* is_not_instance_lbl); |
| 250 | 250 |
| 251 void GenerateBoolToJump(Register bool_reg, Label* is_true, Label* is_false); | 251 void GenerateBoolToJump(Register bool_reg, Label* is_true, Label* is_false); |
| 252 | 252 |
| 253 void CheckClassIds(Register class_id_reg, | 253 void CopyParameters(); |
| 254 const GrowableArray<intptr_t>& class_ids, | |
| 255 Label* is_equal_lbl, | |
| 256 Label* is_not_equal_lbl); | |
| 257 | 254 |
| 255 void GenerateInlinedGetter(intptr_t offset); |
| 256 void GenerateInlinedSetter(intptr_t offset); |
| 258 | 257 |
| 259 // Map a block number in a forward iteration into the block number in the | 258 // Map a block number in a forward iteration into the block number in the |
| 260 // corresponding reverse iteration. Used to obtain an index into | 259 // corresponding reverse iteration. Used to obtain an index into |
| 261 // block_order for reverse iterations. | 260 // block_order for reverse iterations. |
| 262 intptr_t reverse_index(intptr_t index) const { | 261 intptr_t reverse_index(intptr_t index) const { |
| 263 return block_order_.length() - index - 1; | 262 return block_order_.length() - index - 1; |
| 264 } | 263 } |
| 265 | 264 |
| 266 class Assembler* assembler_; | 265 class Assembler* assembler_; |
| 267 const ParsedFunction& parsed_function_; | 266 const ParsedFunction& parsed_function_; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 const intptr_t deopt_id_; | 310 const intptr_t deopt_id_; |
| 312 const intptr_t deopt_token_pos_; | 311 const intptr_t deopt_token_pos_; |
| 313 const intptr_t try_index_; | 312 const intptr_t try_index_; |
| 314 const DeoptReasonId reason_; | 313 const DeoptReasonId reason_; |
| 315 GrowableArray<Register> registers_; | 314 GrowableArray<Register> registers_; |
| 316 Label entry_label_; | 315 Label entry_label_; |
| 317 | 316 |
| 318 DISALLOW_COPY_AND_ASSIGN(DeoptimizationStub); | 317 DISALLOW_COPY_AND_ASSIGN(DeoptimizationStub); |
| 319 }; | 318 }; |
| 320 | 319 |
| 321 | |
| 322 } // namespace dart | 320 } // namespace dart |
| 323 | 321 |
| 324 #endif // VM_FLOW_GRAPH_COMPILER_IA32_H_ | 322 #endif // VM_FLOW_GRAPH_COMPILER_IA32_H_ |
| OLD | NEW |