Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 3551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3562 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(it->isolate(), Nothing<bool>()); | 3562 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(it->isolate(), Nothing<bool>()); |
| 3563 if (result.IsEmpty()) return Just(false); | 3563 if (result.IsEmpty()) return Just(false); |
| 3564 #ifdef DEBUG | 3564 #ifdef DEBUG |
| 3565 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); | 3565 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); |
| 3566 result_internal->VerifyApiCallResultType(); | 3566 result_internal->VerifyApiCallResultType(); |
| 3567 #endif | 3567 #endif |
| 3568 return Just(true); | 3568 return Just(true); |
| 3569 } | 3569 } |
| 3570 | 3570 |
| 3571 | 3571 |
| 3572 MaybeHandle<Object> Object::SetProperty(Handle<Object> object, | |
| 3573 Handle<Name> name, Handle<Object> value, | |
| 3574 LanguageMode language_mode, | |
| 3575 StoreFromKeyed store_mode) { | |
| 3576 LookupIterator it(object, name); | |
| 3577 return SetProperty(&it, value, language_mode, store_mode); | |
| 3578 } | |
| 3579 | |
| 3580 | |
| 3581 Maybe<bool> Object::SetPropertyInternal( | 3572 Maybe<bool> Object::SetPropertyInternal( |
| 3582 LookupIterator* it, Handle<Object> value, LanguageMode language_mode, | 3573 LookupIterator* it, Handle<Object> value, LanguageMode language_mode, |
| 3583 ShouldThrow should_throw, StoreFromKeyed store_mode, bool* found) { | 3574 ShouldThrow should_throw, StoreFromKeyed store_mode, bool* found) { |
| 3584 // Make sure that the top context does not change when doing callbacks or | 3575 // Make sure that the top context does not change when doing callbacks or |
| 3585 // interceptor calls. | 3576 // interceptor calls. |
| 3586 AssertNoContextChange ncc(it->isolate()); | 3577 AssertNoContextChange ncc(it->isolate()); |
| 3587 | 3578 |
| 3588 *found = true; | 3579 *found = true; |
| 3589 | 3580 |
| 3590 bool done = false; | 3581 bool done = false; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3678 if (it->GetReceiver()->IsJSGlobalObject() && is_strict(language_mode)) { | 3669 if (it->GetReceiver()->IsJSGlobalObject() && is_strict(language_mode)) { |
| 3679 RETURN_FAILURE(it->isolate(), should_throw, | 3670 RETURN_FAILURE(it->isolate(), should_throw, |
| 3680 NewReferenceError(MessageTemplate::kNotDefined, it->name())); | 3671 NewReferenceError(MessageTemplate::kNotDefined, it->name())); |
| 3681 } | 3672 } |
| 3682 | 3673 |
| 3683 *found = false; | 3674 *found = false; |
| 3684 return Nothing<bool>(); | 3675 return Nothing<bool>(); |
| 3685 } | 3676 } |
| 3686 | 3677 |
| 3687 | 3678 |
| 3679 MaybeHandle<Object> Object::SetProperty(Handle<Object> object, | |
| 3680 Handle<Name> name, Handle<Object> value, | |
| 3681 LanguageMode language_mode, | |
| 3682 StoreFromKeyed store_mode) { | |
| 3683 LookupIterator it(object, name); | |
| 3684 return SetProperty(&it, value, language_mode, store_mode); | |
| 3685 } | |
| 3686 | |
| 3687 | |
| 3688 MaybeHandle<Object> Object::SetProperty(LookupIterator* it, | 3688 MaybeHandle<Object> Object::SetProperty(LookupIterator* it, |
| 3689 Handle<Object> value, | 3689 Handle<Object> value, |
| 3690 LanguageMode language_mode, | 3690 LanguageMode language_mode, |
| 3691 StoreFromKeyed store_mode) { | 3691 StoreFromKeyed store_mode) { |
| 3692 MAYBE_RETURN_NULL( | 3692 MAYBE_RETURN_NULL( |
| 3693 SetProperty(it, value, language_mode, THROW_ON_ERROR, store_mode)); | 3693 SetProperty(it, value, language_mode, THROW_ON_ERROR, store_mode)); |
| 3694 return value; | 3694 return value; |
| 3695 } | 3695 } |
| 3696 | 3696 |
| 3697 | 3697 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3897 | 3897 |
| 3898 // We have to recheck the length. However, it can only change if the | 3898 // We have to recheck the length. However, it can only change if the |
| 3899 // underlying buffer was neutered, so just check that. | 3899 // underlying buffer was neutered, so just check that. |
| 3900 if (Handle<JSArrayBufferView>::cast(receiver)->WasNeutered()) { | 3900 if (Handle<JSArrayBufferView>::cast(receiver)->WasNeutered()) { |
| 3901 return Just(true); | 3901 return Just(true); |
| 3902 // TODO(neis): According to the spec, this should throw a TypeError. | 3902 // TODO(neis): According to the spec, this should throw a TypeError. |
| 3903 } | 3903 } |
| 3904 } | 3904 } |
| 3905 } | 3905 } |
| 3906 | 3906 |
| 3907 // it->isolate()->UpdateArrayIsConcatSpreadableProtectorOnAddProperty( | |
| 3908 // receiver, it->GetName()); | |
|
Toon Verwaest
2015/11/02 12:32:46
stray change?
Camillo Bruni
2015/11/03 14:49:25
indeed.
| |
| 3909 | |
| 3907 // Possibly migrate to the most up-to-date map that will be able to store | 3910 // Possibly migrate to the most up-to-date map that will be able to store |
| 3908 // |value| under it->name(). | 3911 // |value| under it->name(). |
| 3909 it->PrepareForDataProperty(to_assign); | 3912 it->PrepareForDataProperty(to_assign); |
| 3910 | 3913 |
| 3911 // Write the property value. | 3914 // Write the property value. |
| 3912 it->WriteDataValue(to_assign); | 3915 it->WriteDataValue(to_assign); |
| 3913 | 3916 |
| 3914 // Send the change record if there are observers. | 3917 // Send the change record if there are observers. |
| 3915 if (is_observed && !value->SameValue(*maybe_old.ToHandleChecked())) { | 3918 if (is_observed && !value->SameValue(*maybe_old.ToHandleChecked())) { |
| 3916 RETURN_ON_EXCEPTION_VALUE( | 3919 RETURN_ON_EXCEPTION_VALUE( |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4029 if (FLAG_trace_js_array_abuse && !array->HasFixedTypedArrayElements()) { | 4032 if (FLAG_trace_js_array_abuse && !array->HasFixedTypedArrayElements()) { |
| 4030 CheckArrayAbuse(array, "elements write", it->index(), false); | 4033 CheckArrayAbuse(array, "elements write", it->index(), false); |
| 4031 } | 4034 } |
| 4032 } | 4035 } |
| 4033 | 4036 |
| 4034 Maybe<bool> result = JSObject::AddDataElement(receiver, it->index(), value, | 4037 Maybe<bool> result = JSObject::AddDataElement(receiver, it->index(), value, |
| 4035 attributes, should_throw); | 4038 attributes, should_throw); |
| 4036 JSObject::ValidateElements(receiver); | 4039 JSObject::ValidateElements(receiver); |
| 4037 return result; | 4040 return result; |
| 4038 } else { | 4041 } else { |
| 4042 it->isolate()->UpdateArrayIsConcatSpreadableProtectorOnAddProperty( | |
|
Toon Verwaest
2015/11/02 12:32:45
I don't think all stores go through here. Generic
Camillo Bruni
2015/11/03 14:49:25
I added another test case, if I understood it corr
| |
| 4043 receiver, it->name()); | |
| 4039 // Migrate to the most up-to-date map that will be able to store |value| | 4044 // Migrate to the most up-to-date map that will be able to store |value| |
| 4040 // under it->name() with |attributes|. | 4045 // under it->name() with |attributes|. |
| 4041 it->PrepareTransitionToDataProperty(value, attributes, store_mode); | 4046 it->PrepareTransitionToDataProperty(value, attributes, store_mode); |
| 4042 DCHECK_EQ(LookupIterator::TRANSITION, it->state()); | 4047 DCHECK_EQ(LookupIterator::TRANSITION, it->state()); |
| 4043 it->ApplyTransitionToDataProperty(); | 4048 it->ApplyTransitionToDataProperty(); |
| 4044 | 4049 |
| 4045 // TODO(verwaest): Encapsulate dictionary handling better. | 4050 // TODO(verwaest): Encapsulate dictionary handling better. |
| 4046 if (receiver->map()->is_dictionary_map()) { | 4051 if (receiver->map()->is_dictionary_map()) { |
| 4047 // TODO(verwaest): Probably should ensure this is done beforehand. | 4052 // TODO(verwaest): Probably should ensure this is done beforehand. |
| 4048 it->InternalizeName(); | 4053 it->InternalizeName(); |
| (...skipping 13798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17847 if (cell->value() != *new_value) { | 17852 if (cell->value() != *new_value) { |
| 17848 cell->set_value(*new_value); | 17853 cell->set_value(*new_value); |
| 17849 Isolate* isolate = cell->GetIsolate(); | 17854 Isolate* isolate = cell->GetIsolate(); |
| 17850 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17855 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 17851 isolate, DependentCode::kPropertyCellChangedGroup); | 17856 isolate, DependentCode::kPropertyCellChangedGroup); |
| 17852 } | 17857 } |
| 17853 } | 17858 } |
| 17854 | 17859 |
| 17855 } // namespace internal | 17860 } // namespace internal |
| 17856 } // namespace v8 | 17861 } // namespace v8 |
| OLD | NEW |