| 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 2149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2160 | 2160 |
| 2161 | 2161 |
| 2162 HConstant::HConstant(Handle<Object> handle, Representation r) | 2162 HConstant::HConstant(Handle<Object> handle, Representation r) |
| 2163 : handle_(handle), | 2163 : handle_(handle), |
| 2164 unique_id_(), | 2164 unique_id_(), |
| 2165 has_smi_value_(false), | 2165 has_smi_value_(false), |
| 2166 has_int32_value_(false), | 2166 has_int32_value_(false), |
| 2167 has_double_value_(false), | 2167 has_double_value_(false), |
| 2168 is_internalized_string_(false), | 2168 is_internalized_string_(false), |
| 2169 is_not_in_new_space_(true), | 2169 is_not_in_new_space_(true), |
| 2170 is_cell_(false), |
| 2170 boolean_value_(handle->BooleanValue()) { | 2171 boolean_value_(handle->BooleanValue()) { |
| 2171 if (handle_->IsHeapObject()) { | 2172 if (handle_->IsHeapObject()) { |
| 2172 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); | 2173 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); |
| 2173 is_not_in_new_space_ = !heap->InNewSpace(*handle); | 2174 is_not_in_new_space_ = !heap->InNewSpace(*handle); |
| 2174 } | 2175 } |
| 2175 if (handle_->IsNumber()) { | 2176 if (handle_->IsNumber()) { |
| 2176 double n = handle_->Number(); | 2177 double n = handle_->Number(); |
| 2177 has_int32_value_ = IsInteger32(n); | 2178 has_int32_value_ = IsInteger32(n); |
| 2178 int32_value_ = DoubleToInt32(n); | 2179 int32_value_ = DoubleToInt32(n); |
| 2179 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); | 2180 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); |
| 2180 double_value_ = n; | 2181 double_value_ = n; |
| 2181 has_double_value_ = true; | 2182 has_double_value_ = true; |
| 2182 } else { | 2183 } else { |
| 2183 type_from_value_ = HType::TypeFromValue(handle_); | 2184 type_from_value_ = HType::TypeFromValue(handle_); |
| 2184 is_internalized_string_ = handle_->IsInternalizedString(); | 2185 is_internalized_string_ = handle_->IsInternalizedString(); |
| 2185 } | 2186 } |
| 2187 |
| 2188 is_cell_ = !handle_.is_null() && |
| 2189 (handle_->IsCell() || handle_->IsPropertyCell()); |
| 2186 Initialize(r); | 2190 Initialize(r); |
| 2187 } | 2191 } |
| 2188 | 2192 |
| 2189 | 2193 |
| 2190 HConstant::HConstant(Handle<Object> handle, | 2194 HConstant::HConstant(Handle<Object> handle, |
| 2191 UniqueValueId unique_id, | 2195 UniqueValueId unique_id, |
| 2192 Representation r, | 2196 Representation r, |
| 2193 HType type, | 2197 HType type, |
| 2194 bool is_internalize_string, | 2198 bool is_internalize_string, |
| 2195 bool is_not_in_new_space, | 2199 bool is_not_in_new_space, |
| 2196 bool boolean_value) | 2200 bool boolean_value) |
| 2197 : handle_(handle), | 2201 : handle_(handle), |
| 2198 unique_id_(unique_id), | 2202 unique_id_(unique_id), |
| 2199 has_smi_value_(false), | 2203 has_smi_value_(false), |
| 2200 has_int32_value_(false), | 2204 has_int32_value_(false), |
| 2201 has_double_value_(false), | 2205 has_double_value_(false), |
| 2202 is_internalized_string_(is_internalize_string), | 2206 is_internalized_string_(is_internalize_string), |
| 2203 is_not_in_new_space_(is_not_in_new_space), | 2207 is_not_in_new_space_(is_not_in_new_space), |
| 2208 is_cell_(false), |
| 2204 boolean_value_(boolean_value), | 2209 boolean_value_(boolean_value), |
| 2205 type_from_value_(type) { | 2210 type_from_value_(type) { |
| 2206 ASSERT(!handle.is_null()); | 2211 ASSERT(!handle.is_null()); |
| 2207 ASSERT(!type.IsUninitialized()); | 2212 ASSERT(!type.IsUninitialized()); |
| 2208 ASSERT(!type.IsTaggedNumber()); | 2213 ASSERT(!type.IsTaggedNumber()); |
| 2209 Initialize(r); | 2214 Initialize(r); |
| 2210 } | 2215 } |
| 2211 | 2216 |
| 2212 | 2217 |
| 2213 HConstant::HConstant(int32_t integer_value, | 2218 HConstant::HConstant(int32_t integer_value, |
| 2214 Representation r, | 2219 Representation r, |
| 2215 bool is_not_in_new_space, | 2220 bool is_not_in_new_space, |
| 2216 Handle<Object> optional_handle) | 2221 Handle<Object> optional_handle) |
| 2217 : handle_(optional_handle), | 2222 : handle_(optional_handle), |
| 2218 unique_id_(), | 2223 unique_id_(), |
| 2219 has_int32_value_(true), | 2224 has_int32_value_(true), |
| 2220 has_double_value_(true), | 2225 has_double_value_(true), |
| 2221 is_internalized_string_(false), | 2226 is_internalized_string_(false), |
| 2222 is_not_in_new_space_(is_not_in_new_space), | 2227 is_not_in_new_space_(is_not_in_new_space), |
| 2228 is_cell_(false), |
| 2223 boolean_value_(integer_value != 0), | 2229 boolean_value_(integer_value != 0), |
| 2224 int32_value_(integer_value), | 2230 int32_value_(integer_value), |
| 2225 double_value_(FastI2D(integer_value)) { | 2231 double_value_(FastI2D(integer_value)) { |
| 2226 has_smi_value_ = Smi::IsValid(int32_value_); | 2232 has_smi_value_ = Smi::IsValid(int32_value_); |
| 2227 Initialize(r); | 2233 Initialize(r); |
| 2228 } | 2234 } |
| 2229 | 2235 |
| 2230 | 2236 |
| 2231 HConstant::HConstant(double double_value, | 2237 HConstant::HConstant(double double_value, |
| 2232 Representation r, | 2238 Representation r, |
| 2233 bool is_not_in_new_space, | 2239 bool is_not_in_new_space, |
| 2234 Handle<Object> optional_handle) | 2240 Handle<Object> optional_handle) |
| 2235 : handle_(optional_handle), | 2241 : handle_(optional_handle), |
| 2236 unique_id_(), | 2242 unique_id_(), |
| 2237 has_int32_value_(IsInteger32(double_value)), | 2243 has_int32_value_(IsInteger32(double_value)), |
| 2238 has_double_value_(true), | 2244 has_double_value_(true), |
| 2239 is_internalized_string_(false), | 2245 is_internalized_string_(false), |
| 2240 is_not_in_new_space_(is_not_in_new_space), | 2246 is_not_in_new_space_(is_not_in_new_space), |
| 2247 is_cell_(false), |
| 2241 boolean_value_(double_value != 0 && !std::isnan(double_value)), | 2248 boolean_value_(double_value != 0 && !std::isnan(double_value)), |
| 2242 int32_value_(DoubleToInt32(double_value)), | 2249 int32_value_(DoubleToInt32(double_value)), |
| 2243 double_value_(double_value) { | 2250 double_value_(double_value) { |
| 2244 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); | 2251 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); |
| 2245 Initialize(r); | 2252 Initialize(r); |
| 2246 } | 2253 } |
| 2247 | 2254 |
| 2248 | 2255 |
| 2249 void HConstant::Initialize(Representation r) { | 2256 void HConstant::Initialize(Representation r) { |
| 2250 if (r.IsNone()) { | 2257 if (r.IsNone()) { |
| 2251 if (has_smi_value_) { | 2258 if (has_smi_value_) { |
| 2252 r = Representation::Smi(); | 2259 r = Representation::Smi(); |
| 2253 } else if (has_int32_value_) { | 2260 } else if (has_int32_value_) { |
| 2254 r = Representation::Integer32(); | 2261 r = Representation::Integer32(); |
| 2255 } else if (has_double_value_) { | 2262 } else if (has_double_value_) { |
| 2256 r = Representation::Double(); | 2263 r = Representation::Double(); |
| 2257 } else { | 2264 } else { |
| 2258 r = Representation::Tagged(); | 2265 r = Representation::Tagged(); |
| 2259 } | 2266 } |
| 2260 } | 2267 } |
| 2261 set_representation(r); | 2268 set_representation(r); |
| 2262 SetFlag(kUseGVN); | 2269 SetFlag(kUseGVN); |
| 2263 if (representation().IsInteger32()) { | 2270 if (representation().IsInteger32()) { |
| 2264 ClearGVNFlag(kDependsOnOsrEntries); | 2271 ClearGVNFlag(kDependsOnOsrEntries); |
| 2265 } | 2272 } |
| 2266 } | 2273 } |
| 2267 | 2274 |
| 2268 | 2275 |
| 2276 bool HConstant::EmitAtUses() { |
| 2277 ASSERT(IsLinked()); |
| 2278 if (block()->graph()->has_osr_loop_entry()) return true; |
| 2279 if (representation().IsDouble()) return false; |
| 2280 if (representation().IsTagged() && UseCount() > 1) { |
| 2281 return false; |
| 2282 } |
| 2283 return true; |
| 2284 } |
| 2285 |
| 2286 |
| 2269 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { | 2287 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
| 2270 if (r.IsSmi() && !has_smi_value_) return NULL; | 2288 if (r.IsSmi() && !has_smi_value_) return NULL; |
| 2271 if (r.IsInteger32() && !has_int32_value_) return NULL; | 2289 if (r.IsInteger32() && !has_int32_value_) return NULL; |
| 2272 if (r.IsDouble() && !has_double_value_) return NULL; | 2290 if (r.IsDouble() && !has_double_value_) return NULL; |
| 2273 if (has_int32_value_) { | 2291 if (has_int32_value_) { |
| 2274 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_); | 2292 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_); |
| 2275 } | 2293 } |
| 2276 if (has_double_value_) { | 2294 if (has_double_value_) { |
| 2277 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_); | 2295 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_); |
| 2278 } | 2296 } |
| (...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3810 int offset = (index * kPointerSize) + map->instance_size(); | 3828 int offset = (index * kPointerSize) + map->instance_size(); |
| 3811 return HObjectAccess(kInobject, offset); | 3829 return HObjectAccess(kInobject, offset); |
| 3812 } else { | 3830 } else { |
| 3813 // Non-negative property indices are in the properties array. | 3831 // Non-negative property indices are in the properties array. |
| 3814 int offset = (index * kPointerSize) + FixedArray::kHeaderSize; | 3832 int offset = (index * kPointerSize) + FixedArray::kHeaderSize; |
| 3815 return HObjectAccess(kBackingStore, offset, name); | 3833 return HObjectAccess(kBackingStore, offset, name); |
| 3816 } | 3834 } |
| 3817 } | 3835 } |
| 3818 | 3836 |
| 3819 | 3837 |
| 3838 HObjectAccess HObjectAccess::ForCellPayload(Isolate* isolate) { |
| 3839 return HObjectAccess( |
| 3840 kInobject, Cell::kValueOffset, |
| 3841 Handle<String>(isolate->heap()->cell_value_string())); |
| 3842 } |
| 3843 |
| 3844 |
| 3820 void HObjectAccess::SetGVNFlags(HValue *instr, bool is_store) { | 3845 void HObjectAccess::SetGVNFlags(HValue *instr, bool is_store) { |
| 3821 // set the appropriate GVN flags for a given load or store instruction | 3846 // set the appropriate GVN flags for a given load or store instruction |
| 3822 if (is_store) { | 3847 if (is_store) { |
| 3823 // track dominating allocations in order to eliminate write barriers | 3848 // track dominating allocations in order to eliminate write barriers |
| 3824 instr->SetGVNFlag(kDependsOnNewSpacePromotion); | 3849 instr->SetGVNFlag(kDependsOnNewSpacePromotion); |
| 3825 instr->SetFlag(HValue::kTrackSideEffectDominators); | 3850 instr->SetFlag(HValue::kTrackSideEffectDominators); |
| 3826 } else { | 3851 } else { |
| 3827 // try to GVN loads, but don't hoist above map changes | 3852 // try to GVN loads, but don't hoist above map changes |
| 3828 instr->SetFlag(HValue::kUseGVN); | 3853 instr->SetFlag(HValue::kUseGVN); |
| 3829 instr->SetGVNFlag(kDependsOnMaps); | 3854 instr->SetGVNFlag(kDependsOnMaps); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3879 case kBackingStore: | 3904 case kBackingStore: |
| 3880 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 3905 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
| 3881 stream->Add("[backing-store]"); | 3906 stream->Add("[backing-store]"); |
| 3882 break; | 3907 break; |
| 3883 } | 3908 } |
| 3884 | 3909 |
| 3885 stream->Add("@%d", offset()); | 3910 stream->Add("@%d", offset()); |
| 3886 } | 3911 } |
| 3887 | 3912 |
| 3888 } } // namespace v8::internal | 3913 } } // namespace v8::internal |
| OLD | NEW |