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