Chromium Code Reviews| 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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 772 M(UnboxFloat64x2) \ | 772 M(UnboxFloat64x2) \ |
| 773 M(BinaryFloat64x2Op) \ | 773 M(BinaryFloat64x2Op) \ |
| 774 M(Float64x2Zero) \ | 774 M(Float64x2Zero) \ |
| 775 M(Float64x2Constructor) \ | 775 M(Float64x2Constructor) \ |
| 776 M(Float64x2Splat) \ | 776 M(Float64x2Splat) \ |
| 777 M(Float32x4ToFloat64x2) \ | 777 M(Float32x4ToFloat64x2) \ |
| 778 M(Float64x2ToFloat32x4) \ | 778 M(Float64x2ToFloat32x4) \ |
| 779 M(Simd64x2Shuffle) \ | 779 M(Simd64x2Shuffle) \ |
| 780 M(Float64x2ZeroArg) \ | 780 M(Float64x2ZeroArg) \ |
| 781 M(Float64x2OneArg) \ | 781 M(Float64x2OneArg) \ |
| 782 M(MergedMath2) \ | |
| 783 M(ExtractNthOutput) \ | |
| 782 | 784 |
| 783 | 785 |
| 784 #define FORWARD_DECLARATION(type) class type##Instr; | 786 #define FORWARD_DECLARATION(type) class type##Instr; |
| 785 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) | 787 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) |
| 786 #undef FORWARD_DECLARATION | 788 #undef FORWARD_DECLARATION |
| 787 | 789 |
| 788 | 790 |
| 789 // Functions required in all concrete instruction classes. | 791 // Functions required in all concrete instruction classes. |
| 790 #define DECLARE_INSTRUCTION(type) \ | 792 #define DECLARE_INSTRUCTION(type) \ |
| 791 virtual Tag tag() const { return k##type; } \ | 793 virtual Tag tag() const { return k##type; } \ |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1092 friend class CheckSmiInstr; | 1094 friend class CheckSmiInstr; |
| 1093 friend class CheckArrayBoundInstr; | 1095 friend class CheckArrayBoundInstr; |
| 1094 friend class CheckEitherNonSmiInstr; | 1096 friend class CheckEitherNonSmiInstr; |
| 1095 friend class LICM; | 1097 friend class LICM; |
| 1096 friend class DoubleToSmiInstr; | 1098 friend class DoubleToSmiInstr; |
| 1097 friend class DoubleToDoubleInstr; | 1099 friend class DoubleToDoubleInstr; |
| 1098 friend class DoubleToFloatInstr; | 1100 friend class DoubleToFloatInstr; |
| 1099 friend class FloatToDoubleInstr; | 1101 friend class FloatToDoubleInstr; |
| 1100 friend class InvokeMathCFunctionInstr; | 1102 friend class InvokeMathCFunctionInstr; |
| 1101 friend class MergedMathInstr; | 1103 friend class MergedMathInstr; |
| 1104 friend class MergedMath2Instr; | |
| 1102 friend class FlowGraphOptimizer; | 1105 friend class FlowGraphOptimizer; |
| 1103 friend class LoadIndexedInstr; | 1106 friend class LoadIndexedInstr; |
| 1104 friend class StoreIndexedInstr; | 1107 friend class StoreIndexedInstr; |
| 1105 friend class StoreInstanceFieldInstr; | 1108 friend class StoreInstanceFieldInstr; |
| 1106 friend class ComparisonInstr; | 1109 friend class ComparisonInstr; |
| 1107 friend class TargetEntryInstr; | 1110 friend class TargetEntryInstr; |
| 1108 friend class JoinEntryInstr; | 1111 friend class JoinEntryInstr; |
| 1109 friend class InstanceOfInstr; | 1112 friend class InstanceOfInstr; |
| 1110 friend class PolymorphicInstanceCallInstr; | 1113 friend class PolymorphicInstanceCallInstr; |
| 1111 friend class SmiToDoubleInstr; | 1114 friend class SmiToDoubleInstr; |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1758 | 1761 |
| 1759 intptr_t ssa_temp_index() const { return ssa_temp_index_; } | 1762 intptr_t ssa_temp_index() const { return ssa_temp_index_; } |
| 1760 void set_ssa_temp_index(intptr_t index) { | 1763 void set_ssa_temp_index(intptr_t index) { |
| 1761 ASSERT(index >= 0); | 1764 ASSERT(index >= 0); |
| 1762 ASSERT(is_used()); | 1765 ASSERT(is_used()); |
| 1763 ssa_temp_index_ = index; | 1766 ssa_temp_index_ = index; |
| 1764 } | 1767 } |
| 1765 bool HasSSATemp() const { return ssa_temp_index_ >= 0; } | 1768 bool HasSSATemp() const { return ssa_temp_index_ >= 0; } |
| 1766 void ClearSSATempIndex() { ssa_temp_index_ = -1; } | 1769 void ClearSSATempIndex() { ssa_temp_index_ = -1; } |
| 1767 | 1770 |
| 1771 | |
| 1772 virtual bool RequiresTwoSSATempIndexes() const { | |
| 1773 return false; | |
| 1774 } | |
| 1775 | |
| 1776 intptr_t ssa_temp_index2() const { return ssa_temp_index2_; } | |
| 1777 void set_ssa_temp_index2(intptr_t index) { | |
| 1778 ASSERT(index >= 0); | |
| 1779 ASSERT(is_used()); | |
| 1780 ASSERT(RequiresTwoSSATempIndexes()); | |
| 1781 ssa_temp_index2_ = index; | |
| 1782 } | |
| 1783 void ClearSSATempIndex2() { ssa_temp_index2_ = -1; } | |
| 1784 | |
| 1785 | |
| 1768 bool is_used() const { return (use_kind_ != kEffect); } | 1786 bool is_used() const { return (use_kind_ != kEffect); } |
| 1769 void set_use_kind(UseKind kind) { use_kind_ = kind; } | 1787 void set_use_kind(UseKind kind) { use_kind_ = kind; } |
| 1770 | 1788 |
| 1771 // Compile time type of the definition, which may be requested before type | 1789 // Compile time type of the definition, which may be requested before type |
| 1772 // propagation during graph building. | 1790 // propagation during graph building. |
| 1773 CompileType* Type() { | 1791 CompileType* Type() { |
| 1774 if (type_ == NULL) { | 1792 if (type_ == NULL) { |
| 1775 type_ = ComputeInitialType(); | 1793 type_ = ComputeInitialType(); |
| 1776 } | 1794 } |
| 1777 return type_; | 1795 return type_; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1881 protected: | 1899 protected: |
| 1882 friend class RangeAnalysis; | 1900 friend class RangeAnalysis; |
| 1883 friend class Value; | 1901 friend class Value; |
| 1884 | 1902 |
| 1885 Range* range_; | 1903 Range* range_; |
| 1886 CompileType* type_; | 1904 CompileType* type_; |
| 1887 | 1905 |
| 1888 private: | 1906 private: |
| 1889 intptr_t temp_index_; | 1907 intptr_t temp_index_; |
| 1890 intptr_t ssa_temp_index_; | 1908 intptr_t ssa_temp_index_; |
| 1909 intptr_t ssa_temp_index2_; | |
|
Vyacheslav Egorov (Google)
2014/04/03 18:10:09
Can we sink it down into instructions that actuall
Cutch
2014/04/03 18:35:07
Done.
| |
| 1891 Value* input_use_list_; | 1910 Value* input_use_list_; |
| 1892 Value* env_use_list_; | 1911 Value* env_use_list_; |
| 1893 UseKind use_kind_; | 1912 UseKind use_kind_; |
| 1894 | 1913 |
| 1895 Object& constant_value_; | 1914 Object& constant_value_; |
| 1896 | 1915 |
| 1897 DISALLOW_COPY_AND_ASSIGN(Definition); | 1916 DISALLOW_COPY_AND_ASSIGN(Definition); |
| 1898 }; | 1917 }; |
| 1899 | 1918 |
| 1900 | 1919 |
| (...skipping 5378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7279 } | 7298 } |
| 7280 | 7299 |
| 7281 ZoneGrowableArray<Value*>* inputs_; | 7300 ZoneGrowableArray<Value*>* inputs_; |
| 7282 | 7301 |
| 7283 const MethodRecognizer::Kind recognized_kind_; | 7302 const MethodRecognizer::Kind recognized_kind_; |
| 7284 | 7303 |
| 7285 DISALLOW_COPY_AND_ASSIGN(InvokeMathCFunctionInstr); | 7304 DISALLOW_COPY_AND_ASSIGN(InvokeMathCFunctionInstr); |
| 7286 }; | 7305 }; |
| 7287 | 7306 |
| 7288 | 7307 |
| 7308 class ExtractNthOutputInstr : public TemplateDefinition<1> { | |
| 7309 public: | |
| 7310 // Extract the Nth output register from value. | |
| 7311 ExtractNthOutputInstr(Value* value, intptr_t n, Representation rep) | |
| 7312 : index_(n), | |
| 7313 rep_(rep) { | |
| 7314 SetInputAt(0, value); | |
| 7315 } | |
| 7316 | |
| 7317 Value* value() const { return inputs_[0]; } | |
| 7318 | |
| 7319 DECLARE_INSTRUCTION(ExtractNthOutput) | |
| 7320 | |
| 7321 virtual CompileType ComputeType() const; | |
| 7322 virtual void PrintOperandsTo(BufferFormatter* f) const; | |
| 7323 virtual bool CanDeoptimize() const { return false; } | |
| 7324 | |
| 7325 intptr_t index() const { return index_; } | |
| 7326 | |
| 7327 virtual Representation representation() const { | |
| 7328 return rep_; | |
| 7329 } | |
| 7330 | |
| 7331 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | |
| 7332 ASSERT(idx == 0); | |
| 7333 if (representation() == kTagged) { | |
| 7334 return kPairOfTagged; | |
| 7335 } else if (representation() == kUnboxedDouble) { | |
| 7336 return kPairOfUnboxedDouble; | |
| 7337 } | |
| 7338 UNREACHABLE(); | |
| 7339 return rep_; | |
| 7340 } | |
| 7341 | |
| 7342 virtual bool AllowsCSE() const { return true; } | |
| 7343 virtual EffectSet Effects() const { return EffectSet::None(); } | |
| 7344 virtual EffectSet Dependencies() const { return EffectSet::None(); } | |
| 7345 virtual bool AttributesEqual(Instruction* other) const { | |
| 7346 ExtractNthOutputInstr* other_extract = other->AsExtractNthOutput(); | |
| 7347 return (other_extract->representation() == representation()) && | |
| 7348 (other_extract->index() == index()); | |
| 7349 } | |
| 7350 | |
| 7351 virtual bool MayThrow() const { return false; } | |
| 7352 | |
| 7353 private: | |
| 7354 const intptr_t index_; | |
| 7355 const Representation rep_; | |
| 7356 | |
| 7357 DISALLOW_COPY_AND_ASSIGN(ExtractNthOutputInstr); | |
| 7358 }; | |
| 7359 | |
| 7360 | |
| 7361 class MergedMath2Instr : public Definition { | |
| 7362 public: | |
| 7363 enum Kind { | |
| 7364 kTruncDivMod, | |
| 7365 kSinCos, | |
| 7366 }; | |
| 7367 | |
| 7368 MergedMath2Instr(ZoneGrowableArray<Value*>* inputs, | |
| 7369 intptr_t original_deopt_id, | |
| 7370 MergedMath2Instr::Kind kind); | |
| 7371 | |
| 7372 static intptr_t InputCountFor(MergedMath2Instr::Kind kind) { | |
| 7373 if (kind == kTruncDivMod) { | |
| 7374 return 2; | |
| 7375 } else if (kind == kSinCos) { | |
| 7376 return 1; | |
| 7377 } else { | |
| 7378 UNIMPLEMENTED(); | |
| 7379 return -1; | |
| 7380 } | |
| 7381 } | |
| 7382 | |
| 7383 virtual bool RequiresTwoSSATempIndexes() const { | |
| 7384 return true; | |
| 7385 } | |
| 7386 | |
| 7387 MergedMath2Instr::Kind kind() const { return kind_; } | |
| 7388 | |
| 7389 virtual intptr_t InputCount() const { return inputs_->length(); } | |
| 7390 | |
| 7391 virtual Value* InputAt(intptr_t i) const { | |
| 7392 return (*inputs_)[i]; | |
| 7393 } | |
| 7394 | |
| 7395 static intptr_t OutputIndexOf(intptr_t kind); | |
| 7396 static intptr_t OutputIndexOf(Token::Kind token); | |
| 7397 | |
| 7398 virtual CompileType ComputeType() const; | |
| 7399 virtual void PrintOperandsTo(BufferFormatter* f) const; | |
| 7400 | |
| 7401 virtual bool CanDeoptimize() const { | |
| 7402 if (kind_ == kTruncDivMod) { | |
| 7403 return true; | |
| 7404 } else if (kind_ == kSinCos) { | |
| 7405 return false; | |
| 7406 } else { | |
| 7407 UNIMPLEMENTED(); | |
| 7408 return false; | |
| 7409 } | |
| 7410 } | |
| 7411 | |
| 7412 virtual Representation representation() const { | |
| 7413 if (kind_ == kTruncDivMod) { | |
| 7414 return kPairOfTagged; | |
| 7415 } else if (kind_ == kSinCos) { | |
| 7416 return kPairOfUnboxedDouble; | |
| 7417 } else { | |
| 7418 UNIMPLEMENTED(); | |
| 7419 return kTagged; | |
| 7420 } | |
| 7421 } | |
| 7422 | |
| 7423 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | |
| 7424 ASSERT((0 <= idx) && (idx < InputCount())); | |
| 7425 if (kind_ == kTruncDivMod) { | |
| 7426 return kTagged; | |
| 7427 } else if (kind_ == kSinCos) { | |
| 7428 return kUnboxedDouble; | |
| 7429 } else { | |
| 7430 UNIMPLEMENTED(); | |
| 7431 return kTagged; | |
| 7432 } | |
| 7433 } | |
| 7434 | |
| 7435 virtual intptr_t DeoptimizationTarget() const { return deopt_id_; } | |
| 7436 | |
| 7437 DECLARE_INSTRUCTION(MergedMath2) | |
| 7438 | |
| 7439 virtual bool AllowsCSE() const { return true; } | |
| 7440 virtual EffectSet Effects() const { return EffectSet::None(); } | |
| 7441 virtual EffectSet Dependencies() const { return EffectSet::None(); } | |
| 7442 virtual bool AttributesEqual(Instruction* other) const { | |
| 7443 MergedMath2Instr* other_invoke = other->AsMergedMath2(); | |
| 7444 return other_invoke->kind() == kind(); | |
| 7445 } | |
| 7446 | |
| 7447 virtual bool MayThrow() const { return false; } | |
| 7448 | |
| 7449 static const char* KindToCString(MergedMath2Instr::Kind kind) { | |
| 7450 if (kind == kTruncDivMod) return "TruncDivMod"; | |
| 7451 if (kind == kSinCos) return "SinCos"; | |
| 7452 UNIMPLEMENTED(); | |
| 7453 return ""; | |
| 7454 } | |
| 7455 | |
| 7456 private: | |
| 7457 virtual void RawSetInputAt(intptr_t i, Value* value) { | |
| 7458 (*inputs_)[i] = value; | |
| 7459 } | |
| 7460 | |
| 7461 ZoneGrowableArray<Value*>* inputs_; | |
| 7462 MergedMath2Instr::Kind kind_; | |
| 7463 DISALLOW_COPY_AND_ASSIGN(MergedMath2Instr); | |
| 7464 }; | |
| 7465 | |
| 7466 | |
| 7289 class MergedMathInstr : public Definition { | 7467 class MergedMathInstr : public Definition { |
| 7290 public: | 7468 public: |
| 7291 enum Kind { | 7469 enum Kind { |
| 7292 kTruncDivMod, | 7470 kTruncDivMod, |
| 7293 kTruncDivRem, | 7471 kTruncDivRem, |
| 7294 kSinCos, | 7472 kSinCos, |
| 7295 }; | 7473 }; |
| 7296 | 7474 |
| 7297 MergedMathInstr(ZoneGrowableArray<Value*>* inputs, | 7475 MergedMathInstr(ZoneGrowableArray<Value*>* inputs, |
| 7298 intptr_t original_deopt_id, | 7476 intptr_t original_deopt_id, |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7723 ForwardInstructionIterator* current_iterator_; | 7901 ForwardInstructionIterator* current_iterator_; |
| 7724 | 7902 |
| 7725 private: | 7903 private: |
| 7726 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 7904 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 7727 }; | 7905 }; |
| 7728 | 7906 |
| 7729 | 7907 |
| 7730 } // namespace dart | 7908 } // namespace dart |
| 7731 | 7909 |
| 7732 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 7910 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |