OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1805 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); | 1805 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); |
1806 } | 1806 } |
1807 | 1807 |
1808 | 1808 |
1809 HConstant::HConstant(Handle<Object> handle, Representation r) | 1809 HConstant::HConstant(Handle<Object> handle, Representation r) |
1810 : handle_(handle), | 1810 : handle_(handle), |
1811 has_int32_value_(false), | 1811 has_int32_value_(false), |
1812 has_double_value_(false) { | 1812 has_double_value_(false) { |
1813 // Dereferencing here is safe: the value of a number object does not change. | 1813 // Dereferencing here is safe: the value of a number object does not change. |
1814 AllowHandleDereference allow_handle_deref(Isolate::Current()); | 1814 AllowHandleDereference allow_handle_deref(Isolate::Current()); |
1815 SetFlag(kUseGVN); | |
1816 if (handle_->IsNumber()) { | 1815 if (handle_->IsNumber()) { |
1817 double n = handle_->Number(); | 1816 double n = handle_->Number(); |
1818 has_int32_value_ = IsInteger32(n); | 1817 has_int32_value_ = IsInteger32(n); |
1819 int32_value_ = DoubleToInt32(n); | 1818 int32_value_ = DoubleToInt32(n); |
1820 double_value_ = n; | 1819 double_value_ = n; |
1821 has_double_value_ = true; | 1820 has_double_value_ = true; |
1822 } | 1821 } |
1823 if (r.IsNone()) { | 1822 if (r.IsNone()) { |
1824 if (has_int32_value_) { | 1823 if (has_int32_value_) { |
1825 r = Representation::Integer32(); | 1824 r = Representation::Integer32(); |
1826 } else if (has_double_value_) { | 1825 } else if (has_double_value_) { |
1827 r = Representation::Double(); | 1826 r = Representation::Double(); |
1828 } else { | 1827 } else { |
1829 r = Representation::Tagged(); | 1828 r = Representation::Tagged(); |
1830 } | 1829 } |
1831 } | 1830 } |
1832 set_representation(r); | 1831 Initialize(r); |
1833 } | 1832 } |
1834 | 1833 |
1835 | 1834 |
1836 HConstant::HConstant(int32_t integer_value, Representation r) | 1835 HConstant::HConstant(int32_t integer_value, Representation r) |
1837 : has_int32_value_(true), | 1836 : has_int32_value_(true), |
1838 has_double_value_(true), | 1837 has_double_value_(true), |
1839 int32_value_(integer_value), | 1838 int32_value_(integer_value), |
1840 double_value_(FastI2D(integer_value)) { | 1839 double_value_(FastI2D(integer_value)) { |
1841 set_representation(r); | 1840 Initialize(r); |
1842 SetFlag(kUseGVN); | |
1843 } | 1841 } |
1844 | 1842 |
1845 | 1843 |
1846 HConstant::HConstant(double double_value, Representation r) | 1844 HConstant::HConstant(double double_value, Representation r) |
1847 : has_int32_value_(IsInteger32(double_value)), | 1845 : has_int32_value_(IsInteger32(double_value)), |
1848 has_double_value_(true), | 1846 has_double_value_(true), |
1849 int32_value_(DoubleToInt32(double_value)), | 1847 int32_value_(DoubleToInt32(double_value)), |
1850 double_value_(double_value) { | 1848 double_value_(double_value) { |
1851 set_representation(r); | 1849 Initialize(r); |
1852 SetFlag(kUseGVN); | |
1853 } | 1850 } |
1854 | 1851 |
1855 | 1852 |
| 1853 void HConstant::Initialize(Representation r) { |
| 1854 set_representation(r); |
| 1855 SetFlag(kUseGVN); |
| 1856 if (representation().IsInteger32()) { |
| 1857 ClearGVNFlag(kDependsOnOsrEntries); |
| 1858 } |
| 1859 } |
| 1860 |
| 1861 |
1856 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { | 1862 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
1857 if (r.IsInteger32() && !has_int32_value_) return NULL; | 1863 if (r.IsInteger32() && !has_int32_value_) return NULL; |
1858 if (r.IsDouble() && !has_double_value_) return NULL; | 1864 if (r.IsDouble() && !has_double_value_) return NULL; |
1859 if (handle_.is_null()) { | 1865 if (handle_.is_null()) { |
1860 ASSERT(has_int32_value_ || has_double_value_); | 1866 ASSERT(has_int32_value_ || has_double_value_); |
1861 if (has_int32_value_) return new(zone) HConstant(int32_value_, r); | 1867 if (has_int32_value_) return new(zone) HConstant(int32_value_, r); |
1862 return new(zone) HConstant(double_value_, r); | 1868 return new(zone) HConstant(double_value_, r); |
1863 } | 1869 } |
1864 return new(zone) HConstant(handle_, r); | 1870 return new(zone) HConstant(handle_, r); |
1865 } | 1871 } |
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3256 | 3262 |
3257 | 3263 |
3258 void HCheckFunction::Verify() { | 3264 void HCheckFunction::Verify() { |
3259 HInstruction::Verify(); | 3265 HInstruction::Verify(); |
3260 ASSERT(HasNoUses()); | 3266 ASSERT(HasNoUses()); |
3261 } | 3267 } |
3262 | 3268 |
3263 #endif | 3269 #endif |
3264 | 3270 |
3265 } } // namespace v8::internal | 3271 } } // namespace v8::internal |
OLD | NEW |