| 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 2061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2072 | 2072 |
| 2073 static bool IsInteger32(double value) { | 2073 static bool IsInteger32(double value) { |
| 2074 double roundtrip_value = static_cast<double>(static_cast<int32_t>(value)); | 2074 double roundtrip_value = static_cast<double>(static_cast<int32_t>(value)); |
| 2075 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); | 2075 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); |
| 2076 } | 2076 } |
| 2077 | 2077 |
| 2078 | 2078 |
| 2079 HConstant::HConstant(Handle<Object> handle, Representation r) | 2079 HConstant::HConstant(Handle<Object> handle, Representation r) |
| 2080 : handle_(handle), | 2080 : handle_(handle), |
| 2081 unique_id_(), | 2081 unique_id_(), |
| 2082 has_smi_value_(false), |
| 2082 has_int32_value_(false), | 2083 has_int32_value_(false), |
| 2083 has_double_value_(false), | 2084 has_double_value_(false), |
| 2084 is_internalized_string_(false), | 2085 is_internalized_string_(false), |
| 2085 is_not_in_new_space_(true), | 2086 is_not_in_new_space_(true), |
| 2086 boolean_value_(handle->BooleanValue()) { | 2087 boolean_value_(handle->BooleanValue()) { |
| 2087 if (handle_->IsHeapObject()) { | 2088 if (handle_->IsHeapObject()) { |
| 2088 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); | 2089 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); |
| 2089 is_not_in_new_space_ = !heap->InNewSpace(*handle); | 2090 is_not_in_new_space_ = !heap->InNewSpace(*handle); |
| 2090 } | 2091 } |
| 2091 if (handle_->IsNumber()) { | 2092 if (handle_->IsNumber()) { |
| 2092 double n = handle_->Number(); | 2093 double n = handle_->Number(); |
| 2093 has_int32_value_ = IsInteger32(n); | 2094 has_int32_value_ = IsInteger32(n); |
| 2094 int32_value_ = DoubleToInt32(n); | 2095 int32_value_ = DoubleToInt32(n); |
| 2096 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); |
| 2095 double_value_ = n; | 2097 double_value_ = n; |
| 2096 has_double_value_ = true; | 2098 has_double_value_ = true; |
| 2097 } else { | 2099 } else { |
| 2098 type_from_value_ = HType::TypeFromValue(handle_); | 2100 type_from_value_ = HType::TypeFromValue(handle_); |
| 2099 is_internalized_string_ = handle_->IsInternalizedString(); | 2101 is_internalized_string_ = handle_->IsInternalizedString(); |
| 2100 } | 2102 } |
| 2101 if (r.IsNone()) { | |
| 2102 if (has_int32_value_) { | |
| 2103 r = Representation::Integer32(); | |
| 2104 } else if (has_double_value_) { | |
| 2105 r = Representation::Double(); | |
| 2106 } else { | |
| 2107 r = Representation::Tagged(); | |
| 2108 } | |
| 2109 } | |
| 2110 Initialize(r); | 2103 Initialize(r); |
| 2111 } | 2104 } |
| 2112 | 2105 |
| 2113 | 2106 |
| 2114 HConstant::HConstant(Handle<Object> handle, | 2107 HConstant::HConstant(Handle<Object> handle, |
| 2115 UniqueValueId unique_id, | 2108 UniqueValueId unique_id, |
| 2116 Representation r, | 2109 Representation r, |
| 2117 HType type, | 2110 HType type, |
| 2118 bool is_internalize_string, | 2111 bool is_internalize_string, |
| 2119 bool is_not_in_new_space, | 2112 bool is_not_in_new_space, |
| 2120 bool boolean_value) | 2113 bool boolean_value) |
| 2121 : handle_(handle), | 2114 : handle_(handle), |
| 2122 unique_id_(unique_id), | 2115 unique_id_(unique_id), |
| 2116 has_smi_value_(false), |
| 2123 has_int32_value_(false), | 2117 has_int32_value_(false), |
| 2124 has_double_value_(false), | 2118 has_double_value_(false), |
| 2125 is_internalized_string_(is_internalize_string), | 2119 is_internalized_string_(is_internalize_string), |
| 2126 is_not_in_new_space_(is_not_in_new_space), | 2120 is_not_in_new_space_(is_not_in_new_space), |
| 2127 boolean_value_(boolean_value), | 2121 boolean_value_(boolean_value), |
| 2128 type_from_value_(type) { | 2122 type_from_value_(type) { |
| 2129 ASSERT(!handle.is_null()); | 2123 ASSERT(!handle.is_null()); |
| 2130 ASSERT(!type.IsUninitialized()); | 2124 ASSERT(!type.IsUninitialized()); |
| 2131 ASSERT(!type.IsTaggedNumber()); | 2125 ASSERT(!type.IsTaggedNumber()); |
| 2132 Initialize(r); | 2126 Initialize(r); |
| 2133 } | 2127 } |
| 2134 | 2128 |
| 2135 | 2129 |
| 2136 HConstant::HConstant(int32_t integer_value, | 2130 HConstant::HConstant(int32_t integer_value, |
| 2137 Representation r, | 2131 Representation r, |
| 2138 bool is_not_in_new_space, | 2132 bool is_not_in_new_space, |
| 2139 Handle<Object> optional_handle) | 2133 Handle<Object> optional_handle) |
| 2140 : handle_(optional_handle), | 2134 : handle_(optional_handle), |
| 2141 unique_id_(), | 2135 unique_id_(), |
| 2142 has_int32_value_(true), | 2136 has_int32_value_(true), |
| 2143 has_double_value_(true), | 2137 has_double_value_(true), |
| 2144 is_internalized_string_(false), | 2138 is_internalized_string_(false), |
| 2145 is_not_in_new_space_(is_not_in_new_space), | 2139 is_not_in_new_space_(is_not_in_new_space), |
| 2146 boolean_value_(integer_value != 0), | 2140 boolean_value_(integer_value != 0), |
| 2147 int32_value_(integer_value), | 2141 int32_value_(integer_value), |
| 2148 double_value_(FastI2D(integer_value)) { | 2142 double_value_(FastI2D(integer_value)) { |
| 2143 has_smi_value_ = Smi::IsValid(int32_value_); |
| 2149 Initialize(r); | 2144 Initialize(r); |
| 2150 } | 2145 } |
| 2151 | 2146 |
| 2152 | 2147 |
| 2153 HConstant::HConstant(double double_value, | 2148 HConstant::HConstant(double double_value, |
| 2154 Representation r, | 2149 Representation r, |
| 2155 bool is_not_in_new_space, | 2150 bool is_not_in_new_space, |
| 2156 Handle<Object> optional_handle) | 2151 Handle<Object> optional_handle) |
| 2157 : handle_(optional_handle), | 2152 : handle_(optional_handle), |
| 2158 unique_id_(), | 2153 unique_id_(), |
| 2159 has_int32_value_(IsInteger32(double_value)), | 2154 has_int32_value_(IsInteger32(double_value)), |
| 2160 has_double_value_(true), | 2155 has_double_value_(true), |
| 2161 is_internalized_string_(false), | 2156 is_internalized_string_(false), |
| 2162 is_not_in_new_space_(is_not_in_new_space), | 2157 is_not_in_new_space_(is_not_in_new_space), |
| 2163 boolean_value_(double_value != 0 && !std::isnan(double_value)), | 2158 boolean_value_(double_value != 0 && !std::isnan(double_value)), |
| 2164 int32_value_(DoubleToInt32(double_value)), | 2159 int32_value_(DoubleToInt32(double_value)), |
| 2165 double_value_(double_value) { | 2160 double_value_(double_value) { |
| 2161 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); |
| 2166 Initialize(r); | 2162 Initialize(r); |
| 2167 } | 2163 } |
| 2168 | 2164 |
| 2169 | 2165 |
| 2170 void HConstant::Initialize(Representation r) { | 2166 void HConstant::Initialize(Representation r) { |
| 2167 if (r.IsNone()) { |
| 2168 if (has_int32_value_) { |
| 2169 r = Representation::Integer32(); |
| 2170 } else if (has_double_value_) { |
| 2171 r = Representation::Double(); |
| 2172 } else { |
| 2173 r = Representation::Tagged(); |
| 2174 } |
| 2175 } |
| 2171 set_representation(r); | 2176 set_representation(r); |
| 2172 SetFlag(kUseGVN); | 2177 SetFlag(kUseGVN); |
| 2173 if (representation().IsInteger32()) { | 2178 if (representation().IsInteger32()) { |
| 2174 ClearGVNFlag(kDependsOnOsrEntries); | 2179 ClearGVNFlag(kDependsOnOsrEntries); |
| 2175 } | 2180 } |
| 2176 } | 2181 } |
| 2177 | 2182 |
| 2178 | 2183 |
| 2179 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { | 2184 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
| 2185 if (r.IsSmi() && !has_smi_value_) return NULL; |
| 2180 if (r.IsInteger32() && !has_int32_value_) return NULL; | 2186 if (r.IsInteger32() && !has_int32_value_) return NULL; |
| 2181 if (r.IsDouble() && !has_double_value_) return NULL; | 2187 if (r.IsDouble() && !has_double_value_) return NULL; |
| 2182 if (has_int32_value_) { | 2188 if (has_int32_value_) { |
| 2183 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_); | 2189 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_); |
| 2184 } | 2190 } |
| 2185 if (has_double_value_) { | 2191 if (has_double_value_) { |
| 2186 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_); | 2192 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_); |
| 2187 } | 2193 } |
| 2188 ASSERT(!handle_.is_null()); | 2194 ASSERT(!handle_.is_null()); |
| 2189 return new(zone) HConstant(handle_, | 2195 return new(zone) HConstant(handle_, |
| (...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3795 case kBackingStore: | 3801 case kBackingStore: |
| 3796 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 3802 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
| 3797 stream->Add("[backing-store]"); | 3803 stream->Add("[backing-store]"); |
| 3798 break; | 3804 break; |
| 3799 } | 3805 } |
| 3800 | 3806 |
| 3801 stream->Add("@%d", offset()); | 3807 stream->Add("@%d", offset()); |
| 3802 } | 3808 } |
| 3803 | 3809 |
| 3804 } } // namespace v8::internal | 3810 } } // namespace v8::internal |
| OLD | NEW |