OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ |
6 #define VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define VM_INTERMEDIATE_LANGUAGE_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1803 virtual CompileType* ComputeInitialType() const { | 1803 virtual CompileType* ComputeInitialType() const { |
1804 return ZoneCompileType::Wrap(ComputeType()); | 1804 return ZoneCompileType::Wrap(ComputeType()); |
1805 } | 1805 } |
1806 | 1806 |
1807 // Does this define a mint? | 1807 // Does this define a mint? |
1808 bool IsMintDefinition() { | 1808 bool IsMintDefinition() { |
1809 return (Type()->ToCid() == kMintCid) || | 1809 return (Type()->ToCid() == kMintCid) || |
1810 IsBinaryMintOp() || | 1810 IsBinaryMintOp() || |
1811 IsUnaryMintOp() || | 1811 IsUnaryMintOp() || |
1812 IsShiftMintOp() || | 1812 IsShiftMintOp() || |
| 1813 IsBoxInteger() || |
1813 IsUnboxInteger(); | 1814 IsUnboxInteger(); |
1814 } | 1815 } |
1815 | 1816 |
1816 // Compute compile type for this definition. It is safe to use this | 1817 // Compute compile type for this definition. It is safe to use this |
1817 // approximation even before type propagator was run (e.g. during graph | 1818 // approximation even before type propagator was run (e.g. during graph |
1818 // building). | 1819 // building). |
1819 virtual CompileType ComputeType() const { | 1820 virtual CompileType ComputeType() const { |
1820 return CompileType::Dynamic(); | 1821 return CompileType::Dynamic(); |
1821 } | 1822 } |
1822 | 1823 |
(...skipping 3265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5088 | 5089 |
5089 Definition* Canonicalize(FlowGraph* flow_graph); | 5090 Definition* Canonicalize(FlowGraph* flow_graph); |
5090 | 5091 |
5091 private: | 5092 private: |
5092 DISALLOW_COPY_AND_ASSIGN(BoxInt32x4Instr); | 5093 DISALLOW_COPY_AND_ASSIGN(BoxInt32x4Instr); |
5093 }; | 5094 }; |
5094 | 5095 |
5095 | 5096 |
5096 class BoxIntegerInstr : public TemplateDefinition<1> { | 5097 class BoxIntegerInstr : public TemplateDefinition<1> { |
5097 public: | 5098 public: |
5098 explicit BoxIntegerInstr(Value* value) { | 5099 explicit BoxIntegerInstr(Value* value) : is_smi_(false) { |
5099 SetInputAt(0, value); | 5100 SetInputAt(0, value); |
5100 } | 5101 } |
5101 | 5102 |
5102 Value* value() const { return inputs_[0]; } | 5103 Value* value() const { return inputs_[0]; } |
5103 | 5104 |
| 5105 bool is_smi() const { return is_smi_; } |
| 5106 void set_is_smi(bool is_smi) { is_smi_ = is_smi; } |
| 5107 |
5104 virtual bool CanDeoptimize() const { return false; } | 5108 virtual bool CanDeoptimize() const { return false; } |
5105 | 5109 |
5106 virtual intptr_t DeoptimizationTarget() const { | 5110 virtual intptr_t DeoptimizationTarget() const { |
5107 return Isolate::kNoDeoptId; | 5111 return Isolate::kNoDeoptId; |
5108 } | 5112 } |
5109 | 5113 |
5110 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | 5114 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
5111 ASSERT(idx == 0); | 5115 ASSERT(idx == 0); |
5112 return kUnboxedMint; | 5116 return kUnboxedMint; |
5113 } | 5117 } |
5114 | 5118 |
5115 DECLARE_INSTRUCTION(BoxInteger) | 5119 DECLARE_INSTRUCTION(BoxInteger) |
5116 virtual CompileType ComputeType() const; | 5120 virtual CompileType ComputeType() const; |
| 5121 virtual bool RecomputeType(); |
| 5122 |
| 5123 virtual void InferRange(); |
5117 | 5124 |
5118 virtual bool AllowsCSE() const { return true; } | 5125 virtual bool AllowsCSE() const { return true; } |
5119 virtual EffectSet Effects() const { return EffectSet::None(); } | 5126 virtual EffectSet Effects() const { return EffectSet::None(); } |
5120 virtual EffectSet Dependencies() const { return EffectSet::None(); } | 5127 virtual EffectSet Dependencies() const { return EffectSet::None(); } |
5121 virtual bool AttributesEqual(Instruction* other) const { return true; } | 5128 virtual bool AttributesEqual(Instruction* other) const { return true; } |
5122 | 5129 |
5123 virtual bool MayThrow() const { return false; } | 5130 virtual bool MayThrow() const { return false; } |
5124 | 5131 |
5125 private: | 5132 private: |
| 5133 bool is_smi_; |
| 5134 |
5126 DISALLOW_COPY_AND_ASSIGN(BoxIntegerInstr); | 5135 DISALLOW_COPY_AND_ASSIGN(BoxIntegerInstr); |
5127 }; | 5136 }; |
5128 | 5137 |
5129 | 5138 |
5130 class UnboxDoubleInstr : public TemplateDefinition<1> { | 5139 class UnboxDoubleInstr : public TemplateDefinition<1> { |
5131 public: | 5140 public: |
5132 UnboxDoubleInstr(Value* value, intptr_t deopt_id) { | 5141 UnboxDoubleInstr(Value* value, intptr_t deopt_id) { |
5133 SetInputAt(0, value); | 5142 SetInputAt(0, value); |
5134 deopt_id_ = deopt_id; | 5143 deopt_id_ = deopt_id; |
5135 } | 5144 } |
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7131 ASSERT((idx == 0) || (idx == 1)); | 7140 ASSERT((idx == 0) || (idx == 1)); |
7132 return (idx == 0) ? kUnboxedMint : kTagged; | 7141 return (idx == 0) ? kUnboxedMint : kTagged; |
7133 } | 7142 } |
7134 | 7143 |
7135 virtual intptr_t DeoptimizationTarget() const { | 7144 virtual intptr_t DeoptimizationTarget() const { |
7136 // Direct access since this instruction cannot deoptimize, and the deopt-id | 7145 // Direct access since this instruction cannot deoptimize, and the deopt-id |
7137 // was inherited from another instruction that could deoptimize. | 7146 // was inherited from another instruction that could deoptimize. |
7138 return deopt_id_; | 7147 return deopt_id_; |
7139 } | 7148 } |
7140 | 7149 |
| 7150 virtual void InferRange(); |
| 7151 |
7141 DECLARE_INSTRUCTION(ShiftMintOp) | 7152 DECLARE_INSTRUCTION(ShiftMintOp) |
7142 | 7153 |
7143 virtual bool AllowsCSE() const { return true; } | 7154 virtual bool AllowsCSE() const { return true; } |
7144 virtual EffectSet Effects() const { return EffectSet::None(); } | 7155 virtual EffectSet Effects() const { return EffectSet::None(); } |
7145 virtual EffectSet Dependencies() const { return EffectSet::None(); } | 7156 virtual EffectSet Dependencies() const { return EffectSet::None(); } |
7146 virtual bool AttributesEqual(Instruction* other) const { | 7157 virtual bool AttributesEqual(Instruction* other) const { |
7147 return op_kind() == other->AsShiftMintOp()->op_kind(); | 7158 return op_kind() == other->AsShiftMintOp()->op_kind(); |
7148 } | 7159 } |
7149 | 7160 |
7150 virtual bool MayThrow() const { return false; } | 7161 virtual bool MayThrow() const { return false; } |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8192 ForwardInstructionIterator* current_iterator_; | 8203 ForwardInstructionIterator* current_iterator_; |
8193 | 8204 |
8194 private: | 8205 private: |
8195 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 8206 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
8196 }; | 8207 }; |
8197 | 8208 |
8198 | 8209 |
8199 } // namespace dart | 8210 } // namespace dart |
8200 | 8211 |
8201 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 8212 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
OLD | NEW |