Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: src/hydrogen-instructions.cc

Issue 16925008: Generate StoreGlobal stubs with Hydrogen (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address feedback Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 2157 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 2168
2169 2169
2170 HConstant::HConstant(Handle<Object> handle, Representation r) 2170 HConstant::HConstant(Handle<Object> handle, Representation r)
2171 : handle_(handle), 2171 : handle_(handle),
2172 unique_id_(), 2172 unique_id_(),
2173 has_smi_value_(false), 2173 has_smi_value_(false),
2174 has_int32_value_(false), 2174 has_int32_value_(false),
2175 has_double_value_(false), 2175 has_double_value_(false),
2176 is_internalized_string_(false), 2176 is_internalized_string_(false),
2177 is_not_in_new_space_(true), 2177 is_not_in_new_space_(true),
2178 is_cell_(false),
2178 boolean_value_(handle->BooleanValue()) { 2179 boolean_value_(handle->BooleanValue()) {
2179 if (handle_->IsHeapObject()) { 2180 if (handle_->IsHeapObject()) {
2180 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); 2181 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap();
2181 is_not_in_new_space_ = !heap->InNewSpace(*handle); 2182 is_not_in_new_space_ = !heap->InNewSpace(*handle);
2182 } 2183 }
2183 if (handle_->IsNumber()) { 2184 if (handle_->IsNumber()) {
2184 double n = handle_->Number(); 2185 double n = handle_->Number();
2185 has_int32_value_ = IsInteger32(n); 2186 has_int32_value_ = IsInteger32(n);
2186 int32_value_ = DoubleToInt32(n); 2187 int32_value_ = DoubleToInt32(n);
2187 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); 2188 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_);
2188 double_value_ = n; 2189 double_value_ = n;
2189 has_double_value_ = true; 2190 has_double_value_ = true;
2190 } else { 2191 } else {
2191 type_from_value_ = HType::TypeFromValue(handle_); 2192 type_from_value_ = HType::TypeFromValue(handle_);
2192 is_internalized_string_ = handle_->IsInternalizedString(); 2193 is_internalized_string_ = handle_->IsInternalizedString();
2193 } 2194 }
2195
2196 is_cell_ = !handle_.is_null() &&
2197 (handle_->IsCell() || handle_->IsPropertyCell());
2194 Initialize(r); 2198 Initialize(r);
2195 } 2199 }
2196 2200
2197 2201
2198 HConstant::HConstant(Handle<Object> handle, 2202 HConstant::HConstant(Handle<Object> handle,
2199 UniqueValueId unique_id, 2203 UniqueValueId unique_id,
2200 Representation r, 2204 Representation r,
2201 HType type, 2205 HType type,
2202 bool is_internalize_string, 2206 bool is_internalize_string,
2203 bool is_not_in_new_space, 2207 bool is_not_in_new_space,
2208 bool is_cell,
2204 bool boolean_value) 2209 bool boolean_value)
2205 : handle_(handle), 2210 : handle_(handle),
2206 unique_id_(unique_id), 2211 unique_id_(unique_id),
2207 has_smi_value_(false), 2212 has_smi_value_(false),
2208 has_int32_value_(false), 2213 has_int32_value_(false),
2209 has_double_value_(false), 2214 has_double_value_(false),
2210 is_internalized_string_(is_internalize_string), 2215 is_internalized_string_(is_internalize_string),
2211 is_not_in_new_space_(is_not_in_new_space), 2216 is_not_in_new_space_(is_not_in_new_space),
2217 is_cell_(is_cell),
2212 boolean_value_(boolean_value), 2218 boolean_value_(boolean_value),
2213 type_from_value_(type) { 2219 type_from_value_(type) {
2214 ASSERT(!handle.is_null()); 2220 ASSERT(!handle.is_null());
2215 ASSERT(!type.IsUninitialized()); 2221 ASSERT(!type.IsUninitialized());
2216 ASSERT(!type.IsTaggedNumber()); 2222 ASSERT(!type.IsTaggedNumber());
2217 Initialize(r); 2223 Initialize(r);
2218 } 2224 }
2219 2225
2220 2226
2221 HConstant::HConstant(int32_t integer_value, 2227 HConstant::HConstant(int32_t integer_value,
2222 Representation r, 2228 Representation r,
2223 bool is_not_in_new_space, 2229 bool is_not_in_new_space,
2224 Handle<Object> optional_handle) 2230 Handle<Object> optional_handle)
2225 : handle_(optional_handle), 2231 : handle_(optional_handle),
2226 unique_id_(), 2232 unique_id_(),
2227 has_int32_value_(true), 2233 has_int32_value_(true),
2228 has_double_value_(true), 2234 has_double_value_(true),
2229 is_internalized_string_(false), 2235 is_internalized_string_(false),
2230 is_not_in_new_space_(is_not_in_new_space), 2236 is_not_in_new_space_(is_not_in_new_space),
2237 is_cell_(false),
2231 boolean_value_(integer_value != 0), 2238 boolean_value_(integer_value != 0),
2232 int32_value_(integer_value), 2239 int32_value_(integer_value),
2233 double_value_(FastI2D(integer_value)) { 2240 double_value_(FastI2D(integer_value)) {
2234 has_smi_value_ = Smi::IsValid(int32_value_); 2241 has_smi_value_ = Smi::IsValid(int32_value_);
2235 Initialize(r); 2242 Initialize(r);
2236 } 2243 }
2237 2244
2238 2245
2239 HConstant::HConstant(double double_value, 2246 HConstant::HConstant(double double_value,
2240 Representation r, 2247 Representation r,
2241 bool is_not_in_new_space, 2248 bool is_not_in_new_space,
2242 Handle<Object> optional_handle) 2249 Handle<Object> optional_handle)
2243 : handle_(optional_handle), 2250 : handle_(optional_handle),
2244 unique_id_(), 2251 unique_id_(),
2245 has_int32_value_(IsInteger32(double_value)), 2252 has_int32_value_(IsInteger32(double_value)),
2246 has_double_value_(true), 2253 has_double_value_(true),
2247 is_internalized_string_(false), 2254 is_internalized_string_(false),
2248 is_not_in_new_space_(is_not_in_new_space), 2255 is_not_in_new_space_(is_not_in_new_space),
2256 is_cell_(false),
2249 boolean_value_(double_value != 0 && !std::isnan(double_value)), 2257 boolean_value_(double_value != 0 && !std::isnan(double_value)),
2250 int32_value_(DoubleToInt32(double_value)), 2258 int32_value_(DoubleToInt32(double_value)),
2251 double_value_(double_value) { 2259 double_value_(double_value) {
2252 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); 2260 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_);
2253 Initialize(r); 2261 Initialize(r);
2254 } 2262 }
2255 2263
2256 2264
2257 void HConstant::Initialize(Representation r) { 2265 void HConstant::Initialize(Representation r) {
2258 if (r.IsNone()) { 2266 if (r.IsNone()) {
2259 if (has_smi_value_) { 2267 if (has_smi_value_) {
2260 r = Representation::Smi(); 2268 r = Representation::Smi();
2261 } else if (has_int32_value_) { 2269 } else if (has_int32_value_) {
2262 r = Representation::Integer32(); 2270 r = Representation::Integer32();
2263 } else if (has_double_value_) { 2271 } else if (has_double_value_) {
2264 r = Representation::Double(); 2272 r = Representation::Double();
2265 } else { 2273 } else {
2266 r = Representation::Tagged(); 2274 r = Representation::Tagged();
2267 } 2275 }
2268 } 2276 }
2269 set_representation(r); 2277 set_representation(r);
2270 SetFlag(kUseGVN); 2278 SetFlag(kUseGVN);
2271 if (representation().IsInteger32()) {
2272 ClearGVNFlag(kDependsOnOsrEntries);
2273 }
2274 } 2279 }
2275 2280
2276 2281
2282 bool HConstant::EmitAtUses() {
2283 ASSERT(IsLinked());
2284 if (block()->graph()->has_osr()) {
2285 return block()->graph()->IsStandardConstant(this);
2286 }
2287 if (IsCell()) return false;
2288 if (representation().IsDouble()) return false;
2289 return true;
2290 }
2291
2292
2277 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { 2293 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const {
2278 if (r.IsSmi() && !has_smi_value_) return NULL; 2294 if (r.IsSmi() && !has_smi_value_) return NULL;
2279 if (r.IsInteger32() && !has_int32_value_) return NULL; 2295 if (r.IsInteger32() && !has_int32_value_) return NULL;
2280 if (r.IsDouble() && !has_double_value_) return NULL; 2296 if (r.IsDouble() && !has_double_value_) return NULL;
2281 if (has_int32_value_) { 2297 if (has_int32_value_) {
2282 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_); 2298 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_);
2283 } 2299 }
2284 if (has_double_value_) { 2300 if (has_double_value_) {
2285 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_); 2301 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_);
2286 } 2302 }
2287 ASSERT(!handle_.is_null()); 2303 ASSERT(!handle_.is_null());
2288 return new(zone) HConstant(handle_, 2304 return new(zone) HConstant(handle_,
2289 unique_id_, 2305 unique_id_,
2290 r, 2306 r,
2291 type_from_value_, 2307 type_from_value_,
2292 is_internalized_string_, 2308 is_internalized_string_,
2293 is_not_in_new_space_, 2309 is_not_in_new_space_,
2310 is_cell_,
2294 boolean_value_); 2311 boolean_value_);
2295 } 2312 }
2296 2313
2297 2314
2298 HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) const { 2315 HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) const {
2299 if (has_int32_value_) { 2316 if (has_int32_value_) {
2300 return new(zone) HConstant(int32_value_, 2317 return new(zone) HConstant(int32_value_,
2301 Representation::Integer32(), 2318 Representation::Integer32(),
2302 is_not_in_new_space_, 2319 is_not_in_new_space_,
2303 handle_); 2320 handle_);
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after
3823 int offset = (index * kPointerSize) + map->instance_size(); 3840 int offset = (index * kPointerSize) + map->instance_size();
3824 return HObjectAccess(kInobject, offset); 3841 return HObjectAccess(kInobject, offset);
3825 } else { 3842 } else {
3826 // Non-negative property indices are in the properties array. 3843 // Non-negative property indices are in the properties array.
3827 int offset = (index * kPointerSize) + FixedArray::kHeaderSize; 3844 int offset = (index * kPointerSize) + FixedArray::kHeaderSize;
3828 return HObjectAccess(kBackingStore, offset, name); 3845 return HObjectAccess(kBackingStore, offset, name);
3829 } 3846 }
3830 } 3847 }
3831 3848
3832 3849
3850 HObjectAccess HObjectAccess::ForCellPayload(Isolate* isolate) {
3851 return HObjectAccess(
3852 kInobject, Cell::kValueOffset,
3853 Handle<String>(isolate->heap()->cell_value_string()));
3854 }
3855
3856
3833 void HObjectAccess::SetGVNFlags(HValue *instr, bool is_store) { 3857 void HObjectAccess::SetGVNFlags(HValue *instr, bool is_store) {
3834 // set the appropriate GVN flags for a given load or store instruction 3858 // set the appropriate GVN flags for a given load or store instruction
3835 if (is_store) { 3859 if (is_store) {
3836 // track dominating allocations in order to eliminate write barriers 3860 // track dominating allocations in order to eliminate write barriers
3837 instr->SetGVNFlag(kDependsOnNewSpacePromotion); 3861 instr->SetGVNFlag(kDependsOnNewSpacePromotion);
3838 instr->SetFlag(HValue::kTrackSideEffectDominators); 3862 instr->SetFlag(HValue::kTrackSideEffectDominators);
3839 } else { 3863 } else {
3840 // try to GVN loads, but don't hoist above map changes 3864 // try to GVN loads, but don't hoist above map changes
3841 instr->SetFlag(HValue::kUseGVN); 3865 instr->SetFlag(HValue::kUseGVN);
3842 instr->SetGVNFlag(kDependsOnMaps); 3866 instr->SetGVNFlag(kDependsOnMaps);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3892 case kBackingStore: 3916 case kBackingStore:
3893 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); 3917 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString());
3894 stream->Add("[backing-store]"); 3918 stream->Add("[backing-store]");
3895 break; 3919 break;
3896 } 3920 }
3897 3921
3898 stream->Add("@%d", offset()); 3922 stream->Add("@%d", offset());
3899 } 3923 }
3900 3924
3901 } } // namespace v8::internal 3925 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698