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 1938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 // Include \n in case the source contains a line end comment. | 1949 // Include \n in case the source contains a line end comment. |
1950 auto brackets = factory->NewStringFromStaticChars("\n})"); | 1950 auto brackets = factory->NewStringFromStaticChars("\n})"); |
1951 has_pending_exception = | 1951 has_pending_exception = |
1952 !factory->NewConsString(source_string, brackets).ToHandle(&source_string); | 1952 !factory->NewConsString(source_string, brackets).ToHandle(&source_string); |
1953 RETURN_ON_FAILED_EXECUTION(Function); | 1953 RETURN_ON_FAILED_EXECUTION(Function); |
1954 | 1954 |
1955 i::Handle<i::Context> context = Utils::OpenHandle(*v8_context); | 1955 i::Handle<i::Context> context = Utils::OpenHandle(*v8_context); |
1956 i::Handle<i::SharedFunctionInfo> outer_info(context->closure()->shared(), | 1956 i::Handle<i::SharedFunctionInfo> outer_info(context->closure()->shared(), |
1957 isolate); | 1957 isolate); |
1958 for (size_t i = 0; i < context_extension_count; ++i) { | 1958 for (size_t i = 0; i < context_extension_count; ++i) { |
1959 i::Handle<i::JSObject> extension = | 1959 i::Handle<i::JSReceiver> extension = |
1960 Utils::OpenHandle(*context_extensions[i]); | 1960 Utils::OpenHandle(*context_extensions[i]); |
| 1961 if (!extension->IsJSObject()) return Local<Function>(); |
1961 i::Handle<i::JSFunction> closure(context->closure(), isolate); | 1962 i::Handle<i::JSFunction> closure(context->closure(), isolate); |
1962 context = factory->NewWithContext(closure, context, extension); | 1963 context = factory->NewWithContext(closure, context, extension); |
1963 } | 1964 } |
1964 | 1965 |
1965 i::Handle<i::Object> name_obj; | 1966 i::Handle<i::Object> name_obj; |
1966 int line_offset = 0; | 1967 int line_offset = 0; |
1967 int column_offset = 0; | 1968 int column_offset = 0; |
1968 if (!source->resource_name.IsEmpty()) { | 1969 if (!source->resource_name.IsEmpty()) { |
1969 name_obj = Utils::OpenHandle(*(source->resource_name)); | 1970 name_obj = Utils::OpenHandle(*(source->resource_name)); |
1970 } | 1971 } |
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3034 | 3035 |
3035 void External::CheckCast(v8::Value* that) { | 3036 void External::CheckCast(v8::Value* that) { |
3036 Utils::ApiCheck(Utils::OpenHandle(that)->IsExternal(), | 3037 Utils::ApiCheck(Utils::OpenHandle(that)->IsExternal(), |
3037 "v8::External::Cast()", | 3038 "v8::External::Cast()", |
3038 "Could not convert to external"); | 3039 "Could not convert to external"); |
3039 } | 3040 } |
3040 | 3041 |
3041 | 3042 |
3042 void v8::Object::CheckCast(Value* that) { | 3043 void v8::Object::CheckCast(Value* that) { |
3043 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3044 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3044 Utils::ApiCheck(obj->IsJSObject(), | 3045 Utils::ApiCheck(obj->IsJSReceiver(), "v8::Object::Cast()", |
3045 "v8::Object::Cast()", | |
3046 "Could not convert to object"); | 3046 "Could not convert to object"); |
3047 } | 3047 } |
3048 | 3048 |
3049 | 3049 |
3050 void v8::Function::CheckCast(Value* that) { | 3050 void v8::Function::CheckCast(Value* that) { |
3051 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3051 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3052 Utils::ApiCheck(obj->IsCallable(), "v8::Function::Cast()", | 3052 Utils::ApiCheck(obj->IsCallable(), "v8::Function::Cast()", |
3053 "Could not convert to function"); | 3053 "Could not convert to function"); |
3054 } | 3054 } |
3055 | 3055 |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3473 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3473 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3474 return Set(context, index, value).FromMaybe(false); | 3474 return Set(context, index, value).FromMaybe(false); |
3475 } | 3475 } |
3476 | 3476 |
3477 | 3477 |
3478 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, | 3478 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, |
3479 v8::Local<Name> key, | 3479 v8::Local<Name> key, |
3480 v8::Local<Value> value) { | 3480 v8::Local<Value> value) { |
3481 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", | 3481 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", |
3482 bool); | 3482 bool); |
3483 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3483 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
3484 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); | 3484 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
3485 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3485 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
3486 | 3486 |
3487 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 3487 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
3488 isolate, self, key_obj, i::LookupIterator::OWN); | 3488 isolate, self, key_obj, i::LookupIterator::OWN); |
3489 Maybe<bool> result = i::JSObject::CreateDataProperty(&it, value_obj); | 3489 Maybe<bool> result = i::JSReceiver::CreateDataProperty(&it, value_obj); |
3490 has_pending_exception = result.IsNothing(); | 3490 has_pending_exception = result.IsNothing(); |
3491 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3491 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3492 return result; | 3492 return result; |
3493 } | 3493 } |
3494 | 3494 |
3495 | 3495 |
3496 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, | 3496 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, |
3497 uint32_t index, | 3497 uint32_t index, |
3498 v8::Local<Value> value) { | 3498 v8::Local<Value> value) { |
3499 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", | 3499 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", |
3500 bool); | 3500 bool); |
3501 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3501 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
3502 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3502 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
3503 | 3503 |
3504 i::LookupIterator it(isolate, self, index, i::LookupIterator::OWN); | 3504 i::LookupIterator it(isolate, self, index, i::LookupIterator::OWN); |
3505 Maybe<bool> result = i::JSObject::CreateDataProperty(&it, value_obj); | 3505 Maybe<bool> result = i::JSReceiver::CreateDataProperty(&it, value_obj); |
3506 has_pending_exception = result.IsNothing(); | 3506 has_pending_exception = result.IsNothing(); |
3507 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3507 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3508 return result; | 3508 return result; |
3509 } | 3509 } |
3510 | 3510 |
3511 | 3511 |
3512 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, | 3512 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, |
3513 v8::Local<Name> key, | 3513 v8::Local<Name> key, |
3514 v8::Local<Value> value, | 3514 v8::Local<Value> value, |
3515 v8::PropertyAttribute attributes) { | 3515 v8::PropertyAttribute attributes) { |
3516 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DefineOwnProperty()", | 3516 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DefineOwnProperty()", |
3517 bool); | 3517 bool); |
3518 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3518 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
3519 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); | 3519 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
3520 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3520 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
3521 | 3521 |
3522 if (self->IsAccessCheckNeeded() && | 3522 if (self->IsAccessCheckNeeded() && |
3523 !isolate->MayAccess(handle(isolate->context()), self)) { | 3523 !isolate->MayAccess(handle(isolate->context()), |
3524 isolate->ReportFailedAccessCheck(self); | 3524 i::Handle<i::JSObject>::cast(self))) { |
| 3525 isolate->ReportFailedAccessCheck(i::Handle<i::JSObject>::cast(self)); |
3525 return Nothing<bool>(); | 3526 return Nothing<bool>(); |
3526 } | 3527 } |
3527 | 3528 |
3528 i::PropertyDescriptor desc; | 3529 i::PropertyDescriptor desc; |
3529 desc.set_writable(!(attributes & v8::ReadOnly)); | 3530 desc.set_writable(!(attributes & v8::ReadOnly)); |
3530 desc.set_enumerable(!(attributes & v8::DontEnum)); | 3531 desc.set_enumerable(!(attributes & v8::DontEnum)); |
3531 desc.set_configurable(!(attributes & v8::DontDelete)); | 3532 desc.set_configurable(!(attributes & v8::DontDelete)); |
3532 desc.set_value(value_obj); | 3533 desc.set_value(value_obj); |
3533 bool success = i::JSReceiver::DefineOwnProperty(isolate, self, key_obj, &desc, | 3534 bool success = i::JSReceiver::DefineOwnProperty(isolate, self, key_obj, &desc, |
3534 i::Object::DONT_THROW); | 3535 i::Object::DONT_THROW); |
(...skipping 13 matching lines...) Expand all Loading... |
3548 isolate, js_object, key, &success, i::LookupIterator::OWN); | 3549 isolate, js_object, key, &success, i::LookupIterator::OWN); |
3549 if (!success) return i::MaybeHandle<i::Object>(); | 3550 if (!success) return i::MaybeHandle<i::Object>(); |
3550 | 3551 |
3551 return i::JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs); | 3552 return i::JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs); |
3552 } | 3553 } |
3553 | 3554 |
3554 | 3555 |
3555 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, | 3556 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, |
3556 v8::Local<Value> key, v8::Local<Value> value, | 3557 v8::Local<Value> key, v8::Local<Value> value, |
3557 v8::PropertyAttribute attribs) { | 3558 v8::PropertyAttribute attribs) { |
3558 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); | 3559 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::ForceSet()", bool); |
3559 auto self = Utils::OpenHandle(this); | 3560 auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); |
3560 auto key_obj = Utils::OpenHandle(*key); | 3561 auto key_obj = Utils::OpenHandle(*key); |
3561 auto value_obj = Utils::OpenHandle(*value); | 3562 auto value_obj = Utils::OpenHandle(*value); |
3562 has_pending_exception = | 3563 has_pending_exception = |
3563 DefineObjectProperty(self, key_obj, value_obj, | 3564 DefineObjectProperty(self, key_obj, value_obj, |
3564 static_cast<PropertyAttributes>(attribs)).is_null(); | 3565 static_cast<PropertyAttributes>(attribs)).is_null(); |
3565 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3566 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3566 return Just(true); | 3567 return Just(true); |
3567 } | 3568 } |
3568 | 3569 |
3569 | 3570 |
3570 bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value, | 3571 bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value, |
3571 v8::PropertyAttribute attribs) { | 3572 v8::PropertyAttribute attribs) { |
3572 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3573 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3573 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), | 3574 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), |
3574 "v8::Object::ForceSet", false, i::HandleScope, | 3575 "v8::Object::ForceSet", false, i::HandleScope, |
3575 false); | 3576 false); |
3576 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3577 i::Handle<i::JSObject> self = |
| 3578 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); |
3577 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 3579 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
3578 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3580 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
3579 has_pending_exception = | 3581 has_pending_exception = |
3580 DefineObjectProperty(self, key_obj, value_obj, | 3582 DefineObjectProperty(self, key_obj, value_obj, |
3581 static_cast<PropertyAttributes>(attribs)).is_null(); | 3583 static_cast<PropertyAttributes>(attribs)).is_null(); |
3582 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); | 3584 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); |
3583 return true; | 3585 return true; |
3584 } | 3586 } |
3585 | 3587 |
3586 | 3588 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3695 | 3697 |
3696 | 3698 |
3697 Maybe<bool> v8::Object::SetPrototype(Local<Context> context, | 3699 Maybe<bool> v8::Object::SetPrototype(Local<Context> context, |
3698 Local<Value> value) { | 3700 Local<Value> value) { |
3699 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetPrototype()", bool); | 3701 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetPrototype()", bool); |
3700 auto self = Utils::OpenHandle(this); | 3702 auto self = Utils::OpenHandle(this); |
3701 auto value_obj = Utils::OpenHandle(*value); | 3703 auto value_obj = Utils::OpenHandle(*value); |
3702 // We do not allow exceptions thrown while setting the prototype | 3704 // We do not allow exceptions thrown while setting the prototype |
3703 // to propagate outside. | 3705 // to propagate outside. |
3704 TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); | 3706 TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); |
3705 auto result = i::JSObject::SetPrototype(self, value_obj, false, | 3707 auto result = i::JSReceiver::SetPrototype(self, value_obj, false, |
3706 i::Object::THROW_ON_ERROR); | 3708 i::Object::THROW_ON_ERROR); |
3707 has_pending_exception = result.IsNothing(); | 3709 has_pending_exception = result.IsNothing(); |
3708 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3710 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3709 return Just(true); | 3711 return Just(true); |
3710 } | 3712 } |
3711 | 3713 |
3712 | 3714 |
3713 bool v8::Object::SetPrototype(Local<Value> value) { | 3715 bool v8::Object::SetPrototype(Local<Value> value) { |
3714 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3716 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3715 return SetPrototype(context, value).FromMaybe(false); | 3717 return SetPrototype(context, value).FromMaybe(false); |
3716 } | 3718 } |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3937 } | 3939 } |
3938 | 3940 |
3939 | 3941 |
3940 bool v8::Object::Has(uint32_t index) { | 3942 bool v8::Object::Has(uint32_t index) { |
3941 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3943 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3942 return Has(context, index).FromMaybe(false); | 3944 return Has(context, index).FromMaybe(false); |
3943 } | 3945 } |
3944 | 3946 |
3945 | 3947 |
3946 template <typename Getter, typename Setter, typename Data> | 3948 template <typename Getter, typename Setter, typename Data> |
3947 static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* obj, | 3949 static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* self, |
3948 Local<Name> name, Getter getter, | 3950 Local<Name> name, Getter getter, |
3949 Setter setter, Data data, | 3951 Setter setter, Data data, |
3950 AccessControl settings, | 3952 AccessControl settings, |
3951 PropertyAttribute attributes) { | 3953 PropertyAttribute attributes) { |
3952 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetAccessor()", bool); | 3954 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetAccessor()", bool); |
| 3955 if (!Utils::OpenHandle(self)->IsJSObject()) return Just(false); |
| 3956 i::Handle<i::JSObject> obj = |
| 3957 i::Handle<i::JSObject>::cast(Utils::OpenHandle(self)); |
3953 v8::Local<AccessorSignature> signature; | 3958 v8::Local<AccessorSignature> signature; |
3954 auto info = MakeAccessorInfo(name, getter, setter, data, settings, attributes, | 3959 auto info = MakeAccessorInfo(name, getter, setter, data, settings, attributes, |
3955 signature); | 3960 signature); |
3956 if (info.is_null()) return Nothing<bool>(); | 3961 if (info.is_null()) return Nothing<bool>(); |
3957 bool fast = Utils::OpenHandle(obj)->HasFastProperties(); | 3962 bool fast = obj->HasFastProperties(); |
3958 i::Handle<i::Object> result; | 3963 i::Handle<i::Object> result; |
3959 has_pending_exception = | 3964 has_pending_exception = |
3960 !i::JSObject::SetAccessor(Utils::OpenHandle(obj), info).ToHandle(&result); | 3965 !i::JSObject::SetAccessor(obj, info).ToHandle(&result); |
3961 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3966 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3962 if (result->IsUndefined()) return Nothing<bool>(); | 3967 if (result->IsUndefined()) return Nothing<bool>(); |
3963 if (fast) { | 3968 if (fast) { |
3964 i::JSObject::MigrateSlowToFast(Utils::OpenHandle(obj), 0, "APISetAccessor"); | 3969 i::JSObject::MigrateSlowToFast(obj, 0, "APISetAccessor"); |
3965 } | 3970 } |
3966 return Just(true); | 3971 return Just(true); |
3967 } | 3972 } |
3968 | 3973 |
3969 | 3974 |
3970 Maybe<bool> Object::SetAccessor(Local<Context> context, Local<Name> name, | 3975 Maybe<bool> Object::SetAccessor(Local<Context> context, Local<Name> name, |
3971 AccessorNameGetterCallback getter, | 3976 AccessorNameGetterCallback getter, |
3972 AccessorNameSetterCallback setter, | 3977 AccessorNameSetterCallback setter, |
3973 MaybeLocal<Value> data, AccessControl settings, | 3978 MaybeLocal<Value> data, AccessControl settings, |
3974 PropertyAttribute attribute) { | 3979 PropertyAttribute attribute) { |
(...skipping 23 matching lines...) Expand all Loading... |
3998 | 4003 |
3999 void Object::SetAccessorProperty(Local<Name> name, Local<Function> getter, | 4004 void Object::SetAccessorProperty(Local<Name> name, Local<Function> getter, |
4000 Local<Function> setter, | 4005 Local<Function> setter, |
4001 PropertyAttribute attribute, | 4006 PropertyAttribute attribute, |
4002 AccessControl settings) { | 4007 AccessControl settings) { |
4003 // TODO(verwaest): Remove |settings|. | 4008 // TODO(verwaest): Remove |settings|. |
4004 DCHECK_EQ(v8::DEFAULT, settings); | 4009 DCHECK_EQ(v8::DEFAULT, settings); |
4005 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4010 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4006 ENTER_V8(isolate); | 4011 ENTER_V8(isolate); |
4007 i::HandleScope scope(isolate); | 4012 i::HandleScope scope(isolate); |
| 4013 auto self = Utils::OpenHandle(this); |
| 4014 if (!self->IsJSObject()) return; |
4008 i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter); | 4015 i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter); |
4009 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); | 4016 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); |
4010 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); | 4017 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); |
4011 i::JSObject::DefineAccessor(v8::Utils::OpenHandle(this), | 4018 i::JSObject::DefineAccessor(i::Handle<i::JSObject>::cast(self), |
4012 v8::Utils::OpenHandle(*name), | 4019 v8::Utils::OpenHandle(*name), getter_i, setter_i, |
4013 getter_i, | |
4014 setter_i, | |
4015 static_cast<PropertyAttributes>(attribute)); | 4020 static_cast<PropertyAttributes>(attribute)); |
4016 } | 4021 } |
4017 | 4022 |
4018 | 4023 |
4019 Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context, | 4024 Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context, |
4020 Local<Name> key) { | 4025 Local<Name> key) { |
4021 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasOwnProperty()", | 4026 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasOwnProperty()", |
4022 bool); | 4027 bool); |
4023 auto self = Utils::OpenHandle(this); | 4028 auto self = Utils::OpenHandle(this); |
4024 auto key_val = Utils::OpenHandle(*key); | 4029 auto key_val = Utils::OpenHandle(*key); |
4025 auto result = i::JSReceiver::HasOwnProperty(self, key_val); | 4030 auto result = i::JSReceiver::HasOwnProperty(self, key_val); |
4026 has_pending_exception = result.IsNothing(); | 4031 has_pending_exception = result.IsNothing(); |
4027 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4032 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
4028 return result; | 4033 return result; |
4029 } | 4034 } |
4030 | 4035 |
4031 | 4036 |
4032 bool v8::Object::HasOwnProperty(Local<String> key) { | 4037 bool v8::Object::HasOwnProperty(Local<String> key) { |
4033 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4038 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4034 return HasOwnProperty(context, key).FromMaybe(false); | 4039 return HasOwnProperty(context, key).FromMaybe(false); |
4035 } | 4040 } |
4036 | 4041 |
4037 | 4042 |
4038 Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context, | 4043 Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context, |
4039 Local<Name> key) { | 4044 Local<Name> key) { |
4040 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasRealNamedProperty()", | 4045 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasRealNamedProperty()", |
4041 bool); | 4046 bool); |
4042 auto self = Utils::OpenHandle(this); | 4047 auto self = Utils::OpenHandle(this); |
| 4048 if (!self->IsJSObject()) return Just(false); |
4043 auto key_val = Utils::OpenHandle(*key); | 4049 auto key_val = Utils::OpenHandle(*key); |
4044 auto result = i::JSObject::HasRealNamedProperty(self, key_val); | 4050 auto result = i::JSObject::HasRealNamedProperty( |
| 4051 i::Handle<i::JSObject>::cast(self), key_val); |
4045 has_pending_exception = result.IsNothing(); | 4052 has_pending_exception = result.IsNothing(); |
4046 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4053 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
4047 return result; | 4054 return result; |
4048 } | 4055 } |
4049 | 4056 |
4050 | 4057 |
4051 bool v8::Object::HasRealNamedProperty(Local<String> key) { | 4058 bool v8::Object::HasRealNamedProperty(Local<String> key) { |
4052 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4059 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4053 return HasRealNamedProperty(context, key).FromMaybe(false); | 4060 return HasRealNamedProperty(context, key).FromMaybe(false); |
4054 } | 4061 } |
4055 | 4062 |
4056 | 4063 |
4057 Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context, | 4064 Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context, |
4058 uint32_t index) { | 4065 uint32_t index) { |
4059 PREPARE_FOR_EXECUTION_PRIMITIVE(context, | 4066 PREPARE_FOR_EXECUTION_PRIMITIVE(context, |
4060 "v8::Object::HasRealIndexedProperty()", bool); | 4067 "v8::Object::HasRealIndexedProperty()", bool); |
4061 auto self = Utils::OpenHandle(this); | 4068 auto self = Utils::OpenHandle(this); |
4062 auto result = i::JSObject::HasRealElementProperty(self, index); | 4069 if (!self->IsJSObject()) return Just(false); |
| 4070 auto result = i::JSObject::HasRealElementProperty( |
| 4071 i::Handle<i::JSObject>::cast(self), index); |
4063 has_pending_exception = result.IsNothing(); | 4072 has_pending_exception = result.IsNothing(); |
4064 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4073 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
4065 return result; | 4074 return result; |
4066 } | 4075 } |
4067 | 4076 |
4068 | 4077 |
4069 bool v8::Object::HasRealIndexedProperty(uint32_t index) { | 4078 bool v8::Object::HasRealIndexedProperty(uint32_t index) { |
4070 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4079 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4071 return HasRealIndexedProperty(context, index).FromMaybe(false); | 4080 return HasRealIndexedProperty(context, index).FromMaybe(false); |
4072 } | 4081 } |
4073 | 4082 |
4074 | 4083 |
4075 Maybe<bool> v8::Object::HasRealNamedCallbackProperty(Local<Context> context, | 4084 Maybe<bool> v8::Object::HasRealNamedCallbackProperty(Local<Context> context, |
4076 Local<Name> key) { | 4085 Local<Name> key) { |
4077 PREPARE_FOR_EXECUTION_PRIMITIVE( | 4086 PREPARE_FOR_EXECUTION_PRIMITIVE( |
4078 context, "v8::Object::HasRealNamedCallbackProperty()", bool); | 4087 context, "v8::Object::HasRealNamedCallbackProperty()", bool); |
4079 auto self = Utils::OpenHandle(this); | 4088 auto self = Utils::OpenHandle(this); |
| 4089 if (!self->IsJSObject()) return Just(false); |
4080 auto key_val = Utils::OpenHandle(*key); | 4090 auto key_val = Utils::OpenHandle(*key); |
4081 auto result = i::JSObject::HasRealNamedCallbackProperty(self, key_val); | 4091 auto result = i::JSObject::HasRealNamedCallbackProperty( |
| 4092 i::Handle<i::JSObject>::cast(self), key_val); |
4082 has_pending_exception = result.IsNothing(); | 4093 has_pending_exception = result.IsNothing(); |
4083 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4094 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
4084 return result; | 4095 return result; |
4085 } | 4096 } |
4086 | 4097 |
4087 | 4098 |
4088 bool v8::Object::HasRealNamedCallbackProperty(Local<String> key) { | 4099 bool v8::Object::HasRealNamedCallbackProperty(Local<String> key) { |
4089 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4100 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4090 return HasRealNamedCallbackProperty(context, key).FromMaybe(false); | 4101 return HasRealNamedCallbackProperty(context, key).FromMaybe(false); |
4091 } | 4102 } |
4092 | 4103 |
4093 | 4104 |
4094 bool v8::Object::HasNamedLookupInterceptor() { | 4105 bool v8::Object::HasNamedLookupInterceptor() { |
4095 auto self = Utils::OpenHandle(this); | 4106 auto self = Utils::OpenHandle(this); |
4096 return self->HasNamedInterceptor(); | 4107 return self->IsJSObject() && |
| 4108 i::Handle<i::JSObject>::cast(self)->HasNamedInterceptor(); |
4097 } | 4109 } |
4098 | 4110 |
4099 | 4111 |
4100 bool v8::Object::HasIndexedLookupInterceptor() { | 4112 bool v8::Object::HasIndexedLookupInterceptor() { |
4101 auto self = Utils::OpenHandle(this); | 4113 auto self = Utils::OpenHandle(this); |
4102 return self->HasIndexedInterceptor(); | 4114 return self->IsJSObject() && |
| 4115 i::Handle<i::JSObject>::cast(self)->HasIndexedInterceptor(); |
4103 } | 4116 } |
4104 | 4117 |
4105 | 4118 |
4106 MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( | 4119 MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
4107 Local<Context> context, Local<Name> key) { | 4120 Local<Context> context, Local<Name> key) { |
4108 PREPARE_FOR_EXECUTION( | 4121 PREPARE_FOR_EXECUTION( |
4109 context, "v8::Object::GetRealNamedPropertyInPrototypeChain()", Value); | 4122 context, "v8::Object::GetRealNamedPropertyInPrototypeChain()", Value); |
4110 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 4123 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
| 4124 if (!self->IsJSObject()) return MaybeLocal<Value>(); |
4111 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); | 4125 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
4112 i::PrototypeIterator iter(isolate, self); | 4126 i::PrototypeIterator iter(isolate, self); |
4113 if (iter.IsAtEnd()) return MaybeLocal<Value>(); | 4127 if (iter.IsAtEnd()) return MaybeLocal<Value>(); |
4114 i::Handle<i::JSReceiver> proto = | 4128 i::Handle<i::JSReceiver> proto = |
4115 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); | 4129 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); |
4116 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4130 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
4117 isolate, self, key_obj, proto, | 4131 isolate, self, key_obj, proto, |
4118 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4132 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
4119 Local<Value> result; | 4133 Local<Value> result; |
4120 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); | 4134 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); |
(...skipping 10 matching lines...) Expand all Loading... |
4131 Value); | 4145 Value); |
4132 } | 4146 } |
4133 | 4147 |
4134 | 4148 |
4135 Maybe<PropertyAttribute> | 4149 Maybe<PropertyAttribute> |
4136 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain( | 4150 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain( |
4137 Local<Context> context, Local<Name> key) { | 4151 Local<Context> context, Local<Name> key) { |
4138 PREPARE_FOR_EXECUTION_PRIMITIVE( | 4152 PREPARE_FOR_EXECUTION_PRIMITIVE( |
4139 context, "v8::Object::GetRealNamedPropertyAttributesInPrototypeChain()", | 4153 context, "v8::Object::GetRealNamedPropertyAttributesInPrototypeChain()", |
4140 PropertyAttribute); | 4154 PropertyAttribute); |
4141 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 4155 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
| 4156 if (!self->IsJSObject()) return Nothing<PropertyAttribute>(); |
4142 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); | 4157 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
4143 i::PrototypeIterator iter(isolate, self); | 4158 i::PrototypeIterator iter(isolate, self); |
4144 if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); | 4159 if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); |
4145 i::Handle<i::JSReceiver> proto = | 4160 i::Handle<i::JSReceiver> proto = |
4146 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); | 4161 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); |
4147 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4162 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
4148 isolate, self, key_obj, proto, | 4163 isolate, self, key_obj, proto, |
4149 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4164 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
4150 Maybe<PropertyAttributes> result = i::JSReceiver::GetPropertyAttributes(&it); | 4165 Maybe<PropertyAttributes> result = i::JSReceiver::GetPropertyAttributes(&it); |
4151 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 4166 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4206 | 4221 |
4207 | 4222 |
4208 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( | 4223 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( |
4209 Local<String> key) { | 4224 Local<String> key) { |
4210 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4225 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4211 return GetRealNamedPropertyAttributes(context, key); | 4226 return GetRealNamedPropertyAttributes(context, key); |
4212 } | 4227 } |
4213 | 4228 |
4214 | 4229 |
4215 Local<v8::Object> v8::Object::Clone() { | 4230 Local<v8::Object> v8::Object::Clone() { |
4216 auto self = Utils::OpenHandle(this); | 4231 auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); |
4217 auto isolate = self->GetIsolate(); | 4232 auto isolate = self->GetIsolate(); |
4218 ENTER_V8(isolate); | 4233 ENTER_V8(isolate); |
4219 auto result = isolate->factory()->CopyJSObject(self); | 4234 auto result = isolate->factory()->CopyJSObject(self); |
4220 CHECK(!result.is_null()); | 4235 CHECK(!result.is_null()); |
4221 return Utils::ToLocal(result); | 4236 return Utils::ToLocal(result); |
4222 } | 4237 } |
4223 | 4238 |
4224 | 4239 |
4225 Local<v8::Context> v8::Object::CreationContext() { | 4240 Local<v8::Context> v8::Object::CreationContext() { |
4226 auto self = Utils::OpenHandle(this); | 4241 auto self = Utils::OpenHandle(this); |
4227 auto context = handle(self->GetCreationContext()); | 4242 auto context = handle(self->GetCreationContext()); |
4228 return Utils::ToLocal(context); | 4243 return Utils::ToLocal(context); |
4229 } | 4244 } |
4230 | 4245 |
4231 | 4246 |
4232 int v8::Object::GetIdentityHash() { | 4247 int v8::Object::GetIdentityHash() { |
4233 auto isolate = Utils::OpenHandle(this)->GetIsolate(); | 4248 auto isolate = Utils::OpenHandle(this)->GetIsolate(); |
4234 i::HandleScope scope(isolate); | 4249 i::HandleScope scope(isolate); |
4235 auto self = Utils::OpenHandle(this); | 4250 auto self = Utils::OpenHandle(this); |
4236 return i::JSReceiver::GetOrCreateIdentityHash(self)->value(); | 4251 return i::JSReceiver::GetOrCreateIdentityHash(self)->value(); |
4237 } | 4252 } |
4238 | 4253 |
4239 | 4254 |
4240 bool v8::Object::SetHiddenValue(v8::Local<v8::String> key, | 4255 bool v8::Object::SetHiddenValue(v8::Local<v8::String> key, |
4241 v8::Local<v8::Value> value) { | 4256 v8::Local<v8::Value> value) { |
4242 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4257 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4243 ENTER_V8(isolate); | 4258 ENTER_V8(isolate); |
4244 i::HandleScope scope(isolate); | 4259 i::HandleScope scope(isolate); |
4245 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 4260 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
| 4261 if (!self->IsJSObject()) return false; |
4246 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 4262 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
4247 i::Handle<i::String> key_string = | 4263 i::Handle<i::String> key_string = |
4248 isolate->factory()->InternalizeString(key_obj); | 4264 isolate->factory()->InternalizeString(key_obj); |
4249 if (value.IsEmpty()) { | 4265 if (value.IsEmpty()) { |
4250 i::JSObject::DeleteHiddenProperty(self, key_string); | 4266 i::JSObject::DeleteHiddenProperty(i::Handle<i::JSObject>::cast(self), |
| 4267 key_string); |
4251 return true; | 4268 return true; |
4252 } | 4269 } |
4253 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 4270 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
4254 i::Handle<i::Object> result = | 4271 i::Handle<i::Object> result = i::JSObject::SetHiddenProperty( |
4255 i::JSObject::SetHiddenProperty(self, key_string, value_obj); | 4272 i::Handle<i::JSObject>::cast(self), key_string, value_obj); |
4256 return *result == *self; | 4273 return *result == *self; |
4257 } | 4274 } |
4258 | 4275 |
4259 | 4276 |
4260 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Local<v8::String> key) { | 4277 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Local<v8::String> key) { |
4261 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4278 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4262 ENTER_V8(isolate); | 4279 ENTER_V8(isolate); |
4263 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 4280 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
| 4281 if (!self->IsJSObject()) return v8::Local<v8::Value>(); |
4264 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 4282 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
4265 i::Handle<i::String> key_string = | 4283 i::Handle<i::String> key_string = |
4266 isolate->factory()->InternalizeString(key_obj); | 4284 isolate->factory()->InternalizeString(key_obj); |
4267 i::Handle<i::Object> result(self->GetHiddenProperty(key_string), isolate); | 4285 i::Handle<i::Object> result( |
| 4286 i::Handle<i::JSObject>::cast(self)->GetHiddenProperty(key_string), |
| 4287 isolate); |
4268 if (result->IsTheHole()) return v8::Local<v8::Value>(); | 4288 if (result->IsTheHole()) return v8::Local<v8::Value>(); |
4269 return Utils::ToLocal(result); | 4289 return Utils::ToLocal(result); |
4270 } | 4290 } |
4271 | 4291 |
4272 | 4292 |
4273 bool v8::Object::DeleteHiddenValue(v8::Local<v8::String> key) { | 4293 bool v8::Object::DeleteHiddenValue(v8::Local<v8::String> key) { |
4274 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4294 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4275 ENTER_V8(isolate); | 4295 ENTER_V8(isolate); |
4276 i::HandleScope scope(isolate); | 4296 i::HandleScope scope(isolate); |
4277 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 4297 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
| 4298 if (!self->IsJSObject()) return false; |
4278 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 4299 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
4279 i::Handle<i::String> key_string = | 4300 i::Handle<i::String> key_string = |
4280 isolate->factory()->InternalizeString(key_obj); | 4301 isolate->factory()->InternalizeString(key_obj); |
4281 i::JSObject::DeleteHiddenProperty(self, key_string); | 4302 i::JSObject::DeleteHiddenProperty(i::Handle<i::JSObject>::cast(self), |
| 4303 key_string); |
4282 return true; | 4304 return true; |
4283 } | 4305 } |
4284 | 4306 |
4285 | 4307 |
4286 bool v8::Object::IsCallable() { | 4308 bool v8::Object::IsCallable() { |
4287 auto self = Utils::OpenHandle(this); | 4309 auto self = Utils::OpenHandle(this); |
4288 return self->IsCallable(); | 4310 return self->IsCallable(); |
4289 } | 4311 } |
4290 | 4312 |
4291 | 4313 |
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5295 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5317 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5296 if (obj->IsSmi()) { | 5318 if (obj->IsSmi()) { |
5297 return i::Smi::cast(*obj)->value(); | 5319 return i::Smi::cast(*obj)->value(); |
5298 } else { | 5320 } else { |
5299 return static_cast<uint32_t>(obj->Number()); | 5321 return static_cast<uint32_t>(obj->Number()); |
5300 } | 5322 } |
5301 } | 5323 } |
5302 | 5324 |
5303 | 5325 |
5304 int v8::Object::InternalFieldCount() { | 5326 int v8::Object::InternalFieldCount() { |
5305 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 5327 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
5306 return obj->GetInternalFieldCount(); | 5328 if (!self->IsJSObject()) return 0; |
| 5329 return i::Handle<i::JSObject>::cast(self)->GetInternalFieldCount(); |
5307 } | 5330 } |
5308 | 5331 |
5309 | 5332 |
5310 static bool InternalFieldOK(i::Handle<i::JSObject> obj, | 5333 static bool InternalFieldOK(i::Handle<i::JSReceiver> obj, int index, |
5311 int index, | |
5312 const char* location) { | 5334 const char* location) { |
5313 return Utils::ApiCheck(index < obj->GetInternalFieldCount(), | 5335 return Utils::ApiCheck( |
5314 location, | 5336 obj->IsJSObject() && |
5315 "Internal field out of bounds"); | 5337 (index < i::Handle<i::JSObject>::cast(obj)->GetInternalFieldCount()), |
| 5338 location, "Internal field out of bounds"); |
5316 } | 5339 } |
5317 | 5340 |
5318 | 5341 |
5319 Local<Value> v8::Object::SlowGetInternalField(int index) { | 5342 Local<Value> v8::Object::SlowGetInternalField(int index) { |
5320 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 5343 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this); |
5321 const char* location = "v8::Object::GetInternalField()"; | 5344 const char* location = "v8::Object::GetInternalField()"; |
5322 if (!InternalFieldOK(obj, index, location)) return Local<Value>(); | 5345 if (!InternalFieldOK(obj, index, location)) return Local<Value>(); |
5323 i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate()); | 5346 i::Handle<i::Object> value( |
| 5347 i::Handle<i::JSObject>::cast(obj)->GetInternalField(index), |
| 5348 obj->GetIsolate()); |
5324 return Utils::ToLocal(value); | 5349 return Utils::ToLocal(value); |
5325 } | 5350 } |
5326 | 5351 |
5327 | 5352 |
5328 void v8::Object::SetInternalField(int index, v8::Local<Value> value) { | 5353 void v8::Object::SetInternalField(int index, v8::Local<Value> value) { |
5329 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 5354 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this); |
5330 const char* location = "v8::Object::SetInternalField()"; | 5355 const char* location = "v8::Object::SetInternalField()"; |
5331 if (!InternalFieldOK(obj, index, location)) return; | 5356 if (!InternalFieldOK(obj, index, location)) return; |
5332 i::Handle<i::Object> val = Utils::OpenHandle(*value); | 5357 i::Handle<i::Object> val = Utils::OpenHandle(*value); |
5333 obj->SetInternalField(index, *val); | 5358 i::Handle<i::JSObject>::cast(obj)->SetInternalField(index, *val); |
5334 } | 5359 } |
5335 | 5360 |
5336 | 5361 |
5337 void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) { | 5362 void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) { |
5338 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 5363 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this); |
5339 const char* location = "v8::Object::GetAlignedPointerFromInternalField()"; | 5364 const char* location = "v8::Object::GetAlignedPointerFromInternalField()"; |
5340 if (!InternalFieldOK(obj, index, location)) return NULL; | 5365 if (!InternalFieldOK(obj, index, location)) return NULL; |
5341 return DecodeSmiToAligned(obj->GetInternalField(index), location); | 5366 return DecodeSmiToAligned( |
| 5367 i::Handle<i::JSObject>::cast(obj)->GetInternalField(index), location); |
5342 } | 5368 } |
5343 | 5369 |
5344 | 5370 |
5345 void v8::Object::SetAlignedPointerInInternalField(int index, void* value) { | 5371 void v8::Object::SetAlignedPointerInInternalField(int index, void* value) { |
5346 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 5372 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this); |
5347 const char* location = "v8::Object::SetAlignedPointerInInternalField()"; | 5373 const char* location = "v8::Object::SetAlignedPointerInInternalField()"; |
5348 if (!InternalFieldOK(obj, index, location)) return; | 5374 if (!InternalFieldOK(obj, index, location)) return; |
5349 obj->SetInternalField(index, EncodeAlignedAsSmi(value, location)); | 5375 i::Handle<i::JSObject>::cast(obj) |
| 5376 ->SetInternalField(index, EncodeAlignedAsSmi(value, location)); |
5350 DCHECK_EQ(value, GetAlignedPointerFromInternalField(index)); | 5377 DCHECK_EQ(value, GetAlignedPointerFromInternalField(index)); |
5351 } | 5378 } |
5352 | 5379 |
5353 | 5380 |
5354 static void* ExternalValue(i::Object* obj) { | 5381 static void* ExternalValue(i::Object* obj) { |
5355 // Obscure semantics for undefined, but somehow checked in our unit tests... | 5382 // Obscure semantics for undefined, but somehow checked in our unit tests... |
5356 if (obj->IsUndefined()) return NULL; | 5383 if (obj->IsUndefined()) return NULL; |
5357 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0); | 5384 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0); |
5358 return i::Foreign::cast(foreign)->foreign_address(); | 5385 return i::Foreign::cast(foreign)->foreign_address(); |
5359 } | 5386 } |
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6419 } | 6446 } |
6420 | 6447 |
6421 | 6448 |
6422 Local<Promise::Resolver> Promise::Resolver::New(Isolate* isolate) { | 6449 Local<Promise::Resolver> Promise::Resolver::New(Isolate* isolate) { |
6423 RETURN_TO_LOCAL_UNCHECKED(New(isolate->GetCurrentContext()), | 6450 RETURN_TO_LOCAL_UNCHECKED(New(isolate->GetCurrentContext()), |
6424 Promise::Resolver); | 6451 Promise::Resolver); |
6425 } | 6452 } |
6426 | 6453 |
6427 | 6454 |
6428 Local<Promise> Promise::Resolver::GetPromise() { | 6455 Local<Promise> Promise::Resolver::GetPromise() { |
6429 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); | 6456 i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this); |
6430 return Local<Promise>::Cast(Utils::ToLocal(promise)); | 6457 return Local<Promise>::Cast(Utils::ToLocal(promise)); |
6431 } | 6458 } |
6432 | 6459 |
6433 | 6460 |
6434 Maybe<bool> Promise::Resolver::Resolve(Local<Context> context, | 6461 Maybe<bool> Promise::Resolver::Resolve(Local<Context> context, |
6435 Local<Value> value) { | 6462 Local<Value> value) { |
6436 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool); | 6463 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool); |
6437 auto self = Utils::OpenHandle(this); | 6464 auto self = Utils::OpenHandle(this); |
6438 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; | 6465 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; |
6439 has_pending_exception = | 6466 has_pending_exception = |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6527 } | 6554 } |
6528 | 6555 |
6529 | 6556 |
6530 Local<Promise> Promise::Then(Local<Function> handler) { | 6557 Local<Promise> Promise::Then(Local<Function> handler) { |
6531 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6558 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
6532 RETURN_TO_LOCAL_UNCHECKED(Then(context, handler), Promise); | 6559 RETURN_TO_LOCAL_UNCHECKED(Then(context, handler), Promise); |
6533 } | 6560 } |
6534 | 6561 |
6535 | 6562 |
6536 bool Promise::HasHandler() { | 6563 bool Promise::HasHandler() { |
6537 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); | 6564 i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this); |
6538 i::Isolate* isolate = promise->GetIsolate(); | 6565 i::Isolate* isolate = promise->GetIsolate(); |
6539 LOG_API(isolate, "Promise::HasRejectHandler"); | 6566 LOG_API(isolate, "Promise::HasRejectHandler"); |
6540 ENTER_V8(isolate); | 6567 ENTER_V8(isolate); |
6541 i::Handle<i::Symbol> key = isolate->factory()->promise_has_handler_symbol(); | 6568 i::Handle<i::Symbol> key = isolate->factory()->promise_has_handler_symbol(); |
6542 return i::JSReceiver::GetDataProperty(promise, key)->IsTrue(); | 6569 return i::JSReceiver::GetDataProperty(promise, key)->IsTrue(); |
6543 } | 6570 } |
6544 | 6571 |
6545 | 6572 |
6546 bool v8::ArrayBuffer::IsExternal() const { | 6573 bool v8::ArrayBuffer::IsExternal() const { |
6547 return Utils::OpenHandle(this)->is_external(); | 6574 return Utils::OpenHandle(this)->is_external(); |
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7812 i::Debug* isolate_debug = isolate->debug(); | 7839 i::Debug* isolate_debug = isolate->debug(); |
7813 has_pending_exception = !isolate_debug->Load(); | 7840 has_pending_exception = !isolate_debug->Load(); |
7814 RETURN_ON_FAILED_EXECUTION(Value); | 7841 RETURN_ON_FAILED_EXECUTION(Value); |
7815 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); | 7842 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); |
7816 auto name = isolate->factory()->NewStringFromStaticChars("MakeMirror"); | 7843 auto name = isolate->factory()->NewStringFromStaticChars("MakeMirror"); |
7817 auto fun_obj = i::Object::GetProperty(debug, name).ToHandleChecked(); | 7844 auto fun_obj = i::Object::GetProperty(debug, name).ToHandleChecked(); |
7818 auto v8_fun = Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(fun_obj)); | 7845 auto v8_fun = Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(fun_obj)); |
7819 const int kArgc = 1; | 7846 const int kArgc = 1; |
7820 v8::Local<v8::Value> argv[kArgc] = {obj}; | 7847 v8::Local<v8::Value> argv[kArgc] = {obj}; |
7821 Local<Value> result; | 7848 Local<Value> result; |
7822 has_pending_exception = !v8_fun->Call(context, Utils::ToLocal(debug), kArgc, | 7849 has_pending_exception = |
7823 argv).ToLocal(&result); | 7850 !v8_fun->Call(context, Utils::ToLocal(debug), kArgc, argv) |
| 7851 .ToLocal(&result); |
7824 RETURN_ON_FAILED_EXECUTION(Value); | 7852 RETURN_ON_FAILED_EXECUTION(Value); |
7825 RETURN_ESCAPED(result); | 7853 RETURN_ESCAPED(result); |
7826 } | 7854 } |
7827 | 7855 |
7828 | 7856 |
7829 Local<Value> Debug::GetMirror(v8::Local<v8::Value> obj) { | 7857 Local<Value> Debug::GetMirror(v8::Local<v8::Value> obj) { |
7830 RETURN_TO_LOCAL_UNCHECKED(GetMirror(Local<Context>(), obj), Value); | 7858 RETURN_TO_LOCAL_UNCHECKED(GetMirror(Local<Context>(), obj), Value); |
7831 } | 7859 } |
7832 | 7860 |
7833 | 7861 |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8500 Address callback_address = | 8528 Address callback_address = |
8501 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8529 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8502 VMState<EXTERNAL> state(isolate); | 8530 VMState<EXTERNAL> state(isolate); |
8503 ExternalCallbackScope call_scope(isolate, callback_address); | 8531 ExternalCallbackScope call_scope(isolate, callback_address); |
8504 callback(info); | 8532 callback(info); |
8505 } | 8533 } |
8506 | 8534 |
8507 | 8535 |
8508 } // namespace internal | 8536 } // namespace internal |
8509 } // namespace v8 | 8537 } // namespace v8 |
OLD | NEW |