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 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
795 js_object->GetElementsAccessor()->Get(receiver, js_object, index), | 795 js_object->GetElementsAccessor()->Get(receiver, js_object, index), |
796 Object); | 796 Object); |
797 if (!result->IsTheHole()) return result; | 797 if (!result->IsTheHole()) return result; |
798 } | 798 } |
799 } | 799 } |
800 | 800 |
801 return isolate->factory()->undefined_value(); | 801 return isolate->factory()->undefined_value(); |
802 } | 802 } |
803 | 803 |
804 | 804 |
805 MaybeHandle<Object> Object::SetElementWithReceiver( | |
806 Isolate* isolate, Handle<Object> object, Handle<Object> receiver, | |
807 uint32_t index, Handle<Object> value, StrictMode strict_mode) { | |
808 // Iterate up the prototype chain until an element is found or the null | |
809 // prototype is encountered. | |
810 bool done = false; | |
811 for (PrototypeIterator iter(isolate, object, | |
812 object->IsJSProxy() || object->IsJSObject() | |
813 ? PrototypeIterator::START_AT_RECEIVER | |
814 : PrototypeIterator::START_AT_PROTOTYPE); | |
815 !iter.IsAtEnd() && !done; iter.Advance()) { | |
816 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { | |
817 // TODO(dslomov): implement. | |
818 isolate->ThrowIllegalOperation(); | |
819 return MaybeHandle<Object>(); | |
820 } | |
821 | |
822 Handle<JSObject> js_object = | |
823 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); | |
824 | |
825 // Check access rights if needed. | |
826 if (js_object->IsAccessCheckNeeded()) { | |
827 if (!isolate->MayIndexedAccess(js_object, index, v8::ACCESS_SET)) { | |
828 isolate->ReportFailedAccessCheck(js_object, v8::ACCESS_SET); | |
829 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | |
830 return isolate->factory()->undefined_value(); | |
831 } | |
832 } | |
833 | |
834 if (js_object->HasIndexedInterceptor()) { | |
835 Maybe<PropertyAttributes> from_interceptor = | |
836 JSObject::GetElementAttributeFromInterceptor(js_object, receiver, | |
837 index); | |
838 if (!from_interceptor.has_value) return MaybeHandle<Object>(); | |
839 if ((from_interceptor.value & READ_ONLY) != 0) { | |
840 return WriteToReadOnlyElement(isolate, receiver, index, value, | |
841 strict_mode); | |
842 } | |
843 done = from_interceptor.value != ABSENT; | |
844 } | |
845 | |
846 if (!done && | |
847 js_object->elements() != isolate->heap()->empty_fixed_array()) { | |
848 ElementsAccessor* accessor = js_object->GetElementsAccessor(); | |
849 PropertyAttributes attrs = | |
850 accessor->GetAttributes(receiver, js_object, index); | |
851 if ((attrs & READ_ONLY) != 0) { | |
852 return WriteToReadOnlyElement(isolate, receiver, index, value, | |
853 strict_mode); | |
854 } | |
855 Handle<Object> element_structure; | |
856 if (accessor->GetStructure(receiver, js_object, index) | |
Toon Verwaest
2014/10/15 08:31:28
Come to think about it, you also only want to call
| |
857 .ToHandle(&element_structure)) { | |
858 return JSObject::SetElementWithCallback( | |
859 receiver, element_structure, index, value, js_object, strict_mode); | |
860 } else { | |
861 done = attrs != ABSENT; | |
862 } | |
863 } | |
864 } | |
865 | |
866 if (!receiver->IsJSObject()) { | |
867 return WriteToReadOnlyElement(isolate, receiver, index, value, strict_mode); | |
868 } | |
869 Handle<JSObject> target = Handle<JSObject>::cast(receiver); | |
870 ElementsAccessor* accessor = target->GetElementsAccessor(); | |
871 PropertyAttributes attrs = accessor->GetAttributes(receiver, target, index); | |
872 if ((attrs & READ_ONLY) != 0) { | |
873 return WriteToReadOnlyElement(isolate, receiver, index, value, strict_mode); | |
874 } | |
875 PropertyAttributes new_attrs = attrs != ABSENT ? attrs : NONE; | |
876 return JSObject::SetElement(target, index, value, new_attrs, strict_mode, | |
877 false); | |
878 } | |
879 | |
880 | |
805 Map* Object::GetRootMap(Isolate* isolate) { | 881 Map* Object::GetRootMap(Isolate* isolate) { |
806 DisallowHeapAllocation no_alloc; | 882 DisallowHeapAllocation no_alloc; |
807 if (IsSmi()) { | 883 if (IsSmi()) { |
808 Context* context = isolate->context()->native_context(); | 884 Context* context = isolate->context()->native_context(); |
809 return context->number_function()->initial_map(); | 885 return context->number_function()->initial_map(); |
810 } | 886 } |
811 | 887 |
812 HeapObject* heap_object = HeapObject::cast(this); | 888 HeapObject* heap_object = HeapObject::cast(this); |
813 | 889 |
814 // The object is either a number, a string, a boolean, | 890 // The object is either a number, a string, a boolean, |
(...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2923 if (strict_mode != STRICT) return value; | 2999 if (strict_mode != STRICT) return value; |
2924 | 3000 |
2925 Handle<Object> args[] = {it->name(), it->GetReceiver()}; | 3001 Handle<Object> args[] = {it->name(), it->GetReceiver()}; |
2926 THROW_NEW_ERROR(it->isolate(), | 3002 THROW_NEW_ERROR(it->isolate(), |
2927 NewTypeError("strict_read_only_property", | 3003 NewTypeError("strict_read_only_property", |
2928 HandleVector(args, arraysize(args))), | 3004 HandleVector(args, arraysize(args))), |
2929 Object); | 3005 Object); |
2930 } | 3006 } |
2931 | 3007 |
2932 | 3008 |
3009 MaybeHandle<Object> Object::WriteToReadOnlyElement(Isolate* isolate, | |
3010 Handle<Object> receiver, | |
3011 uint32_t index, | |
3012 Handle<Object> value, | |
3013 StrictMode strict_mode) { | |
3014 if (strict_mode != STRICT) return value; | |
3015 | |
3016 Handle<Object> args[] = {isolate->factory()->NewNumberFromUint(index), | |
3017 receiver}; | |
3018 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property", | |
3019 HandleVector(args, arraysize(args))), | |
3020 Object); | |
3021 } | |
3022 | |
3023 | |
2933 Handle<Object> Object::SetDataProperty(LookupIterator* it, | 3024 Handle<Object> Object::SetDataProperty(LookupIterator* it, |
2934 Handle<Object> value) { | 3025 Handle<Object> value) { |
2935 // Proxies are handled on the WithHandler path. Other non-JSObjects cannot | 3026 // Proxies are handled on the WithHandler path. Other non-JSObjects cannot |
2936 // have own properties. | 3027 // have own properties. |
2937 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); | 3028 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); |
2938 | 3029 |
2939 // Store on the holder which may be hidden behind the receiver. | 3030 // Store on the holder which may be hidden behind the receiver. |
2940 DCHECK(it->HolderIsReceiverOrHiddenPrototype()); | 3031 DCHECK(it->HolderIsReceiverOrHiddenPrototype()); |
2941 | 3032 |
2942 // Old value for the observation change record. | 3033 // Old value for the observation change record. |
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4050 Maybe<PropertyAttributes> JSObject::GetElementAttributeWithInterceptor( | 4141 Maybe<PropertyAttributes> JSObject::GetElementAttributeWithInterceptor( |
4051 Handle<JSObject> object, Handle<JSReceiver> receiver, uint32_t index, | 4142 Handle<JSObject> object, Handle<JSReceiver> receiver, uint32_t index, |
4052 bool check_prototype) { | 4143 bool check_prototype) { |
4053 Isolate* isolate = object->GetIsolate(); | 4144 Isolate* isolate = object->GetIsolate(); |
4054 HandleScope scope(isolate); | 4145 HandleScope scope(isolate); |
4055 | 4146 |
4056 // Make sure that the top context does not change when doing | 4147 // Make sure that the top context does not change when doing |
4057 // callbacks or interceptor calls. | 4148 // callbacks or interceptor calls. |
4058 AssertNoContextChange ncc(isolate); | 4149 AssertNoContextChange ncc(isolate); |
4059 | 4150 |
4151 Maybe<PropertyAttributes> from_interceptor = | |
4152 GetElementAttributeFromInterceptor(object, receiver, index); | |
4153 if (!from_interceptor.has_value) return Maybe<PropertyAttributes>(); | |
4154 if (from_interceptor.value != ABSENT) return maybe(from_interceptor.value); | |
4155 | |
4156 return GetElementAttributeWithoutInterceptor(object, receiver, index, | |
4157 check_prototype); | |
4158 } | |
4159 | |
4160 | |
4161 Maybe<PropertyAttributes> JSObject::GetElementAttributeFromInterceptor( | |
4162 Handle<JSObject> object, Handle<Object> receiver, uint32_t index) { | |
4163 Isolate* isolate = object->GetIsolate(); | |
4164 AssertNoContextChange ncc(isolate); | |
4165 | |
4060 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor()); | 4166 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor()); |
4061 PropertyCallbackArguments args( | 4167 PropertyCallbackArguments args( |
4062 isolate, interceptor->data(), *receiver, *object); | 4168 isolate, interceptor->data(), *receiver, *object); |
4063 if (!interceptor->query()->IsUndefined()) { | 4169 if (!interceptor->query()->IsUndefined()) { |
4064 v8::IndexedPropertyQueryCallback query = | 4170 v8::IndexedPropertyQueryCallback query = |
4065 v8::ToCData<v8::IndexedPropertyQueryCallback>(interceptor->query()); | 4171 v8::ToCData<v8::IndexedPropertyQueryCallback>(interceptor->query()); |
4066 LOG(isolate, | 4172 LOG(isolate, |
4067 ApiIndexedPropertyAccess("interceptor-indexed-has", *object, index)); | 4173 ApiIndexedPropertyAccess("interceptor-indexed-has", *object, index)); |
4068 v8::Handle<v8::Integer> result = args.Call(query, index); | 4174 v8::Handle<v8::Integer> result = args.Call(query, index); |
4069 if (!result.IsEmpty()) | 4175 if (!result.IsEmpty()) |
4070 return maybe(static_cast<PropertyAttributes>(result->Int32Value())); | 4176 return maybe(static_cast<PropertyAttributes>(result->Int32Value())); |
4071 } else if (!interceptor->getter()->IsUndefined()) { | 4177 } else if (!interceptor->getter()->IsUndefined()) { |
4072 v8::IndexedPropertyGetterCallback getter = | 4178 v8::IndexedPropertyGetterCallback getter = |
4073 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter()); | 4179 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter()); |
4074 LOG(isolate, | 4180 LOG(isolate, |
4075 ApiIndexedPropertyAccess( | 4181 ApiIndexedPropertyAccess( |
4076 "interceptor-indexed-get-has", *object, index)); | 4182 "interceptor-indexed-get-has", *object, index)); |
4077 v8::Handle<v8::Value> result = args.Call(getter, index); | 4183 v8::Handle<v8::Value> result = args.Call(getter, index); |
4078 if (!result.IsEmpty()) return maybe(NONE); | 4184 if (!result.IsEmpty()) return maybe(NONE); |
4079 } | 4185 } |
4080 | 4186 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Maybe<PropertyAttributes>()); |
4081 return GetElementAttributeWithoutInterceptor( | 4187 return maybe(ABSENT); |
4082 object, receiver, index, check_prototype); | |
4083 } | 4188 } |
4084 | 4189 |
4085 | 4190 |
4086 Maybe<PropertyAttributes> JSObject::GetElementAttributeWithoutInterceptor( | 4191 Maybe<PropertyAttributes> JSObject::GetElementAttributeWithoutInterceptor( |
4087 Handle<JSObject> object, Handle<JSReceiver> receiver, uint32_t index, | 4192 Handle<JSObject> object, Handle<JSReceiver> receiver, uint32_t index, |
4088 bool check_prototype) { | 4193 bool check_prototype) { |
4089 PropertyAttributes attr = object->GetElementsAccessor()->GetAttributes( | 4194 PropertyAttributes attr = object->GetElementsAccessor()->GetAttributes( |
4090 receiver, object, index); | 4195 receiver, object, index); |
4091 if (attr != ABSENT) return maybe(attr); | 4196 if (attr != ABSENT) return maybe(attr); |
4092 | 4197 |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4861 mode); | 4966 mode); |
4862 } | 4967 } |
4863 | 4968 |
4864 Handle<Object> old_value; | 4969 Handle<Object> old_value; |
4865 bool should_enqueue_change_record = false; | 4970 bool should_enqueue_change_record = false; |
4866 if (object->map()->is_observed()) { | 4971 if (object->map()->is_observed()) { |
4867 Maybe<bool> maybe = HasOwnElement(object, index); | 4972 Maybe<bool> maybe = HasOwnElement(object, index); |
4868 if (!maybe.has_value) return MaybeHandle<Object>(); | 4973 if (!maybe.has_value) return MaybeHandle<Object>(); |
4869 should_enqueue_change_record = maybe.value; | 4974 should_enqueue_change_record = maybe.value; |
4870 if (should_enqueue_change_record) { | 4975 if (should_enqueue_change_record) { |
4871 if (!GetOwnElementAccessorPair(object, index).is_null()) { | 4976 if (!GetOwnElementStructure(object, index).is_null()) { |
Toon Verwaest
2014/10/15 08:31:28
These cases actually only blacklist accessor pairs
| |
4872 old_value = Handle<Object>::cast(factory->the_hole_value()); | 4977 old_value = Handle<Object>::cast(factory->the_hole_value()); |
4873 } else { | 4978 } else { |
4874 old_value = Object::GetElement( | 4979 old_value = Object::GetElement( |
4875 isolate, object, index).ToHandleChecked(); | 4980 isolate, object, index).ToHandleChecked(); |
4876 } | 4981 } |
4877 } | 4982 } |
4878 } | 4983 } |
4879 | 4984 |
4880 // Skip interceptor if forcing deletion. | 4985 // Skip interceptor if forcing deletion. |
4881 MaybeHandle<Object> maybe_result; | 4986 MaybeHandle<Object> maybe_result; |
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6123 if (is_observed) { | 6228 if (is_observed) { |
6124 if (is_element) { | 6229 if (is_element) { |
6125 Maybe<bool> maybe = HasOwnElement(object, index); | 6230 Maybe<bool> maybe = HasOwnElement(object, index); |
6126 // Workaround for a GCC 4.4.3 bug which leads to "‘preexists’ may be used | 6231 // Workaround for a GCC 4.4.3 bug which leads to "‘preexists’ may be used |
6127 // uninitialized in this function". | 6232 // uninitialized in this function". |
6128 if (!maybe.has_value) { | 6233 if (!maybe.has_value) { |
6129 DCHECK(false); | 6234 DCHECK(false); |
6130 return isolate->factory()->undefined_value(); | 6235 return isolate->factory()->undefined_value(); |
6131 } | 6236 } |
6132 preexists = maybe.value; | 6237 preexists = maybe.value; |
6133 if (preexists && GetOwnElementAccessorPair(object, index).is_null()) { | 6238 if (preexists && GetOwnElementStructure(object, index).is_null()) { |
6134 old_value = | 6239 old_value = |
6135 Object::GetElement(isolate, object, index).ToHandleChecked(); | 6240 Object::GetElement(isolate, object, index).ToHandleChecked(); |
6136 } | 6241 } |
6137 } else { | 6242 } else { |
6138 LookupIterator it(object, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); | 6243 LookupIterator it(object, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); |
6139 CHECK(GetPropertyAttributes(&it).has_value); | 6244 CHECK(GetPropertyAttributes(&it).has_value); |
6140 preexists = it.IsFound(); | 6245 preexists = it.IsFound(); |
6141 if (preexists && (it.state() == LookupIterator::DATA || | 6246 if (preexists && (it.state() == LookupIterator::DATA || |
6142 it.GetAccessors()->IsAccessorInfo())) { | 6247 it.GetAccessors()->IsAccessorInfo())) { |
6143 old_value = GetProperty(&it).ToHandleChecked(); | 6248 old_value = GetProperty(&it).ToHandleChecked(); |
(...skipping 4964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11108 Handle<JSObject> object, | 11213 Handle<JSObject> object, |
11109 uint32_t index, | 11214 uint32_t index, |
11110 List<Handle<Object> >* old_values, | 11215 List<Handle<Object> >* old_values, |
11111 List<uint32_t>* indices) { | 11216 List<uint32_t>* indices) { |
11112 Maybe<PropertyAttributes> maybe = | 11217 Maybe<PropertyAttributes> maybe = |
11113 JSReceiver::GetOwnElementAttribute(object, index); | 11218 JSReceiver::GetOwnElementAttribute(object, index); |
11114 DCHECK(maybe.has_value); | 11219 DCHECK(maybe.has_value); |
11115 DCHECK(maybe.value != ABSENT); | 11220 DCHECK(maybe.value != ABSENT); |
11116 if (maybe.value == DONT_DELETE) return false; | 11221 if (maybe.value == DONT_DELETE) return false; |
11117 Handle<Object> value; | 11222 Handle<Object> value; |
11118 if (!JSObject::GetOwnElementAccessorPair(object, index).is_null()) { | 11223 if (!JSObject::GetOwnElementStructure(object, index).is_null()) { |
11119 value = Handle<Object>::cast(isolate->factory()->the_hole_value()); | 11224 value = Handle<Object>::cast(isolate->factory()->the_hole_value()); |
11120 } else { | 11225 } else { |
11121 value = Object::GetElement(isolate, object, index).ToHandleChecked(); | 11226 value = Object::GetElement(isolate, object, index).ToHandleChecked(); |
11122 } | 11227 } |
11123 old_values->Add(value); | 11228 old_values->Add(value); |
11124 indices->Add(index); | 11229 indices->Add(index); |
11125 return true; | 11230 return true; |
11126 } | 11231 } |
11127 | 11232 |
11128 static void EnqueueSpliceRecord(Handle<JSArray> object, | 11233 static void EnqueueSpliceRecord(Handle<JSArray> object, |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11757 uint32_t arg_count, | 11862 uint32_t arg_count, |
11758 EnsureElementsMode mode) { | 11863 EnsureElementsMode mode) { |
11759 // Elements in |Arguments| are ordered backwards (because they're on the | 11864 // Elements in |Arguments| are ordered backwards (because they're on the |
11760 // stack), but the method that's called here iterates over them in forward | 11865 // stack), but the method that's called here iterates over them in forward |
11761 // direction. | 11866 // direction. |
11762 return EnsureCanContainElements( | 11867 return EnsureCanContainElements( |
11763 object, args->arguments() - first_arg - (arg_count - 1), arg_count, mode); | 11868 object, args->arguments() - first_arg - (arg_count - 1), arg_count, mode); |
11764 } | 11869 } |
11765 | 11870 |
11766 | 11871 |
11767 MaybeHandle<AccessorPair> JSObject::GetOwnElementAccessorPair( | 11872 MaybeHandle<Object> JSObject::GetOwnElementStructure(Handle<JSObject> object, |
11768 Handle<JSObject> object, | 11873 uint32_t index) { |
11769 uint32_t index) { | |
11770 if (object->IsJSGlobalProxy()) { | 11874 if (object->IsJSGlobalProxy()) { |
11771 PrototypeIterator iter(object->GetIsolate(), object); | 11875 PrototypeIterator iter(object->GetIsolate(), object); |
11772 if (iter.IsAtEnd()) return MaybeHandle<AccessorPair>(); | 11876 if (iter.IsAtEnd()) return MaybeHandle<AccessorPair>(); |
11773 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); | 11877 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); |
11774 return GetOwnElementAccessorPair( | 11878 return GetOwnElementStructure( |
11775 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index); | 11879 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index); |
11776 } | 11880 } |
11777 | 11881 |
11778 // Check for lookup interceptor. | 11882 // Check for lookup interceptor. |
11779 if (object->HasIndexedInterceptor()) return MaybeHandle<AccessorPair>(); | 11883 if (object->HasIndexedInterceptor()) return MaybeHandle<AccessorPair>(); |
11780 | 11884 |
11781 return object->GetElementsAccessor()->GetAccessorPair(object, object, index); | 11885 return object->GetElementsAccessor()->GetStructure(object, object, index); |
11782 } | 11886 } |
11783 | 11887 |
11784 | 11888 |
11785 MaybeHandle<Object> JSObject::SetElementWithInterceptor( | 11889 MaybeHandle<Object> JSObject::SetElementWithInterceptor( |
11786 Handle<JSObject> object, | 11890 Handle<JSObject> object, |
11787 uint32_t index, | 11891 uint32_t index, |
11788 Handle<Object> value, | 11892 Handle<Object> value, |
11789 PropertyAttributes attributes, | 11893 PropertyAttributes attributes, |
11790 StrictMode strict_mode, | 11894 StrictMode strict_mode, |
11791 bool check_prototype, | 11895 bool check_prototype, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11864 if (structure->IsDeclaredAccessorInfo()) { | 11968 if (structure->IsDeclaredAccessorInfo()) { |
11865 return GetDeclaredAccessorProperty( | 11969 return GetDeclaredAccessorProperty( |
11866 receiver, Handle<DeclaredAccessorInfo>::cast(structure), isolate); | 11970 receiver, Handle<DeclaredAccessorInfo>::cast(structure), isolate); |
11867 } | 11971 } |
11868 | 11972 |
11869 UNREACHABLE(); | 11973 UNREACHABLE(); |
11870 return MaybeHandle<Object>(); | 11974 return MaybeHandle<Object>(); |
11871 } | 11975 } |
11872 | 11976 |
11873 | 11977 |
11874 MaybeHandle<Object> JSObject::SetElementWithCallback(Handle<JSObject> object, | 11978 MaybeHandle<Object> JSObject::SetElementWithCallback( |
11875 Handle<Object> structure, | 11979 Handle<Object> object, Handle<Object> structure, uint32_t index, |
11876 uint32_t index, | 11980 Handle<Object> value, Handle<JSObject> holder, StrictMode strict_mode) { |
11877 Handle<Object> value, | 11981 Isolate* isolate = holder->GetIsolate(); |
11878 Handle<JSObject> holder, | |
11879 StrictMode strict_mode) { | |
11880 Isolate* isolate = object->GetIsolate(); | |
11881 | 11982 |
11882 // We should never get here to initialize a const with the hole | 11983 // We should never get here to initialize a const with the hole |
11883 // value since a const declaration would conflict with the setter. | 11984 // value since a const declaration would conflict with the setter. |
11884 DCHECK(!value->IsTheHole()); | 11985 DCHECK(!value->IsTheHole()); |
11885 DCHECK(!structure->IsForeign()); | 11986 DCHECK(!structure->IsForeign()); |
11886 if (structure->IsExecutableAccessorInfo()) { | 11987 if (structure->IsExecutableAccessorInfo()) { |
11887 // api style callbacks | 11988 // api style callbacks |
11888 Handle<ExecutableAccessorInfo> data = | 11989 Handle<ExecutableAccessorInfo> data = |
11889 Handle<ExecutableAccessorInfo>::cast(structure); | 11990 Handle<ExecutableAccessorInfo>::cast(structure); |
11890 Object* call_obj = data->setter(); | 11991 Object* call_obj = data->setter(); |
11891 v8::AccessorNameSetterCallback call_fun = | 11992 v8::AccessorNameSetterCallback call_fun = |
11892 v8::ToCData<v8::AccessorNameSetterCallback>(call_obj); | 11993 v8::ToCData<v8::AccessorNameSetterCallback>(call_obj); |
11893 if (call_fun == NULL) return value; | 11994 if (call_fun == NULL) return value; |
11894 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); | 11995 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); |
11895 Handle<String> key(isolate->factory()->NumberToString(number)); | 11996 Handle<String> key(isolate->factory()->NumberToString(number)); |
11896 LOG(isolate, ApiNamedPropertyAccess("store", *object, *key)); | 11997 LOG(isolate, ApiNamedPropertyAccess("store", *holder, *key)); |
11897 PropertyCallbackArguments | 11998 PropertyCallbackArguments |
11898 args(isolate, data->data(), *object, *holder); | 11999 args(isolate, data->data(), *object, *holder); |
11899 args.Call(call_fun, | 12000 args.Call(call_fun, |
11900 v8::Utils::ToLocal(key), | 12001 v8::Utils::ToLocal(key), |
11901 v8::Utils::ToLocal(value)); | 12002 v8::Utils::ToLocal(value)); |
11902 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 12003 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
11903 return value; | 12004 return value; |
11904 } | 12005 } |
11905 | 12006 |
11906 if (structure->IsAccessorPair()) { | 12007 if (structure->IsAccessorPair()) { |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12406 Maybe<PropertyAttributes> maybe = | 12507 Maybe<PropertyAttributes> maybe = |
12407 JSReceiver::GetOwnElementAttribute(object, index); | 12508 JSReceiver::GetOwnElementAttribute(object, index); |
12408 if (!maybe.has_value) return MaybeHandle<Object>(); | 12509 if (!maybe.has_value) return MaybeHandle<Object>(); |
12409 PropertyAttributes old_attributes = maybe.value; | 12510 PropertyAttributes old_attributes = maybe.value; |
12410 | 12511 |
12411 Handle<Object> old_value = isolate->factory()->the_hole_value(); | 12512 Handle<Object> old_value = isolate->factory()->the_hole_value(); |
12412 Handle<Object> old_length_handle; | 12513 Handle<Object> old_length_handle; |
12413 Handle<Object> new_length_handle; | 12514 Handle<Object> new_length_handle; |
12414 | 12515 |
12415 if (old_attributes != ABSENT) { | 12516 if (old_attributes != ABSENT) { |
12416 if (GetOwnElementAccessorPair(object, index).is_null()) { | 12517 if (GetOwnElementStructure(object, index).is_null()) { |
12417 old_value = Object::GetElement(isolate, object, index).ToHandleChecked(); | 12518 old_value = Object::GetElement(isolate, object, index).ToHandleChecked(); |
12418 } | 12519 } |
12419 } else if (object->IsJSArray()) { | 12520 } else if (object->IsJSArray()) { |
12420 // Store old array length in case adding an element grows the array. | 12521 // Store old array length in case adding an element grows the array. |
12421 old_length_handle = handle(Handle<JSArray>::cast(object)->length(), | 12522 old_length_handle = handle(Handle<JSArray>::cast(object)->length(), |
12422 isolate); | 12523 isolate); |
12423 } | 12524 } |
12424 | 12525 |
12425 // Check for lookup interceptor | 12526 // Check for lookup interceptor |
12426 Handle<Object> result; | 12527 Handle<Object> result; |
(...skipping 3961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16388 Handle<DependentCode> codes = | 16489 Handle<DependentCode> codes = |
16389 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), | 16490 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), |
16390 DependentCode::kPropertyCellChangedGroup, | 16491 DependentCode::kPropertyCellChangedGroup, |
16391 info->object_wrapper()); | 16492 info->object_wrapper()); |
16392 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 16493 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
16393 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 16494 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
16394 cell, info->zone()); | 16495 cell, info->zone()); |
16395 } | 16496 } |
16396 | 16497 |
16397 } } // namespace v8::internal | 16498 } } // namespace v8::internal |
OLD | NEW |