OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 | 925 |
926 void Template::Set(v8::Local<Name> name, v8::Local<Data> value, | 926 void Template::Set(v8::Local<Name> name, v8::Local<Data> value, |
927 v8::PropertyAttribute attribute) { | 927 v8::PropertyAttribute attribute) { |
928 auto templ = Utils::OpenHandle(this); | 928 auto templ = Utils::OpenHandle(this); |
929 i::Isolate* isolate = templ->GetIsolate(); | 929 i::Isolate* isolate = templ->GetIsolate(); |
930 ENTER_V8(isolate); | 930 ENTER_V8(isolate); |
931 i::HandleScope scope(isolate); | 931 i::HandleScope scope(isolate); |
932 // TODO(dcarney): split api to allow values of v8::Value or v8::TemplateInfo. | 932 // TODO(dcarney): split api to allow values of v8::Value or v8::TemplateInfo. |
933 i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name), | 933 i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name), |
934 Utils::OpenHandle(*value), | 934 Utils::OpenHandle(*value), |
935 static_cast<PropertyAttributes>(attribute)); | 935 static_cast<i::PropertyAttributes>(attribute)); |
936 } | 936 } |
937 | 937 |
938 | 938 |
939 void Template::SetAccessorProperty( | 939 void Template::SetAccessorProperty( |
940 v8::Local<v8::Name> name, | 940 v8::Local<v8::Name> name, |
941 v8::Local<FunctionTemplate> getter, | 941 v8::Local<FunctionTemplate> getter, |
942 v8::Local<FunctionTemplate> setter, | 942 v8::Local<FunctionTemplate> setter, |
943 v8::PropertyAttribute attribute, | 943 v8::PropertyAttribute attribute, |
944 v8::AccessControl access_control) { | 944 v8::AccessControl access_control) { |
945 // TODO(verwaest): Remove |access_control|. | 945 // TODO(verwaest): Remove |access_control|. |
946 DCHECK_EQ(v8::DEFAULT, access_control); | 946 DCHECK_EQ(v8::DEFAULT, access_control); |
947 auto templ = Utils::OpenHandle(this); | 947 auto templ = Utils::OpenHandle(this); |
948 auto isolate = templ->GetIsolate(); | 948 auto isolate = templ->GetIsolate(); |
949 ENTER_V8(isolate); | 949 ENTER_V8(isolate); |
950 DCHECK(!name.IsEmpty()); | 950 DCHECK(!name.IsEmpty()); |
951 DCHECK(!getter.IsEmpty() || !setter.IsEmpty()); | 951 DCHECK(!getter.IsEmpty() || !setter.IsEmpty()); |
952 i::HandleScope scope(isolate); | 952 i::HandleScope scope(isolate); |
953 i::ApiNatives::AddAccessorProperty( | 953 i::ApiNatives::AddAccessorProperty( |
954 isolate, templ, Utils::OpenHandle(*name), | 954 isolate, templ, Utils::OpenHandle(*name), |
955 Utils::OpenHandle(*getter, true), Utils::OpenHandle(*setter, true), | 955 Utils::OpenHandle(*getter, true), Utils::OpenHandle(*setter, true), |
956 static_cast<PropertyAttributes>(attribute)); | 956 static_cast<i::PropertyAttributes>(attribute)); |
957 } | 957 } |
958 | 958 |
959 | 959 |
960 // --- F u n c t i o n T e m p l a t e --- | 960 // --- F u n c t i o n T e m p l a t e --- |
961 static void InitializeFunctionTemplate( | 961 static void InitializeFunctionTemplate( |
962 i::Handle<i::FunctionTemplateInfo> info) { | 962 i::Handle<i::FunctionTemplateInfo> info) { |
963 InitializeTemplate(info, Consts::FUNCTION_TEMPLATE); | 963 InitializeTemplate(info, Consts::FUNCTION_TEMPLATE); |
964 info->set_flag(0); | 964 info->set_flag(0); |
965 } | 965 } |
966 | 966 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 } | 1101 } |
1102 | 1102 |
1103 | 1103 |
1104 static i::Handle<i::AccessorInfo> SetAccessorInfoProperties( | 1104 static i::Handle<i::AccessorInfo> SetAccessorInfoProperties( |
1105 i::Handle<i::AccessorInfo> obj, v8::Local<Name> name, | 1105 i::Handle<i::AccessorInfo> obj, v8::Local<Name> name, |
1106 v8::AccessControl settings, v8::PropertyAttribute attributes, | 1106 v8::AccessControl settings, v8::PropertyAttribute attributes, |
1107 v8::Local<AccessorSignature> signature) { | 1107 v8::Local<AccessorSignature> signature) { |
1108 obj->set_name(*Utils::OpenHandle(*name)); | 1108 obj->set_name(*Utils::OpenHandle(*name)); |
1109 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); | 1109 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); |
1110 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); | 1110 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); |
1111 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); | 1111 obj->set_property_attributes(static_cast<i::PropertyAttributes>(attributes)); |
1112 if (!signature.IsEmpty()) { | 1112 if (!signature.IsEmpty()) { |
1113 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); | 1113 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); |
1114 } | 1114 } |
1115 return obj; | 1115 return obj; |
1116 } | 1116 } |
1117 | 1117 |
1118 | 1118 |
1119 template <typename Getter, typename Setter> | 1119 template <typename Getter, typename Setter> |
1120 static i::Handle<i::AccessorInfo> MakeAccessorInfo( | 1120 static i::Handle<i::AccessorInfo> MakeAccessorInfo( |
1121 v8::Local<Name> name, Getter getter, Setter setter, v8::Local<Value> data, | 1121 v8::Local<Name> name, Getter getter, Setter setter, v8::Local<Value> data, |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 | 1323 |
1324 | 1324 |
1325 void Template::SetIntrinsicDataProperty(Local<Name> name, Intrinsic intrinsic, | 1325 void Template::SetIntrinsicDataProperty(Local<Name> name, Intrinsic intrinsic, |
1326 PropertyAttribute attribute) { | 1326 PropertyAttribute attribute) { |
1327 auto templ = Utils::OpenHandle(this); | 1327 auto templ = Utils::OpenHandle(this); |
1328 i::Isolate* isolate = templ->GetIsolate(); | 1328 i::Isolate* isolate = templ->GetIsolate(); |
1329 ENTER_V8(isolate); | 1329 ENTER_V8(isolate); |
1330 i::HandleScope scope(isolate); | 1330 i::HandleScope scope(isolate); |
1331 i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name), | 1331 i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name), |
1332 intrinsic, | 1332 intrinsic, |
1333 static_cast<PropertyAttributes>(attribute)); | 1333 static_cast<i::PropertyAttributes>(attribute)); |
1334 } | 1334 } |
1335 | 1335 |
1336 | 1336 |
1337 void ObjectTemplate::SetAccessor(v8::Local<String> name, | 1337 void ObjectTemplate::SetAccessor(v8::Local<String> name, |
1338 AccessorGetterCallback getter, | 1338 AccessorGetterCallback getter, |
1339 AccessorSetterCallback setter, | 1339 AccessorSetterCallback setter, |
1340 v8::Local<Value> data, AccessControl settings, | 1340 v8::Local<Value> data, AccessControl settings, |
1341 PropertyAttribute attribute, | 1341 PropertyAttribute attribute, |
1342 v8::Local<AccessorSignature> signature) { | 1342 v8::Local<AccessorSignature> signature) { |
1343 TemplateSetAccessor( | 1343 TemplateSetAccessor( |
(...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3524 i::Object::DONT_THROW); | 3524 i::Object::DONT_THROW); |
3525 // Even though we said DONT_THROW, there might be accessors that do throw. | 3525 // Even though we said DONT_THROW, there might be accessors that do throw. |
3526 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3526 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3527 return Just(success); | 3527 return Just(success); |
3528 } | 3528 } |
3529 | 3529 |
3530 | 3530 |
3531 MUST_USE_RESULT | 3531 MUST_USE_RESULT |
3532 static i::MaybeHandle<i::Object> DefineObjectProperty( | 3532 static i::MaybeHandle<i::Object> DefineObjectProperty( |
3533 i::Handle<i::JSObject> js_object, i::Handle<i::Object> key, | 3533 i::Handle<i::JSObject> js_object, i::Handle<i::Object> key, |
3534 i::Handle<i::Object> value, PropertyAttributes attrs) { | 3534 i::Handle<i::Object> value, i::PropertyAttributes attrs) { |
3535 i::Isolate* isolate = js_object->GetIsolate(); | 3535 i::Isolate* isolate = js_object->GetIsolate(); |
3536 bool success = false; | 3536 bool success = false; |
3537 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 3537 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
3538 isolate, js_object, key, &success, i::LookupIterator::OWN); | 3538 isolate, js_object, key, &success, i::LookupIterator::OWN); |
3539 if (!success) return i::MaybeHandle<i::Object>(); | 3539 if (!success) return i::MaybeHandle<i::Object>(); |
3540 | 3540 |
3541 return i::JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs); | 3541 return i::JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs); |
3542 } | 3542 } |
3543 | 3543 |
3544 | 3544 |
3545 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, | 3545 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, |
3546 v8::Local<Value> key, v8::Local<Value> value, | 3546 v8::Local<Value> key, v8::Local<Value> value, |
3547 v8::PropertyAttribute attribs) { | 3547 v8::PropertyAttribute attribs) { |
3548 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::ForceSet()", bool); | 3548 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::ForceSet()", bool); |
3549 auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); | 3549 auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); |
3550 auto key_obj = Utils::OpenHandle(*key); | 3550 auto key_obj = Utils::OpenHandle(*key); |
3551 auto value_obj = Utils::OpenHandle(*value); | 3551 auto value_obj = Utils::OpenHandle(*value); |
3552 has_pending_exception = | 3552 has_pending_exception = |
3553 DefineObjectProperty(self, key_obj, value_obj, | 3553 DefineObjectProperty(self, key_obj, value_obj, |
3554 static_cast<PropertyAttributes>(attribs)).is_null(); | 3554 static_cast<i::PropertyAttributes>(attribs)) |
| 3555 .is_null(); |
3555 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3556 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3556 return Just(true); | 3557 return Just(true); |
3557 } | 3558 } |
3558 | 3559 |
3559 | 3560 |
3560 bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value, | 3561 bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value, |
3561 v8::PropertyAttribute attribs) { | 3562 v8::PropertyAttribute attribs) { |
3562 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3563 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3563 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), | 3564 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), |
3564 "v8::Object::ForceSet", false, i::HandleScope, | 3565 "v8::Object::ForceSet", false, i::HandleScope, |
3565 false); | 3566 false); |
3566 i::Handle<i::JSObject> self = | 3567 i::Handle<i::JSObject> self = |
3567 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); | 3568 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); |
3568 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 3569 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
3569 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3570 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
3570 has_pending_exception = | 3571 has_pending_exception = |
3571 DefineObjectProperty(self, key_obj, value_obj, | 3572 DefineObjectProperty(self, key_obj, value_obj, |
3572 static_cast<PropertyAttributes>(attribs)).is_null(); | 3573 static_cast<i::PropertyAttributes>(attribs)) |
| 3574 .is_null(); |
3573 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); | 3575 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); |
3574 return true; | 3576 return true; |
3575 } | 3577 } |
3576 | 3578 |
3577 | 3579 |
3578 Maybe<bool> v8::Object::SetPrivate(Local<Context> context, Local<Private> key, | 3580 Maybe<bool> v8::Object::SetPrivate(Local<Context> context, Local<Private> key, |
3579 Local<Value> value) { | 3581 Local<Value> value) { |
3580 return DefineOwnProperty(context, Local<Name>(reinterpret_cast<Name*>(*key)), | 3582 return DefineOwnProperty(context, Local<Name>(reinterpret_cast<Name*>(*key)), |
3581 value, DontEnum); | 3583 value, DontEnum); |
3582 } | 3584 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3632 auto key_obj = Utils::OpenHandle(*key); | 3634 auto key_obj = Utils::OpenHandle(*key); |
3633 if (!key_obj->IsName()) { | 3635 if (!key_obj->IsName()) { |
3634 has_pending_exception = | 3636 has_pending_exception = |
3635 !i::Object::ToString(isolate, key_obj).ToHandle(&key_obj); | 3637 !i::Object::ToString(isolate, key_obj).ToHandle(&key_obj); |
3636 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 3638 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
3637 } | 3639 } |
3638 auto key_name = i::Handle<i::Name>::cast(key_obj); | 3640 auto key_name = i::Handle<i::Name>::cast(key_obj); |
3639 auto result = i::JSReceiver::GetPropertyAttributes(self, key_name); | 3641 auto result = i::JSReceiver::GetPropertyAttributes(self, key_name); |
3640 has_pending_exception = result.IsNothing(); | 3642 has_pending_exception = result.IsNothing(); |
3641 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 3643 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
3642 if (result.FromJust() == ABSENT) { | 3644 if (result.FromJust() == i::ABSENT) { |
3643 return Just(static_cast<PropertyAttribute>(NONE)); | 3645 return Just(static_cast<PropertyAttribute>(i::NONE)); |
3644 } | 3646 } |
3645 return Just(static_cast<PropertyAttribute>(result.FromJust())); | 3647 return Just(static_cast<PropertyAttribute>(result.FromJust())); |
3646 } | 3648 } |
3647 | 3649 |
3648 | 3650 |
3649 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Local<Value> key) { | 3651 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Local<Value> key) { |
3650 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3652 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3651 return GetPropertyAttributes(context, key) | 3653 return GetPropertyAttributes(context, key) |
3652 .FromMaybe(static_cast<PropertyAttribute>(NONE)); | 3654 .FromMaybe(static_cast<PropertyAttribute>(i::NONE)); |
3653 } | 3655 } |
3654 | 3656 |
3655 | 3657 |
3656 MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context, | 3658 MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context, |
3657 Local<String> key) { | 3659 Local<String> key) { |
3658 PREPARE_FOR_EXECUTION(context, "v8::Object::GetOwnPropertyDescriptor()", | 3660 PREPARE_FOR_EXECUTION(context, "v8::Object::GetOwnPropertyDescriptor()", |
3659 Value); | 3661 Value); |
3660 auto obj = Utils::OpenHandle(this); | 3662 auto obj = Utils::OpenHandle(this); |
3661 auto key_name = Utils::OpenHandle(*key); | 3663 auto key_name = Utils::OpenHandle(*key); |
3662 i::Handle<i::Object> args[] = { obj, key_name }; | 3664 i::Handle<i::Object> args[] = { obj, key_name }; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3721 } | 3723 } |
3722 // IsTemplateFor() ensures that iter.GetCurrent() can't be a Proxy here. | 3724 // IsTemplateFor() ensures that iter.GetCurrent() can't be a Proxy here. |
3723 return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate)); | 3725 return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate)); |
3724 } | 3726 } |
3725 | 3727 |
3726 | 3728 |
3727 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) { | 3729 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) { |
3728 PREPARE_FOR_EXECUTION(context, "v8::Object::GetPropertyNames()", Array); | 3730 PREPARE_FOR_EXECUTION(context, "v8::Object::GetPropertyNames()", Array); |
3729 auto self = Utils::OpenHandle(this); | 3731 auto self = Utils::OpenHandle(this); |
3730 i::Handle<i::FixedArray> value; | 3732 i::Handle<i::FixedArray> value; |
3731 has_pending_exception = !i::JSReceiver::GetKeys( | 3733 has_pending_exception = |
3732 self, i::JSReceiver::INCLUDE_PROTOS).ToHandle(&value); | 3734 !i::JSReceiver::GetKeys(self, i::JSReceiver::INCLUDE_PROTOS, |
| 3735 i::ENUMERABLE_STRINGS) |
| 3736 .ToHandle(&value); |
3733 RETURN_ON_FAILED_EXECUTION(Array); | 3737 RETURN_ON_FAILED_EXECUTION(Array); |
3734 // Because we use caching to speed up enumeration it is important | 3738 // Because we use caching to speed up enumeration it is important |
3735 // to never change the result of the basic enumeration function so | 3739 // to never change the result of the basic enumeration function so |
3736 // we clone the result. | 3740 // we clone the result. |
3737 auto elms = isolate->factory()->CopyFixedArray(value); | 3741 auto elms = isolate->factory()->CopyFixedArray(value); |
3738 auto result = isolate->factory()->NewJSArrayWithElements(elms); | 3742 auto result = isolate->factory()->NewJSArrayWithElements(elms); |
3739 RETURN_ESCAPED(Utils::ToLocal(result)); | 3743 RETURN_ESCAPED(Utils::ToLocal(result)); |
3740 } | 3744 } |
3741 | 3745 |
3742 | 3746 |
3743 Local<Array> v8::Object::GetPropertyNames() { | 3747 Local<Array> v8::Object::GetPropertyNames() { |
3744 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3748 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3745 RETURN_TO_LOCAL_UNCHECKED(GetPropertyNames(context), Array); | 3749 RETURN_TO_LOCAL_UNCHECKED(GetPropertyNames(context), Array); |
3746 } | 3750 } |
3747 | 3751 |
3748 | 3752 |
3749 MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context) { | 3753 MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context) { |
3750 PREPARE_FOR_EXECUTION(context, "v8::Object::GetOwnPropertyNames()", Array); | 3754 PREPARE_FOR_EXECUTION(context, "v8::Object::GetOwnPropertyNames()", Array); |
3751 auto self = Utils::OpenHandle(this); | 3755 auto self = Utils::OpenHandle(this); |
3752 i::Handle<i::FixedArray> value; | 3756 i::Handle<i::FixedArray> value; |
3753 has_pending_exception = !i::JSReceiver::GetKeys( | 3757 has_pending_exception = !i::JSReceiver::GetKeys(self, i::JSReceiver::OWN_ONLY, |
3754 self, i::JSReceiver::OWN_ONLY).ToHandle(&value); | 3758 i::ENUMERABLE_STRINGS) |
| 3759 .ToHandle(&value); |
3755 RETURN_ON_FAILED_EXECUTION(Array); | 3760 RETURN_ON_FAILED_EXECUTION(Array); |
3756 // Because we use caching to speed up enumeration it is important | 3761 // Because we use caching to speed up enumeration it is important |
3757 // to never change the result of the basic enumeration function so | 3762 // to never change the result of the basic enumeration function so |
3758 // we clone the result. | 3763 // we clone the result. |
3759 auto elms = isolate->factory()->CopyFixedArray(value); | 3764 auto elms = isolate->factory()->CopyFixedArray(value); |
3760 auto result = isolate->factory()->NewJSArrayWithElements(elms); | 3765 auto result = isolate->factory()->NewJSArrayWithElements(elms); |
3761 RETURN_ESCAPED(Utils::ToLocal(result)); | 3766 RETURN_ESCAPED(Utils::ToLocal(result)); |
3762 } | 3767 } |
3763 | 3768 |
3764 | 3769 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3997 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4002 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3998 ENTER_V8(isolate); | 4003 ENTER_V8(isolate); |
3999 i::HandleScope scope(isolate); | 4004 i::HandleScope scope(isolate); |
4000 auto self = Utils::OpenHandle(this); | 4005 auto self = Utils::OpenHandle(this); |
4001 if (!self->IsJSObject()) return; | 4006 if (!self->IsJSObject()) return; |
4002 i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter); | 4007 i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter); |
4003 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); | 4008 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); |
4004 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); | 4009 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); |
4005 i::JSObject::DefineAccessor(i::Handle<i::JSObject>::cast(self), | 4010 i::JSObject::DefineAccessor(i::Handle<i::JSObject>::cast(self), |
4006 v8::Utils::OpenHandle(*name), getter_i, setter_i, | 4011 v8::Utils::OpenHandle(*name), getter_i, setter_i, |
4007 static_cast<PropertyAttributes>(attribute)); | 4012 static_cast<i::PropertyAttributes>(attribute)); |
4008 } | 4013 } |
4009 | 4014 |
4010 | 4015 |
4011 Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context, | 4016 Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context, |
4012 Local<Name> key) { | 4017 Local<Name> key) { |
4013 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasOwnProperty()", | 4018 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasOwnProperty()", |
4014 bool); | 4019 bool); |
4015 auto self = Utils::OpenHandle(this); | 4020 auto self = Utils::OpenHandle(this); |
4016 auto key_val = Utils::OpenHandle(*key); | 4021 auto key_val = Utils::OpenHandle(*key); |
4017 auto result = i::JSReceiver::HasOwnProperty(self, key_val); | 4022 auto result = i::JSReceiver::HasOwnProperty(self, key_val); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4142 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); | 4147 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
4143 if (!self->IsJSObject()) return Nothing<PropertyAttribute>(); | 4148 if (!self->IsJSObject()) return Nothing<PropertyAttribute>(); |
4144 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); | 4149 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
4145 i::PrototypeIterator iter(isolate, self); | 4150 i::PrototypeIterator iter(isolate, self); |
4146 if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); | 4151 if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); |
4147 i::Handle<i::JSReceiver> proto = | 4152 i::Handle<i::JSReceiver> proto = |
4148 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); | 4153 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); |
4149 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4154 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
4150 isolate, self, key_obj, proto, | 4155 isolate, self, key_obj, proto, |
4151 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4156 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
4152 Maybe<PropertyAttributes> result = i::JSReceiver::GetPropertyAttributes(&it); | 4157 Maybe<i::PropertyAttributes> result = |
| 4158 i::JSReceiver::GetPropertyAttributes(&it); |
4153 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 4159 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
4154 if (!it.IsFound()) return Nothing<PropertyAttribute>(); | 4160 if (!it.IsFound()) return Nothing<PropertyAttribute>(); |
4155 if (result.FromJust() == ABSENT) return Just(None); | 4161 if (result.FromJust() == i::ABSENT) return Just(None); |
4156 return Just(static_cast<PropertyAttribute>(result.FromJust())); | 4162 return Just(static_cast<PropertyAttribute>(result.FromJust())); |
4157 } | 4163 } |
4158 | 4164 |
4159 | 4165 |
4160 Maybe<PropertyAttribute> | 4166 Maybe<PropertyAttribute> |
4161 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(Local<String> key) { | 4167 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(Local<String> key) { |
4162 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4168 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4163 return GetRealNamedPropertyAttributesInPrototypeChain(context, key); | 4169 return GetRealNamedPropertyAttributesInPrototypeChain(context, key); |
4164 } | 4170 } |
4165 | 4171 |
(...skipping 26 matching lines...) Expand all Loading... |
4192 context, "v8::Object::GetRealNamedPropertyAttributes()", | 4198 context, "v8::Object::GetRealNamedPropertyAttributes()", |
4193 PropertyAttribute); | 4199 PropertyAttribute); |
4194 auto self = Utils::OpenHandle(this); | 4200 auto self = Utils::OpenHandle(this); |
4195 auto key_obj = Utils::OpenHandle(*key); | 4201 auto key_obj = Utils::OpenHandle(*key); |
4196 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4202 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
4197 isolate, self, key_obj, | 4203 isolate, self, key_obj, |
4198 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4204 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
4199 auto result = i::JSReceiver::GetPropertyAttributes(&it); | 4205 auto result = i::JSReceiver::GetPropertyAttributes(&it); |
4200 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 4206 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
4201 if (!it.IsFound()) return Nothing<PropertyAttribute>(); | 4207 if (!it.IsFound()) return Nothing<PropertyAttribute>(); |
4202 if (result.FromJust() == ABSENT) { | 4208 if (result.FromJust() == i::ABSENT) { |
4203 return Just(static_cast<PropertyAttribute>(NONE)); | 4209 return Just(static_cast<PropertyAttribute>(i::NONE)); |
4204 } | 4210 } |
4205 return Just<PropertyAttribute>( | 4211 return Just<PropertyAttribute>( |
4206 static_cast<PropertyAttribute>(result.FromJust())); | 4212 static_cast<PropertyAttribute>(result.FromJust())); |
4207 } | 4213 } |
4208 | 4214 |
4209 | 4215 |
4210 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( | 4216 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( |
4211 Local<String> key) { | 4217 Local<String> key) { |
4212 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4218 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4213 return GetRealNamedPropertyAttributes(context, key); | 4219 return GetRealNamedPropertyAttributes(context, key); |
(...skipping 4304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8518 Address callback_address = | 8524 Address callback_address = |
8519 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8525 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8520 VMState<EXTERNAL> state(isolate); | 8526 VMState<EXTERNAL> state(isolate); |
8521 ExternalCallbackScope call_scope(isolate, callback_address); | 8527 ExternalCallbackScope call_scope(isolate, callback_address); |
8522 callback(info); | 8528 callback(info); |
8523 } | 8529 } |
8524 | 8530 |
8525 | 8531 |
8526 } // namespace internal | 8532 } // namespace internal |
8527 } // namespace v8 | 8533 } // namespace v8 |
OLD | NEW |