OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
8 #include "src/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
9 #include "src/lookup.h" | 9 #include "src/lookup.h" |
10 #include "src/lookup-inl.h" | 10 #include "src/lookup-inl.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 ReloadPropertyInformation(); | 95 ReloadPropertyInformation(); |
96 } | 96 } |
97 | 97 |
98 | 98 |
99 void LookupIterator::ReconfigureDataProperty(Handle<Object> value, | 99 void LookupIterator::ReconfigureDataProperty(Handle<Object> value, |
100 PropertyAttributes attributes) { | 100 PropertyAttributes attributes) { |
101 DCHECK(state_ == DATA || state_ == ACCESSOR); | 101 DCHECK(state_ == DATA || state_ == ACCESSOR); |
102 DCHECK(HolderIsReceiverOrHiddenPrototype()); | 102 DCHECK(HolderIsReceiverOrHiddenPrototype()); |
103 Handle<JSObject> holder = GetHolder<JSObject>(); | 103 Handle<JSObject> holder = GetHolder<JSObject>(); |
104 if (holder_map_->is_dictionary_map()) { | 104 if (holder_map_->is_dictionary_map()) { |
105 PropertyDetails details(attributes, FIELD, 0); | 105 PropertyDetails details(attributes, DATA_FIELD, 0); |
106 JSObject::SetNormalizedProperty(holder, name(), value, details); | 106 JSObject::SetNormalizedProperty(holder, name(), value, details); |
107 } else { | 107 } else { |
108 holder_map_ = Map::ReconfigureDataProperty(holder_map_, descriptor_number(), | 108 holder_map_ = Map::ReconfigureDataProperty(holder_map_, descriptor_number(), |
109 attributes); | 109 attributes); |
110 JSObject::MigrateToMap(holder, holder_map_); | 110 JSObject::MigrateToMap(holder, holder_map_); |
111 } | 111 } |
112 | 112 |
113 ReloadPropertyInformation(); | 113 ReloadPropertyInformation(); |
114 } | 114 } |
115 | 115 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 if (!holder_map_->is_dictionary_map()) return; | 167 if (!holder_map_->is_dictionary_map()) return; |
168 | 168 |
169 // We have to deoptimize since accesses to data properties may have been | 169 // We have to deoptimize since accesses to data properties may have been |
170 // inlined without a corresponding map-check. | 170 // inlined without a corresponding map-check. |
171 if (holder_map_->IsGlobalObjectMap()) { | 171 if (holder_map_->IsGlobalObjectMap()) { |
172 Deoptimizer::DeoptimizeGlobalObject(*receiver); | 172 Deoptimizer::DeoptimizeGlobalObject(*receiver); |
173 } | 173 } |
174 | 174 |
175 // Install the accessor into the dictionary-mode object. | 175 // Install the accessor into the dictionary-mode object. |
176 PropertyDetails details(attributes, CALLBACKS, 0); | 176 PropertyDetails details(attributes, ACCESSOR_CONSTANT, 0); |
177 Handle<AccessorPair> pair; | 177 Handle<AccessorPair> pair; |
178 if (state() == ACCESSOR && GetAccessors()->IsAccessorPair()) { | 178 if (state() == ACCESSOR && GetAccessors()->IsAccessorPair()) { |
179 pair = Handle<AccessorPair>::cast(GetAccessors()); | 179 pair = Handle<AccessorPair>::cast(GetAccessors()); |
180 // If the component and attributes are identical, nothing has to be done. | 180 // If the component and attributes are identical, nothing has to be done. |
181 if (pair->get(component) == *accessor) { | 181 if (pair->get(component) == *accessor) { |
182 if (property_details().attributes() == attributes) return; | 182 if (property_details().attributes() == attributes) return; |
183 } else { | 183 } else { |
184 pair = AccessorPair::Copy(pair); | 184 pair = AccessorPair::Copy(pair); |
185 pair->set(component, *accessor); | 185 pair->set(component, *accessor); |
186 } | 186 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 | 221 |
222 Handle<Object> LookupIterator::FetchValue() const { | 222 Handle<Object> LookupIterator::FetchValue() const { |
223 Object* result = NULL; | 223 Object* result = NULL; |
224 Handle<JSObject> holder = GetHolder<JSObject>(); | 224 Handle<JSObject> holder = GetHolder<JSObject>(); |
225 if (holder_map_->is_dictionary_map()) { | 225 if (holder_map_->is_dictionary_map()) { |
226 result = holder->property_dictionary()->ValueAt(number_); | 226 result = holder->property_dictionary()->ValueAt(number_); |
227 if (holder_map_->IsGlobalObjectMap()) { | 227 if (holder_map_->IsGlobalObjectMap()) { |
228 result = PropertyCell::cast(result)->value(); | 228 result = PropertyCell::cast(result)->value(); |
229 } | 229 } |
230 } else if (property_details_.type() == v8::internal::FIELD) { | 230 } else if (property_details_.type() == v8::internal::DATA_FIELD) { |
231 FieldIndex field_index = FieldIndex::ForDescriptor(*holder_map_, number_); | 231 FieldIndex field_index = FieldIndex::ForDescriptor(*holder_map_, number_); |
232 return JSObject::FastPropertyAt(holder, property_details_.representation(), | 232 return JSObject::FastPropertyAt(holder, property_details_.representation(), |
233 field_index); | 233 field_index); |
234 } else { | 234 } else { |
235 result = holder_map_->instance_descriptors()->GetValue(number_); | 235 result = holder_map_->instance_descriptors()->GetValue(number_); |
236 } | 236 } |
237 return handle(result, isolate_); | 237 return handle(result, isolate_); |
238 } | 238 } |
239 | 239 |
240 | 240 |
241 int LookupIterator::GetConstantIndex() const { | 241 int LookupIterator::GetConstantIndex() const { |
242 DCHECK(has_property_); | 242 DCHECK(has_property_); |
243 DCHECK(!holder_map_->is_dictionary_map()); | 243 DCHECK(!holder_map_->is_dictionary_map()); |
244 DCHECK_EQ(v8::internal::CONSTANT, property_details_.type()); | 244 DCHECK_EQ(v8::internal::DATA_CONSTANT, property_details_.type()); |
245 return descriptor_number(); | 245 return descriptor_number(); |
246 } | 246 } |
247 | 247 |
248 | 248 |
249 FieldIndex LookupIterator::GetFieldIndex() const { | 249 FieldIndex LookupIterator::GetFieldIndex() const { |
250 DCHECK(has_property_); | 250 DCHECK(has_property_); |
251 DCHECK(!holder_map_->is_dictionary_map()); | 251 DCHECK(!holder_map_->is_dictionary_map()); |
252 DCHECK_EQ(v8::internal::FIELD, property_details_.type()); | 252 DCHECK_EQ(v8::internal::DATA_FIELD, property_details_.type()); |
253 int index = | 253 int index = |
254 holder_map_->instance_descriptors()->GetFieldIndex(descriptor_number()); | 254 holder_map_->instance_descriptors()->GetFieldIndex(descriptor_number()); |
255 bool is_double = representation().IsDouble(); | 255 bool is_double = representation().IsDouble(); |
256 return FieldIndex::ForPropertyIndex(*holder_map_, index, is_double); | 256 return FieldIndex::ForPropertyIndex(*holder_map_, index, is_double); |
257 } | 257 } |
258 | 258 |
259 | 259 |
260 Handle<HeapType> LookupIterator::GetFieldType() const { | 260 Handle<HeapType> LookupIterator::GetFieldType() const { |
261 DCHECK(has_property_); | 261 DCHECK(has_property_); |
262 DCHECK(!holder_map_->is_dictionary_map()); | 262 DCHECK(!holder_map_->is_dictionary_map()); |
263 DCHECK_EQ(v8::internal::FIELD, property_details_.type()); | 263 DCHECK_EQ(v8::internal::DATA_FIELD, property_details_.type()); |
264 return handle( | 264 return handle( |
265 holder_map_->instance_descriptors()->GetFieldType(descriptor_number()), | 265 holder_map_->instance_descriptors()->GetFieldType(descriptor_number()), |
266 isolate_); | 266 isolate_); |
267 } | 267 } |
268 | 268 |
269 | 269 |
270 Handle<PropertyCell> LookupIterator::GetPropertyCell() const { | 270 Handle<PropertyCell> LookupIterator::GetPropertyCell() const { |
271 Handle<JSObject> holder = GetHolder<JSObject>(); | 271 Handle<JSObject> holder = GetHolder<JSObject>(); |
272 Handle<GlobalObject> global = Handle<GlobalObject>::cast(holder); | 272 Handle<GlobalObject> global = Handle<GlobalObject>::cast(holder); |
273 Object* value = global->property_dictionary()->ValueAt(dictionary_entry()); | 273 Object* value = global->property_dictionary()->ValueAt(dictionary_entry()); |
(...skipping 19 matching lines...) Expand all Loading... |
293 Handle<JSObject> holder = GetHolder<JSObject>(); | 293 Handle<JSObject> holder = GetHolder<JSObject>(); |
294 if (holder_map_->is_dictionary_map()) { | 294 if (holder_map_->is_dictionary_map()) { |
295 NameDictionary* property_dictionary = holder->property_dictionary(); | 295 NameDictionary* property_dictionary = holder->property_dictionary(); |
296 if (holder->IsGlobalObject()) { | 296 if (holder->IsGlobalObject()) { |
297 Handle<PropertyCell> cell( | 297 Handle<PropertyCell> cell( |
298 PropertyCell::cast(property_dictionary->ValueAt(dictionary_entry()))); | 298 PropertyCell::cast(property_dictionary->ValueAt(dictionary_entry()))); |
299 value = PropertyCell::SetValueInferType(cell, value); | 299 value = PropertyCell::SetValueInferType(cell, value); |
300 } else { | 300 } else { |
301 property_dictionary->ValueAtPut(dictionary_entry(), *value); | 301 property_dictionary->ValueAtPut(dictionary_entry(), *value); |
302 } | 302 } |
303 } else if (property_details_.type() == v8::internal::FIELD) { | 303 } else if (property_details_.type() == v8::internal::DATA_FIELD) { |
304 holder->WriteToField(descriptor_number(), *value); | 304 holder->WriteToField(descriptor_number(), *value); |
305 } else { | 305 } else { |
306 DCHECK_EQ(v8::internal::CONSTANT, property_details_.type()); | 306 DCHECK_EQ(v8::internal::DATA_CONSTANT, property_details_.type()); |
307 } | 307 } |
308 return value; | 308 return value; |
309 } | 309 } |
310 | 310 |
311 | 311 |
312 bool LookupIterator::IsSpecialNumericIndex() const { | 312 bool LookupIterator::IsSpecialNumericIndex() const { |
313 if (GetStoreTarget()->IsJSTypedArray() && name()->IsString()) { | 313 if (GetStoreTarget()->IsJSTypedArray() && name()->IsString()) { |
314 Handle<String> name_string = Handle<String>::cast(name()); | 314 Handle<String> name_string = Handle<String>::cast(name()); |
315 if (name_string->length() > 0) { | 315 if (name_string->length() > 0) { |
316 double d = | 316 double d = |
(...skipping 12 matching lines...) Expand all Loading... |
329 } | 329 } |
330 return false; | 330 return false; |
331 } | 331 } |
332 | 332 |
333 | 333 |
334 void LookupIterator::InternalizeName() { | 334 void LookupIterator::InternalizeName() { |
335 if (name_->IsUniqueName()) return; | 335 if (name_->IsUniqueName()) return; |
336 name_ = factory()->InternalizeString(Handle<String>::cast(name_)); | 336 name_ = factory()->InternalizeString(Handle<String>::cast(name_)); |
337 } | 337 } |
338 } } // namespace v8::internal | 338 } } // namespace v8::internal |
OLD | NEW |