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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 464 |
465 MaybeHandle<Object> Object::SetPropertyWithAccessor( | 465 MaybeHandle<Object> Object::SetPropertyWithAccessor( |
466 Handle<Object> receiver, Handle<Name> name, Handle<Object> value, | 466 Handle<Object> receiver, Handle<Name> name, Handle<Object> value, |
467 Handle<JSObject> holder, Handle<Object> structure, StrictMode strict_mode) { | 467 Handle<JSObject> holder, Handle<Object> structure, StrictMode strict_mode) { |
468 Isolate* isolate = name->GetIsolate(); | 468 Isolate* isolate = name->GetIsolate(); |
469 | 469 |
470 // We should never get here to initialize a const with the hole | 470 // We should never get here to initialize a const with the hole |
471 // value since a const declaration would conflict with the setter. | 471 // value since a const declaration would conflict with the setter. |
472 ASSERT(!structure->IsForeign()); | 472 ASSERT(!structure->IsForeign()); |
473 if (structure->IsExecutableAccessorInfo()) { | 473 if (structure->IsExecutableAccessorInfo()) { |
| 474 // Don't call executable accessor setters with non-JSObject receivers. |
| 475 if (!receiver->IsJSObject()) return value; |
474 // api style callbacks | 476 // api style callbacks |
475 ExecutableAccessorInfo* data = ExecutableAccessorInfo::cast(*structure); | 477 ExecutableAccessorInfo* data = ExecutableAccessorInfo::cast(*structure); |
476 if (!data->IsCompatibleReceiver(*receiver)) { | 478 if (!data->IsCompatibleReceiver(*receiver)) { |
477 Handle<Object> args[2] = { name, receiver }; | 479 Handle<Object> args[2] = { name, receiver }; |
478 Handle<Object> error = | 480 Handle<Object> error = |
479 isolate->factory()->NewTypeError("incompatible_method_receiver", | 481 isolate->factory()->NewTypeError("incompatible_method_receiver", |
480 HandleVector(args, | 482 HandleVector(args, |
481 ARRAY_SIZE(args))); | 483 ARRAY_SIZE(args))); |
482 return isolate->Throw<Object>(error); | 484 return isolate->Throw<Object>(error); |
483 } | 485 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 | 549 |
548 Debug* debug = isolate->debug(); | 550 Debug* debug = isolate->debug(); |
549 // Handle stepping into a setter if step into is active. | 551 // Handle stepping into a setter if step into is active. |
550 // TODO(rossberg): should this apply to getters that are function proxies? | 552 // TODO(rossberg): should this apply to getters that are function proxies? |
551 if (debug->StepInActive() && setter->IsJSFunction()) { | 553 if (debug->StepInActive() && setter->IsJSFunction()) { |
552 debug->HandleStepIn( | 554 debug->HandleStepIn( |
553 Handle<JSFunction>::cast(setter), Handle<Object>::null(), 0, false); | 555 Handle<JSFunction>::cast(setter), Handle<Object>::null(), 0, false); |
554 } | 556 } |
555 | 557 |
556 Handle<Object> argv[] = { value }; | 558 Handle<Object> argv[] = { value }; |
557 RETURN_ON_EXCEPTION( | 559 RETURN_ON_EXCEPTION(isolate, Execution::Call(isolate, setter, receiver, |
558 isolate, | 560 ARRAY_SIZE(argv), argv, true), |
559 Execution::Call(isolate, setter, receiver, ARRAY_SIZE(argv), argv), | 561 Object); |
560 Object); | |
561 return value; | 562 return value; |
562 } | 563 } |
563 | 564 |
564 | 565 |
565 static bool FindAllCanReadHolder(LookupIterator* it) { | 566 static bool FindAllCanReadHolder(LookupIterator* it) { |
566 it->skip_interceptor(); | 567 it->skip_interceptor(); |
567 it->skip_access_check(); | 568 it->skip_access_check(); |
568 for (; it->IsFound(); it->Next()) { | 569 for (; it->IsFound(); it->Next()) { |
569 if (it->state() == LookupIterator::PROPERTY && | 570 if (it->state() == LookupIterator::PROPERTY && |
570 it->HasProperty() && | 571 it->HasProperty() && |
(...skipping 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2952 v8::ToCData<v8::NamedPropertySetterCallback>(interceptor->setter()); | 2953 v8::ToCData<v8::NamedPropertySetterCallback>(interceptor->setter()); |
2953 v8::Handle<v8::Value> result = args.Call( | 2954 v8::Handle<v8::Value> result = args.Call( |
2954 setter, v8::Utils::ToLocal(name_string), v8::Utils::ToLocal(value)); | 2955 setter, v8::Utils::ToLocal(name_string), v8::Utils::ToLocal(value)); |
2955 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(it->isolate(), Object); | 2956 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(it->isolate(), Object); |
2956 if (!result.IsEmpty()) return value; | 2957 if (!result.IsEmpty()) return value; |
2957 | 2958 |
2958 return MaybeHandle<Object>(); | 2959 return MaybeHandle<Object>(); |
2959 } | 2960 } |
2960 | 2961 |
2961 | 2962 |
2962 MaybeHandle<Object> JSReceiver::SetProperty(Handle<JSReceiver> object, | 2963 MaybeHandle<Object> Object::SetProperty(Handle<Object> object, |
2963 Handle<Name> name, | 2964 Handle<Name> name, Handle<Object> value, |
2964 Handle<Object> value, | 2965 StrictMode strict_mode, |
2965 StrictMode strict_mode, | 2966 StoreFromKeyed store_mode) { |
2966 StoreFromKeyed store_mode) { | |
2967 LookupIterator it(object, name); | 2967 LookupIterator it(object, name); |
2968 return Object::SetProperty(&it, value, strict_mode, store_mode); | 2968 return SetProperty(&it, value, strict_mode, store_mode); |
2969 } | 2969 } |
2970 | 2970 |
2971 | 2971 |
2972 MaybeHandle<Object> Object::SetProperty(LookupIterator* it, | 2972 MaybeHandle<Object> Object::SetProperty(LookupIterator* it, |
2973 Handle<Object> value, | 2973 Handle<Object> value, |
2974 StrictMode strict_mode, | 2974 StrictMode strict_mode, |
2975 StoreFromKeyed store_mode) { | 2975 StoreFromKeyed store_mode) { |
2976 // Make sure that the top context does not change when doing callbacks or | 2976 // Make sure that the top context does not change when doing callbacks or |
2977 // interceptor calls. | 2977 // interceptor calls. |
2978 AssertNoContextChange ncc(it->isolate()); | 2978 AssertNoContextChange ncc(it->isolate()); |
(...skipping 13959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16938 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16938 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16939 static const char* error_messages_[] = { | 16939 static const char* error_messages_[] = { |
16940 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16940 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16941 }; | 16941 }; |
16942 #undef ERROR_MESSAGES_TEXTS | 16942 #undef ERROR_MESSAGES_TEXTS |
16943 return error_messages_[reason]; | 16943 return error_messages_[reason]; |
16944 } | 16944 } |
16945 | 16945 |
16946 | 16946 |
16947 } } // namespace v8::internal | 16947 } } // namespace v8::internal |
OLD | NEW |