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

Side by Side Diff: src/objects.cc

Issue 958053003: Removed funky Maybe constructor and made fields private. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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/ic/ic-state.cc ('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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 LookupIterator* it) { 480 LookupIterator* it) {
481 Handle<JSObject> checked = it->GetHolder<JSObject>(); 481 Handle<JSObject> checked = it->GetHolder<JSObject>();
482 while (FindAllCanReadHolder(it)) { 482 while (FindAllCanReadHolder(it)) {
483 if (it->state() == LookupIterator::ACCESSOR) { 483 if (it->state() == LookupIterator::ACCESSOR) {
484 return Just(it->property_details().attributes()); 484 return Just(it->property_details().attributes());
485 } 485 }
486 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); 486 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
487 auto result = GetPropertyAttributesWithInterceptor( 487 auto result = GetPropertyAttributesWithInterceptor(
488 it->GetHolder<JSObject>(), it->GetReceiver(), it->name()); 488 it->GetHolder<JSObject>(), it->GetReceiver(), it->name());
489 if (it->isolate()->has_scheduled_exception()) break; 489 if (it->isolate()->has_scheduled_exception()) break;
490 if (result.has_value && result.value != ABSENT) return result; 490 if (result.IsJust() && result.FromJust() != ABSENT) return result;
491 } 491 }
492 it->isolate()->ReportFailedAccessCheck(checked); 492 it->isolate()->ReportFailedAccessCheck(checked);
493 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(it->isolate(), 493 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(it->isolate(),
494 Nothing<PropertyAttributes>()); 494 Nothing<PropertyAttributes>());
495 return Just(ABSENT); 495 return Just(ABSENT);
496 } 496 }
497 497
498 498
499 static bool FindAllCanWriteHolder(LookupIterator* it) { 499 static bool FindAllCanWriteHolder(LookupIterator* it) {
500 for (; it->IsFound(); it->Next()) { 500 for (; it->IsFound(); it->Next()) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 Handle<JSObject> holder = object; 618 Handle<JSObject> holder = object;
619 PrototypeIterator::WhereToStart where_to_start = 619 PrototypeIterator::WhereToStart where_to_start =
620 PrototypeIterator::START_AT_RECEIVER; 620 PrototypeIterator::START_AT_RECEIVER;
621 while (true) { 621 while (true) {
622 auto all_can_read_holder = 622 auto all_can_read_holder =
623 FindIndexedAllCanReadHolder(isolate, holder, where_to_start); 623 FindIndexedAllCanReadHolder(isolate, holder, where_to_start);
624 if (!all_can_read_holder.ToHandle(&holder)) break; 624 if (!all_can_read_holder.ToHandle(&holder)) break;
625 auto result = 625 auto result =
626 JSObject::GetElementAttributeFromInterceptor(object, receiver, index); 626 JSObject::GetElementAttributeFromInterceptor(object, receiver, index);
627 if (isolate->has_scheduled_exception()) break; 627 if (isolate->has_scheduled_exception()) break;
628 if (result.has_value && result.value != ABSENT) return result; 628 if (result.IsJust() && result.FromJust() != ABSENT) return result;
629 where_to_start = PrototypeIterator::START_AT_PROTOTYPE; 629 where_to_start = PrototypeIterator::START_AT_PROTOTYPE;
630 } 630 }
631 isolate->ReportFailedAccessCheck(object); 631 isolate->ReportFailedAccessCheck(object);
632 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<PropertyAttributes>()); 632 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<PropertyAttributes>());
633 return Just(ABSENT); 633 return Just(ABSENT);
634 } 634 }
635 635
636 636
637 MaybeHandle<Object> Object::GetElementWithReceiver(Isolate* isolate, 637 MaybeHandle<Object> Object::GetElementWithReceiver(Isolate* isolate,
638 Handle<Object> object, 638 Handle<Object> object,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 isolate->ReportFailedAccessCheck(js_object); 716 isolate->ReportFailedAccessCheck(js_object);
717 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 717 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
718 return isolate->factory()->undefined_value(); 718 return isolate->factory()->undefined_value();
719 } 719 }
720 } 720 }
721 721
722 if (js_object->HasIndexedInterceptor()) { 722 if (js_object->HasIndexedInterceptor()) {
723 Maybe<PropertyAttributes> from_interceptor = 723 Maybe<PropertyAttributes> from_interceptor =
724 JSObject::GetElementAttributeFromInterceptor(js_object, receiver, 724 JSObject::GetElementAttributeFromInterceptor(js_object, receiver,
725 index); 725 index);
726 if (!from_interceptor.has_value) return MaybeHandle<Object>(); 726 if (!from_interceptor.IsJust()) return MaybeHandle<Object>();
727 if ((from_interceptor.value & READ_ONLY) != 0) { 727 if ((from_interceptor.FromJust() & READ_ONLY) != 0) {
728 return WriteToReadOnlyElement(isolate, receiver, index, value, 728 return WriteToReadOnlyElement(isolate, receiver, index, value,
729 language_mode); 729 language_mode);
730 } 730 }
731 done = from_interceptor.value != ABSENT; 731 done = from_interceptor.FromJust() != ABSENT;
732 } 732 }
733 733
734 if (!done && 734 if (!done &&
735 js_object->elements() != isolate->heap()->empty_fixed_array()) { 735 js_object->elements() != isolate->heap()->empty_fixed_array()) {
736 ElementsAccessor* accessor = js_object->GetElementsAccessor(); 736 ElementsAccessor* accessor = js_object->GetElementsAccessor();
737 PropertyAttributes attrs = accessor->GetAttributes(js_object, index); 737 PropertyAttributes attrs = accessor->GetAttributes(js_object, index);
738 if ((attrs & READ_ONLY) != 0) { 738 if ((attrs & READ_ONLY) != 0) {
739 return WriteToReadOnlyElement(isolate, receiver, index, value, 739 return WriteToReadOnlyElement(isolate, receiver, index, value,
740 language_mode); 740 language_mode);
741 } 741 }
(...skipping 2369 matching lines...) Expand 10 before | Expand all | Expand 10 after
3111 case LookupIterator::INTERCEPTOR: 3111 case LookupIterator::INTERCEPTOR:
3112 if (it->HolderIsReceiverOrHiddenPrototype()) { 3112 if (it->HolderIsReceiverOrHiddenPrototype()) {
3113 MaybeHandle<Object> maybe_result = 3113 MaybeHandle<Object> maybe_result =
3114 JSObject::SetPropertyWithInterceptor(it, value); 3114 JSObject::SetPropertyWithInterceptor(it, value);
3115 if (!maybe_result.is_null()) return maybe_result; 3115 if (!maybe_result.is_null()) return maybe_result;
3116 if (it->isolate()->has_pending_exception()) return maybe_result; 3116 if (it->isolate()->has_pending_exception()) return maybe_result;
3117 } else { 3117 } else {
3118 Maybe<PropertyAttributes> maybe_attributes = 3118 Maybe<PropertyAttributes> maybe_attributes =
3119 JSObject::GetPropertyAttributesWithInterceptor( 3119 JSObject::GetPropertyAttributesWithInterceptor(
3120 it->GetHolder<JSObject>(), it->GetReceiver(), it->name()); 3120 it->GetHolder<JSObject>(), it->GetReceiver(), it->name());
3121 if (!maybe_attributes.has_value) return MaybeHandle<Object>(); 3121 if (!maybe_attributes.IsJust()) return MaybeHandle<Object>();
3122 done = maybe_attributes.value != ABSENT; 3122 done = maybe_attributes.FromJust() != ABSENT;
3123 if (done && (maybe_attributes.value & READ_ONLY) != 0) { 3123 if (done && (maybe_attributes.FromJust() & READ_ONLY) != 0) {
3124 return WriteToReadOnlyProperty(it, value, language_mode); 3124 return WriteToReadOnlyProperty(it, value, language_mode);
3125 } 3125 }
3126 } 3126 }
3127 break; 3127 break;
3128 3128
3129 case LookupIterator::ACCESSOR: 3129 case LookupIterator::ACCESSOR:
3130 if (it->property_details().IsReadOnly()) { 3130 if (it->property_details().IsReadOnly()) {
3131 return WriteToReadOnlyProperty(it, value, language_mode); 3131 return WriteToReadOnlyProperty(it, value, language_mode);
3132 } 3132 }
3133 return SetPropertyWithAccessor(it->GetReceiver(), it->name(), value, 3133 return SetPropertyWithAccessor(it->GetReceiver(), it->name(), value,
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
4155 void JSObject::AddProperty(Handle<JSObject> object, Handle<Name> name, 4155 void JSObject::AddProperty(Handle<JSObject> object, Handle<Name> name,
4156 Handle<Object> value, 4156 Handle<Object> value,
4157 PropertyAttributes attributes) { 4157 PropertyAttributes attributes) {
4158 LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR); 4158 LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
4159 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state()); 4159 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state());
4160 #ifdef DEBUG 4160 #ifdef DEBUG
4161 uint32_t index; 4161 uint32_t index;
4162 DCHECK(!object->IsJSProxy()); 4162 DCHECK(!object->IsJSProxy());
4163 DCHECK(!name->AsArrayIndex(&index)); 4163 DCHECK(!name->AsArrayIndex(&index));
4164 Maybe<PropertyAttributes> maybe = GetPropertyAttributes(&it); 4164 Maybe<PropertyAttributes> maybe = GetPropertyAttributes(&it);
4165 DCHECK(maybe.has_value); 4165 DCHECK(maybe.IsJust());
4166 DCHECK(!it.IsFound()); 4166 DCHECK(!it.IsFound());
4167 DCHECK(object->map()->is_extensible() || 4167 DCHECK(object->map()->is_extensible() ||
4168 it.isolate()->IsInternallyUsedPropertyName(name)); 4168 it.isolate()->IsInternallyUsedPropertyName(name));
4169 #endif 4169 #endif
4170 AddDataProperty(&it, value, attributes, STRICT, 4170 AddDataProperty(&it, value, attributes, STRICT,
4171 CERTAINLY_NOT_STORE_FROM_KEYED).Check(); 4171 CERTAINLY_NOT_STORE_FROM_KEYED).Check();
4172 } 4172 }
4173 4173
4174 4174
4175 // Reconfigures a property to a data property with attributes, even if it is not 4175 // Reconfigures a property to a data property with attributes, even if it is not
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
4350 case LookupIterator::NOT_FOUND: 4350 case LookupIterator::NOT_FOUND:
4351 case LookupIterator::TRANSITION: 4351 case LookupIterator::TRANSITION:
4352 UNREACHABLE(); 4352 UNREACHABLE();
4353 case LookupIterator::JSPROXY: 4353 case LookupIterator::JSPROXY:
4354 return JSProxy::GetPropertyAttributesWithHandler( 4354 return JSProxy::GetPropertyAttributesWithHandler(
4355 it->GetHolder<JSProxy>(), it->GetReceiver(), it->name()); 4355 it->GetHolder<JSProxy>(), it->GetReceiver(), it->name());
4356 case LookupIterator::INTERCEPTOR: { 4356 case LookupIterator::INTERCEPTOR: {
4357 Maybe<PropertyAttributes> result = 4357 Maybe<PropertyAttributes> result =
4358 JSObject::GetPropertyAttributesWithInterceptor( 4358 JSObject::GetPropertyAttributesWithInterceptor(
4359 it->GetHolder<JSObject>(), it->GetReceiver(), it->name()); 4359 it->GetHolder<JSObject>(), it->GetReceiver(), it->name());
4360 if (!result.has_value) return result; 4360 if (!result.IsJust()) return result;
4361 if (result.value != ABSENT) return result; 4361 if (result.FromJust() != ABSENT) return result;
4362 break; 4362 break;
4363 } 4363 }
4364 case LookupIterator::ACCESS_CHECK: 4364 case LookupIterator::ACCESS_CHECK:
4365 if (it->HasAccess()) break; 4365 if (it->HasAccess()) break;
4366 return JSObject::GetPropertyAttributesWithFailedAccessCheck(it); 4366 return JSObject::GetPropertyAttributesWithFailedAccessCheck(it);
4367 case LookupIterator::ACCESSOR: 4367 case LookupIterator::ACCESSOR:
4368 case LookupIterator::DATA: 4368 case LookupIterator::DATA:
4369 return Just(it->property_details().attributes()); 4369 return Just(it->property_details().attributes());
4370 } 4370 }
4371 } 4371 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4411 bool check_prototype) { 4411 bool check_prototype) {
4412 Isolate* isolate = object->GetIsolate(); 4412 Isolate* isolate = object->GetIsolate();
4413 HandleScope scope(isolate); 4413 HandleScope scope(isolate);
4414 4414
4415 // Make sure that the top context does not change when doing 4415 // Make sure that the top context does not change when doing
4416 // callbacks or interceptor calls. 4416 // callbacks or interceptor calls.
4417 AssertNoContextChange ncc(isolate); 4417 AssertNoContextChange ncc(isolate);
4418 4418
4419 Maybe<PropertyAttributes> from_interceptor = 4419 Maybe<PropertyAttributes> from_interceptor =
4420 GetElementAttributeFromInterceptor(object, receiver, index); 4420 GetElementAttributeFromInterceptor(object, receiver, index);
4421 if (!from_interceptor.has_value) return Nothing<PropertyAttributes>(); 4421 if (!from_interceptor.IsJust()) return Nothing<PropertyAttributes>();
4422 if (from_interceptor.value != ABSENT) return Just(from_interceptor.value); 4422 if (from_interceptor.FromJust() != ABSENT)
4423 return Just(from_interceptor.FromJust());
4423 4424
4424 return GetElementAttributeWithoutInterceptor(object, receiver, index, 4425 return GetElementAttributeWithoutInterceptor(object, receiver, index,
4425 check_prototype); 4426 check_prototype);
4426 } 4427 }
4427 4428
4428 4429
4429 Maybe<PropertyAttributes> JSObject::GetElementAttributeFromInterceptor( 4430 Maybe<PropertyAttributes> JSObject::GetElementAttributeFromInterceptor(
4430 Handle<JSObject> object, Handle<Object> receiver, uint32_t index) { 4431 Handle<JSObject> object, Handle<Object> receiver, uint32_t index) {
4431 Isolate* isolate = object->GetIsolate(); 4432 Isolate* isolate = object->GetIsolate();
4432 AssertNoContextChange ncc(isolate); 4433 AssertNoContextChange ncc(isolate);
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
5079 bool was_present = false; 5080 bool was_present = false;
5080 ObjectHashTable::Remove(hashtable, key, &was_present); 5081 ObjectHashTable::Remove(hashtable, key, &was_present);
5081 } 5082 }
5082 5083
5083 5084
5084 bool JSObject::HasHiddenProperties(Handle<JSObject> object) { 5085 bool JSObject::HasHiddenProperties(Handle<JSObject> object) {
5085 Handle<Name> hidden = object->GetIsolate()->factory()->hidden_string(); 5086 Handle<Name> hidden = object->GetIsolate()->factory()->hidden_string();
5086 LookupIterator it(object, hidden, LookupIterator::OWN_SKIP_INTERCEPTOR); 5087 LookupIterator it(object, hidden, LookupIterator::OWN_SKIP_INTERCEPTOR);
5087 Maybe<PropertyAttributes> maybe = GetPropertyAttributes(&it); 5088 Maybe<PropertyAttributes> maybe = GetPropertyAttributes(&it);
5088 // Cannot get an exception since the hidden_string isn't accessible to JS. 5089 // Cannot get an exception since the hidden_string isn't accessible to JS.
5089 DCHECK(maybe.has_value); 5090 DCHECK(maybe.IsJust());
5090 return maybe.value != ABSENT; 5091 return maybe.FromJust() != ABSENT;
5091 } 5092 }
5092 5093
5093 5094
5094 Object* JSObject::GetHiddenPropertiesHashTable() { 5095 Object* JSObject::GetHiddenPropertiesHashTable() {
5095 DCHECK(!IsJSGlobalProxy()); 5096 DCHECK(!IsJSGlobalProxy());
5096 if (HasFastProperties()) { 5097 if (HasFastProperties()) {
5097 // If the object has fast properties, check whether the first slot 5098 // If the object has fast properties, check whether the first slot
5098 // in the descriptor array matches the hidden string. Since the 5099 // in the descriptor array matches the hidden string. Since the
5099 // hidden strings hash code is zero (and no other name has hash 5100 // hidden strings hash code is zero (and no other name has hash
5100 // code zero) it will always occupy the first entry if present. 5101 // code zero) it will always occupy the first entry if present.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
5255 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); 5256 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject());
5256 return DeleteElement( 5257 return DeleteElement(
5257 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index, 5258 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index,
5258 language_mode); 5259 language_mode);
5259 } 5260 }
5260 5261
5261 Handle<Object> old_value; 5262 Handle<Object> old_value;
5262 bool should_enqueue_change_record = false; 5263 bool should_enqueue_change_record = false;
5263 if (object->map()->is_observed()) { 5264 if (object->map()->is_observed()) {
5264 Maybe<bool> maybe = HasOwnElement(object, index); 5265 Maybe<bool> maybe = HasOwnElement(object, index);
5265 if (!maybe.has_value) return MaybeHandle<Object>(); 5266 if (!maybe.IsJust()) return MaybeHandle<Object>();
5266 should_enqueue_change_record = maybe.value; 5267 should_enqueue_change_record = maybe.FromJust();
5267 if (should_enqueue_change_record) { 5268 if (should_enqueue_change_record) {
5268 if (!GetOwnElementAccessorPair(object, index).is_null()) { 5269 if (!GetOwnElementAccessorPair(object, index).is_null()) {
5269 old_value = Handle<Object>::cast(factory->the_hole_value()); 5270 old_value = Handle<Object>::cast(factory->the_hole_value());
5270 } else { 5271 } else {
5271 old_value = Object::GetElement( 5272 old_value = Object::GetElement(
5272 isolate, object, index).ToHandleChecked(); 5273 isolate, object, index).ToHandleChecked();
5273 } 5274 }
5274 } 5275 }
5275 } 5276 }
5276 5277
5277 // Skip interceptor if forcing deletion. 5278 // Skip interceptor if forcing deletion.
5278 MaybeHandle<Object> maybe_result; 5279 MaybeHandle<Object> maybe_result;
5279 if (object->HasIndexedInterceptor()) { 5280 if (object->HasIndexedInterceptor()) {
5280 maybe_result = DeleteElementWithInterceptor(object, index); 5281 maybe_result = DeleteElementWithInterceptor(object, index);
5281 } else { 5282 } else {
5282 maybe_result = 5283 maybe_result =
5283 object->GetElementsAccessor()->Delete(object, index, language_mode); 5284 object->GetElementsAccessor()->Delete(object, index, language_mode);
5284 } 5285 }
5285 Handle<Object> result; 5286 Handle<Object> result;
5286 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, maybe_result, Object); 5287 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, maybe_result, Object);
5287 5288
5288 if (should_enqueue_change_record) { 5289 if (should_enqueue_change_record) {
5289 Maybe<bool> maybe = HasOwnElement(object, index); 5290 Maybe<bool> maybe = HasOwnElement(object, index);
5290 if (!maybe.has_value) return MaybeHandle<Object>(); 5291 if (!maybe.IsJust()) return MaybeHandle<Object>();
5291 if (!maybe.value) { 5292 if (!maybe.FromJust()) {
5292 Handle<String> name = factory->Uint32ToString(index); 5293 Handle<String> name = factory->Uint32ToString(index);
5293 RETURN_ON_EXCEPTION( 5294 RETURN_ON_EXCEPTION(
5294 isolate, EnqueueChangeRecord(object, "delete", name, old_value), 5295 isolate, EnqueueChangeRecord(object, "delete", name, old_value),
5295 Object); 5296 Object);
5296 } 5297 }
5297 } 5298 }
5298 5299
5299 return result; 5300 return result;
5300 } 5301 }
5301 5302
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
5932 } 5933 }
5933 } else { 5934 } else {
5934 Handle<FixedArray> names = 5935 Handle<FixedArray> names =
5935 isolate->factory()->NewFixedArray(copy->NumberOfOwnProperties()); 5936 isolate->factory()->NewFixedArray(copy->NumberOfOwnProperties());
5936 copy->GetOwnPropertyNames(*names, 0); 5937 copy->GetOwnPropertyNames(*names, 0);
5937 for (int i = 0; i < names->length(); i++) { 5938 for (int i = 0; i < names->length(); i++) {
5938 DCHECK(names->get(i)->IsString()); 5939 DCHECK(names->get(i)->IsString());
5939 Handle<String> key_string(String::cast(names->get(i))); 5940 Handle<String> key_string(String::cast(names->get(i)));
5940 Maybe<PropertyAttributes> maybe = 5941 Maybe<PropertyAttributes> maybe =
5941 JSReceiver::GetOwnPropertyAttributes(copy, key_string); 5942 JSReceiver::GetOwnPropertyAttributes(copy, key_string);
5942 DCHECK(maybe.has_value); 5943 DCHECK(maybe.IsJust());
5943 PropertyAttributes attributes = maybe.value; 5944 PropertyAttributes attributes = maybe.FromJust();
5944 // Only deep copy fields from the object literal expression. 5945 // Only deep copy fields from the object literal expression.
5945 // In particular, don't try to copy the length attribute of 5946 // In particular, don't try to copy the length attribute of
5946 // an array. 5947 // an array.
5947 if (attributes != NONE) continue; 5948 if (attributes != NONE) continue;
5948 Handle<Object> value = 5949 Handle<Object> value =
5949 Object::GetProperty(copy, key_string).ToHandleChecked(); 5950 Object::GetProperty(copy, key_string).ToHandleChecked();
5950 if (value->IsJSObject()) { 5951 if (value->IsJSObject()) {
5951 Handle<JSObject> result; 5952 Handle<JSObject> result;
5952 ASSIGN_RETURN_ON_EXCEPTION( 5953 ASSIGN_RETURN_ON_EXCEPTION(
5953 isolate, result, 5954 isolate, result,
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
6592 6593
6593 Handle<Object> old_value = isolate->factory()->the_hole_value(); 6594 Handle<Object> old_value = isolate->factory()->the_hole_value();
6594 bool is_observed = object->map()->is_observed() && 6595 bool is_observed = object->map()->is_observed() &&
6595 !isolate->IsInternallyUsedPropertyName(name); 6596 !isolate->IsInternallyUsedPropertyName(name);
6596 bool preexists = false; 6597 bool preexists = false;
6597 if (is_observed) { 6598 if (is_observed) {
6598 if (is_element) { 6599 if (is_element) {
6599 Maybe<bool> maybe = HasOwnElement(object, index); 6600 Maybe<bool> maybe = HasOwnElement(object, index);
6600 // Workaround for a GCC 4.4.3 bug which leads to "‘preexists’ may be used 6601 // Workaround for a GCC 4.4.3 bug which leads to "‘preexists’ may be used
6601 // uninitialized in this function". 6602 // uninitialized in this function".
6602 if (!maybe.has_value) { 6603 if (!maybe.IsJust()) {
6603 DCHECK(false); 6604 DCHECK(false);
6604 return isolate->factory()->undefined_value(); 6605 return isolate->factory()->undefined_value();
6605 } 6606 }
6606 preexists = maybe.value; 6607 preexists = maybe.FromJust();
6607 if (preexists && GetOwnElementAccessorPair(object, index).is_null()) { 6608 if (preexists && GetOwnElementAccessorPair(object, index).is_null()) {
6608 old_value = 6609 old_value =
6609 Object::GetElement(isolate, object, index).ToHandleChecked(); 6610 Object::GetElement(isolate, object, index).ToHandleChecked();
6610 } 6611 }
6611 } else { 6612 } else {
6612 LookupIterator it(object, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); 6613 LookupIterator it(object, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
6613 CHECK(GetPropertyAttributes(&it).has_value); 6614 CHECK(GetPropertyAttributes(&it).IsJust());
6614 preexists = it.IsFound(); 6615 preexists = it.IsFound();
6615 if (preexists && (it.state() == LookupIterator::DATA || 6616 if (preexists && (it.state() == LookupIterator::DATA ||
6616 it.GetAccessors()->IsAccessorInfo())) { 6617 it.GetAccessors()->IsAccessorInfo())) {
6617 old_value = GetProperty(&it).ToHandleChecked(); 6618 old_value = GetProperty(&it).ToHandleChecked();
6618 } 6619 }
6619 } 6620 }
6620 } 6621 }
6621 6622
6622 if (is_element) { 6623 if (is_element) {
6623 DefineElementAccessor(object, index, getter, setter, attributes); 6624 DefineElementAccessor(object, index, getter, setter, attributes);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
6709 break; 6710 break;
6710 case SLOPPY_ARGUMENTS_ELEMENTS: 6711 case SLOPPY_ARGUMENTS_ELEMENTS:
6711 UNIMPLEMENTED(); 6712 UNIMPLEMENTED();
6712 break; 6713 break;
6713 } 6714 }
6714 6715
6715 SetElementCallback(object, index, info, info->property_attributes()); 6716 SetElementCallback(object, index, info, info->property_attributes());
6716 } else { 6717 } else {
6717 // Lookup the name. 6718 // Lookup the name.
6718 LookupIterator it(object, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); 6719 LookupIterator it(object, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
6719 CHECK(GetPropertyAttributes(&it).has_value); 6720 CHECK(GetPropertyAttributes(&it).IsJust());
6720 // ES5 forbids turning a property into an accessor if it's not 6721 // ES5 forbids turning a property into an accessor if it's not
6721 // configurable. See 8.6.1 (Table 5). 6722 // configurable. See 8.6.1 (Table 5).
6722 if (it.IsFound() && (it.IsReadOnly() || !it.IsConfigurable())) { 6723 if (it.IsFound() && (it.IsReadOnly() || !it.IsConfigurable())) {
6723 return factory->undefined_value(); 6724 return factory->undefined_value();
6724 } 6725 }
6725 6726
6726 SetPropertyCallback(object, name, info, info->property_attributes()); 6727 SetPropertyCallback(object, name, info, info->property_attributes());
6727 } 6728 }
6728 6729
6729 return object; 6730 return object;
(...skipping 5067 matching lines...) Expand 10 before | Expand all | Expand 10 after
11797 // Returns false if the passed-in index is marked non-configurable, 11798 // Returns false if the passed-in index is marked non-configurable,
11798 // which will cause the ES5 truncation operation to halt, and thus 11799 // which will cause the ES5 truncation operation to halt, and thus
11799 // no further old values need be collected. 11800 // no further old values need be collected.
11800 static bool GetOldValue(Isolate* isolate, 11801 static bool GetOldValue(Isolate* isolate,
11801 Handle<JSObject> object, 11802 Handle<JSObject> object,
11802 uint32_t index, 11803 uint32_t index,
11803 List<Handle<Object> >* old_values, 11804 List<Handle<Object> >* old_values,
11804 List<uint32_t>* indices) { 11805 List<uint32_t>* indices) {
11805 Maybe<PropertyAttributes> maybe = 11806 Maybe<PropertyAttributes> maybe =
11806 JSReceiver::GetOwnElementAttribute(object, index); 11807 JSReceiver::GetOwnElementAttribute(object, index);
11807 DCHECK(maybe.has_value); 11808 DCHECK(maybe.IsJust());
11808 DCHECK(maybe.value != ABSENT); 11809 DCHECK(maybe.FromJust() != ABSENT);
11809 if (maybe.value == DONT_DELETE) return false; 11810 if (maybe.FromJust() == DONT_DELETE) return false;
11810 Handle<Object> value; 11811 Handle<Object> value;
11811 if (!JSObject::GetOwnElementAccessorPair(object, index).is_null()) { 11812 if (!JSObject::GetOwnElementAccessorPair(object, index).is_null()) {
11812 value = Handle<Object>::cast(isolate->factory()->the_hole_value()); 11813 value = Handle<Object>::cast(isolate->factory()->the_hole_value());
11813 } else { 11814 } else {
11814 value = Object::GetElement(isolate, object, index).ToHandleChecked(); 11815 value = Object::GetElement(isolate, object, index).ToHandleChecked();
11815 } 11816 }
11816 old_values->Add(value); 11817 old_values->Add(value);
11817 indices->Add(index); 11818 indices->Add(index);
11818 return true; 11819 return true;
11819 } 11820 }
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
13079 ? SetElementWithInterceptor(object, index, value, attributes, 13080 ? SetElementWithInterceptor(object, index, value, attributes,
13080 language_mode, check_prototype, 13081 language_mode, check_prototype,
13081 set_mode) 13082 set_mode)
13082 : SetElementWithoutInterceptor(object, index, value, attributes, 13083 : SetElementWithoutInterceptor(object, index, value, attributes,
13083 language_mode, check_prototype, 13084 language_mode, check_prototype,
13084 set_mode); 13085 set_mode);
13085 } 13086 }
13086 13087
13087 Maybe<PropertyAttributes> maybe = 13088 Maybe<PropertyAttributes> maybe =
13088 JSReceiver::GetOwnElementAttribute(object, index); 13089 JSReceiver::GetOwnElementAttribute(object, index);
13089 if (!maybe.has_value) return MaybeHandle<Object>(); 13090 if (!maybe.IsJust()) return MaybeHandle<Object>();
13090 PropertyAttributes old_attributes = maybe.value; 13091 PropertyAttributes old_attributes = maybe.FromJust();
13091 13092
13092 Handle<Object> old_value = isolate->factory()->the_hole_value(); 13093 Handle<Object> old_value = isolate->factory()->the_hole_value();
13093 Handle<Object> old_length_handle; 13094 Handle<Object> old_length_handle;
13094 Handle<Object> new_length_handle; 13095 Handle<Object> new_length_handle;
13095 13096
13096 if (old_attributes != ABSENT) { 13097 if (old_attributes != ABSENT) {
13097 if (GetOwnElementAccessorPair(object, index).is_null()) { 13098 if (GetOwnElementAccessorPair(object, index).is_null()) {
13098 old_value = Object::GetElement(isolate, object, index).ToHandleChecked(); 13099 old_value = Object::GetElement(isolate, object, index).ToHandleChecked();
13099 } 13100 }
13100 } else if (object->IsJSArray()) { 13101 } else if (object->IsJSArray()) {
13101 // Store old array length in case adding an element grows the array. 13102 // Store old array length in case adding an element grows the array.
13102 old_length_handle = handle(Handle<JSArray>::cast(object)->length(), 13103 old_length_handle = handle(Handle<JSArray>::cast(object)->length(),
13103 isolate); 13104 isolate);
13104 } 13105 }
13105 13106
13106 // Check for lookup interceptor 13107 // Check for lookup interceptor
13107 Handle<Object> result; 13108 Handle<Object> result;
13108 ASSIGN_RETURN_ON_EXCEPTION( 13109 ASSIGN_RETURN_ON_EXCEPTION(
13109 isolate, result, 13110 isolate, result,
13110 object->HasIndexedInterceptor() 13111 object->HasIndexedInterceptor()
13111 ? SetElementWithInterceptor(object, index, value, attributes, 13112 ? SetElementWithInterceptor(object, index, value, attributes,
13112 language_mode, check_prototype, set_mode) 13113 language_mode, check_prototype, set_mode)
13113 : SetElementWithoutInterceptor(object, index, value, attributes, 13114 : SetElementWithoutInterceptor(object, index, value, attributes,
13114 language_mode, check_prototype, 13115 language_mode, check_prototype,
13115 set_mode), 13116 set_mode),
13116 Object); 13117 Object);
13117 13118
13118 Handle<String> name = isolate->factory()->Uint32ToString(index); 13119 Handle<String> name = isolate->factory()->Uint32ToString(index);
13119 maybe = GetOwnElementAttribute(object, index); 13120 maybe = GetOwnElementAttribute(object, index);
13120 if (!maybe.has_value) return MaybeHandle<Object>(); 13121 if (!maybe.IsJust()) return MaybeHandle<Object>();
13121 PropertyAttributes new_attributes = maybe.value; 13122 PropertyAttributes new_attributes = maybe.FromJust();
13122 13123
13123 if (old_attributes == ABSENT) { 13124 if (old_attributes == ABSENT) {
13124 if (object->IsJSArray() && 13125 if (object->IsJSArray() &&
13125 !old_length_handle->SameValue( 13126 !old_length_handle->SameValue(
13126 Handle<JSArray>::cast(object)->length())) { 13127 Handle<JSArray>::cast(object)->length())) {
13127 new_length_handle = handle(Handle<JSArray>::cast(object)->length(), 13128 new_length_handle = handle(Handle<JSArray>::cast(object)->length(),
13128 isolate); 13129 isolate);
13129 uint32_t old_length = 0; 13130 uint32_t old_length = 0;
13130 uint32_t new_length = 0; 13131 uint32_t new_length = 0;
13131 CHECK(old_length_handle->ToArrayIndex(&old_length)); 13132 CHECK(old_length_handle->ToArrayIndex(&old_length));
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
13908 v8::Utils::OpenHandle(*result)->HasSloppyArgumentsElements()); 13909 v8::Utils::OpenHandle(*result)->HasSloppyArgumentsElements());
13909 // Rebox before returning. 13910 // Rebox before returning.
13910 return handle(*v8::Utils::OpenHandle(*result), isolate); 13911 return handle(*v8::Utils::OpenHandle(*result), isolate);
13911 } 13912 }
13912 13913
13913 13914
13914 Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object, 13915 Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object,
13915 Handle<Name> key) { 13916 Handle<Name> key) {
13916 LookupIterator it(object, key, LookupIterator::OWN_SKIP_INTERCEPTOR); 13917 LookupIterator it(object, key, LookupIterator::OWN_SKIP_INTERCEPTOR);
13917 Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it); 13918 Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it);
13918 if (!maybe_result.has_value) return Nothing<bool>(); 13919 if (!maybe_result.IsJust()) return Nothing<bool>();
13919 return Just(it.IsFound()); 13920 return Just(it.IsFound());
13920 } 13921 }
13921 13922
13922 13923
13923 Maybe<bool> JSObject::HasRealElementProperty(Handle<JSObject> object, 13924 Maybe<bool> JSObject::HasRealElementProperty(Handle<JSObject> object,
13924 uint32_t index) { 13925 uint32_t index) {
13925 Isolate* isolate = object->GetIsolate(); 13926 Isolate* isolate = object->GetIsolate();
13926 HandleScope scope(isolate); 13927 HandleScope scope(isolate);
13927 // Check access rights if needed. 13928 // Check access rights if needed.
13928 if (object->IsAccessCheckNeeded()) { 13929 if (object->IsAccessCheckNeeded()) {
13929 if (!isolate->MayAccess(object)) { 13930 if (!isolate->MayAccess(object)) {
13930 isolate->ReportFailedAccessCheck(object); 13931 isolate->ReportFailedAccessCheck(object);
13931 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); 13932 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>());
13932 return Just(false); 13933 return Just(false);
13933 } 13934 }
13934 } 13935 }
13935 13936
13936 if (object->IsJSGlobalProxy()) { 13937 if (object->IsJSGlobalProxy()) {
13937 HandleScope scope(isolate); 13938 HandleScope scope(isolate);
13938 PrototypeIterator iter(isolate, object); 13939 PrototypeIterator iter(isolate, object);
13939 if (iter.IsAtEnd()) return Just(false); 13940 if (iter.IsAtEnd()) return Just(false);
13940 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); 13941 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject());
13941 return HasRealElementProperty( 13942 return HasRealElementProperty(
13942 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index); 13943 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index);
13943 } 13944 }
13944 13945
13945 Maybe<PropertyAttributes> result = 13946 Maybe<PropertyAttributes> result =
13946 GetElementAttributeWithoutInterceptor(object, object, index, false); 13947 GetElementAttributeWithoutInterceptor(object, object, index, false);
13947 return result.has_value ? Just(result.value != ABSENT) : Nothing<bool>(); 13948 return result.IsJust() ? Just(result.FromJust() != ABSENT) : Nothing<bool>();
13948 } 13949 }
13949 13950
13950 13951
13951 Maybe<bool> JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object, 13952 Maybe<bool> JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object,
13952 Handle<Name> key) { 13953 Handle<Name> key) {
13953 LookupIterator it(object, key, LookupIterator::OWN_SKIP_INTERCEPTOR); 13954 LookupIterator it(object, key, LookupIterator::OWN_SKIP_INTERCEPTOR);
13954 Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it); 13955 Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it);
13955 return maybe_result.has_value ? Just(it.state() == LookupIterator::ACCESSOR) 13956 return maybe_result.IsJust() ? Just(it.state() == LookupIterator::ACCESSOR)
13956 : Nothing<bool>(); 13957 : Nothing<bool>();
13957 } 13958 }
13958 13959
13959 13960
13960 int JSObject::NumberOfOwnProperties(PropertyAttributes filter) { 13961 int JSObject::NumberOfOwnProperties(PropertyAttributes filter) {
13961 if (HasFastProperties()) { 13962 if (HasFastProperties()) {
13962 Map* map = this->map(); 13963 Map* map = this->map();
13963 if (filter == NONE) return map->NumberOfOwnDescriptors(); 13964 if (filter == NONE) return map->NumberOfOwnDescriptors();
13964 if (filter & DONT_ENUM) { 13965 if (filter & DONT_ENUM) {
13965 int result = map->EnumLength(); 13966 int result = map->EnumLength();
13966 if (result != kInvalidEnumCacheSentinel) return result; 13967 if (result != kInvalidEnumCacheSentinel) return result;
(...skipping 3196 matching lines...) Expand 10 before | Expand all | Expand 10 after
17163 CompilationInfo* info) { 17164 CompilationInfo* info) {
17164 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( 17165 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo(
17165 handle(cell->dependent_code(), info->isolate()), 17166 handle(cell->dependent_code(), info->isolate()),
17166 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); 17167 DependentCode::kPropertyCellChangedGroup, info->object_wrapper());
17167 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 17168 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
17168 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 17169 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
17169 cell, info->zone()); 17170 cell, info->zone());
17170 } 17171 }
17171 17172
17172 } } // namespace v8::internal 17173 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic/ic-state.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698