| 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 RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ |
| 6 #define RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define RUNTIME_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/flags.h" | 10 #include "vm/flags.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 private: | 171 private: |
| 172 bool CanComputeIsInstanceOf(const AbstractType& type, | 172 bool CanComputeIsInstanceOf(const AbstractType& type, |
| 173 bool is_nullable, | 173 bool is_nullable, |
| 174 bool* is_instance); | 174 bool* is_instance); |
| 175 | 175 |
| 176 bool is_nullable_; | 176 bool is_nullable_; |
| 177 intptr_t cid_; | 177 intptr_t cid_; |
| 178 const AbstractType* type_; | 178 const AbstractType* type_; |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 // TODO(alexmarkov): remove EffectSet as there are no tracked effects anymore |
| 181 class EffectSet : public ValueObject { | 182 class EffectSet : public ValueObject { |
| 182 public: | 183 public: |
| 183 enum Effects { | 184 enum Effects { |
| 184 kNoEffects = 0, | 185 kNoEffects = 0, |
| 185 kExternalization = 1, | 186 kUnusedEffect = 1, // Currently unused. |
| 186 kLastEffect = kExternalization | 187 kLastEffect = kUnusedEffect |
| 187 }; | 188 }; |
| 188 | 189 |
| 189 EffectSet(const EffectSet& other) : ValueObject(), effects_(other.effects_) {} | 190 EffectSet(const EffectSet& other) : ValueObject(), effects_(other.effects_) {} |
| 190 | 191 |
| 191 bool IsNone() const { return effects_ == kNoEffects; } | 192 bool IsNone() const { return effects_ == kNoEffects; } |
| 192 | 193 |
| 193 static EffectSet None() { return EffectSet(kNoEffects); } | 194 static EffectSet None() { return EffectSet(kNoEffects); } |
| 194 static EffectSet All() { | 195 static EffectSet All() { |
| 195 ASSERT(EffectSet::kLastEffect == 1); | 196 ASSERT(EffectSet::kLastEffect == 1); |
| 196 return EffectSet(kExternalization); | 197 return EffectSet(kUnusedEffect); |
| 197 } | 198 } |
| 198 | 199 |
| 199 static EffectSet Externalization() { return EffectSet(kExternalization); } | |
| 200 | |
| 201 bool ToInt() { return effects_; } | 200 bool ToInt() { return effects_; } |
| 202 | 201 |
| 203 private: | 202 private: |
| 204 explicit EffectSet(intptr_t effects) : effects_(effects) {} | 203 explicit EffectSet(intptr_t effects) : effects_(effects) {} |
| 205 | 204 |
| 206 intptr_t effects_; | 205 intptr_t effects_; |
| 207 }; | 206 }; |
| 208 | 207 |
| 209 class Value : public ZoneAllocated { | 208 class Value : public ZoneAllocated { |
| 210 public: | 209 public: |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 void SetLength(intptr_t len) { cid_ranges_.SetLength(len); } | 622 void SetLength(intptr_t len) { cid_ranges_.SetLength(len); } |
| 624 | 623 |
| 625 bool is_empty() const { return cid_ranges_.is_empty(); } | 624 bool is_empty() const { return cid_ranges_.is_empty(); } |
| 626 | 625 |
| 627 void Sort(int compare(CidRange* const* a, CidRange* const* b)) { | 626 void Sort(int compare(CidRange* const* a, CidRange* const* b)) { |
| 628 cid_ranges_.Sort(compare); | 627 cid_ranges_.Sort(compare); |
| 629 } | 628 } |
| 630 | 629 |
| 631 bool IsMonomorphic() const; | 630 bool IsMonomorphic() const; |
| 632 intptr_t MonomorphicReceiverCid() const; | 631 intptr_t MonomorphicReceiverCid() const; |
| 633 bool ContainsExternalizableCids() const; | |
| 634 intptr_t ComputeLowestCid() const; | 632 intptr_t ComputeLowestCid() const; |
| 635 intptr_t ComputeHighestCid() const; | 633 intptr_t ComputeHighestCid() const; |
| 636 | 634 |
| 637 protected: | 635 protected: |
| 638 void CreateHelper(Zone* zone, | 636 void CreateHelper(Zone* zone, |
| 639 const ICData& ic_data, | 637 const ICData& ic_data, |
| 640 int argument_number, | 638 int argument_number, |
| 641 bool include_targets); | 639 bool include_targets); |
| 642 GrowableArray<CidRange*> cid_ranges_; | 640 GrowableArray<CidRange*> cid_ranges_; |
| 643 Zone* zone_; | 641 Zone* zone_; |
| (...skipping 3744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4388 | 4386 |
| 4389 virtual EffectSet Effects() const { return EffectSet::None(); } | 4387 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 4390 virtual bool AttributesEqual(Instruction* other) const { return true; } | 4388 virtual bool AttributesEqual(Instruction* other) const { return true; } |
| 4391 | 4389 |
| 4392 private: | 4390 private: |
| 4393 intptr_t offset_; | 4391 intptr_t offset_; |
| 4394 | 4392 |
| 4395 DISALLOW_COPY_AND_ASSIGN(LoadUntaggedInstr); | 4393 DISALLOW_COPY_AND_ASSIGN(LoadUntaggedInstr); |
| 4396 }; | 4394 }; |
| 4397 | 4395 |
| 4398 class LoadClassIdInstr : public TemplateDefinition<1, NoThrow> { | 4396 class LoadClassIdInstr : public TemplateDefinition<1, NoThrow, Pure> { |
| 4399 public: | 4397 public: |
| 4400 explicit LoadClassIdInstr(Value* object) { SetInputAt(0, object); } | 4398 explicit LoadClassIdInstr(Value* object) { SetInputAt(0, object); } |
| 4401 | 4399 |
| 4402 virtual Representation representation() const { return kTagged; } | 4400 virtual Representation representation() const { return kTagged; } |
| 4403 DECLARE_INSTRUCTION(LoadClassId) | 4401 DECLARE_INSTRUCTION(LoadClassId) |
| 4404 virtual CompileType ComputeType() const; | 4402 virtual CompileType ComputeType() const; |
| 4405 | 4403 |
| 4406 Value* object() const { return inputs_[0]; } | 4404 Value* object() const { return inputs_[0]; } |
| 4407 | 4405 |
| 4408 virtual bool ComputeCanDeoptimize() const { return false; } | 4406 virtual bool ComputeCanDeoptimize() const { return false; } |
| 4409 | 4407 |
| 4410 virtual bool AllowsCSE() const { return true; } | |
| 4411 virtual EffectSet Dependencies() const { | |
| 4412 return EffectSet::Externalization(); | |
| 4413 } | |
| 4414 virtual EffectSet Effects() const { return EffectSet::None(); } | |
| 4415 virtual bool AttributesEqual(Instruction* other) const { return true; } | 4408 virtual bool AttributesEqual(Instruction* other) const { return true; } |
| 4416 | 4409 |
| 4417 private: | 4410 private: |
| 4418 DISALLOW_COPY_AND_ASSIGN(LoadClassIdInstr); | 4411 DISALLOW_COPY_AND_ASSIGN(LoadClassIdInstr); |
| 4419 }; | 4412 }; |
| 4420 | 4413 |
| 4421 class LoadFieldInstr : public TemplateDefinition<1, NoThrow> { | 4414 class LoadFieldInstr : public TemplateDefinition<1, NoThrow> { |
| 4422 public: | 4415 public: |
| 4423 LoadFieldInstr(Value* instance, | 4416 LoadFieldInstr(Value* instance, |
| 4424 intptr_t offset_in_bytes, | 4417 intptr_t offset_in_bytes, |
| (...skipping 3181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7606 bool IsNullCheck() const { return IsDeoptIfNull() || IsDeoptIfNotNull(); } | 7599 bool IsNullCheck() const { return IsDeoptIfNull() || IsDeoptIfNotNull(); } |
| 7607 | 7600 |
| 7608 bool IsDeoptIfNull() const; | 7601 bool IsDeoptIfNull() const; |
| 7609 bool IsDeoptIfNotNull() const; | 7602 bool IsDeoptIfNotNull() const; |
| 7610 | 7603 |
| 7611 bool IsBitTest() const; | 7604 bool IsBitTest() const; |
| 7612 static bool IsCompactCidRange(const Cids& cids); | 7605 static bool IsCompactCidRange(const Cids& cids); |
| 7613 intptr_t ComputeCidMask() const; | 7606 intptr_t ComputeCidMask() const; |
| 7614 | 7607 |
| 7615 virtual bool AllowsCSE() const { return true; } | 7608 virtual bool AllowsCSE() const { return true; } |
| 7616 virtual EffectSet Dependencies() const; | 7609 virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| 7617 virtual EffectSet Effects() const { return EffectSet::None(); } | 7610 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 7618 virtual bool AttributesEqual(Instruction* other) const; | 7611 virtual bool AttributesEqual(Instruction* other) const; |
| 7619 | 7612 |
| 7620 bool licm_hoisted() const { return licm_hoisted_; } | 7613 bool licm_hoisted() const { return licm_hoisted_; } |
| 7621 void set_licm_hoisted(bool value) { licm_hoisted_ = value; } | 7614 void set_licm_hoisted(bool value) { licm_hoisted_ = value; } |
| 7622 | 7615 |
| 7623 PRINT_OPERANDS_TO_SUPPORT | 7616 PRINT_OPERANDS_TO_SUPPORT |
| 7624 | 7617 |
| 7625 private: | 7618 private: |
| 7626 const Cids& cids_; | 7619 const Cids& cids_; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7686 Value* value() const { return inputs_[0]; } | 7679 Value* value() const { return inputs_[0]; } |
| 7687 const CidRange& cids() const { return cids_; } | 7680 const CidRange& cids() const { return cids_; } |
| 7688 | 7681 |
| 7689 DECLARE_INSTRUCTION(CheckClassId) | 7682 DECLARE_INSTRUCTION(CheckClassId) |
| 7690 | 7683 |
| 7691 virtual bool ComputeCanDeoptimize() const { return true; } | 7684 virtual bool ComputeCanDeoptimize() const { return true; } |
| 7692 | 7685 |
| 7693 virtual Instruction* Canonicalize(FlowGraph* flow_graph); | 7686 virtual Instruction* Canonicalize(FlowGraph* flow_graph); |
| 7694 | 7687 |
| 7695 virtual bool AllowsCSE() const { return true; } | 7688 virtual bool AllowsCSE() const { return true; } |
| 7696 virtual EffectSet Dependencies() const; | 7689 virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| 7697 virtual EffectSet Effects() const { return EffectSet::None(); } | 7690 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 7698 virtual bool AttributesEqual(Instruction* other) const { return true; } | 7691 virtual bool AttributesEqual(Instruction* other) const { return true; } |
| 7699 | 7692 |
| 7700 PRINT_OPERANDS_TO_SUPPORT | 7693 PRINT_OPERANDS_TO_SUPPORT |
| 7701 | 7694 |
| 7702 private: | 7695 private: |
| 7703 bool Contains(intptr_t cid) const; | 7696 bool Contains(intptr_t cid) const; |
| 7704 | 7697 |
| 7705 CidRange cids_; | 7698 CidRange cids_; |
| 7706 | 7699 |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8096 #define DEFINE_UNIMPLEMENTED_INSTRUCTION(Name) \ | 8089 #define DEFINE_UNIMPLEMENTED_INSTRUCTION(Name) \ |
| 8097 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ | 8090 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ |
| 8098 UNIMPLEMENTED(); \ | 8091 UNIMPLEMENTED(); \ |
| 8099 return NULL; \ | 8092 return NULL; \ |
| 8100 } \ | 8093 } \ |
| 8101 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } | 8094 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } |
| 8102 | 8095 |
| 8103 } // namespace dart | 8096 } // namespace dart |
| 8104 | 8097 |
| 8105 #endif // RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ | 8098 #endif // RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |