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/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/base/ieee754.h" | 9 #include "src/base/ieee754.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 4218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4229 // Add to dictionary. | 4229 // Add to dictionary. |
4230 Handle<Object> callbacks(descs->GetCallbacksObject(i), isolate()); | 4230 Handle<Object> callbacks(descs->GetCallbacksObject(i), isolate()); |
4231 PropertyDetails d(details.attributes(), ACCESSOR_CONSTANT, i + 1, | 4231 PropertyDetails d(details.attributes(), ACCESSOR_CONSTANT, i + 1, |
4232 PropertyCellType::kMutable); | 4232 PropertyCellType::kMutable); |
4233 JSObject::SetNormalizedProperty(to, key, callbacks, d); | 4233 JSObject::SetNormalizedProperty(to, key, callbacks, d); |
4234 break; | 4234 break; |
4235 } | 4235 } |
4236 } | 4236 } |
4237 } | 4237 } |
4238 } else if (from->IsJSGlobalObject()) { | 4238 } else if (from->IsJSGlobalObject()) { |
| 4239 // Copy all keys and values in enumeration order. |
4239 Handle<GlobalDictionary> properties = | 4240 Handle<GlobalDictionary> properties = |
4240 Handle<GlobalDictionary>(from->global_dictionary()); | 4241 Handle<GlobalDictionary>(from->global_dictionary()); |
4241 int capacity = properties->Capacity(); | 4242 Handle<FixedArray> key_indices = |
4242 for (int i = 0; i < capacity; i++) { | 4243 GlobalDictionary::GetOrderedKeyIndices(properties); |
4243 Object* raw_key(properties->KeyAt(i)); | 4244 for (int i = 0; i < key_indices->length(); i++) { |
4244 if (properties->IsKey(isolate(), raw_key)) { | 4245 int key_index = Smi::cast(key_indices->get(i))->value(); |
4245 DCHECK(raw_key->IsName()); | 4246 Object* raw_key = properties->KeyAt(key_index); |
4246 // If the property is already there we skip it. | 4247 DCHECK(properties->IsKey(isolate(), raw_key)); |
4247 Handle<Name> key(Name::cast(raw_key)); | 4248 DCHECK(raw_key->IsName()); |
4248 LookupIterator it(to, key, LookupIterator::OWN_SKIP_INTERCEPTOR); | 4249 // If the property is already there we skip it. |
4249 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state()); | 4250 Handle<Name> key(Name::cast(raw_key), isolate()); |
4250 if (it.IsFound()) continue; | 4251 LookupIterator it(to, key, LookupIterator::OWN_SKIP_INTERCEPTOR); |
4251 // Set the property. | 4252 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state()); |
4252 DCHECK(properties->ValueAt(i)->IsPropertyCell()); | 4253 if (it.IsFound()) continue; |
4253 Handle<PropertyCell> cell(PropertyCell::cast(properties->ValueAt(i))); | 4254 // Set the property. |
4254 Handle<Object> value(cell->value(), isolate()); | 4255 DCHECK(properties->ValueAt(key_index)->IsPropertyCell()); |
4255 if (value->IsTheHole(isolate())) continue; | 4256 Handle<PropertyCell> cell( |
4256 PropertyDetails details = cell->property_details(); | 4257 PropertyCell::cast(properties->ValueAt(key_index)), isolate()); |
4257 DCHECK_EQ(kData, details.kind()); | 4258 Handle<Object> value(cell->value(), isolate()); |
4258 JSObject::AddProperty(to, key, value, details.attributes()); | 4259 if (value->IsTheHole(isolate())) continue; |
4259 } | 4260 PropertyDetails details = cell->property_details(); |
| 4261 DCHECK_EQ(kData, details.kind()); |
| 4262 JSObject::AddProperty(to, key, value, details.attributes()); |
4260 } | 4263 } |
4261 } else { | 4264 } else { |
| 4265 // Copy all keys and values in enumeration order. |
4262 Handle<NameDictionary> properties = | 4266 Handle<NameDictionary> properties = |
4263 Handle<NameDictionary>(from->property_dictionary()); | 4267 Handle<NameDictionary>(from->property_dictionary()); |
4264 int capacity = properties->Capacity(); | 4268 Handle<FixedArray> key_indices = |
4265 for (int i = 0; i < capacity; i++) { | 4269 NameDictionary::GetOrderedKeyIndices(properties); |
4266 Object* raw_key(properties->KeyAt(i)); | 4270 for (int i = 0; i < key_indices->length(); i++) { |
4267 if (properties->IsKey(isolate(), raw_key)) { | 4271 int key_index = Smi::cast(key_indices->get(i))->value(); |
4268 DCHECK(raw_key->IsName()); | 4272 Object* raw_key = properties->KeyAt(key_index); |
4269 // If the property is already there we skip it. | 4273 DCHECK(properties->IsKey(isolate(), raw_key)); |
4270 Handle<Name> key(Name::cast(raw_key)); | 4274 DCHECK(raw_key->IsName()); |
4271 LookupIterator it(to, key, LookupIterator::OWN_SKIP_INTERCEPTOR); | 4275 // If the property is already there we skip it. |
4272 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state()); | 4276 Handle<Name> key(Name::cast(raw_key), isolate()); |
4273 if (it.IsFound()) continue; | 4277 LookupIterator it(to, key, LookupIterator::OWN_SKIP_INTERCEPTOR); |
4274 // Set the property. | 4278 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state()); |
4275 Handle<Object> value = Handle<Object>(properties->ValueAt(i), | 4279 if (it.IsFound()) continue; |
4276 isolate()); | 4280 // Set the property. |
4277 DCHECK(!value->IsCell()); | 4281 Handle<Object> value = |
4278 DCHECK(!value->IsTheHole(isolate())); | 4282 Handle<Object>(properties->ValueAt(key_index), isolate()); |
4279 PropertyDetails details = properties->DetailsAt(i); | 4283 DCHECK(!value->IsCell()); |
4280 DCHECK_EQ(kData, details.kind()); | 4284 DCHECK(!value->IsTheHole(isolate())); |
4281 JSObject::AddProperty(to, key, value, details.attributes()); | 4285 PropertyDetails details = properties->DetailsAt(key_index); |
4282 } | 4286 DCHECK_EQ(kData, details.kind()); |
| 4287 JSObject::AddProperty(to, key, value, details.attributes()); |
4283 } | 4288 } |
4284 } | 4289 } |
4285 } | 4290 } |
4286 | 4291 |
4287 | 4292 |
4288 void Genesis::TransferIndexedProperties(Handle<JSObject> from, | 4293 void Genesis::TransferIndexedProperties(Handle<JSObject> from, |
4289 Handle<JSObject> to) { | 4294 Handle<JSObject> to) { |
4290 // Cloning the elements array is sufficient. | 4295 // Cloning the elements array is sufficient. |
4291 Handle<FixedArray> from_elements = | 4296 Handle<FixedArray> from_elements = |
4292 Handle<FixedArray>(FixedArray::cast(from->elements())); | 4297 Handle<FixedArray>(FixedArray::cast(from->elements())); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4558 } | 4563 } |
4559 | 4564 |
4560 | 4565 |
4561 // Called when the top-level V8 mutex is destroyed. | 4566 // Called when the top-level V8 mutex is destroyed. |
4562 void Bootstrapper::FreeThreadResources() { | 4567 void Bootstrapper::FreeThreadResources() { |
4563 DCHECK(!IsActive()); | 4568 DCHECK(!IsActive()); |
4564 } | 4569 } |
4565 | 4570 |
4566 } // namespace internal | 4571 } // namespace internal |
4567 } // namespace v8 | 4572 } // namespace v8 |
OLD | NEW |