| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 #ifndef VM_OPT_CODE_GENERATOR_IA32_H_ | |
| 6 #define VM_OPT_CODE_GENERATOR_IA32_H_ | |
| 7 | |
| 8 #ifndef VM_OPT_CODE_GENERATOR_H_ | |
| 9 #error Do not include opt_code_generator_ia32.h; use opt_code_generator.h. | |
| 10 #endif | |
| 11 | |
| 12 #include "vm/code_generator.h" | |
| 13 | |
| 14 namespace dart { | |
| 15 | |
| 16 // Forward declarations. | |
| 17 class ClassesForLocals; | |
| 18 class DeoptimizationBlob; | |
| 19 struct InstanceSetterArgs; | |
| 20 | |
| 21 // Temporary hierarchy, until optimized code generator implemented. | |
| 22 // The optimizing compiler does not run if type checks are enabled. | |
| 23 class OptimizingCodeGenerator : public CodeGenerator { | |
| 24 public: | |
| 25 OptimizingCodeGenerator(Assembler* assembler, | |
| 26 const ParsedFunction& parsed_function); | |
| 27 | |
| 28 virtual void VisitBinaryOpNode(BinaryOpNode* node); | |
| 29 virtual void VisitInstanceGetterNode(InstanceGetterNode* node); | |
| 30 virtual void VisitInstanceSetterNode(InstanceSetterNode* node); | |
| 31 virtual void VisitComparisonNode(ComparisonNode* node); | |
| 32 virtual void VisitLoadIndexedNode(LoadIndexedNode* node); | |
| 33 virtual void VisitStoreIndexedNode(StoreIndexedNode* node); | |
| 34 virtual void VisitLiteralNode(LiteralNode* node); | |
| 35 virtual void VisitLoadLocalNode(LoadLocalNode* node); | |
| 36 virtual void VisitStoreLocalNode(StoreLocalNode* node); | |
| 37 virtual void VisitForNode(ForNode* node); | |
| 38 virtual void VisitDoWhileNode(DoWhileNode* node); | |
| 39 virtual void VisitWhileNode(WhileNode* node); | |
| 40 virtual void VisitIfNode(IfNode* node); | |
| 41 virtual void VisitInstanceCallNode(InstanceCallNode* node); | |
| 42 virtual void VisitStaticCallNode(StaticCallNode* node); | |
| 43 virtual void VisitReturnNode(ReturnNode* node); | |
| 44 virtual void VisitSequenceNode(SequenceNode* node_sequence); | |
| 45 virtual void VisitStoreInstanceFieldNode(StoreInstanceFieldNode* node); | |
| 46 virtual void VisitCatchClauseNode(CatchClauseNode* node); | |
| 47 virtual void VisitTryCatchNode(TryCatchNode* node); | |
| 48 virtual void VisitUnaryOpNode(UnaryOpNode* node); | |
| 49 | |
| 50 virtual bool IsOptimizing() const { return true; } | |
| 51 | |
| 52 virtual void GenerateDeferredCode(); | |
| 53 | |
| 54 virtual void InitGenerator(); | |
| 55 | |
| 56 private: | |
| 57 friend class DeoptimizationBlob; | |
| 58 | |
| 59 DeoptimizationBlob* AddDeoptimizationBlob(AstNode* node, | |
| 60 DeoptReasonId reason_id); | |
| 61 DeoptimizationBlob* AddDeoptimizationBlob(AstNode* node, | |
| 62 Register reg1, | |
| 63 DeoptReasonId reason_id); | |
| 64 DeoptimizationBlob* AddDeoptimizationBlob(AstNode* node, | |
| 65 Register reg1, | |
| 66 Register reg2, | |
| 67 DeoptReasonId reason_id); | |
| 68 DeoptimizationBlob* AddDeoptimizationBlob(AstNode* node, | |
| 69 Register reg1, | |
| 70 Register reg2, | |
| 71 Register reg3, | |
| 72 DeoptReasonId reason_id); | |
| 73 | |
| 74 void InlineInstanceGettersWithSameTarget(AstNode* node, | |
| 75 AstNode* receiver, | |
| 76 const String& field_name, | |
| 77 Register recv_reg); | |
| 78 | |
| 79 // Helper method to load a value quickly into register instead of pushing | |
| 80 // and popping it. | |
| 81 void VisitLoadOne(AstNode* node, Register reg); | |
| 82 void VisitLoadTwo(AstNode* left, | |
| 83 AstNode* right, | |
| 84 Register left_reg, | |
| 85 Register right_reg); | |
| 86 | |
| 87 void InlineInstanceGetter(AstNode* node, | |
| 88 AstNode* receiver, | |
| 89 const String& field_name, | |
| 90 Register recv_reg); | |
| 91 | |
| 92 void GenerateInstanceSetter(const InstanceSetterArgs& args); | |
| 93 void InlineInstanceSetter(AstNode* node, | |
| 94 AstNode* receiver, | |
| 95 const String& field_name, | |
| 96 Register recv_reg, | |
| 97 Register value_reg); | |
| 98 | |
| 99 void CallDeoptimize(intptr_t node_id, intptr_t token_pos); | |
| 100 | |
| 101 void GenerateSmiUnaryOp(UnaryOpNode* node); | |
| 102 void GenerateDoubleUnaryOp(UnaryOpNode* node); | |
| 103 | |
| 104 void GenerateSmiBinaryOp(BinaryOpNode* node); | |
| 105 void GenerateSmiShiftBinaryOp(BinaryOpNode* node); | |
| 106 | |
| 107 void GenerateDoubleBinaryOp(BinaryOpNode* node, bool receiver_can_be_smi); | |
| 108 void GenerateMintBinaryOp(BinaryOpNode* node, bool allow_smi); | |
| 109 void CheckIfDoubleOrSmi(Register reg, | |
| 110 Register temp, | |
| 111 Label* is_smi, | |
| 112 Label* not_double_or_smi); | |
| 113 void GenerateDirectCall(intptr_t node_id, | |
| 114 intptr_t token_pos, | |
| 115 const Function& target, | |
| 116 intptr_t arg_count, | |
| 117 const Array& optional_argument_names); | |
| 118 void GenerateCheckedInstanceCalls(AstNode* node, | |
| 119 AstNode* receiver, | |
| 120 intptr_t token_pos, | |
| 121 intptr_t num_args, | |
| 122 const Array& optional_arguments_names); | |
| 123 void GenerateInlineCacheCall(intptr_t node_id, | |
| 124 intptr_t token_pos, | |
| 125 const ICData& ic_data, | |
| 126 intptr_t num_args, | |
| 127 const Array& optional_arguments_names); | |
| 128 void NormalizeClassChecks(const ICData& ic_data, | |
| 129 const Function& null_target, | |
| 130 GrowableArray<const Class*>* classes, | |
| 131 GrowableArray<const Function*>* targets); | |
| 132 bool GenerateSmiComparison(ComparisonNode* node); | |
| 133 void GenerateSmiEquality(ComparisonNode* node); | |
| 134 bool GenerateDoubleComparison(ComparisonNode* node); | |
| 135 bool GenerateEqualityComparison(ComparisonNode* node); | |
| 136 void GenerateLogicalBinaryOp(BinaryOpNode* node); | |
| 137 void GenerateConditionalJumps(const CodeGenInfo& nInfo, Condition condition); | |
| 138 bool TryInlineInstanceCall(InstanceCallNode* node); | |
| 139 bool TryInlineStaticCall(StaticCallNode* node); | |
| 140 | |
| 141 bool IsResultInEaxRequested(AstNode* node) const; | |
| 142 bool NodeMayBeSmi(AstNode* node) const; | |
| 143 | |
| 144 void HandleResult(AstNode* node, Register result_reg); | |
| 145 void PropagateBackLocalClass(AstNode* node, const Class& cls); | |
| 146 | |
| 147 void PrintCollectedClasses(AstNode* node); | |
| 148 void TraceOpt(AstNode* node, const char* message); | |
| 149 void TraceNotOpt(AstNode* node, const char* message); | |
| 150 | |
| 151 GrowableArray<DeoptimizationBlob*> deoptimization_blobs_; | |
| 152 ClassesForLocals* classes_for_locals_; | |
| 153 const Class& smi_class_; | |
| 154 const Class& double_class_; | |
| 155 const Class& growable_object_array_class_; | |
| 156 | |
| 157 DISALLOW_IMPLICIT_CONSTRUCTORS(OptimizingCodeGenerator); | |
| 158 }; | |
| 159 | |
| 160 } // namespace dart | |
| 161 | |
| 162 | |
| 163 #endif // VM_OPT_CODE_GENERATOR_IA32_H_ | |
| OLD | NEW |