OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 range_(NULL), | 454 range_(NULL), |
455 flags_(0) {} | 455 flags_(0) {} |
456 virtual ~HValue() {} | 456 virtual ~HValue() {} |
457 | 457 |
458 HBasicBlock* block() const { return block_; } | 458 HBasicBlock* block() const { return block_; } |
459 void SetBlock(HBasicBlock* block); | 459 void SetBlock(HBasicBlock* block); |
460 | 460 |
461 int id() const { return id_; } | 461 int id() const { return id_; } |
462 void set_id(int id) { id_ = id; } | 462 void set_id(int id) { id_ = id; } |
463 | 463 |
464 const ZoneList<HValue*>* uses() const { return &uses_; } | 464 ZoneList<HValue*>* uses() { return &uses_; } |
465 | 465 |
466 virtual bool EmitAtUses() const { return false; } | 466 virtual bool EmitAtUses() { return false; } |
467 Representation representation() const { return representation_; } | 467 Representation representation() const { return representation_; } |
468 void ChangeRepresentation(Representation r) { | 468 void ChangeRepresentation(Representation r) { |
469 // Representation was already set and is allowed to be changed. | 469 // Representation was already set and is allowed to be changed. |
470 ASSERT(!representation_.IsNone()); | 470 ASSERT(!representation_.IsNone()); |
471 ASSERT(!r.IsNone()); | 471 ASSERT(!r.IsNone()); |
472 ASSERT(CheckFlag(kFlexibleRepresentation)); | 472 ASSERT(CheckFlag(kFlexibleRepresentation)); |
473 RepresentationChanged(r); | 473 RepresentationChanged(r); |
474 representation_ = r; | 474 representation_ = r; |
475 } | 475 } |
476 | 476 |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1793 protected: | 1793 protected: |
1794 virtual bool DataEquals(HValue* other) { return true; } | 1794 virtual bool DataEquals(HValue* other) { return true; } |
1795 }; | 1795 }; |
1796 | 1796 |
1797 | 1797 |
1798 class HPhi: public HValue { | 1798 class HPhi: public HValue { |
1799 public: | 1799 public: |
1800 explicit HPhi(int merged_index) | 1800 explicit HPhi(int merged_index) |
1801 : inputs_(2), | 1801 : inputs_(2), |
1802 merged_index_(merged_index), | 1802 merged_index_(merged_index), |
1803 phi_id_(-1) { | 1803 phi_id_(-1), |
| 1804 is_live_(false) { |
1804 for (int i = 0; i < Representation::kNumRepresentations; i++) { | 1805 for (int i = 0; i < Representation::kNumRepresentations; i++) { |
1805 non_phi_uses_[i] = 0; | 1806 non_phi_uses_[i] = 0; |
1806 indirect_uses_[i] = 0; | 1807 indirect_uses_[i] = 0; |
1807 } | 1808 } |
1808 ASSERT(merged_index >= 0); | 1809 ASSERT(merged_index >= 0); |
1809 set_representation(Representation::Tagged()); | 1810 set_representation(Representation::Tagged()); |
1810 SetFlag(kFlexibleRepresentation); | 1811 SetFlag(kFlexibleRepresentation); |
1811 } | 1812 } |
1812 | 1813 |
1813 virtual Representation InferredRepresentation() { | 1814 virtual Representation InferredRepresentation() { |
(...skipping 13 matching lines...) Expand all Loading... |
1827 | 1828 |
1828 virtual Range* InferRange(); | 1829 virtual Range* InferRange(); |
1829 virtual Representation RequiredInputRepresentation(int index) const { | 1830 virtual Representation RequiredInputRepresentation(int index) const { |
1830 return representation(); | 1831 return representation(); |
1831 } | 1832 } |
1832 virtual HType CalculateInferredType(); | 1833 virtual HType CalculateInferredType(); |
1833 virtual int OperandCount() { return inputs_.length(); } | 1834 virtual int OperandCount() { return inputs_.length(); } |
1834 virtual HValue* OperandAt(int index) { return inputs_[index]; } | 1835 virtual HValue* OperandAt(int index) { return inputs_[index]; } |
1835 HValue* GetRedundantReplacement(); | 1836 HValue* GetRedundantReplacement(); |
1836 void AddInput(HValue* value); | 1837 void AddInput(HValue* value); |
| 1838 bool HasRealUses(); |
1837 | 1839 |
1838 bool IsReceiver() { return merged_index_ == 0; } | 1840 bool IsReceiver() { return merged_index_ == 0; } |
1839 | 1841 |
1840 int merged_index() const { return merged_index_; } | 1842 int merged_index() const { return merged_index_; } |
1841 | 1843 |
1842 virtual const char* Mnemonic() const { return "phi"; } | 1844 virtual const char* Mnemonic() const { return "phi"; } |
1843 | 1845 |
1844 virtual void PrintTo(StringStream* stream); | 1846 virtual void PrintTo(StringStream* stream); |
1845 | 1847 |
1846 #ifdef DEBUG | 1848 #ifdef DEBUG |
(...skipping 18 matching lines...) Expand all Loading... |
1865 int tagged_indirect_uses() const { | 1867 int tagged_indirect_uses() const { |
1866 return indirect_uses_[Representation::kTagged]; | 1868 return indirect_uses_[Representation::kTagged]; |
1867 } | 1869 } |
1868 int int32_indirect_uses() const { | 1870 int int32_indirect_uses() const { |
1869 return indirect_uses_[Representation::kInteger32]; | 1871 return indirect_uses_[Representation::kInteger32]; |
1870 } | 1872 } |
1871 int double_indirect_uses() const { | 1873 int double_indirect_uses() const { |
1872 return indirect_uses_[Representation::kDouble]; | 1874 return indirect_uses_[Representation::kDouble]; |
1873 } | 1875 } |
1874 int phi_id() { return phi_id_; } | 1876 int phi_id() { return phi_id_; } |
| 1877 bool is_live() { return is_live_; } |
| 1878 void set_is_live(bool b) { is_live_ = b; } |
1875 | 1879 |
1876 protected: | 1880 protected: |
1877 virtual void DeleteFromGraph(); | 1881 virtual void DeleteFromGraph(); |
1878 virtual void InternalSetOperandAt(int index, HValue* value) { | 1882 virtual void InternalSetOperandAt(int index, HValue* value) { |
1879 inputs_[index] = value; | 1883 inputs_[index] = value; |
1880 } | 1884 } |
1881 | 1885 |
1882 private: | 1886 private: |
1883 ZoneList<HValue*> inputs_; | 1887 ZoneList<HValue*> inputs_; |
1884 int merged_index_; | 1888 int merged_index_; |
1885 | 1889 |
1886 int non_phi_uses_[Representation::kNumRepresentations]; | 1890 int non_phi_uses_[Representation::kNumRepresentations]; |
1887 int indirect_uses_[Representation::kNumRepresentations]; | 1891 int indirect_uses_[Representation::kNumRepresentations]; |
1888 int phi_id_; | 1892 int phi_id_; |
| 1893 bool is_live_; |
1889 }; | 1894 }; |
1890 | 1895 |
1891 | 1896 |
1892 class HArgumentsObject: public HTemplateInstruction<0> { | 1897 class HArgumentsObject: public HTemplateInstruction<0> { |
1893 public: | 1898 public: |
1894 HArgumentsObject() { | 1899 HArgumentsObject() { |
1895 set_representation(Representation::Tagged()); | 1900 set_representation(Representation::Tagged()); |
1896 SetFlag(kIsArguments); | 1901 SetFlag(kIsArguments); |
1897 } | 1902 } |
1898 | 1903 |
(...skipping 10 matching lines...) Expand all Loading... |
1909 HConstant(Handle<Object> handle, Representation r); | 1914 HConstant(Handle<Object> handle, Representation r); |
1910 | 1915 |
1911 Handle<Object> handle() const { return handle_; } | 1916 Handle<Object> handle() const { return handle_; } |
1912 | 1917 |
1913 bool InOldSpace() const { return !Heap::InNewSpace(*handle_); } | 1918 bool InOldSpace() const { return !Heap::InNewSpace(*handle_); } |
1914 | 1919 |
1915 virtual Representation RequiredInputRepresentation(int index) const { | 1920 virtual Representation RequiredInputRepresentation(int index) const { |
1916 return Representation::None(); | 1921 return Representation::None(); |
1917 } | 1922 } |
1918 | 1923 |
1919 virtual bool EmitAtUses() const { return !representation().IsDouble(); } | 1924 virtual bool EmitAtUses() { return !representation().IsDouble(); } |
1920 virtual void PrintDataTo(StringStream* stream); | 1925 virtual void PrintDataTo(StringStream* stream); |
1921 virtual HType CalculateInferredType(); | 1926 virtual HType CalculateInferredType(); |
1922 bool IsInteger() const { return handle_->IsSmi(); } | 1927 bool IsInteger() const { return handle_->IsSmi(); } |
1923 HConstant* CopyToRepresentation(Representation r) const; | 1928 HConstant* CopyToRepresentation(Representation r) const; |
1924 HConstant* CopyToTruncatedInt32() const; | 1929 HConstant* CopyToTruncatedInt32() const; |
1925 bool HasInteger32Value() const { return has_int32_value_; } | 1930 bool HasInteger32Value() const { return has_int32_value_; } |
1926 int32_t Integer32Value() const { | 1931 int32_t Integer32Value() const { |
1927 ASSERT(HasInteger32Value()); | 1932 ASSERT(HasInteger32Value()); |
1928 return int32_value_; | 1933 return int32_value_; |
1929 } | 1934 } |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2184 public: | 2189 public: |
2185 HCompare(HValue* left, HValue* right, Token::Value token) | 2190 HCompare(HValue* left, HValue* right, Token::Value token) |
2186 : HBinaryOperation(left, right), token_(token) { | 2191 : HBinaryOperation(left, right), token_(token) { |
2187 ASSERT(Token::IsCompareOp(token)); | 2192 ASSERT(Token::IsCompareOp(token)); |
2188 set_representation(Representation::Tagged()); | 2193 set_representation(Representation::Tagged()); |
2189 SetAllSideEffects(); | 2194 SetAllSideEffects(); |
2190 } | 2195 } |
2191 | 2196 |
2192 void SetInputRepresentation(Representation r); | 2197 void SetInputRepresentation(Representation r); |
2193 | 2198 |
2194 virtual bool EmitAtUses() const { | 2199 virtual bool EmitAtUses() { |
2195 return !HasSideEffects() && (uses()->length() <= 1); | 2200 return !HasSideEffects() && (uses()->length() <= 1); |
2196 } | 2201 } |
2197 | 2202 |
2198 virtual Representation RequiredInputRepresentation(int index) const { | 2203 virtual Representation RequiredInputRepresentation(int index) const { |
2199 return input_representation_; | 2204 return input_representation_; |
2200 } | 2205 } |
2201 Representation GetInputRepresentation() const { | 2206 Representation GetInputRepresentation() const { |
2202 return input_representation_; | 2207 return input_representation_; |
2203 } | 2208 } |
2204 Token::Value token() const { return token_; } | 2209 Token::Value token() const { return token_; } |
(...skipping 20 matching lines...) Expand all Loading... |
2225 | 2230 |
2226 | 2231 |
2227 class HCompareJSObjectEq: public HBinaryOperation { | 2232 class HCompareJSObjectEq: public HBinaryOperation { |
2228 public: | 2233 public: |
2229 HCompareJSObjectEq(HValue* left, HValue* right) | 2234 HCompareJSObjectEq(HValue* left, HValue* right) |
2230 : HBinaryOperation(left, right) { | 2235 : HBinaryOperation(left, right) { |
2231 set_representation(Representation::Tagged()); | 2236 set_representation(Representation::Tagged()); |
2232 SetFlag(kUseGVN); | 2237 SetFlag(kUseGVN); |
2233 } | 2238 } |
2234 | 2239 |
2235 virtual bool EmitAtUses() const { | 2240 virtual bool EmitAtUses() { |
2236 return !HasSideEffects() && (uses()->length() <= 1); | 2241 return !HasSideEffects() && (uses()->length() <= 1); |
2237 } | 2242 } |
2238 | 2243 |
2239 virtual Representation RequiredInputRepresentation(int index) const { | 2244 virtual Representation RequiredInputRepresentation(int index) const { |
2240 return Representation::Tagged(); | 2245 return Representation::Tagged(); |
2241 } | 2246 } |
2242 virtual HType CalculateInferredType(); | 2247 virtual HType CalculateInferredType(); |
2243 | 2248 |
2244 DECLARE_CONCRETE_INSTRUCTION(CompareJSObjectEq, "compare-js-object-eq") | 2249 DECLARE_CONCRETE_INSTRUCTION(CompareJSObjectEq, "compare-js-object-eq") |
2245 | 2250 |
2246 protected: | 2251 protected: |
2247 virtual bool DataEquals(HValue* other) { return true; } | 2252 virtual bool DataEquals(HValue* other) { return true; } |
2248 }; | 2253 }; |
2249 | 2254 |
2250 | 2255 |
2251 class HUnaryPredicate: public HUnaryOperation { | 2256 class HUnaryPredicate: public HUnaryOperation { |
2252 public: | 2257 public: |
2253 explicit HUnaryPredicate(HValue* value) : HUnaryOperation(value) { | 2258 explicit HUnaryPredicate(HValue* value) : HUnaryOperation(value) { |
2254 set_representation(Representation::Tagged()); | 2259 set_representation(Representation::Tagged()); |
2255 SetFlag(kUseGVN); | 2260 SetFlag(kUseGVN); |
2256 } | 2261 } |
2257 | 2262 |
2258 virtual bool EmitAtUses() const { | 2263 virtual bool EmitAtUses() { |
2259 return !HasSideEffects() && (uses()->length() <= 1); | 2264 return !HasSideEffects() && (uses()->length() <= 1); |
2260 } | 2265 } |
2261 | 2266 |
2262 virtual Representation RequiredInputRepresentation(int index) const { | 2267 virtual Representation RequiredInputRepresentation(int index) const { |
2263 return Representation::Tagged(); | 2268 return Representation::Tagged(); |
2264 } | 2269 } |
2265 virtual HType CalculateInferredType(); | 2270 virtual HType CalculateInferredType(); |
2266 }; | 2271 }; |
2267 | 2272 |
2268 | 2273 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2308 }; | 2313 }; |
2309 | 2314 |
2310 | 2315 |
2311 class HIsConstructCall: public HTemplateInstruction<0> { | 2316 class HIsConstructCall: public HTemplateInstruction<0> { |
2312 public: | 2317 public: |
2313 HIsConstructCall() { | 2318 HIsConstructCall() { |
2314 set_representation(Representation::Tagged()); | 2319 set_representation(Representation::Tagged()); |
2315 SetFlag(kUseGVN); | 2320 SetFlag(kUseGVN); |
2316 } | 2321 } |
2317 | 2322 |
2318 virtual bool EmitAtUses() const { | 2323 virtual bool EmitAtUses() { |
2319 return !HasSideEffects() && (uses()->length() <= 1); | 2324 return !HasSideEffects() && (uses()->length() <= 1); |
2320 } | 2325 } |
2321 | 2326 |
2322 virtual Representation RequiredInputRepresentation(int index) const { | 2327 virtual Representation RequiredInputRepresentation(int index) const { |
2323 return Representation::None(); | 2328 return Representation::None(); |
2324 } | 2329 } |
2325 | 2330 |
2326 DECLARE_CONCRETE_INSTRUCTION(IsConstructCall, "is_construct_call") | 2331 DECLARE_CONCRETE_INSTRUCTION(IsConstructCall, "is_construct_call") |
2327 | 2332 |
2328 protected: | 2333 protected: |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2430 SetOperandAt(1, left); | 2435 SetOperandAt(1, left); |
2431 SetOperandAt(2, right); | 2436 SetOperandAt(2, right); |
2432 set_representation(Representation::Tagged()); | 2437 set_representation(Representation::Tagged()); |
2433 SetAllSideEffects(); | 2438 SetAllSideEffects(); |
2434 } | 2439 } |
2435 | 2440 |
2436 HValue* context() { return OperandAt(0); } | 2441 HValue* context() { return OperandAt(0); } |
2437 HValue* left() { return OperandAt(1); } | 2442 HValue* left() { return OperandAt(1); } |
2438 HValue* right() { return OperandAt(2); } | 2443 HValue* right() { return OperandAt(2); } |
2439 | 2444 |
2440 virtual bool EmitAtUses() const { | 2445 virtual bool EmitAtUses() { |
2441 return !HasSideEffects() && (uses()->length() <= 1); | 2446 return !HasSideEffects() && (uses()->length() <= 1); |
2442 } | 2447 } |
2443 | 2448 |
2444 virtual Representation RequiredInputRepresentation(int index) const { | 2449 virtual Representation RequiredInputRepresentation(int index) const { |
2445 return Representation::Tagged(); | 2450 return Representation::Tagged(); |
2446 } | 2451 } |
2447 | 2452 |
2448 virtual void PrintDataTo(StringStream* stream); | 2453 virtual void PrintDataTo(StringStream* stream); |
2449 | 2454 |
2450 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance_of") | 2455 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance_of") |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3446 HValue* object() { return left(); } | 3451 HValue* object() { return left(); } |
3447 HValue* key() { return right(); } | 3452 HValue* key() { return right(); } |
3448 }; | 3453 }; |
3449 | 3454 |
3450 #undef DECLARE_INSTRUCTION | 3455 #undef DECLARE_INSTRUCTION |
3451 #undef DECLARE_CONCRETE_INSTRUCTION | 3456 #undef DECLARE_CONCRETE_INSTRUCTION |
3452 | 3457 |
3453 } } // namespace v8::internal | 3458 } } // namespace v8::internal |
3454 | 3459 |
3455 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 3460 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |