| 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/lookup.h" | 5 #include "src/lookup.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/elements.h" | 9 #include "src/elements.h" |
| 10 #include "src/field-type.h" | 10 #include "src/field-type.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 } | 363 } |
| 364 // TODO(verwaest): Get rid of the name_ argument. | 364 // TODO(verwaest): Get rid of the name_ argument. |
| 365 JSReceiver::DeleteNormalizedProperty(holder, name_, number_); | 365 JSReceiver::DeleteNormalizedProperty(holder, name_, number_); |
| 366 if (holder->IsJSObject()) { | 366 if (holder->IsJSObject()) { |
| 367 JSObject::ReoptimizeIfPrototype(Handle<JSObject>::cast(holder)); | 367 JSObject::ReoptimizeIfPrototype(Handle<JSObject>::cast(holder)); |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 state_ = NOT_FOUND; | 370 state_ = NOT_FOUND; |
| 371 } | 371 } |
| 372 | 372 |
| 373 | |
| 374 void LookupIterator::TransitionToAccessorProperty( | 373 void LookupIterator::TransitionToAccessorProperty( |
| 375 AccessorComponent component, Handle<Object> accessor, | 374 Handle<Object> getter, Handle<Object> setter, |
| 376 PropertyAttributes attributes) { | 375 PropertyAttributes attributes) { |
| 377 DCHECK(!accessor->IsNull()); | 376 DCHECK(!getter->IsNull() || !setter->IsNull()); |
| 378 // Can only be called when the receiver is a JSObject. JSProxy has to be | 377 // Can only be called when the receiver is a JSObject. JSProxy has to be |
| 379 // handled via a trap. Adding properties to primitive values is not | 378 // handled via a trap. Adding properties to primitive values is not |
| 380 // observable. | 379 // observable. |
| 381 Handle<JSObject> receiver = GetStoreTarget(); | 380 Handle<JSObject> receiver = GetStoreTarget(); |
| 382 | 381 |
| 383 if (!IsElement() && !receiver->map()->is_dictionary_map()) { | 382 if (!IsElement() && !receiver->map()->is_dictionary_map()) { |
| 384 Handle<Map> old_map(receiver->map(), isolate_); | 383 Handle<Map> old_map(receiver->map(), isolate_); |
| 385 | 384 |
| 386 if (!holder_.is_identical_to(receiver)) { | 385 if (!holder_.is_identical_to(receiver)) { |
| 387 holder_ = receiver; | 386 holder_ = receiver; |
| 388 state_ = NOT_FOUND; | 387 state_ = NOT_FOUND; |
| 389 } else if (state_ == INTERCEPTOR) { | 388 } else if (state_ == INTERCEPTOR) { |
| 390 LookupInRegularHolder<false>(*old_map, *holder_); | 389 LookupInRegularHolder<false>(*old_map, *holder_); |
| 391 } | 390 } |
| 392 int descriptor = | 391 int descriptor = |
| 393 IsFound() ? static_cast<int>(number_) : DescriptorArray::kNotFound; | 392 IsFound() ? static_cast<int>(number_) : DescriptorArray::kNotFound; |
| 394 | 393 |
| 395 Handle<Map> new_map = Map::TransitionToAccessorProperty( | 394 Handle<Map> new_map = Map::TransitionToAccessorProperty( |
| 396 old_map, name_, descriptor, component, accessor, attributes); | 395 isolate_, old_map, name_, descriptor, getter, setter, attributes); |
| 397 bool simple_transition = new_map->GetBackPointer() == receiver->map(); | 396 bool simple_transition = new_map->GetBackPointer() == receiver->map(); |
| 398 JSObject::MigrateToMap(receiver, new_map); | 397 JSObject::MigrateToMap(receiver, new_map); |
| 399 | 398 |
| 400 if (simple_transition) { | 399 if (simple_transition) { |
| 401 int number = new_map->LastAdded(); | 400 int number = new_map->LastAdded(); |
| 402 number_ = static_cast<uint32_t>(number); | 401 number_ = static_cast<uint32_t>(number); |
| 403 property_details_ = new_map->GetLastDescriptorDetails(); | 402 property_details_ = new_map->GetLastDescriptorDetails(); |
| 404 state_ = ACCESSOR; | 403 state_ = ACCESSOR; |
| 405 return; | 404 return; |
| 406 } | 405 } |
| 407 | 406 |
| 408 ReloadPropertyInformation<false>(); | 407 ReloadPropertyInformation<false>(); |
| 409 if (!new_map->is_dictionary_map()) return; | 408 if (!new_map->is_dictionary_map()) return; |
| 410 } | 409 } |
| 411 | 410 |
| 412 Handle<AccessorPair> pair; | 411 Handle<AccessorPair> pair; |
| 413 if (state() == ACCESSOR && GetAccessors()->IsAccessorPair()) { | 412 if (state() == ACCESSOR && GetAccessors()->IsAccessorPair()) { |
| 414 pair = Handle<AccessorPair>::cast(GetAccessors()); | 413 pair = Handle<AccessorPair>::cast(GetAccessors()); |
| 415 // If the component and attributes are identical, nothing has to be done. | 414 // If the component and attributes are identical, nothing has to be done. |
| 416 if (pair->get(component) == *accessor) { | 415 if (pair->Equals(*getter, *setter)) { |
| 417 if (property_details().attributes() == attributes) { | 416 if (property_details().attributes() == attributes) { |
| 418 if (!IsElement()) JSObject::ReoptimizeIfPrototype(receiver); | 417 if (!IsElement()) JSObject::ReoptimizeIfPrototype(receiver); |
| 419 return; | 418 return; |
| 420 } | 419 } |
| 421 } else { | 420 } else { |
| 422 pair = AccessorPair::Copy(pair); | 421 pair = AccessorPair::Copy(pair); |
| 423 pair->set(component, *accessor); | 422 pair->SetComponents(*getter, *setter); |
| 424 } | 423 } |
| 425 } else { | 424 } else { |
| 426 pair = factory()->NewAccessorPair(); | 425 pair = factory()->NewAccessorPair(); |
| 427 pair->set(component, *accessor); | 426 pair->SetComponents(*getter, *setter); |
| 428 } | 427 } |
| 429 | 428 |
| 430 TransitionToAccessorPair(pair, attributes); | 429 TransitionToAccessorPair(pair, attributes); |
| 431 | 430 |
| 432 #if VERIFY_HEAP | 431 #if VERIFY_HEAP |
| 433 if (FLAG_verify_heap) { | 432 if (FLAG_verify_heap) { |
| 434 receiver->JSObjectVerify(); | 433 receiver->JSObjectVerify(); |
| 435 } | 434 } |
| 436 #endif | 435 #endif |
| 437 } | 436 } |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 case v8::internal::kAccessor: | 763 case v8::internal::kAccessor: |
| 765 return ACCESSOR; | 764 return ACCESSOR; |
| 766 } | 765 } |
| 767 | 766 |
| 768 UNREACHABLE(); | 767 UNREACHABLE(); |
| 769 return state_; | 768 return state_; |
| 770 } | 769 } |
| 771 | 770 |
| 772 } // namespace internal | 771 } // namespace internal |
| 773 } // namespace v8 | 772 } // namespace v8 |
| OLD | NEW |