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

Side by Side Diff: src/objects.cc

Issue 1181733002: Revert of Replace SetObjectProperty / DefineObjectProperty with less powerful alternatives where relevant. (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
3226 MaybeHandle<Object> Object::RedefineNonconfigurableProperty( 3237 MaybeHandle<Object> Object::RedefineNonconfigurableProperty(
3227 Isolate* isolate, Handle<Object> name, Handle<Object> value, 3238 Isolate* isolate, Handle<Object> name, Handle<Object> value,
3228 LanguageMode language_mode) { 3239 LanguageMode language_mode) {
3229 if (is_sloppy(language_mode)) return value; 3240 if (is_sloppy(language_mode)) return value;
3230 THROW_NEW_ERROR(isolate, 3241 THROW_NEW_ERROR(isolate,
3231 NewTypeError(MessageTemplate::kRedefineDisallowed, name), 3242 NewTypeError(MessageTemplate::kRedefineDisallowed, name),
3232 Object); 3243 Object);
3233 } 3244 }
3234 3245
3235 3246
3236 MaybeHandle<Object> Object::SetDataProperty(LookupIterator* it, 3247 MaybeHandle<Object> Object::SetDataProperty(LookupIterator* it,
3237 Handle<Object> value) { 3248 Handle<Object> value) {
3238 // Proxies are handled on the WithHandler path. Other non-JSObjects cannot 3249 // Proxies are handled on the WithHandler path. Other non-JSObjects cannot
3239 // have own properties. 3250 // have own properties.
3240 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); 3251 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver());
3241 3252
3242 // Store on the holder which may be hidden behind the receiver. 3253 // Store on the holder which may be hidden behind the receiver.
3243 DCHECK(it->HolderIsReceiverOrHiddenPrototype()); 3254 DCHECK(it->HolderIsReceiverOrHiddenPrototype());
3244 3255
3245 // Old value for the observation change record. 3256 // Old value for the observation change record.
3246 // Fetch before transforming the object since the encoding may become 3257 // Fetch before transforming the object since the encoding may become
3247 // incompatible with what's cached in |it|. 3258 // incompatible with what's cached in |it|.
3248 bool is_observed = receiver->map()->is_observed() && 3259 bool is_observed = receiver->map()->is_observed() &&
3249 (it->IsElement() || 3260 (it->IsElement() ||
3250 !it->isolate()->IsInternallyUsedPropertyName(it->name())); 3261 !it->isolate()->IsInternallyUsedPropertyName(it->name()));
3251 MaybeHandle<Object> maybe_old; 3262 MaybeHandle<Object> maybe_old;
3252 if (is_observed) maybe_old = it->GetDataValue(); 3263 if (is_observed) maybe_old = it->GetDataValue();
3253 3264
3254 Handle<Object> to_assign = value;
3255 // Convert the incoming value to a number for storing into typed arrays. 3265 // Convert the incoming value to a number for storing into typed arrays.
3256 if (it->IsElement() && (receiver->HasExternalArrayElements() || 3266 if (it->IsElement() && (receiver->HasExternalArrayElements() ||
3257 receiver->HasFixedTypedArrayElements())) { 3267 receiver->HasFixedTypedArrayElements())) {
3258 if (!value->IsNumber() && !value->IsUndefined()) { 3268 if (!value->IsNumber() && !value->IsUndefined()) {
3259 ASSIGN_RETURN_ON_EXCEPTION(it->isolate(), to_assign, 3269 ASSIGN_RETURN_ON_EXCEPTION(it->isolate(), value,
3260 Execution::ToNumber(it->isolate(), value), 3270 Execution::ToNumber(it->isolate(), value),
3261 Object); 3271 Object);
3262 } 3272 }
3263 } 3273 }
3264 3274
3265 // Possibly migrate to the most up-to-date map that will be able to store 3275 // Possibly migrate to the most up-to-date map that will be able to store
3266 // |value| under it->name(). 3276 // |value| under it->name().
3267 it->PrepareForDataProperty(to_assign); 3277 it->PrepareForDataProperty(value);
3268 3278
3269 // Write the property value. 3279 // Write the property value.
3270 it->WriteDataValue(to_assign); 3280 value = it->WriteDataValue(value);
3271 3281
3272 // Send the change record if there are observers. 3282 // Send the change record if there are observers.
3273 if (is_observed && !value->SameValue(*maybe_old.ToHandleChecked())) { 3283 if (is_observed && !value->SameValue(*maybe_old.ToHandleChecked())) {
3274 RETURN_ON_EXCEPTION(it->isolate(), JSObject::EnqueueChangeRecord( 3284 RETURN_ON_EXCEPTION(it->isolate(), JSObject::EnqueueChangeRecord(
3275 receiver, "update", it->GetName(), 3285 receiver, "update", it->GetName(),
3276 maybe_old.ToHandleChecked()), 3286 maybe_old.ToHandleChecked()),
3277 Object); 3287 Object);
3278 } 3288 }
3279 3289
3280 return value; 3290 return value;
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
4237 4247
4238 4248
4239 // Reconfigures a property to a data property with attributes, even if it is not 4249 // Reconfigures a property to a data property with attributes, even if it is not
4240 // reconfigurable. 4250 // reconfigurable.
4241 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes( 4251 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
4242 Handle<JSObject> object, Handle<Name> name, Handle<Object> value, 4252 Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
4243 PropertyAttributes attributes) { 4253 PropertyAttributes attributes) {
4244 DCHECK(!value->IsTheHole()); 4254 DCHECK(!value->IsTheHole());
4245 LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR); 4255 LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
4246 if (it.state() == LookupIterator::ACCESS_CHECK) { 4256 if (it.state() == LookupIterator::ACCESS_CHECK) {
4247 if (!it.HasAccess()) { 4257 if (!it.isolate()->MayAccess(object)) {
4248 return SetPropertyWithFailedAccessCheck(&it, value, SLOPPY); 4258 return SetPropertyWithFailedAccessCheck(&it, value, SLOPPY);
4249 } 4259 }
4250 it.Next(); 4260 it.Next();
4251 } 4261 }
4252 4262
4253 if (it.IsFound()) { 4263 if (it.IsFound()) {
4254 return ReconfigureAsDataProperty(&it, value, attributes); 4264 return ReconfigureAsDataProperty(&it, value, attributes);
4255 } 4265 }
4256 4266
4257 return AddDataProperty(&it, value, attributes, STRICT, 4267 return AddDataProperty(&it, value, attributes, STRICT,
4258 CERTAINLY_NOT_STORE_FROM_KEYED); 4268 CERTAINLY_NOT_STORE_FROM_KEYED);
4259 } 4269 }
4260 4270
4261 4271
4262 MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes( 4272 MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes(
4263 Handle<JSObject> object, uint32_t index, Handle<Object> value, 4273 Handle<JSObject> object, uint32_t index, Handle<Object> value,
4264 PropertyAttributes attributes) { 4274 PropertyAttributes attributes) {
4265 DCHECK(!object->HasExternalArrayElements()); 4275 DCHECK(!object->HasExternalArrayElements());
4266 Isolate* isolate = object->GetIsolate(); 4276 Isolate* isolate = object->GetIsolate();
4267 LookupIterator it(isolate, object, index, 4277 LookupIterator it(isolate, object, index,
4268 LookupIterator::OWN_SKIP_INTERCEPTOR); 4278 LookupIterator::OWN_SKIP_INTERCEPTOR);
4269 if (it.state() == LookupIterator::ACCESS_CHECK) { 4279 if (it.state() == LookupIterator::ACCESS_CHECK) {
4270 if (!it.HasAccess()) { 4280 if (!isolate->MayAccess(object)) {
4271 return SetPropertyWithFailedAccessCheck(&it, value, STRICT); 4281 return SetPropertyWithFailedAccessCheck(&it, value, STRICT);
4272 } 4282 }
4273 it.Next(); 4283 it.Next();
4274 } 4284 }
4275 4285
4276 if (it.IsFound()) { 4286 if (it.IsFound()) {
4277 return ReconfigureAsDataProperty(&it, value, attributes); 4287 return ReconfigureAsDataProperty(&it, value, attributes);
4278 } 4288 }
4279 4289
4280 return AddDataProperty(&it, value, attributes, STRICT, 4290 return AddDataProperty(&it, value, attributes, STRICT,
(...skipping 12435 matching lines...) Expand 10 before | Expand all | Expand 10 after
16716 Handle<Object> new_value) { 16726 Handle<Object> new_value) {
16717 if (cell->value() != *new_value) { 16727 if (cell->value() != *new_value) {
16718 cell->set_value(*new_value); 16728 cell->set_value(*new_value);
16719 Isolate* isolate = cell->GetIsolate(); 16729 Isolate* isolate = cell->GetIsolate();
16720 cell->dependent_code()->DeoptimizeDependentCodeGroup( 16730 cell->dependent_code()->DeoptimizeDependentCodeGroup(
16721 isolate, DependentCode::kPropertyCellChangedGroup); 16731 isolate, DependentCode::kPropertyCellChangedGroup);
16722 } 16732 }
16723 } 16733 }
16724 } // namespace internal 16734 } // namespace internal
16725 } // namespace v8 16735 } // 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