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

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: Finish code dependencies Created 7 years, 6 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 2135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2146 2146
2147 2147
2148 HConstant::HConstant(Handle<Object> handle, Representation r) 2148 HConstant::HConstant(Handle<Object> handle, Representation r)
2149 : handle_(handle), 2149 : handle_(handle),
2150 unique_id_(), 2150 unique_id_(),
2151 has_smi_value_(false), 2151 has_smi_value_(false),
2152 has_int32_value_(false), 2152 has_int32_value_(false),
2153 has_double_value_(false), 2153 has_double_value_(false),
2154 is_internalized_string_(false), 2154 is_internalized_string_(false),
2155 is_not_in_new_space_(true), 2155 is_not_in_new_space_(true),
2156 is_cell_(false),
2156 boolean_value_(handle->BooleanValue()) { 2157 boolean_value_(handle->BooleanValue()) {
2157 if (handle_->IsHeapObject()) { 2158 if (handle_->IsHeapObject()) {
2158 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); 2159 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap();
2159 is_not_in_new_space_ = !heap->InNewSpace(*handle); 2160 is_not_in_new_space_ = !heap->InNewSpace(*handle);
2160 } 2161 }
2161 if (handle_->IsNumber()) { 2162 if (handle_->IsNumber()) {
2162 double n = handle_->Number(); 2163 double n = handle_->Number();
2163 has_int32_value_ = IsInteger32(n); 2164 has_int32_value_ = IsInteger32(n);
2164 int32_value_ = DoubleToInt32(n); 2165 int32_value_ = DoubleToInt32(n);
2165 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); 2166 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_);
2166 double_value_ = n; 2167 double_value_ = n;
2167 has_double_value_ = true; 2168 has_double_value_ = true;
2168 } else { 2169 } else {
2169 type_from_value_ = HType::TypeFromValue(handle_); 2170 type_from_value_ = HType::TypeFromValue(handle_);
2170 is_internalized_string_ = handle_->IsInternalizedString(); 2171 is_internalized_string_ = handle_->IsInternalizedString();
2171 } 2172 }
2173
2174 is_cell_ = !handle_.is_null() &&
2175 (handle_->IsCell() || handle_->IsPropertyCell());
2172 Initialize(r); 2176 Initialize(r);
2173 } 2177 }
2174 2178
2175 2179
2176 HConstant::HConstant(Handle<Object> handle, 2180 HConstant::HConstant(Handle<Object> handle,
2177 UniqueValueId unique_id, 2181 UniqueValueId unique_id,
2178 Representation r, 2182 Representation r,
2179 HType type, 2183 HType type,
2180 bool is_internalize_string, 2184 bool is_internalize_string,
2181 bool is_not_in_new_space, 2185 bool is_not_in_new_space,
2182 bool boolean_value) 2186 bool boolean_value)
2183 : handle_(handle), 2187 : handle_(handle),
2184 unique_id_(unique_id), 2188 unique_id_(unique_id),
2185 has_smi_value_(false), 2189 has_smi_value_(false),
2186 has_int32_value_(false), 2190 has_int32_value_(false),
2187 has_double_value_(false), 2191 has_double_value_(false),
2188 is_internalized_string_(is_internalize_string), 2192 is_internalized_string_(is_internalize_string),
2189 is_not_in_new_space_(is_not_in_new_space), 2193 is_not_in_new_space_(is_not_in_new_space),
2194 is_cell_(false),
2190 boolean_value_(boolean_value), 2195 boolean_value_(boolean_value),
2191 type_from_value_(type) { 2196 type_from_value_(type) {
2192 ASSERT(!handle.is_null()); 2197 ASSERT(!handle.is_null());
2193 ASSERT(!type.IsUninitialized()); 2198 ASSERT(!type.IsUninitialized());
2194 ASSERT(!type.IsTaggedNumber()); 2199 ASSERT(!type.IsTaggedNumber());
2195 Initialize(r); 2200 Initialize(r);
2196 } 2201 }
2197 2202
2198 2203
2199 HConstant::HConstant(int32_t integer_value, 2204 HConstant::HConstant(int32_t integer_value,
2200 Representation r, 2205 Representation r,
2201 bool is_not_in_new_space, 2206 bool is_not_in_new_space,
2202 Handle<Object> optional_handle) 2207 Handle<Object> optional_handle)
2203 : handle_(optional_handle), 2208 : handle_(optional_handle),
2204 unique_id_(), 2209 unique_id_(),
2205 has_int32_value_(true), 2210 has_int32_value_(true),
2206 has_double_value_(true), 2211 has_double_value_(true),
2207 is_internalized_string_(false), 2212 is_internalized_string_(false),
2208 is_not_in_new_space_(is_not_in_new_space), 2213 is_not_in_new_space_(is_not_in_new_space),
2214 is_cell_(false),
2209 boolean_value_(integer_value != 0), 2215 boolean_value_(integer_value != 0),
2210 int32_value_(integer_value), 2216 int32_value_(integer_value),
2211 double_value_(FastI2D(integer_value)) { 2217 double_value_(FastI2D(integer_value)) {
2212 has_smi_value_ = Smi::IsValid(int32_value_); 2218 has_smi_value_ = Smi::IsValid(int32_value_);
2213 Initialize(r); 2219 Initialize(r);
2214 } 2220 }
2215 2221
2216 2222
2217 HConstant::HConstant(double double_value, 2223 HConstant::HConstant(double double_value,
2218 Representation r, 2224 Representation r,
2219 bool is_not_in_new_space, 2225 bool is_not_in_new_space,
2220 Handle<Object> optional_handle) 2226 Handle<Object> optional_handle)
2221 : handle_(optional_handle), 2227 : handle_(optional_handle),
2222 unique_id_(), 2228 unique_id_(),
2223 has_int32_value_(IsInteger32(double_value)), 2229 has_int32_value_(IsInteger32(double_value)),
2224 has_double_value_(true), 2230 has_double_value_(true),
2225 is_internalized_string_(false), 2231 is_internalized_string_(false),
2226 is_not_in_new_space_(is_not_in_new_space), 2232 is_not_in_new_space_(is_not_in_new_space),
2233 is_cell_(false),
2227 boolean_value_(double_value != 0 && !std::isnan(double_value)), 2234 boolean_value_(double_value != 0 && !std::isnan(double_value)),
2228 int32_value_(DoubleToInt32(double_value)), 2235 int32_value_(DoubleToInt32(double_value)),
2229 double_value_(double_value) { 2236 double_value_(double_value) {
2230 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); 2237 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_);
2231 Initialize(r); 2238 Initialize(r);
2232 } 2239 }
2233 2240
2234 2241
2235 void HConstant::Initialize(Representation r) { 2242 void HConstant::Initialize(Representation r) {
2236 if (r.IsNone()) { 2243 if (r.IsNone()) {
2237 if (has_smi_value_) { 2244 if (has_smi_value_) {
2238 r = Representation::Smi(); 2245 r = Representation::Smi();
2239 } else if (has_int32_value_) { 2246 } else if (has_int32_value_) {
2240 r = Representation::Integer32(); 2247 r = Representation::Integer32();
2241 } else if (has_double_value_) { 2248 } else if (has_double_value_) {
2242 r = Representation::Double(); 2249 r = Representation::Double();
2243 } else { 2250 } else {
2244 r = Representation::Tagged(); 2251 r = Representation::Tagged();
2245 } 2252 }
2246 } 2253 }
2247 set_representation(r); 2254 set_representation(r);
2248 SetFlag(kUseGVN); 2255 SetFlag(kUseGVN);
2249 if (representation().IsInteger32()) { 2256 if (representation().IsInteger32()) {
2250 ClearGVNFlag(kDependsOnOsrEntries); 2257 ClearGVNFlag(kDependsOnOsrEntries);
2251 } 2258 }
2252 } 2259 }
2253 2260
2254 2261
2262 bool HConstant::EmitAtUses() {
2263 ASSERT(IsLinked());
2264 if (block()->graph()->has_osr_loop_entry()) return true;
2265 if (representation().IsDouble()) return false;
2266 if (representation().IsTagged() && UseCount() > 1) {
2267 return false;
2268 }
2269 return true;
2270 }
2271
2272
2255 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { 2273 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const {
2256 if (r.IsSmi() && !has_smi_value_) return NULL; 2274 if (r.IsSmi() && !has_smi_value_) return NULL;
2257 if (r.IsInteger32() && !has_int32_value_) return NULL; 2275 if (r.IsInteger32() && !has_int32_value_) return NULL;
2258 if (r.IsDouble() && !has_double_value_) return NULL; 2276 if (r.IsDouble() && !has_double_value_) return NULL;
2259 if (has_int32_value_) { 2277 if (has_int32_value_) {
2260 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_); 2278 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_);
2261 } 2279 }
2262 if (has_double_value_) { 2280 if (has_double_value_) {
2263 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_); 2281 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_);
2264 } 2282 }
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after
3797 int offset = (index * kPointerSize) + map->instance_size(); 3815 int offset = (index * kPointerSize) + map->instance_size();
3798 return HObjectAccess(kInobject, offset); 3816 return HObjectAccess(kInobject, offset);
3799 } else { 3817 } else {
3800 // Non-negative property indices are in the properties array. 3818 // Non-negative property indices are in the properties array.
3801 int offset = (index * kPointerSize) + FixedArray::kHeaderSize; 3819 int offset = (index * kPointerSize) + FixedArray::kHeaderSize;
3802 return HObjectAccess(kBackingStore, offset, name); 3820 return HObjectAccess(kBackingStore, offset, name);
3803 } 3821 }
3804 } 3822 }
3805 3823
3806 3824
3825 HObjectAccess HObjectAccess::ForCellPayload(Isolate* isolate) {
3826 return HObjectAccess(
3827 kInobject, Cell::kValueOffset,
3828 Handle<String>(isolate->heap()->cell_value_string()));
3829 }
3830
3831
3807 void HObjectAccess::SetGVNFlags(HValue *instr, bool is_store) { 3832 void HObjectAccess::SetGVNFlags(HValue *instr, bool is_store) {
3808 // set the appropriate GVN flags for a given load or store instruction 3833 // set the appropriate GVN flags for a given load or store instruction
3809 if (is_store) { 3834 if (is_store) {
3810 // track dominating allocations in order to eliminate write barriers 3835 // track dominating allocations in order to eliminate write barriers
3811 instr->SetGVNFlag(kDependsOnNewSpacePromotion); 3836 instr->SetGVNFlag(kDependsOnNewSpacePromotion);
3812 instr->SetFlag(HValue::kTrackSideEffectDominators); 3837 instr->SetFlag(HValue::kTrackSideEffectDominators);
3813 } else { 3838 } else {
3814 // try to GVN loads, but don't hoist above map changes 3839 // try to GVN loads, but don't hoist above map changes
3815 instr->SetFlag(HValue::kUseGVN); 3840 instr->SetFlag(HValue::kUseGVN);
3816 instr->SetGVNFlag(kDependsOnMaps); 3841 instr->SetGVNFlag(kDependsOnMaps);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3866 case kBackingStore: 3891 case kBackingStore:
3867 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); 3892 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString());
3868 stream->Add("[backing-store]"); 3893 stream->Add("[backing-store]");
3869 break; 3894 break;
3870 } 3895 }
3871 3896
3872 stream->Add("@%d", offset()); 3897 stream->Add("@%d", offset());
3873 } 3898 }
3874 3899
3875 } } // namespace v8::internal 3900 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | src/types.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698