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 3461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3472 } | 3472 } |
3473 | 3473 |
3474 | 3474 |
3475 Local<Value> v8::Object::GetOwnPropertyDescriptor(Local<String> key) { | 3475 Local<Value> v8::Object::GetOwnPropertyDescriptor(Local<String> key) { |
3476 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3476 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3477 RETURN_TO_LOCAL_UNCHECKED(GetOwnPropertyDescriptor(context, key), Value); | 3477 RETURN_TO_LOCAL_UNCHECKED(GetOwnPropertyDescriptor(context, key), Value); |
3478 } | 3478 } |
3479 | 3479 |
3480 | 3480 |
3481 Local<Value> v8::Object::GetPrototype() { | 3481 Local<Value> v8::Object::GetPrototype() { |
3482 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3482 auto isolate = Utils::OpenHandle(this)->GetIsolate(); |
3483 ON_BAILOUT(isolate, "v8::Object::GetPrototype()", return Local<v8::Value>()); | 3483 auto self = Utils::OpenHandle(this); |
3484 ENTER_V8(isolate); | |
3485 i::Handle<i::Object> self = Utils::OpenHandle(this); | |
3486 i::PrototypeIterator iter(isolate, self); | 3484 i::PrototypeIterator iter(isolate, self); |
3487 return Utils::ToLocal(i::PrototypeIterator::GetCurrent(iter)); | 3485 return Utils::ToLocal(i::PrototypeIterator::GetCurrent(iter)); |
3488 } | 3486 } |
3489 | 3487 |
3490 | 3488 |
3491 bool v8::Object::SetPrototype(Handle<Value> value) { | 3489 Maybe<bool> v8::Object::SetPrototype(Local<Context> context, |
3492 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3490 Local<Value> value) { |
3493 ON_BAILOUT(isolate, "v8::Object::SetPrototype()", return false); | 3491 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetPrototype()", bool); |
3494 ENTER_V8(isolate); | 3492 auto self = Utils::OpenHandle(this); |
3495 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3493 auto value_obj = Utils::OpenHandle(*value); |
3496 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | |
3497 // We do not allow exceptions thrown while setting the prototype | 3494 // We do not allow exceptions thrown while setting the prototype |
3498 // to propagate outside. | 3495 // to propagate outside. |
3499 TryCatch try_catch; | 3496 TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); |
3500 EXCEPTION_PREAMBLE(isolate); | 3497 auto result = i::JSObject::SetPrototype(self, value_obj, false); |
3501 i::MaybeHandle<i::Object> result = | |
3502 i::JSObject::SetPrototype(self, value_obj, false); | |
3503 has_pending_exception = result.is_null(); | 3498 has_pending_exception = result.is_null(); |
3504 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3499 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3505 return true; | 3500 return Just(true); |
| 3501 } |
| 3502 |
| 3503 |
| 3504 bool v8::Object::SetPrototype(Handle<Value> value) { |
| 3505 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 3506 return SetPrototype(context, value).FromMaybe(false); |
3506 } | 3507 } |
3507 | 3508 |
3508 | 3509 |
3509 Local<Object> v8::Object::FindInstanceInPrototypeChain( | 3510 Local<Object> v8::Object::FindInstanceInPrototypeChain( |
3510 v8::Handle<FunctionTemplate> tmpl) { | 3511 v8::Handle<FunctionTemplate> tmpl) { |
3511 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3512 auto isolate = Utils::OpenHandle(this)->GetIsolate(); |
3512 ON_BAILOUT(isolate, | |
3513 "v8::Object::FindInstanceInPrototypeChain()", | |
3514 return Local<v8::Object>()); | |
3515 ENTER_V8(isolate); | |
3516 i::PrototypeIterator iter(isolate, *Utils::OpenHandle(this), | 3513 i::PrototypeIterator iter(isolate, *Utils::OpenHandle(this), |
3517 i::PrototypeIterator::START_AT_RECEIVER); | 3514 i::PrototypeIterator::START_AT_RECEIVER); |
3518 i::FunctionTemplateInfo* tmpl_info = *Utils::OpenHandle(*tmpl); | 3515 auto tmpl_info = *Utils::OpenHandle(*tmpl); |
3519 while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) { | 3516 while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) { |
3520 iter.Advance(); | 3517 iter.Advance(); |
3521 if (iter.IsAtEnd()) { | 3518 if (iter.IsAtEnd()) { |
3522 return Local<Object>(); | 3519 return Local<Object>(); |
3523 } | 3520 } |
3524 } | 3521 } |
3525 return Utils::ToLocal( | 3522 return Utils::ToLocal( |
3526 i::handle(i::JSObject::cast(iter.GetCurrent()), isolate)); | 3523 i::handle(i::JSObject::cast(iter.GetCurrent()), isolate)); |
3527 } | 3524 } |
3528 | 3525 |
3529 | 3526 |
| 3527 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) { |
| 3528 PREPARE_FOR_EXECUTION(context, "v8::Object::GetPropertyNames()", Array); |
| 3529 auto self = Utils::OpenHandle(this); |
| 3530 i::Handle<i::FixedArray> value; |
| 3531 has_pending_exception = !i::JSReceiver::GetKeys( |
| 3532 self, i::JSReceiver::INCLUDE_PROTOS).ToHandle(&value); |
| 3533 RETURN_ON_FAILED_EXECUTION(Array); |
| 3534 // Because we use caching to speed up enumeration it is important |
| 3535 // to never change the result of the basic enumeration function so |
| 3536 // we clone the result. |
| 3537 auto elms = isolate->factory()->CopyFixedArray(value); |
| 3538 auto result = isolate->factory()->NewJSArrayWithElements(elms); |
| 3539 RETURN_ESCAPED(Utils::ToLocal(result)); |
| 3540 } |
| 3541 |
| 3542 |
3530 Local<Array> v8::Object::GetPropertyNames() { | 3543 Local<Array> v8::Object::GetPropertyNames() { |
3531 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3544 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3532 ON_BAILOUT(isolate, "v8::Object::GetPropertyNames()", | 3545 RETURN_TO_LOCAL_UNCHECKED(GetPropertyNames(context), Array); |
3533 return Local<v8::Array>()); | 3546 } |
3534 ENTER_V8(isolate); | 3547 |
3535 i::HandleScope scope(isolate); | 3548 |
3536 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3549 MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context) { |
3537 EXCEPTION_PREAMBLE(isolate); | 3550 PREPARE_FOR_EXECUTION(context, "v8::Object::GetOwnPropertyNames()", Array); |
| 3551 auto self = Utils::OpenHandle(this); |
3538 i::Handle<i::FixedArray> value; | 3552 i::Handle<i::FixedArray> value; |
3539 has_pending_exception = !i::JSReceiver::GetKeys( | 3553 has_pending_exception = !i::JSReceiver::GetKeys( |
3540 self, i::JSReceiver::INCLUDE_PROTOS).ToHandle(&value); | 3554 self, i::JSReceiver::OWN_ONLY).ToHandle(&value); |
3541 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Array>()); | 3555 RETURN_ON_FAILED_EXECUTION(Array); |
3542 // Because we use caching to speed up enumeration it is important | 3556 // Because we use caching to speed up enumeration it is important |
3543 // to never change the result of the basic enumeration function so | 3557 // to never change the result of the basic enumeration function so |
3544 // we clone the result. | 3558 // we clone the result. |
3545 i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value); | 3559 auto elms = isolate->factory()->CopyFixedArray(value); |
3546 i::Handle<i::JSArray> result = | 3560 auto result = isolate->factory()->NewJSArrayWithElements(elms); |
3547 isolate->factory()->NewJSArrayWithElements(elms); | 3561 RETURN_ESCAPED(Utils::ToLocal(result)); |
3548 return Utils::ToLocal(scope.CloseAndEscape(result)); | |
3549 } | 3562 } |
3550 | 3563 |
3551 | 3564 |
3552 Local<Array> v8::Object::GetOwnPropertyNames() { | 3565 Local<Array> v8::Object::GetOwnPropertyNames() { |
3553 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3566 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3554 ON_BAILOUT(isolate, "v8::Object::GetOwnPropertyNames()", | 3567 RETURN_TO_LOCAL_UNCHECKED(GetOwnPropertyNames(context), Array); |
3555 return Local<v8::Array>()); | |
3556 ENTER_V8(isolate); | |
3557 i::HandleScope scope(isolate); | |
3558 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | |
3559 EXCEPTION_PREAMBLE(isolate); | |
3560 i::Handle<i::FixedArray> value; | |
3561 has_pending_exception = !i::JSReceiver::GetKeys( | |
3562 self, i::JSReceiver::OWN_ONLY).ToHandle(&value); | |
3563 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Array>()); | |
3564 // Because we use caching to speed up enumeration it is important | |
3565 // to never change the result of the basic enumeration function so | |
3566 // we clone the result. | |
3567 i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value); | |
3568 i::Handle<i::JSArray> result = | |
3569 isolate->factory()->NewJSArrayWithElements(elms); | |
3570 return Utils::ToLocal(scope.CloseAndEscape(result)); | |
3571 } | 3568 } |
3572 | 3569 |
3573 | 3570 |
3574 Local<String> v8::Object::ObjectProtoToString() { | 3571 Local<String> v8::Object::ObjectProtoToString() { |
3575 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); | 3572 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); |
3576 Isolate* isolate = reinterpret_cast<Isolate*>(i_isolate); | 3573 Isolate* isolate = reinterpret_cast<Isolate*>(i_isolate); |
3577 ON_BAILOUT(i_isolate, "v8::Object::ObjectProtoToString()", | 3574 ON_BAILOUT(i_isolate, "v8::Object::ObjectProtoToString()", |
3578 return Local<v8::String>()); | 3575 return Local<v8::String>()); |
3579 ENTER_V8(i_isolate); | 3576 ENTER_V8(i_isolate); |
3580 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3577 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3812 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); | 3809 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); |
3813 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); | 3810 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); |
3814 i::JSObject::DefineAccessor(v8::Utils::OpenHandle(this), | 3811 i::JSObject::DefineAccessor(v8::Utils::OpenHandle(this), |
3815 v8::Utils::OpenHandle(*name), | 3812 v8::Utils::OpenHandle(*name), |
3816 getter_i, | 3813 getter_i, |
3817 setter_i, | 3814 setter_i, |
3818 static_cast<PropertyAttributes>(attribute)); | 3815 static_cast<PropertyAttributes>(attribute)); |
3819 } | 3816 } |
3820 | 3817 |
3821 | 3818 |
| 3819 Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context, |
| 3820 Local<Name> key) { |
| 3821 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasOwnProperty()", |
| 3822 bool); |
| 3823 auto self = Utils::OpenHandle(this); |
| 3824 auto key_val = Utils::OpenHandle(*key); |
| 3825 auto result = i::JSReceiver::HasOwnProperty(self, key_val); |
| 3826 has_pending_exception = result.IsNothing(); |
| 3827 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3828 return result; |
| 3829 } |
| 3830 |
| 3831 |
3822 bool v8::Object::HasOwnProperty(Handle<String> key) { | 3832 bool v8::Object::HasOwnProperty(Handle<String> key) { |
3823 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3833 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3824 ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()", | 3834 return HasOwnProperty(context, key).FromMaybe(false); |
3825 return false); | 3835 } |
3826 EXCEPTION_PREAMBLE(isolate); | 3836 |
3827 Maybe<bool> maybe = i::JSReceiver::HasOwnProperty(Utils::OpenHandle(this), | 3837 |
3828 Utils::OpenHandle(*key)); | 3838 Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context, |
3829 has_pending_exception = !maybe.IsJust(); | 3839 Local<Name> key) { |
3830 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3840 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasRealNamedProperty()", |
3831 return maybe.FromJust(); | 3841 bool); |
| 3842 auto self = Utils::OpenHandle(this); |
| 3843 auto key_val = Utils::OpenHandle(*key); |
| 3844 auto result = i::JSObject::HasRealNamedProperty(self, key_val); |
| 3845 has_pending_exception = result.IsNothing(); |
| 3846 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3847 return result; |
3832 } | 3848 } |
3833 | 3849 |
3834 | 3850 |
3835 bool v8::Object::HasRealNamedProperty(Handle<String> key) { | 3851 bool v8::Object::HasRealNamedProperty(Handle<String> key) { |
3836 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3852 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3837 ON_BAILOUT(isolate, "v8::Object::HasRealNamedProperty()", | 3853 return HasRealNamedProperty(context, key).FromMaybe(false); |
3838 return false); | 3854 } |
3839 EXCEPTION_PREAMBLE(isolate); | 3855 |
3840 Maybe<bool> maybe = i::JSObject::HasRealNamedProperty( | 3856 |
3841 Utils::OpenHandle(this), Utils::OpenHandle(*key)); | 3857 Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context, |
3842 has_pending_exception = !maybe.IsJust(); | 3858 uint32_t index) { |
3843 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3859 PREPARE_FOR_EXECUTION_PRIMITIVE(context, |
3844 return maybe.FromJust(); | 3860 "v8::Object::HasRealIndexedProperty()", bool); |
| 3861 auto self = Utils::OpenHandle(this); |
| 3862 auto result = i::JSObject::HasRealElementProperty(self, index); |
| 3863 has_pending_exception = result.IsNothing(); |
| 3864 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3865 return result; |
3845 } | 3866 } |
3846 | 3867 |
3847 | 3868 |
3848 bool v8::Object::HasRealIndexedProperty(uint32_t index) { | 3869 bool v8::Object::HasRealIndexedProperty(uint32_t index) { |
3849 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3870 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3850 ON_BAILOUT(isolate, "v8::Object::HasRealIndexedProperty()", | 3871 return HasRealIndexedProperty(context, index).FromMaybe(false); |
3851 return false); | 3872 } |
3852 EXCEPTION_PREAMBLE(isolate); | 3873 |
3853 Maybe<bool> maybe = | 3874 |
3854 i::JSObject::HasRealElementProperty(Utils::OpenHandle(this), index); | 3875 Maybe<bool> v8::Object::HasRealNamedCallbackProperty(Local<Context> context, |
3855 has_pending_exception = !maybe.IsJust(); | 3876 Local<Name> key) { |
3856 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3877 PREPARE_FOR_EXECUTION_PRIMITIVE( |
3857 return maybe.FromJust(); | 3878 context, "v8::Object::HasRealNamedCallbackProperty()", bool); |
| 3879 auto self = Utils::OpenHandle(this); |
| 3880 auto key_val = Utils::OpenHandle(*key); |
| 3881 auto result = i::JSObject::HasRealNamedCallbackProperty(self, key_val); |
| 3882 has_pending_exception = result.IsNothing(); |
| 3883 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3884 return result; |
3858 } | 3885 } |
3859 | 3886 |
3860 | 3887 |
3861 bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) { | 3888 bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) { |
3862 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3889 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3863 ON_BAILOUT(isolate, | 3890 return HasRealNamedCallbackProperty(context, key).FromMaybe(false); |
3864 "v8::Object::HasRealNamedCallbackProperty()", | |
3865 return false); | |
3866 ENTER_V8(isolate); | |
3867 EXCEPTION_PREAMBLE(isolate); | |
3868 Maybe<bool> maybe = i::JSObject::HasRealNamedCallbackProperty( | |
3869 Utils::OpenHandle(this), Utils::OpenHandle(*key)); | |
3870 has_pending_exception = !maybe.IsJust(); | |
3871 EXCEPTION_BAILOUT_CHECK(isolate, false); | |
3872 return maybe.FromJust(); | |
3873 } | 3891 } |
3874 | 3892 |
3875 | 3893 |
3876 bool v8::Object::HasNamedLookupInterceptor() { | 3894 bool v8::Object::HasNamedLookupInterceptor() { |
3877 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3895 auto self = Utils::OpenHandle(this); |
3878 ON_BAILOUT(isolate, "v8::Object::HasNamedLookupInterceptor()", | 3896 return self->HasNamedInterceptor(); |
3879 return false); | |
3880 return Utils::OpenHandle(this)->HasNamedInterceptor(); | |
3881 } | 3897 } |
3882 | 3898 |
3883 | 3899 |
3884 bool v8::Object::HasIndexedLookupInterceptor() { | 3900 bool v8::Object::HasIndexedLookupInterceptor() { |
3885 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3901 auto self = Utils::OpenHandle(this); |
3886 ON_BAILOUT(isolate, "v8::Object::HasIndexedLookupInterceptor()", | 3902 return self->HasIndexedInterceptor(); |
3887 return false); | |
3888 return Utils::OpenHandle(this)->HasIndexedInterceptor(); | |
3889 } | 3903 } |
3890 | 3904 |
3891 | 3905 |
3892 static Local<Value> GetPropertyByLookup(i::LookupIterator* it) { | 3906 MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
3893 // If the property being looked up is a callback, it can throw an exception. | 3907 Local<Context> context, Local<Name> key) { |
3894 EXCEPTION_PREAMBLE(it->isolate()); | 3908 PREPARE_FOR_EXECUTION( |
3895 i::Handle<i::Object> result; | 3909 context, "v8::Object::GetRealNamedPropertyInPrototypeChain()", Value); |
3896 has_pending_exception = !i::Object::GetProperty(it).ToHandle(&result); | 3910 auto self = Utils::OpenHandle(this); |
3897 EXCEPTION_BAILOUT_CHECK(it->isolate(), Local<Value>()); | 3911 auto key_obj = Utils::OpenHandle(*key); |
3898 | 3912 i::PrototypeIterator iter(isolate, self); |
3899 if (it->IsFound()) return Utils::ToLocal(result); | 3913 if (iter.IsAtEnd()) return MaybeLocal<Value>(); |
3900 return Local<Value>(); | 3914 auto proto = i::PrototypeIterator::GetCurrent(iter); |
3901 } | 3915 i::LookupIterator it(self, key_obj, i::Handle<i::JSReceiver>::cast(proto), |
3902 | 3916 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
3903 | 3917 if (!it.IsFound()) return MaybeLocal<Value>(); |
3904 static Maybe<PropertyAttribute> GetPropertyAttributesByLookup( | 3918 Local<Value> result; |
3905 i::LookupIterator* it) { | 3919 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); |
3906 Maybe<PropertyAttributes> attr = i::JSReceiver::GetPropertyAttributes(it); | 3920 RETURN_ON_FAILED_EXECUTION(Value); |
3907 return it->IsFound() ? Just<PropertyAttribute>( | 3921 RETURN_ESCAPED(result); |
3908 static_cast<PropertyAttribute>(attr.FromJust())) | |
3909 : Nothing<PropertyAttribute>(); | |
3910 } | 3922 } |
3911 | 3923 |
3912 | 3924 |
3913 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( | 3925 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
3914 Handle<String> key) { | 3926 Handle<String> key) { |
3915 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3927 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3916 ON_BAILOUT(isolate, | 3928 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedPropertyInPrototypeChain(context, key), |
3917 "v8::Object::GetRealNamedPropertyInPrototypeChain()", | 3929 Value); |
3918 return Local<Value>()); | 3930 } |
3919 ENTER_V8(isolate); | 3931 |
3920 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); | 3932 |
3921 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 3933 Maybe<PropertyAttribute> |
3922 i::PrototypeIterator iter(isolate, self_obj); | 3934 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain( |
3923 if (iter.IsAtEnd()) return Local<Value>(); | 3935 Local<Context> context, Local<Name> key) { |
3924 i::Handle<i::Object> proto = i::PrototypeIterator::GetCurrent(iter); | 3936 PREPARE_FOR_EXECUTION_PRIMITIVE( |
3925 i::LookupIterator it(self_obj, key_obj, i::Handle<i::JSReceiver>::cast(proto), | 3937 context, "v8::Object::GetRealNamedPropertyAttributesInPrototypeChain()", |
| 3938 PropertyAttribute); |
| 3939 auto self = Utils::OpenHandle(this); |
| 3940 auto key_obj = Utils::OpenHandle(*key); |
| 3941 i::PrototypeIterator iter(isolate, self); |
| 3942 if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); |
| 3943 auto proto = i::PrototypeIterator::GetCurrent(iter); |
| 3944 i::LookupIterator it(self, key_obj, i::Handle<i::JSReceiver>::cast(proto), |
3926 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 3945 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
3927 return GetPropertyByLookup(&it); | 3946 if (!it.IsFound()) return Nothing<PropertyAttribute>(); |
| 3947 auto result = i::JSReceiver::GetPropertyAttributes(&it); |
| 3948 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
| 3949 if (result.FromJust() == ABSENT) { |
| 3950 return Just(static_cast<PropertyAttribute>(NONE)); |
| 3951 } |
| 3952 return Just<PropertyAttribute>( |
| 3953 static_cast<PropertyAttribute>(result.FromJust())); |
3928 } | 3954 } |
3929 | 3955 |
3930 | 3956 |
3931 Maybe<PropertyAttribute> | 3957 Maybe<PropertyAttribute> |
3932 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(Handle<String> key) { | 3958 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(Handle<String> key) { |
3933 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3959 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3934 ON_BAILOUT(isolate, | 3960 return GetRealNamedPropertyAttributesInPrototypeChain(context, key); |
3935 "v8::Object::GetRealNamedPropertyAttributesInPrototypeChain()", | 3961 } |
3936 return Nothing<PropertyAttribute>()); | 3962 |
3937 ENTER_V8(isolate); | 3963 |
3938 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); | 3964 MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context, |
3939 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 3965 Local<Name> key) { |
3940 i::PrototypeIterator iter(isolate, self_obj); | 3966 PREPARE_FOR_EXECUTION( |
3941 if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); | 3967 context, "v8::Object::GetRealNamedPropertyInPrototypeChain()", Value); |
3942 i::Handle<i::Object> proto = i::PrototypeIterator::GetCurrent(iter); | 3968 auto self = Utils::OpenHandle(this); |
3943 i::LookupIterator it(self_obj, key_obj, i::Handle<i::JSReceiver>::cast(proto), | 3969 auto key_obj = Utils::OpenHandle(*key); |
| 3970 i::LookupIterator it(self, key_obj, |
3944 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 3971 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
3945 return GetPropertyAttributesByLookup(&it); | 3972 if (!it.IsFound()) return MaybeLocal<Value>(); |
| 3973 Local<Value> result; |
| 3974 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); |
| 3975 RETURN_ON_FAILED_EXECUTION(Value); |
| 3976 RETURN_ESCAPED(result); |
3946 } | 3977 } |
3947 | 3978 |
3948 | 3979 |
3949 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { | 3980 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { |
3950 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3981 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3951 ON_BAILOUT(isolate, "v8::Object::GetRealNamedProperty()", | 3982 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedProperty(context, key), Value); |
3952 return Local<Value>()); | 3983 } |
3953 ENTER_V8(isolate); | 3984 |
3954 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); | 3985 |
3955 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 3986 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( |
3956 i::LookupIterator it(self_obj, key_obj, | 3987 Local<Context> context, Local<Name> key) { |
| 3988 PREPARE_FOR_EXECUTION_PRIMITIVE( |
| 3989 context, "v8::Object::GetRealNamedPropertyAttributes()", |
| 3990 PropertyAttribute); |
| 3991 auto self = Utils::OpenHandle(this); |
| 3992 auto key_obj = Utils::OpenHandle(*key); |
| 3993 i::LookupIterator it(self, key_obj, |
3957 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 3994 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
3958 return GetPropertyByLookup(&it); | 3995 if (!it.IsFound()) return Nothing<PropertyAttribute>(); |
| 3996 auto result = i::JSReceiver::GetPropertyAttributes(&it); |
| 3997 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
| 3998 if (result.FromJust() == ABSENT) { |
| 3999 return Just(static_cast<PropertyAttribute>(NONE)); |
| 4000 } |
| 4001 return Just<PropertyAttribute>( |
| 4002 static_cast<PropertyAttribute>(result.FromJust())); |
3959 } | 4003 } |
3960 | 4004 |
3961 | 4005 |
3962 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( | 4006 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( |
3963 Handle<String> key) { | 4007 Handle<String> key) { |
3964 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4008 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3965 ON_BAILOUT(isolate, "v8::Object::GetRealNamedPropertyAttributes()", | 4009 return GetRealNamedPropertyAttributes(context, key); |
3966 return Nothing<PropertyAttribute>()); | |
3967 ENTER_V8(isolate); | |
3968 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); | |
3969 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | |
3970 i::LookupIterator it(self_obj, key_obj, | |
3971 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | |
3972 return GetPropertyAttributesByLookup(&it); | |
3973 } | 4010 } |
3974 | 4011 |
3975 | 4012 |
3976 // Turns on access checks by copying the map and setting the check flag. | 4013 // Turns on access checks by copying the map and setting the check flag. |
3977 // Because the object gets a new map, existing inline cache caching | 4014 // Because the object gets a new map, existing inline cache caching |
3978 // the old map of this object will fail. | 4015 // the old map of this object will fail. |
3979 void v8::Object::TurnOnAccessCheck() { | 4016 void v8::Object::TurnOnAccessCheck() { |
3980 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4017 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3981 ON_BAILOUT(isolate, "v8::Object::TurnOnAccessCheck()", return); | |
3982 ENTER_V8(isolate); | 4018 ENTER_V8(isolate); |
3983 i::HandleScope scope(isolate); | 4019 i::HandleScope scope(isolate); |
3984 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 4020 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
3985 | 4021 |
3986 // When turning on access checks for a global object deoptimize all functions | 4022 // When turning on access checks for a global object deoptimize all functions |
3987 // as optimized code does not always handle access checks. | 4023 // as optimized code does not always handle access checks. |
3988 i::Deoptimizer::DeoptimizeGlobalObject(*obj); | 4024 i::Deoptimizer::DeoptimizeGlobalObject(*obj); |
3989 | 4025 |
3990 i::Handle<i::Map> new_map = | 4026 i::Handle<i::Map> new_map = |
3991 i::Map::Copy(i::Handle<i::Map>(obj->map()), "APITurnOnAccessCheck"); | 4027 i::Map::Copy(i::Handle<i::Map>(obj->map()), "APITurnOnAccessCheck"); |
3992 new_map->set_is_access_check_needed(true); | 4028 new_map->set_is_access_check_needed(true); |
3993 i::JSObject::MigrateToMap(obj, new_map); | 4029 i::JSObject::MigrateToMap(obj, new_map); |
3994 } | 4030 } |
3995 | 4031 |
3996 | 4032 |
3997 Local<v8::Object> v8::Object::Clone() { | 4033 Local<v8::Object> v8::Object::Clone() { |
3998 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4034 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3999 ON_BAILOUT(isolate, "v8::Object::Clone()", return Local<Object>()); | 4035 ON_BAILOUT(isolate, "v8::Object::Clone()", return Local<Object>()); |
4000 ENTER_V8(isolate); | 4036 ENTER_V8(isolate); |
4001 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 4037 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
4002 EXCEPTION_PREAMBLE(isolate); | 4038 EXCEPTION_PREAMBLE(isolate); |
4003 i::Handle<i::JSObject> result = isolate->factory()->CopyJSObject(self); | 4039 i::Handle<i::JSObject> result = isolate->factory()->CopyJSObject(self); |
4004 has_pending_exception = result.is_null(); | 4040 has_pending_exception = result.is_null(); |
4005 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); | 4041 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); |
4006 return Utils::ToLocal(result); | 4042 return Utils::ToLocal(result); |
4007 } | 4043 } |
4008 | 4044 |
4009 | 4045 |
4010 Local<v8::Context> v8::Object::CreationContext() { | 4046 Local<v8::Context> v8::Object::CreationContext() { |
4011 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4047 auto self = Utils::OpenHandle(this); |
4012 ON_BAILOUT(isolate, | 4048 auto context = handle(self->GetCreationContext()); |
4013 "v8::Object::CreationContext()", return Local<v8::Context>()); | 4049 return Utils::ToLocal(context); |
4014 ENTER_V8(isolate); | |
4015 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | |
4016 i::Context* context = self->GetCreationContext(); | |
4017 return Utils::ToLocal(i::Handle<i::Context>(context)); | |
4018 } | 4050 } |
4019 | 4051 |
4020 | 4052 |
4021 int v8::Object::GetIdentityHash() { | 4053 int v8::Object::GetIdentityHash() { |
4022 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4054 auto isolate = Utils::OpenHandle(this)->GetIsolate(); |
4023 ON_BAILOUT(isolate, "v8::Object::GetIdentityHash()", return 0); | |
4024 ENTER_V8(isolate); | |
4025 i::HandleScope scope(isolate); | 4055 i::HandleScope scope(isolate); |
4026 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 4056 auto self = Utils::OpenHandle(this); |
4027 return i::JSReceiver::GetOrCreateIdentityHash(self)->value(); | 4057 return i::JSReceiver::GetOrCreateIdentityHash(self)->value(); |
4028 } | 4058 } |
4029 | 4059 |
4030 | 4060 |
4031 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, | 4061 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, |
4032 v8::Handle<v8::Value> value) { | 4062 v8::Handle<v8::Value> value) { |
4033 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4063 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4034 ON_BAILOUT(isolate, "v8::Object::SetHiddenValue()", return false); | |
4035 if (value.IsEmpty()) return DeleteHiddenValue(key); | 4064 if (value.IsEmpty()) return DeleteHiddenValue(key); |
4036 ENTER_V8(isolate); | 4065 ENTER_V8(isolate); |
4037 i::HandleScope scope(isolate); | 4066 i::HandleScope scope(isolate); |
4038 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 4067 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
4039 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 4068 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
4040 i::Handle<i::String> key_string = | 4069 i::Handle<i::String> key_string = |
4041 isolate->factory()->InternalizeString(key_obj); | 4070 isolate->factory()->InternalizeString(key_obj); |
4042 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 4071 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
4043 i::Handle<i::Object> result = | 4072 i::Handle<i::Object> result = |
4044 i::JSObject::SetHiddenProperty(self, key_string, value_obj); | 4073 i::JSObject::SetHiddenProperty(self, key_string, value_obj); |
4045 return *result == *self; | 4074 return *result == *self; |
4046 } | 4075 } |
4047 | 4076 |
4048 | 4077 |
4049 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) { | 4078 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) { |
4050 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4079 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4051 ON_BAILOUT(isolate, "v8::Object::GetHiddenValue()", | |
4052 return Local<v8::Value>()); | |
4053 ENTER_V8(isolate); | 4080 ENTER_V8(isolate); |
4054 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 4081 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
4055 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 4082 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
4056 i::Handle<i::String> key_string = | 4083 i::Handle<i::String> key_string = |
4057 isolate->factory()->InternalizeString(key_obj); | 4084 isolate->factory()->InternalizeString(key_obj); |
4058 i::Handle<i::Object> result(self->GetHiddenProperty(key_string), isolate); | 4085 i::Handle<i::Object> result(self->GetHiddenProperty(key_string), isolate); |
4059 if (result->IsTheHole()) return v8::Local<v8::Value>(); | 4086 if (result->IsTheHole()) return v8::Local<v8::Value>(); |
4060 return Utils::ToLocal(result); | 4087 return Utils::ToLocal(result); |
4061 } | 4088 } |
4062 | 4089 |
4063 | 4090 |
4064 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) { | 4091 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) { |
4065 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4092 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4066 ON_BAILOUT(isolate, "v8::DeleteHiddenValue()", return false); | |
4067 ENTER_V8(isolate); | 4093 ENTER_V8(isolate); |
4068 i::HandleScope scope(isolate); | 4094 i::HandleScope scope(isolate); |
4069 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 4095 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
4070 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 4096 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
4071 i::Handle<i::String> key_string = | 4097 i::Handle<i::String> key_string = |
4072 isolate->factory()->InternalizeString(key_obj); | 4098 isolate->factory()->InternalizeString(key_obj); |
4073 i::JSObject::DeleteHiddenProperty(self, key_string); | 4099 i::JSObject::DeleteHiddenProperty(self, key_string); |
4074 return true; | 4100 return true; |
4075 } | 4101 } |
4076 | 4102 |
(...skipping 3897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7974 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8000 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7975 Address callback_address = | 8001 Address callback_address = |
7976 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8002 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7977 VMState<EXTERNAL> state(isolate); | 8003 VMState<EXTERNAL> state(isolate); |
7978 ExternalCallbackScope call_scope(isolate, callback_address); | 8004 ExternalCallbackScope call_scope(isolate, callback_address); |
7979 callback(info); | 8005 callback(info); |
7980 } | 8006 } |
7981 | 8007 |
7982 | 8008 |
7983 } } // namespace v8::internal | 8009 } } // namespace v8::internal |
OLD | NEW |