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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 if ((from_interceptor.value & READ_ONLY) != 0) { | 724 if ((from_interceptor.value & READ_ONLY) != 0) { |
725 return WriteToReadOnlyElement(isolate, receiver, index, value, | 725 return WriteToReadOnlyElement(isolate, receiver, index, value, |
726 language_mode); | 726 language_mode); |
727 } | 727 } |
728 done = from_interceptor.value != ABSENT; | 728 done = from_interceptor.value != ABSENT; |
729 } | 729 } |
730 | 730 |
731 if (!done && | 731 if (!done && |
732 js_object->elements() != isolate->heap()->empty_fixed_array()) { | 732 js_object->elements() != isolate->heap()->empty_fixed_array()) { |
733 ElementsAccessor* accessor = js_object->GetElementsAccessor(); | 733 ElementsAccessor* accessor = js_object->GetElementsAccessor(); |
734 PropertyAttributes attrs = | 734 PropertyAttributes attrs = accessor->GetAttributes(js_object, index); |
735 accessor->GetAttributes(receiver, js_object, index); | |
736 if ((attrs & READ_ONLY) != 0) { | 735 if ((attrs & READ_ONLY) != 0) { |
737 return WriteToReadOnlyElement(isolate, receiver, index, value, | 736 return WriteToReadOnlyElement(isolate, receiver, index, value, |
738 language_mode); | 737 language_mode); |
739 } | 738 } |
740 Handle<AccessorPair> accessor_pair; | 739 Handle<AccessorPair> pair; |
741 if (accessor->GetAccessorPair(receiver, js_object, index) | 740 if (accessor->GetAccessorPair(js_object, index).ToHandle(&pair)) { |
742 .ToHandle(&accessor_pair)) { | 741 return JSObject::SetElementWithCallback(receiver, pair, index, value, |
743 return JSObject::SetElementWithCallback( | 742 js_object, language_mode); |
744 receiver, accessor_pair, index, value, js_object, language_mode); | |
745 } else { | 743 } else { |
746 done = attrs != ABSENT; | 744 done = attrs != ABSENT; |
747 } | 745 } |
748 } | 746 } |
749 } | 747 } |
750 | 748 |
751 if (!receiver->IsJSObject()) { | 749 if (!receiver->IsJSObject()) { |
752 return WriteToReadOnlyElement(isolate, receiver, index, value, | 750 return WriteToReadOnlyElement(isolate, receiver, index, value, |
753 language_mode); | 751 language_mode); |
754 } | 752 } |
755 Handle<JSObject> target = Handle<JSObject>::cast(receiver); | 753 Handle<JSObject> target = Handle<JSObject>::cast(receiver); |
756 ElementsAccessor* accessor = target->GetElementsAccessor(); | 754 ElementsAccessor* accessor = target->GetElementsAccessor(); |
757 PropertyAttributes attrs = accessor->GetAttributes(receiver, target, index); | 755 PropertyAttributes attrs = accessor->GetAttributes(target, index); |
758 if ((attrs & READ_ONLY) != 0) { | 756 if ((attrs & READ_ONLY) != 0) { |
759 return WriteToReadOnlyElement(isolate, receiver, index, value, | 757 return WriteToReadOnlyElement(isolate, receiver, index, value, |
760 language_mode); | 758 language_mode); |
761 } | 759 } |
762 PropertyAttributes new_attrs = attrs != ABSENT ? attrs : NONE; | 760 PropertyAttributes new_attrs = attrs != ABSENT ? attrs : NONE; |
763 return JSObject::SetElement(target, index, value, new_attrs, language_mode, | 761 return JSObject::SetElement(target, index, value, new_attrs, language_mode, |
764 false); | 762 false); |
765 } | 763 } |
766 | 764 |
767 | 765 |
(...skipping 3597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4365 if (!result.IsEmpty()) return maybe(NONE); | 4363 if (!result.IsEmpty()) return maybe(NONE); |
4366 } | 4364 } |
4367 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Maybe<PropertyAttributes>()); | 4365 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Maybe<PropertyAttributes>()); |
4368 return maybe(ABSENT); | 4366 return maybe(ABSENT); |
4369 } | 4367 } |
4370 | 4368 |
4371 | 4369 |
4372 Maybe<PropertyAttributes> JSObject::GetElementAttributeWithoutInterceptor( | 4370 Maybe<PropertyAttributes> JSObject::GetElementAttributeWithoutInterceptor( |
4373 Handle<JSObject> object, Handle<JSReceiver> receiver, uint32_t index, | 4371 Handle<JSObject> object, Handle<JSReceiver> receiver, uint32_t index, |
4374 bool check_prototype) { | 4372 bool check_prototype) { |
4375 PropertyAttributes attr = object->GetElementsAccessor()->GetAttributes( | 4373 PropertyAttributes attr = |
4376 receiver, object, index); | 4374 object->GetElementsAccessor()->GetAttributes(object, index); |
4377 if (attr != ABSENT) return maybe(attr); | 4375 if (attr != ABSENT) return maybe(attr); |
4378 | 4376 |
4379 // Handle [] on String objects. | 4377 // Handle [] on String objects. |
4380 if (object->IsStringObjectWithCharacterAt(index)) { | 4378 if (object->IsStringObjectWithCharacterAt(index)) { |
4381 return maybe(static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE)); | 4379 return maybe(static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE)); |
4382 } | 4380 } |
4383 | 4381 |
4384 if (!check_prototype) return maybe(ABSENT); | 4382 if (!check_prototype) return maybe(ABSENT); |
4385 | 4383 |
4386 PrototypeIterator iter(object->GetIsolate(), object); | 4384 PrototypeIterator iter(object->GetIsolate(), object); |
(...skipping 8131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12518 PrototypeIterator iter(object->GetIsolate(), object); | 12516 PrototypeIterator iter(object->GetIsolate(), object); |
12519 if (iter.IsAtEnd()) return MaybeHandle<AccessorPair>(); | 12517 if (iter.IsAtEnd()) return MaybeHandle<AccessorPair>(); |
12520 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); | 12518 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); |
12521 return GetOwnElementAccessorPair( | 12519 return GetOwnElementAccessorPair( |
12522 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index); | 12520 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index); |
12523 } | 12521 } |
12524 | 12522 |
12525 // Check for lookup interceptor. | 12523 // Check for lookup interceptor. |
12526 if (object->HasIndexedInterceptor()) return MaybeHandle<AccessorPair>(); | 12524 if (object->HasIndexedInterceptor()) return MaybeHandle<AccessorPair>(); |
12527 | 12525 |
12528 return object->GetElementsAccessor()->GetAccessorPair(object, object, index); | 12526 return object->GetElementsAccessor()->GetAccessorPair(object, index); |
12529 } | 12527 } |
12530 | 12528 |
12531 | 12529 |
12532 MaybeHandle<Object> JSObject::SetElementWithInterceptor( | 12530 MaybeHandle<Object> JSObject::SetElementWithInterceptor( |
12533 Handle<JSObject> object, uint32_t index, Handle<Object> value, | 12531 Handle<JSObject> object, uint32_t index, Handle<Object> value, |
12534 PropertyAttributes attributes, LanguageMode language_mode, | 12532 PropertyAttributes attributes, LanguageMode language_mode, |
12535 bool check_prototype, SetPropertyMode set_mode) { | 12533 bool check_prototype, SetPropertyMode set_mode) { |
12536 Isolate* isolate = object->GetIsolate(); | 12534 Isolate* isolate = object->GetIsolate(); |
12537 | 12535 |
12538 // Make sure that the top context does not change when doing | 12536 // Make sure that the top context does not change when doing |
(...skipping 4663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17202 CompilationInfo* info) { | 17200 CompilationInfo* info) { |
17203 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( | 17201 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( |
17204 handle(cell->dependent_code(), info->isolate()), | 17202 handle(cell->dependent_code(), info->isolate()), |
17205 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); | 17203 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); |
17206 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 17204 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
17207 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 17205 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
17208 cell, info->zone()); | 17206 cell, info->zone()); |
17209 } | 17207 } |
17210 | 17208 |
17211 } } // namespace v8::internal | 17209 } } // namespace v8::internal |
OLD | NEW |