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

Side by Side Diff: src/objects.cc

Issue 1180943002: Reland of Replace SetObjectProperty / DefineObjectProperty with less powerful alternatives where re… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <iomanip> 5 #include <iomanip>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 3205 matching lines...) Expand 10 before | Expand all | Expand 10 after
3216 Isolate* isolate, Handle<Object> receiver, Handle<Object> name, 3216 Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
3217 Handle<Object> value, LanguageMode language_mode) { 3217 Handle<Object> value, LanguageMode language_mode) {
3218 if (is_sloppy(language_mode)) return value; 3218 if (is_sloppy(language_mode)) return value;
3219 THROW_NEW_ERROR( 3219 THROW_NEW_ERROR(
3220 isolate, 3220 isolate,
3221 NewTypeError(MessageTemplate::kStrictReadOnlyProperty, name, receiver), 3221 NewTypeError(MessageTemplate::kStrictReadOnlyProperty, name, receiver),
3222 Object); 3222 Object);
3223 } 3223 }
3224 3224
3225 3225
3226 MaybeHandle<Object> Object::WriteToReadOnlyElement(Isolate* isolate,
3227 Handle<Object> receiver,
3228 uint32_t index,
3229 Handle<Object> value,
3230 LanguageMode language_mode) {
3231 return WriteToReadOnlyProperty(isolate, receiver,
3232 isolate->factory()->NewNumberFromUint(index),
3233 value, language_mode);
3234 }
3235
3236
3237 MaybeHandle<Object> Object::RedefineNonconfigurableProperty( 3226 MaybeHandle<Object> Object::RedefineNonconfigurableProperty(
3238 Isolate* isolate, Handle<Object> name, Handle<Object> value, 3227 Isolate* isolate, Handle<Object> name, Handle<Object> value,
3239 LanguageMode language_mode) { 3228 LanguageMode language_mode) {
3240 if (is_sloppy(language_mode)) return value; 3229 if (is_sloppy(language_mode)) return value;
3241 THROW_NEW_ERROR(isolate, 3230 THROW_NEW_ERROR(isolate,
3242 NewTypeError(MessageTemplate::kRedefineDisallowed, name), 3231 NewTypeError(MessageTemplate::kRedefineDisallowed, name),
3243 Object); 3232 Object);
3244 } 3233 }
3245 3234
3246 3235
3247 MaybeHandle<Object> Object::SetDataProperty(LookupIterator* it, 3236 MaybeHandle<Object> Object::SetDataProperty(LookupIterator* it,
3248 Handle<Object> value) { 3237 Handle<Object> value) {
3249 // Proxies are handled on the WithHandler path. Other non-JSObjects cannot 3238 // Proxies are handled on the WithHandler path. Other non-JSObjects cannot
3250 // have own properties. 3239 // have own properties.
3251 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); 3240 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver());
3252 3241
3253 // Store on the holder which may be hidden behind the receiver. 3242 // Store on the holder which may be hidden behind the receiver.
3254 DCHECK(it->HolderIsReceiverOrHiddenPrototype()); 3243 DCHECK(it->HolderIsReceiverOrHiddenPrototype());
3255 3244
3256 // Old value for the observation change record. 3245 // Old value for the observation change record.
3257 // Fetch before transforming the object since the encoding may become 3246 // Fetch before transforming the object since the encoding may become
3258 // incompatible with what's cached in |it|. 3247 // incompatible with what's cached in |it|.
3259 bool is_observed = receiver->map()->is_observed() && 3248 bool is_observed = receiver->map()->is_observed() &&
3260 (it->IsElement() || 3249 (it->IsElement() ||
3261 !it->isolate()->IsInternallyUsedPropertyName(it->name())); 3250 !it->isolate()->IsInternallyUsedPropertyName(it->name()));
3262 MaybeHandle<Object> maybe_old; 3251 MaybeHandle<Object> maybe_old;
3263 if (is_observed) maybe_old = it->GetDataValue(); 3252 if (is_observed) maybe_old = it->GetDataValue();
3264 3253
3254 Handle<Object> to_assign = value;
3265 // Convert the incoming value to a number for storing into typed arrays. 3255 // Convert the incoming value to a number for storing into typed arrays.
3266 if (it->IsElement() && (receiver->HasExternalArrayElements() || 3256 if (it->IsElement() && (receiver->HasExternalArrayElements() ||
3267 receiver->HasFixedTypedArrayElements())) { 3257 receiver->HasFixedTypedArrayElements())) {
3268 if (!value->IsNumber() && !value->IsUndefined()) { 3258 if (!value->IsNumber() && !value->IsUndefined()) {
3269 ASSIGN_RETURN_ON_EXCEPTION(it->isolate(), value, 3259 ASSIGN_RETURN_ON_EXCEPTION(it->isolate(), to_assign,
3270 Execution::ToNumber(it->isolate(), value), 3260 Execution::ToNumber(it->isolate(), value),
3271 Object); 3261 Object);
3272 } 3262 }
3273 } 3263 }
3274 3264
3275 // Possibly migrate to the most up-to-date map that will be able to store 3265 // Possibly migrate to the most up-to-date map that will be able to store
3276 // |value| under it->name(). 3266 // |value| under it->name().
3277 it->PrepareForDataProperty(value); 3267 it->PrepareForDataProperty(to_assign);
3278 3268
3279 // Write the property value. 3269 // Write the property value.
3280 value = it->WriteDataValue(value); 3270 it->WriteDataValue(to_assign);
3281 3271
3282 // Send the change record if there are observers. 3272 // Send the change record if there are observers.
3283 if (is_observed && !value->SameValue(*maybe_old.ToHandleChecked())) { 3273 if (is_observed && !value->SameValue(*maybe_old.ToHandleChecked())) {
3284 RETURN_ON_EXCEPTION(it->isolate(), JSObject::EnqueueChangeRecord( 3274 RETURN_ON_EXCEPTION(it->isolate(), JSObject::EnqueueChangeRecord(
3285 receiver, "update", it->GetName(), 3275 receiver, "update", it->GetName(),
3286 maybe_old.ToHandleChecked()), 3276 maybe_old.ToHandleChecked()),
3287 Object); 3277 Object);
3288 } 3278 }
3289 3279
3290 return value; 3280 return value;
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
4251 4241
4252 4242
4253 // Reconfigures a property to a data property with attributes, even if it is not 4243 // Reconfigures a property to a data property with attributes, even if it is not
4254 // reconfigurable. 4244 // reconfigurable.
4255 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes( 4245 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
4256 Handle<JSObject> object, Handle<Name> name, Handle<Object> value, 4246 Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
4257 PropertyAttributes attributes, ExecutableAccessorInfoHandling handling) { 4247 PropertyAttributes attributes, ExecutableAccessorInfoHandling handling) {
4258 DCHECK(!value->IsTheHole()); 4248 DCHECK(!value->IsTheHole());
4259 LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR); 4249 LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
4260 if (it.state() == LookupIterator::ACCESS_CHECK) { 4250 if (it.state() == LookupIterator::ACCESS_CHECK) {
4261 if (!it.isolate()->MayAccess(object)) { 4251 if (!it.HasAccess()) {
4262 return SetPropertyWithFailedAccessCheck(&it, value, SLOPPY); 4252 return SetPropertyWithFailedAccessCheck(&it, value, SLOPPY);
4263 } 4253 }
4264 it.Next(); 4254 it.Next();
4265 } 4255 }
4266 4256
4267 if (it.IsFound()) { 4257 if (it.IsFound()) {
4268 return ReconfigureAsDataProperty(&it, value, attributes, handling); 4258 return ReconfigureAsDataProperty(&it, value, attributes, handling);
4269 } 4259 }
4270 4260
4271 return AddDataProperty(&it, value, attributes, STRICT, 4261 return AddDataProperty(&it, value, attributes, STRICT,
4272 CERTAINLY_NOT_STORE_FROM_KEYED); 4262 CERTAINLY_NOT_STORE_FROM_KEYED);
4273 } 4263 }
4274 4264
4275 4265
4276 MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes( 4266 MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes(
4277 Handle<JSObject> object, uint32_t index, Handle<Object> value, 4267 Handle<JSObject> object, uint32_t index, Handle<Object> value,
4278 PropertyAttributes attributes, ExecutableAccessorInfoHandling handling) { 4268 PropertyAttributes attributes, ExecutableAccessorInfoHandling handling) {
4279 DCHECK(!object->HasExternalArrayElements()); 4269 DCHECK(!object->HasExternalArrayElements());
4280 Isolate* isolate = object->GetIsolate(); 4270 Isolate* isolate = object->GetIsolate();
4281 LookupIterator it(isolate, object, index, 4271 LookupIterator it(isolate, object, index,
4282 LookupIterator::OWN_SKIP_INTERCEPTOR); 4272 LookupIterator::OWN_SKIP_INTERCEPTOR);
4283 if (it.state() == LookupIterator::ACCESS_CHECK) { 4273 if (it.state() == LookupIterator::ACCESS_CHECK) {
4284 if (!isolate->MayAccess(object)) { 4274 if (!it.HasAccess()) {
4285 return SetPropertyWithFailedAccessCheck(&it, value, STRICT); 4275 return SetPropertyWithFailedAccessCheck(&it, value, STRICT);
4286 } 4276 }
4287 it.Next(); 4277 it.Next();
4288 } 4278 }
4289 4279
4290 if (it.IsFound()) { 4280 if (it.IsFound()) {
4291 return ReconfigureAsDataProperty(&it, value, attributes, handling); 4281 return ReconfigureAsDataProperty(&it, value, attributes, handling);
4292 } 4282 }
4293 4283
4294 return AddDataProperty(&it, value, attributes, STRICT, 4284 return AddDataProperty(&it, value, attributes, STRICT,
(...skipping 12364 matching lines...) Expand 10 before | Expand all | Expand 10 after
16659 Handle<Object> new_value) { 16649 Handle<Object> new_value) {
16660 if (cell->value() != *new_value) { 16650 if (cell->value() != *new_value) {
16661 cell->set_value(*new_value); 16651 cell->set_value(*new_value);
16662 Isolate* isolate = cell->GetIsolate(); 16652 Isolate* isolate = cell->GetIsolate();
16663 cell->dependent_code()->DeoptimizeDependentCodeGroup( 16653 cell->dependent_code()->DeoptimizeDependentCodeGroup(
16664 isolate, DependentCode::kPropertyCellChangedGroup); 16654 isolate, DependentCode::kPropertyCellChangedGroup);
16665 } 16655 }
16666 } 16656 }
16667 } // namespace internal 16657 } // namespace internal
16668 } // namespace v8 16658 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698