Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Side by Side Diff: src/api.cc

Issue 1413463006: Map v8::Object to v8::internal::JSReceiver (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/api.h ('k') | src/debug/debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 // Include \n in case the source contains a line end comment. 1968 // Include \n in case the source contains a line end comment.
1969 auto brackets = factory->NewStringFromStaticChars("\n})"); 1969 auto brackets = factory->NewStringFromStaticChars("\n})");
1970 has_pending_exception = 1970 has_pending_exception =
1971 !factory->NewConsString(source_string, brackets).ToHandle(&source_string); 1971 !factory->NewConsString(source_string, brackets).ToHandle(&source_string);
1972 RETURN_ON_FAILED_EXECUTION(Function); 1972 RETURN_ON_FAILED_EXECUTION(Function);
1973 1973
1974 i::Handle<i::Context> context = Utils::OpenHandle(*v8_context); 1974 i::Handle<i::Context> context = Utils::OpenHandle(*v8_context);
1975 i::Handle<i::SharedFunctionInfo> outer_info(context->closure()->shared(), 1975 i::Handle<i::SharedFunctionInfo> outer_info(context->closure()->shared(),
1976 isolate); 1976 isolate);
1977 for (size_t i = 0; i < context_extension_count; ++i) { 1977 for (size_t i = 0; i < context_extension_count; ++i) {
1978 i::Handle<i::JSObject> extension = 1978 i::Handle<i::JSReceiver> extension =
1979 Utils::OpenHandle(*context_extensions[i]); 1979 Utils::OpenHandle(*context_extensions[i]);
1980 if (!extension->IsJSObject()) return Local<Function>();
1980 i::Handle<i::JSFunction> closure(context->closure(), isolate); 1981 i::Handle<i::JSFunction> closure(context->closure(), isolate);
1981 context = factory->NewWithContext(closure, context, extension); 1982 context = factory->NewWithContext(closure, context, extension);
1982 } 1983 }
1983 1984
1984 i::Handle<i::Object> name_obj; 1985 i::Handle<i::Object> name_obj;
1985 int line_offset = 0; 1986 int line_offset = 0;
1986 int column_offset = 0; 1987 int column_offset = 0;
1987 if (!source->resource_name.IsEmpty()) { 1988 if (!source->resource_name.IsEmpty()) {
1988 name_obj = Utils::OpenHandle(*(source->resource_name)); 1989 name_obj = Utils::OpenHandle(*(source->resource_name));
1989 } 1990 }
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
3053 3054
3054 void External::CheckCast(v8::Value* that) { 3055 void External::CheckCast(v8::Value* that) {
3055 Utils::ApiCheck(Utils::OpenHandle(that)->IsExternal(), 3056 Utils::ApiCheck(Utils::OpenHandle(that)->IsExternal(),
3056 "v8::External::Cast()", 3057 "v8::External::Cast()",
3057 "Could not convert to external"); 3058 "Could not convert to external");
3058 } 3059 }
3059 3060
3060 3061
3061 void v8::Object::CheckCast(Value* that) { 3062 void v8::Object::CheckCast(Value* that) {
3062 i::Handle<i::Object> obj = Utils::OpenHandle(that); 3063 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3063 Utils::ApiCheck(obj->IsJSObject(), 3064 Utils::ApiCheck(obj->IsJSReceiver(), "v8::Object::Cast()",
3064 "v8::Object::Cast()",
3065 "Could not convert to object"); 3065 "Could not convert to object");
3066 } 3066 }
3067 3067
3068 3068
3069 void v8::Function::CheckCast(Value* that) { 3069 void v8::Function::CheckCast(Value* that) {
3070 i::Handle<i::Object> obj = Utils::OpenHandle(that); 3070 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3071 Utils::ApiCheck(obj->IsCallable(), "v8::Function::Cast()", 3071 Utils::ApiCheck(obj->IsCallable(), "v8::Function::Cast()",
3072 "Could not convert to function"); 3072 "Could not convert to function");
3073 } 3073 }
3074 3074
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
3492 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 3492 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
3493 return Set(context, index, value).FromMaybe(false); 3493 return Set(context, index, value).FromMaybe(false);
3494 } 3494 }
3495 3495
3496 3496
3497 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, 3497 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context,
3498 v8::Local<Name> key, 3498 v8::Local<Name> key,
3499 v8::Local<Value> value) { 3499 v8::Local<Value> value) {
3500 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", 3500 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()",
3501 bool); 3501 bool);
3502 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3502 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
3503 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); 3503 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
3504 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 3504 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3505 3505
3506 i::LookupIterator it = i::LookupIterator::PropertyOrElement( 3506 i::LookupIterator it = i::LookupIterator::PropertyOrElement(
3507 isolate, self, key_obj, i::LookupIterator::OWN); 3507 isolate, self, key_obj, i::LookupIterator::OWN);
3508 Maybe<bool> result = i::JSObject::CreateDataProperty(&it, value_obj); 3508 Maybe<bool> result = i::JSReceiver::CreateDataProperty(&it, value_obj);
3509 has_pending_exception = result.IsNothing(); 3509 has_pending_exception = result.IsNothing();
3510 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3510 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3511 return result; 3511 return result;
3512 } 3512 }
3513 3513
3514 3514
3515 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, 3515 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context,
3516 uint32_t index, 3516 uint32_t index,
3517 v8::Local<Value> value) { 3517 v8::Local<Value> value) {
3518 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", 3518 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()",
3519 bool); 3519 bool);
3520 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3520 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
3521 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 3521 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3522 3522
3523 i::LookupIterator it(isolate, self, index, i::LookupIterator::OWN); 3523 i::LookupIterator it(isolate, self, index, i::LookupIterator::OWN);
3524 Maybe<bool> result = i::JSObject::CreateDataProperty(&it, value_obj); 3524 Maybe<bool> result = i::JSReceiver::CreateDataProperty(&it, value_obj);
3525 has_pending_exception = result.IsNothing(); 3525 has_pending_exception = result.IsNothing();
3526 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3526 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3527 return result; 3527 return result;
3528 } 3528 }
3529 3529
3530 3530
3531 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, 3531 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context,
3532 v8::Local<Name> key, 3532 v8::Local<Name> key,
3533 v8::Local<Value> value, 3533 v8::Local<Value> value,
3534 v8::PropertyAttribute attributes) { 3534 v8::PropertyAttribute attributes) {
3535 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DefineOwnProperty()", 3535 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DefineOwnProperty()",
3536 bool); 3536 bool);
3537 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3537 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
3538 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); 3538 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
3539 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 3539 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3540 3540
3541 if (self->IsAccessCheckNeeded() && 3541 if (self->IsAccessCheckNeeded() &&
3542 !isolate->MayAccess(handle(isolate->context()), self)) { 3542 !isolate->MayAccess(handle(isolate->context()),
3543 isolate->ReportFailedAccessCheck(self); 3543 i::Handle<i::JSObject>::cast(self))) {
jochen (gone - plz use gerrit) 2015/11/06 22:23:28 proxies can't have access checks, so that's safe
3544 isolate->ReportFailedAccessCheck(i::Handle<i::JSObject>::cast(self));
3544 return Nothing<bool>(); 3545 return Nothing<bool>();
3545 } 3546 }
3546 3547
3547 i::PropertyDescriptor desc; 3548 i::PropertyDescriptor desc;
3548 desc.set_writable(!(attributes & v8::ReadOnly)); 3549 desc.set_writable(!(attributes & v8::ReadOnly));
3549 desc.set_enumerable(!(attributes & v8::DontEnum)); 3550 desc.set_enumerable(!(attributes & v8::DontEnum));
3550 desc.set_configurable(!(attributes & v8::DontDelete)); 3551 desc.set_configurable(!(attributes & v8::DontDelete));
3551 desc.set_value(value_obj); 3552 desc.set_value(value_obj);
3552 bool success = i::JSReceiver::DefineOwnProperty(isolate, self, key_obj, &desc, 3553 bool success = i::JSReceiver::DefineOwnProperty(isolate, self, key_obj, &desc,
3553 i::Object::DONT_THROW); 3554 i::Object::DONT_THROW);
(...skipping 13 matching lines...) Expand all
3567 isolate, js_object, key, &success, i::LookupIterator::OWN); 3568 isolate, js_object, key, &success, i::LookupIterator::OWN);
3568 if (!success) return i::MaybeHandle<i::Object>(); 3569 if (!success) return i::MaybeHandle<i::Object>();
3569 3570
3570 return i::JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs); 3571 return i::JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs);
3571 } 3572 }
3572 3573
3573 3574
3574 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, 3575 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context,
3575 v8::Local<Value> key, v8::Local<Value> value, 3576 v8::Local<Value> key, v8::Local<Value> value,
3576 v8::PropertyAttribute attribs) { 3577 v8::PropertyAttribute attribs) {
3577 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); 3578 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::ForceSet()", bool);
3578 auto self = Utils::OpenHandle(this); 3579 auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
jochen (gone - plz use gerrit) 2015/11/06 22:23:28 deprecated method, just don't call this on proxies
3579 auto key_obj = Utils::OpenHandle(*key); 3580 auto key_obj = Utils::OpenHandle(*key);
3580 auto value_obj = Utils::OpenHandle(*value); 3581 auto value_obj = Utils::OpenHandle(*value);
3581 has_pending_exception = 3582 has_pending_exception =
3582 DefineObjectProperty(self, key_obj, value_obj, 3583 DefineObjectProperty(self, key_obj, value_obj,
3583 static_cast<PropertyAttributes>(attribs)).is_null(); 3584 static_cast<PropertyAttributes>(attribs)).is_null();
3584 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3585 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3585 return Just(true); 3586 return Just(true);
3586 } 3587 }
3587 3588
3588 3589
3589 bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value, 3590 bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value,
3590 v8::PropertyAttribute attribs) { 3591 v8::PropertyAttribute attribs) {
3591 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3592 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3592 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), 3593 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(),
3593 "v8::Object::ForceSet", false, i::HandleScope, 3594 "v8::Object::ForceSet", false, i::HandleScope,
3594 false); 3595 false);
3595 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3596 i::Handle<i::JSObject> self =
3597 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
3596 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3598 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3597 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 3599 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3598 has_pending_exception = 3600 has_pending_exception =
3599 DefineObjectProperty(self, key_obj, value_obj, 3601 DefineObjectProperty(self, key_obj, value_obj,
3600 static_cast<PropertyAttributes>(attribs)).is_null(); 3602 static_cast<PropertyAttributes>(attribs)).is_null();
3601 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); 3603 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false);
3602 return true; 3604 return true;
3603 } 3605 }
3604 3606
3605 3607
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
3714 3716
3715 3717
3716 Maybe<bool> v8::Object::SetPrototype(Local<Context> context, 3718 Maybe<bool> v8::Object::SetPrototype(Local<Context> context,
3717 Local<Value> value) { 3719 Local<Value> value) {
3718 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetPrototype()", bool); 3720 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetPrototype()", bool);
3719 auto self = Utils::OpenHandle(this); 3721 auto self = Utils::OpenHandle(this);
3720 auto value_obj = Utils::OpenHandle(*value); 3722 auto value_obj = Utils::OpenHandle(*value);
3721 // We do not allow exceptions thrown while setting the prototype 3723 // We do not allow exceptions thrown while setting the prototype
3722 // to propagate outside. 3724 // to propagate outside.
3723 TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); 3725 TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
3724 auto result = i::JSObject::SetPrototype(self, value_obj, false, 3726 auto result = i::JSReceiver::SetPrototype(self, value_obj, false,
3725 i::Object::THROW_ON_ERROR); 3727 i::Object::THROW_ON_ERROR);
3726 has_pending_exception = result.IsNothing(); 3728 has_pending_exception = result.IsNothing();
3727 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3729 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3728 return Just(true); 3730 return Just(true);
3729 } 3731 }
3730 3732
3731 3733
3732 bool v8::Object::SetPrototype(Local<Value> value) { 3734 bool v8::Object::SetPrototype(Local<Value> value) {
3733 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 3735 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
3734 return SetPrototype(context, value).FromMaybe(false); 3736 return SetPrototype(context, value).FromMaybe(false);
3735 } 3737 }
3736 3738
3737 3739
3738 Local<Object> v8::Object::FindInstanceInPrototypeChain( 3740 Local<Object> v8::Object::FindInstanceInPrototypeChain(
3739 v8::Local<FunctionTemplate> tmpl) { 3741 v8::Local<FunctionTemplate> tmpl) {
3740 auto isolate = Utils::OpenHandle(this)->GetIsolate(); 3742 auto isolate = Utils::OpenHandle(this)->GetIsolate();
3741 i::PrototypeIterator iter(isolate, *Utils::OpenHandle(this), 3743 i::PrototypeIterator iter(isolate, *Utils::OpenHandle(this),
3742 i::PrototypeIterator::START_AT_RECEIVER); 3744 i::PrototypeIterator::START_AT_RECEIVER);
3743 auto tmpl_info = *Utils::OpenHandle(*tmpl); 3745 auto tmpl_info = *Utils::OpenHandle(*tmpl);
3744 while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) { 3746 while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) {
3745 iter.Advance(); 3747 iter.Advance();
3746 if (iter.IsAtEnd()) { 3748 if (iter.IsAtEnd()) {
3747 return Local<Object>(); 3749 return Local<Object>();
3748 } 3750 }
3749 } 3751 }
3750 // IsTemplateFor() ensures that iter.GetCurrent() can't be a Proxy here. 3752 // IsTemplateFor() ensures that iter.GetCurrent() can't be a Proxy here.
3751 return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate)); 3753 return Utils::ReceiverToLocal(
3754 i::handle(iter.GetCurrent<i::JSObject>(), isolate));
3752 } 3755 }
3753 3756
3754 3757
3755 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) { 3758 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) {
3756 PREPARE_FOR_EXECUTION(context, "v8::Object::GetPropertyNames()", Array); 3759 PREPARE_FOR_EXECUTION(context, "v8::Object::GetPropertyNames()", Array);
3757 auto self = Utils::OpenHandle(this); 3760 auto self = Utils::OpenHandle(this);
3758 i::Handle<i::FixedArray> value; 3761 i::Handle<i::FixedArray> value;
3759 has_pending_exception = !i::JSReceiver::GetKeys( 3762 has_pending_exception = !i::JSReceiver::GetKeys(
3760 self, i::JSReceiver::INCLUDE_PROTOS).ToHandle(&value); 3763 self, i::JSReceiver::INCLUDE_PROTOS).ToHandle(&value);
3761 RETURN_ON_FAILED_EXECUTION(Array); 3764 RETURN_ON_FAILED_EXECUTION(Array);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
3956 } 3959 }
3957 3960
3958 3961
3959 bool v8::Object::Has(uint32_t index) { 3962 bool v8::Object::Has(uint32_t index) {
3960 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 3963 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
3961 return Has(context, index).FromMaybe(false); 3964 return Has(context, index).FromMaybe(false);
3962 } 3965 }
3963 3966
3964 3967
3965 template <typename Getter, typename Setter, typename Data> 3968 template <typename Getter, typename Setter, typename Data>
3966 static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* obj, 3969 static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* self,
3967 Local<Name> name, Getter getter, 3970 Local<Name> name, Getter getter,
3968 Setter setter, Data data, 3971 Setter setter, Data data,
3969 AccessControl settings, 3972 AccessControl settings,
3970 PropertyAttribute attributes) { 3973 PropertyAttribute attributes) {
3971 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetAccessor()", bool); 3974 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetAccessor()", bool);
3975 if (!Utils::OpenHandle(self)->IsJSObject()) return Just(false);
3976 i::Handle<i::JSObject> obj =
3977 i::Handle<i::JSObject>::cast(Utils::OpenHandle(self));
3972 v8::Local<AccessorSignature> signature; 3978 v8::Local<AccessorSignature> signature;
3973 auto info = MakeAccessorInfo(name, getter, setter, data, settings, attributes, 3979 auto info = MakeAccessorInfo(name, getter, setter, data, settings, attributes,
3974 signature); 3980 signature);
3975 if (info.is_null()) return Nothing<bool>(); 3981 if (info.is_null()) return Nothing<bool>();
3976 bool fast = Utils::OpenHandle(obj)->HasFastProperties(); 3982 bool fast = obj->HasFastProperties();
3977 i::Handle<i::Object> result; 3983 i::Handle<i::Object> result;
3978 has_pending_exception = 3984 has_pending_exception =
3979 !i::JSObject::SetAccessor(Utils::OpenHandle(obj), info).ToHandle(&result); 3985 !i::JSObject::SetAccessor(obj, info).ToHandle(&result);
3980 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3986 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3981 if (result->IsUndefined()) return Nothing<bool>(); 3987 if (result->IsUndefined()) return Nothing<bool>();
3982 if (fast) { 3988 if (fast) {
3983 i::JSObject::MigrateSlowToFast(Utils::OpenHandle(obj), 0, "APISetAccessor"); 3989 i::JSObject::MigrateSlowToFast(obj, 0, "APISetAccessor");
3984 } 3990 }
3985 return Just(true); 3991 return Just(true);
3986 } 3992 }
3987 3993
3988 3994
3989 Maybe<bool> Object::SetAccessor(Local<Context> context, Local<Name> name, 3995 Maybe<bool> Object::SetAccessor(Local<Context> context, Local<Name> name,
3990 AccessorNameGetterCallback getter, 3996 AccessorNameGetterCallback getter,
3991 AccessorNameSetterCallback setter, 3997 AccessorNameSetterCallback setter,
3992 MaybeLocal<Value> data, AccessControl settings, 3998 MaybeLocal<Value> data, AccessControl settings,
3993 PropertyAttribute attribute) { 3999 PropertyAttribute attribute) {
(...skipping 23 matching lines...) Expand all
4017 4023
4018 void Object::SetAccessorProperty(Local<Name> name, Local<Function> getter, 4024 void Object::SetAccessorProperty(Local<Name> name, Local<Function> getter,
4019 Local<Function> setter, 4025 Local<Function> setter,
4020 PropertyAttribute attribute, 4026 PropertyAttribute attribute,
4021 AccessControl settings) { 4027 AccessControl settings) {
4022 // TODO(verwaest): Remove |settings|. 4028 // TODO(verwaest): Remove |settings|.
4023 DCHECK_EQ(v8::DEFAULT, settings); 4029 DCHECK_EQ(v8::DEFAULT, settings);
4024 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4030 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4025 ENTER_V8(isolate); 4031 ENTER_V8(isolate);
4026 i::HandleScope scope(isolate); 4032 i::HandleScope scope(isolate);
4033 auto self = Utils::OpenHandle(this);
4034 if (!self->IsJSObject()) return;
4027 i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter); 4035 i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter);
4028 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); 4036 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true);
4029 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); 4037 if (setter_i.is_null()) setter_i = isolate->factory()->null_value();
4030 i::JSObject::DefineAccessor(v8::Utils::OpenHandle(this), 4038 i::JSObject::DefineAccessor(i::Handle<i::JSObject>::cast(self),
4031 v8::Utils::OpenHandle(*name), 4039 v8::Utils::OpenHandle(*name), getter_i, setter_i,
4032 getter_i,
4033 setter_i,
4034 static_cast<PropertyAttributes>(attribute)); 4040 static_cast<PropertyAttributes>(attribute));
4035 } 4041 }
4036 4042
4037 4043
4038 Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context, 4044 Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context,
4039 Local<Name> key) { 4045 Local<Name> key) {
4040 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasOwnProperty()", 4046 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasOwnProperty()",
4041 bool); 4047 bool);
4042 auto self = Utils::OpenHandle(this); 4048 auto self = Utils::OpenHandle(this);
4043 auto key_val = Utils::OpenHandle(*key); 4049 auto key_val = Utils::OpenHandle(*key);
4044 auto result = i::JSReceiver::HasOwnProperty(self, key_val); 4050 auto result = i::JSReceiver::HasOwnProperty(self, key_val);
4045 has_pending_exception = result.IsNothing(); 4051 has_pending_exception = result.IsNothing();
4046 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 4052 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
4047 return result; 4053 return result;
4048 } 4054 }
4049 4055
4050 4056
4051 bool v8::Object::HasOwnProperty(Local<String> key) { 4057 bool v8::Object::HasOwnProperty(Local<String> key) {
4052 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4058 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4053 return HasOwnProperty(context, key).FromMaybe(false); 4059 return HasOwnProperty(context, key).FromMaybe(false);
4054 } 4060 }
4055 4061
4056 4062
4057 Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context, 4063 Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context,
4058 Local<Name> key) { 4064 Local<Name> key) {
4059 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasRealNamedProperty()", 4065 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasRealNamedProperty()",
4060 bool); 4066 bool);
4061 auto self = Utils::OpenHandle(this); 4067 auto self = Utils::OpenHandle(this);
4068 if (!self->IsJSObject()) return Just(false);
jochen (gone - plz use gerrit) 2015/11/06 22:23:28 we probably want to have hasOwnProperty and getOwn
4062 auto key_val = Utils::OpenHandle(*key); 4069 auto key_val = Utils::OpenHandle(*key);
4063 auto result = i::JSObject::HasRealNamedProperty(self, key_val); 4070 auto result = i::JSObject::HasRealNamedProperty(
4071 i::Handle<i::JSObject>::cast(self), key_val);
4064 has_pending_exception = result.IsNothing(); 4072 has_pending_exception = result.IsNothing();
4065 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 4073 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
4066 return result; 4074 return result;
4067 } 4075 }
4068 4076
4069 4077
4070 bool v8::Object::HasRealNamedProperty(Local<String> key) { 4078 bool v8::Object::HasRealNamedProperty(Local<String> key) {
4071 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4079 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4072 return HasRealNamedProperty(context, key).FromMaybe(false); 4080 return HasRealNamedProperty(context, key).FromMaybe(false);
4073 } 4081 }
4074 4082
4075 4083
4076 Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context, 4084 Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context,
4077 uint32_t index) { 4085 uint32_t index) {
4078 PREPARE_FOR_EXECUTION_PRIMITIVE(context, 4086 PREPARE_FOR_EXECUTION_PRIMITIVE(context,
4079 "v8::Object::HasRealIndexedProperty()", bool); 4087 "v8::Object::HasRealIndexedProperty()", bool);
4080 auto self = Utils::OpenHandle(this); 4088 auto self = Utils::OpenHandle(this);
4081 auto result = i::JSObject::HasRealElementProperty(self, index); 4089 if (!self->IsJSObject()) return Just(false);
4090 auto result = i::JSObject::HasRealElementProperty(
4091 i::Handle<i::JSObject>::cast(self), index);
4082 has_pending_exception = result.IsNothing(); 4092 has_pending_exception = result.IsNothing();
4083 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 4093 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
4084 return result; 4094 return result;
4085 } 4095 }
4086 4096
4087 4097
4088 bool v8::Object::HasRealIndexedProperty(uint32_t index) { 4098 bool v8::Object::HasRealIndexedProperty(uint32_t index) {
4089 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4099 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4090 return HasRealIndexedProperty(context, index).FromMaybe(false); 4100 return HasRealIndexedProperty(context, index).FromMaybe(false);
4091 } 4101 }
4092 4102
4093 4103
4094 Maybe<bool> v8::Object::HasRealNamedCallbackProperty(Local<Context> context, 4104 Maybe<bool> v8::Object::HasRealNamedCallbackProperty(Local<Context> context,
4095 Local<Name> key) { 4105 Local<Name> key) {
4096 PREPARE_FOR_EXECUTION_PRIMITIVE( 4106 PREPARE_FOR_EXECUTION_PRIMITIVE(
4097 context, "v8::Object::HasRealNamedCallbackProperty()", bool); 4107 context, "v8::Object::HasRealNamedCallbackProperty()", bool);
4098 auto self = Utils::OpenHandle(this); 4108 auto self = Utils::OpenHandle(this);
4109 if (!self->IsJSObject()) return Just(false);
4099 auto key_val = Utils::OpenHandle(*key); 4110 auto key_val = Utils::OpenHandle(*key);
4100 auto result = i::JSObject::HasRealNamedCallbackProperty(self, key_val); 4111 auto result = i::JSObject::HasRealNamedCallbackProperty(
4112 i::Handle<i::JSObject>::cast(self), key_val);
4101 has_pending_exception = result.IsNothing(); 4113 has_pending_exception = result.IsNothing();
4102 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 4114 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
4103 return result; 4115 return result;
4104 } 4116 }
4105 4117
4106 4118
4107 bool v8::Object::HasRealNamedCallbackProperty(Local<String> key) { 4119 bool v8::Object::HasRealNamedCallbackProperty(Local<String> key) {
4108 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4120 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4109 return HasRealNamedCallbackProperty(context, key).FromMaybe(false); 4121 return HasRealNamedCallbackProperty(context, key).FromMaybe(false);
4110 } 4122 }
4111 4123
4112 4124
4113 bool v8::Object::HasNamedLookupInterceptor() { 4125 bool v8::Object::HasNamedLookupInterceptor() {
4114 auto self = Utils::OpenHandle(this); 4126 auto self = Utils::OpenHandle(this);
4115 return self->HasNamedInterceptor(); 4127 return self->IsJSObject() &&
4128 i::Handle<i::JSObject>::cast(self)->HasNamedInterceptor();
4116 } 4129 }
4117 4130
4118 4131
4119 bool v8::Object::HasIndexedLookupInterceptor() { 4132 bool v8::Object::HasIndexedLookupInterceptor() {
4120 auto self = Utils::OpenHandle(this); 4133 auto self = Utils::OpenHandle(this);
4121 return self->HasIndexedInterceptor(); 4134 return self->IsJSObject() &&
4135 i::Handle<i::JSObject>::cast(self)->HasIndexedInterceptor();
4122 } 4136 }
4123 4137
4124 4138
4125 MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( 4139 MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
4126 Local<Context> context, Local<Name> key) { 4140 Local<Context> context, Local<Name> key) {
4127 PREPARE_FOR_EXECUTION( 4141 PREPARE_FOR_EXECUTION(
4128 context, "v8::Object::GetRealNamedPropertyInPrototypeChain()", Value); 4142 context, "v8::Object::GetRealNamedPropertyInPrototypeChain()", Value);
4129 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 4143 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
4144 if (!self->IsJSObject()) return MaybeLocal<Value>();
4130 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); 4145 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
4131 i::PrototypeIterator iter(isolate, self); 4146 i::PrototypeIterator iter(isolate, self);
4132 if (iter.IsAtEnd()) return MaybeLocal<Value>(); 4147 if (iter.IsAtEnd()) return MaybeLocal<Value>();
4133 i::Handle<i::JSReceiver> proto = 4148 i::Handle<i::JSReceiver> proto =
4134 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); 4149 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter);
4135 i::LookupIterator it = i::LookupIterator::PropertyOrElement( 4150 i::LookupIterator it = i::LookupIterator::PropertyOrElement(
4136 isolate, self, key_obj, proto, 4151 isolate, self, key_obj, proto,
4137 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); 4152 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
4138 Local<Value> result; 4153 Local<Value> result;
4139 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); 4154 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result);
(...skipping 10 matching lines...) Expand all
4150 Value); 4165 Value);
4151 } 4166 }
4152 4167
4153 4168
4154 Maybe<PropertyAttribute> 4169 Maybe<PropertyAttribute>
4155 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain( 4170 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(
4156 Local<Context> context, Local<Name> key) { 4171 Local<Context> context, Local<Name> key) {
4157 PREPARE_FOR_EXECUTION_PRIMITIVE( 4172 PREPARE_FOR_EXECUTION_PRIMITIVE(
4158 context, "v8::Object::GetRealNamedPropertyAttributesInPrototypeChain()", 4173 context, "v8::Object::GetRealNamedPropertyAttributesInPrototypeChain()",
4159 PropertyAttribute); 4174 PropertyAttribute);
4160 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 4175 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
4176 if (!self->IsJSObject()) return Nothing<PropertyAttribute>();
4161 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); 4177 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
4162 i::PrototypeIterator iter(isolate, self); 4178 i::PrototypeIterator iter(isolate, self);
4163 if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); 4179 if (iter.IsAtEnd()) return Nothing<PropertyAttribute>();
4164 i::Handle<i::JSReceiver> proto = 4180 i::Handle<i::JSReceiver> proto =
4165 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); 4181 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter);
4166 i::LookupIterator it = i::LookupIterator::PropertyOrElement( 4182 i::LookupIterator it = i::LookupIterator::PropertyOrElement(
4167 isolate, self, key_obj, proto, 4183 isolate, self, key_obj, proto,
4168 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); 4184 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
4169 Maybe<PropertyAttributes> result = i::JSReceiver::GetPropertyAttributes(&it); 4185 Maybe<PropertyAttributes> result = i::JSReceiver::GetPropertyAttributes(&it);
4170 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); 4186 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
4225 4241
4226 4242
4227 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( 4243 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes(
4228 Local<String> key) { 4244 Local<String> key) {
4229 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4245 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4230 return GetRealNamedPropertyAttributes(context, key); 4246 return GetRealNamedPropertyAttributes(context, key);
4231 } 4247 }
4232 4248
4233 4249
4234 Local<v8::Object> v8::Object::Clone() { 4250 Local<v8::Object> v8::Object::Clone() {
4235 auto self = Utils::OpenHandle(this); 4251 auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
4236 auto isolate = self->GetIsolate(); 4252 auto isolate = self->GetIsolate();
4237 ENTER_V8(isolate); 4253 ENTER_V8(isolate);
4238 auto result = isolate->factory()->CopyJSObject(self); 4254 auto result = isolate->factory()->CopyJSObject(self);
4239 CHECK(!result.is_null()); 4255 CHECK(!result.is_null());
4240 return Utils::ToLocal(result); 4256 return Utils::ReceiverToLocal(result);
4241 } 4257 }
4242 4258
4243 4259
4244 Local<v8::Context> v8::Object::CreationContext() { 4260 Local<v8::Context> v8::Object::CreationContext() {
4245 auto self = Utils::OpenHandle(this); 4261 auto self = Utils::OpenHandle(this);
4246 auto context = handle(self->GetCreationContext()); 4262 auto context = handle(self->GetCreationContext());
4247 return Utils::ToLocal(context); 4263 return Utils::ToLocal(context);
4248 } 4264 }
4249 4265
4250 4266
4251 int v8::Object::GetIdentityHash() { 4267 int v8::Object::GetIdentityHash() {
4252 auto isolate = Utils::OpenHandle(this)->GetIsolate(); 4268 auto isolate = Utils::OpenHandle(this)->GetIsolate();
4253 i::HandleScope scope(isolate); 4269 i::HandleScope scope(isolate);
4254 auto self = Utils::OpenHandle(this); 4270 auto self = Utils::OpenHandle(this);
4255 return i::JSReceiver::GetOrCreateIdentityHash(self)->value(); 4271 return i::JSReceiver::GetOrCreateIdentityHash(self)->value();
4256 } 4272 }
4257 4273
4258 4274
4259 bool v8::Object::SetHiddenValue(v8::Local<v8::String> key, 4275 bool v8::Object::SetHiddenValue(v8::Local<v8::String> key,
4260 v8::Local<v8::Value> value) { 4276 v8::Local<v8::Value> value) {
4261 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4277 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4262 ENTER_V8(isolate); 4278 ENTER_V8(isolate);
4263 i::HandleScope scope(isolate); 4279 i::HandleScope scope(isolate);
4264 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 4280 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
4281 if (!self->IsJSObject()) return false;
4265 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 4282 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
4266 i::Handle<i::String> key_string = 4283 i::Handle<i::String> key_string =
4267 isolate->factory()->InternalizeString(key_obj); 4284 isolate->factory()->InternalizeString(key_obj);
4268 if (value.IsEmpty()) { 4285 if (value.IsEmpty()) {
4269 i::JSObject::DeleteHiddenProperty(self, key_string); 4286 i::JSObject::DeleteHiddenProperty(i::Handle<i::JSObject>::cast(self),
4287 key_string);
4270 return true; 4288 return true;
4271 } 4289 }
4272 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 4290 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
4273 i::Handle<i::Object> result = 4291 i::Handle<i::Object> result = i::JSObject::SetHiddenProperty(
4274 i::JSObject::SetHiddenProperty(self, key_string, value_obj); 4292 i::Handle<i::JSObject>::cast(self), key_string, value_obj);
4275 return *result == *self; 4293 return *result == *self;
4276 } 4294 }
4277 4295
4278 4296
4279 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Local<v8::String> key) { 4297 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Local<v8::String> key) {
4280 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4298 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4281 ENTER_V8(isolate); 4299 ENTER_V8(isolate);
4282 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 4300 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
4301 if (!self->IsJSObject()) return v8::Local<v8::Value>();
4283 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 4302 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
4284 i::Handle<i::String> key_string = 4303 i::Handle<i::String> key_string =
4285 isolate->factory()->InternalizeString(key_obj); 4304 isolate->factory()->InternalizeString(key_obj);
4286 i::Handle<i::Object> result(self->GetHiddenProperty(key_string), isolate); 4305 i::Handle<i::Object> result(
4306 i::Handle<i::JSObject>::cast(self)->GetHiddenProperty(key_string),
4307 isolate);
4287 if (result->IsTheHole()) return v8::Local<v8::Value>(); 4308 if (result->IsTheHole()) return v8::Local<v8::Value>();
4288 return Utils::ToLocal(result); 4309 return Utils::ToLocal(result);
4289 } 4310 }
4290 4311
4291 4312
4292 bool v8::Object::DeleteHiddenValue(v8::Local<v8::String> key) { 4313 bool v8::Object::DeleteHiddenValue(v8::Local<v8::String> key) {
4293 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4314 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4294 ENTER_V8(isolate); 4315 ENTER_V8(isolate);
4295 i::HandleScope scope(isolate); 4316 i::HandleScope scope(isolate);
4296 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 4317 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
4318 if (!self->IsJSObject()) return false;
4297 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 4319 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
4298 i::Handle<i::String> key_string = 4320 i::Handle<i::String> key_string =
4299 isolate->factory()->InternalizeString(key_obj); 4321 isolate->factory()->InternalizeString(key_obj);
4300 i::JSObject::DeleteHiddenProperty(self, key_string); 4322 i::JSObject::DeleteHiddenProperty(i::Handle<i::JSObject>::cast(self),
4323 key_string);
4301 return true; 4324 return true;
4302 } 4325 }
4303 4326
4304 4327
4305 bool v8::Object::IsCallable() { 4328 bool v8::Object::IsCallable() {
4306 auto self = Utils::OpenHandle(this); 4329 auto self = Utils::OpenHandle(this);
4307 return self->IsCallable(); 4330 return self->IsCallable();
4308 } 4331 }
4309 4332
4310 4333
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
5314 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5337 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5315 if (obj->IsSmi()) { 5338 if (obj->IsSmi()) {
5316 return i::Smi::cast(*obj)->value(); 5339 return i::Smi::cast(*obj)->value();
5317 } else { 5340 } else {
5318 return static_cast<uint32_t>(obj->Number()); 5341 return static_cast<uint32_t>(obj->Number());
5319 } 5342 }
5320 } 5343 }
5321 5344
5322 5345
5323 int v8::Object::InternalFieldCount() { 5346 int v8::Object::InternalFieldCount() {
5324 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 5347 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
5325 return obj->GetInternalFieldCount(); 5348 if (!self->IsJSObject()) return 0;
5349 return i::Handle<i::JSObject>::cast(self)->GetInternalFieldCount();
5326 } 5350 }
5327 5351
5328 5352
5329 static bool InternalFieldOK(i::Handle<i::JSObject> obj, 5353 static bool InternalFieldOK(i::Handle<i::JSReceiver> obj, int index,
5330 int index,
5331 const char* location) { 5354 const char* location) {
5332 return Utils::ApiCheck(index < obj->GetInternalFieldCount(), 5355 return Utils::ApiCheck(
5333 location, 5356 obj->IsJSObject() &&
5334 "Internal field out of bounds"); 5357 (index < i::Handle<i::JSObject>::cast(obj)->GetInternalFieldCount()),
5358 location, "Internal field out of bounds");
5335 } 5359 }
5336 5360
5337 5361
5338 Local<Value> v8::Object::SlowGetInternalField(int index) { 5362 Local<Value> v8::Object::SlowGetInternalField(int index) {
5339 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 5363 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
5340 const char* location = "v8::Object::GetInternalField()"; 5364 const char* location = "v8::Object::GetInternalField()";
5341 if (!InternalFieldOK(obj, index, location)) return Local<Value>(); 5365 if (!InternalFieldOK(obj, index, location)) return Local<Value>();
5342 i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate()); 5366 i::Handle<i::Object> value(
5367 i::Handle<i::JSObject>::cast(obj)->GetInternalField(index),
5368 obj->GetIsolate());
5343 return Utils::ToLocal(value); 5369 return Utils::ToLocal(value);
5344 } 5370 }
5345 5371
5346 5372
5347 void v8::Object::SetInternalField(int index, v8::Local<Value> value) { 5373 void v8::Object::SetInternalField(int index, v8::Local<Value> value) {
5348 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 5374 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
5349 const char* location = "v8::Object::SetInternalField()"; 5375 const char* location = "v8::Object::SetInternalField()";
5350 if (!InternalFieldOK(obj, index, location)) return; 5376 if (!InternalFieldOK(obj, index, location)) return;
5351 i::Handle<i::Object> val = Utils::OpenHandle(*value); 5377 i::Handle<i::Object> val = Utils::OpenHandle(*value);
5352 obj->SetInternalField(index, *val); 5378 i::Handle<i::JSObject>::cast(obj)->SetInternalField(index, *val);
5353 } 5379 }
5354 5380
5355 5381
5356 void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) { 5382 void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) {
5357 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 5383 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
5358 const char* location = "v8::Object::GetAlignedPointerFromInternalField()"; 5384 const char* location = "v8::Object::GetAlignedPointerFromInternalField()";
5359 if (!InternalFieldOK(obj, index, location)) return NULL; 5385 if (!InternalFieldOK(obj, index, location)) return NULL;
5360 return DecodeSmiToAligned(obj->GetInternalField(index), location); 5386 return DecodeSmiToAligned(
5387 i::Handle<i::JSObject>::cast(obj)->GetInternalField(index), location);
5361 } 5388 }
5362 5389
5363 5390
5364 void v8::Object::SetAlignedPointerInInternalField(int index, void* value) { 5391 void v8::Object::SetAlignedPointerInInternalField(int index, void* value) {
5365 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 5392 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
5366 const char* location = "v8::Object::SetAlignedPointerInInternalField()"; 5393 const char* location = "v8::Object::SetAlignedPointerInInternalField()";
5367 if (!InternalFieldOK(obj, index, location)) return; 5394 if (!InternalFieldOK(obj, index, location)) return;
5368 obj->SetInternalField(index, EncodeAlignedAsSmi(value, location)); 5395 i::Handle<i::JSObject>::cast(obj)
5396 ->SetInternalField(index, EncodeAlignedAsSmi(value, location));
5369 DCHECK_EQ(value, GetAlignedPointerFromInternalField(index)); 5397 DCHECK_EQ(value, GetAlignedPointerFromInternalField(index));
5370 } 5398 }
5371 5399
5372 5400
5373 static void* ExternalValue(i::Object* obj) { 5401 static void* ExternalValue(i::Object* obj) {
5374 // Obscure semantics for undefined, but somehow checked in our unit tests... 5402 // Obscure semantics for undefined, but somehow checked in our unit tests...
5375 if (obj->IsUndefined()) return NULL; 5403 if (obj->IsUndefined()) return NULL;
5376 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0); 5404 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0);
5377 return i::Foreign::cast(foreign)->foreign_address(); 5405 return i::Foreign::cast(foreign)->foreign_address();
5378 } 5406 }
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
5579 v8::Local<v8::Object> Context::Global() { 5607 v8::Local<v8::Object> Context::Global() {
5580 i::Handle<i::Context> context = Utils::OpenHandle(this); 5608 i::Handle<i::Context> context = Utils::OpenHandle(this);
5581 i::Isolate* isolate = context->GetIsolate(); 5609 i::Isolate* isolate = context->GetIsolate();
5582 i::Handle<i::Object> global(context->global_proxy(), isolate); 5610 i::Handle<i::Object> global(context->global_proxy(), isolate);
5583 // TODO(dcarney): This should always return the global proxy 5611 // TODO(dcarney): This should always return the global proxy
5584 // but can't presently as calls to GetProtoype will return the wrong result. 5612 // but can't presently as calls to GetProtoype will return the wrong result.
5585 if (i::Handle<i::JSGlobalProxy>::cast( 5613 if (i::Handle<i::JSGlobalProxy>::cast(
5586 global)->IsDetachedFrom(context->global_object())) { 5614 global)->IsDetachedFrom(context->global_object())) {
5587 global = i::Handle<i::Object>(context->global_object(), isolate); 5615 global = i::Handle<i::Object>(context->global_object(), isolate);
5588 } 5616 }
5589 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); 5617 return Utils::ReceiverToLocal(i::Handle<i::JSObject>::cast(global));
5590 } 5618 }
5591 5619
5592 5620
5593 void Context::DetachGlobal() { 5621 void Context::DetachGlobal() {
5594 i::Handle<i::Context> context = Utils::OpenHandle(this); 5622 i::Handle<i::Context> context = Utils::OpenHandle(this);
5595 i::Isolate* isolate = context->GetIsolate(); 5623 i::Isolate* isolate = context->GetIsolate();
5596 ENTER_V8(isolate); 5624 ENTER_V8(isolate);
5597 isolate->bootstrapper()->DetachGlobal(context); 5625 isolate->bootstrapper()->DetachGlobal(context);
5598 } 5626 }
5599 5627
5600 5628
5601 Local<v8::Object> Context::GetExtrasBindingObject() { 5629 Local<v8::Object> Context::GetExtrasBindingObject() {
5602 i::Handle<i::Context> context = Utils::OpenHandle(this); 5630 i::Handle<i::Context> context = Utils::OpenHandle(this);
5603 i::Isolate* isolate = context->GetIsolate(); 5631 i::Isolate* isolate = context->GetIsolate();
5604 i::Handle<i::JSObject> binding(context->extras_binding_object(), isolate); 5632 i::Handle<i::JSObject> binding(context->extras_binding_object(), isolate);
5605 return Utils::ToLocal(binding); 5633 return Utils::ReceiverToLocal(binding);
5606 } 5634 }
5607 5635
5608 5636
5609 void Context::AllowCodeGenerationFromStrings(bool allow) { 5637 void Context::AllowCodeGenerationFromStrings(bool allow) {
5610 i::Handle<i::Context> context = Utils::OpenHandle(this); 5638 i::Handle<i::Context> context = Utils::OpenHandle(this);
5611 i::Isolate* isolate = context->GetIsolate(); 5639 i::Isolate* isolate = context->GetIsolate();
5612 ENTER_V8(isolate); 5640 ENTER_V8(isolate);
5613 context->set_allow_code_gen_from_strings( 5641 context->set_allow_code_gen_from_strings(
5614 allow ? isolate->heap()->true_value() : isolate->heap()->false_value()); 5642 allow ? isolate->heap()->true_value() : isolate->heap()->false_value());
5615 } 5643 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
5955 return reinterpret_cast<Isolate*>(i_isolate); 5983 return reinterpret_cast<Isolate*>(i_isolate);
5956 } 5984 }
5957 5985
5958 5986
5959 Local<v8::Object> v8::Object::New(Isolate* isolate) { 5987 Local<v8::Object> v8::Object::New(Isolate* isolate) {
5960 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5988 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5961 LOG_API(i_isolate, "Object::New"); 5989 LOG_API(i_isolate, "Object::New");
5962 ENTER_V8(i_isolate); 5990 ENTER_V8(i_isolate);
5963 i::Handle<i::JSObject> obj = 5991 i::Handle<i::JSObject> obj =
5964 i_isolate->factory()->NewJSObject(i_isolate->object_function()); 5992 i_isolate->factory()->NewJSObject(i_isolate->object_function());
5965 return Utils::ToLocal(obj); 5993 return Utils::ReceiverToLocal(obj);
5966 } 5994 }
5967 5995
5968 5996
5969 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) { 5997 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) {
5970 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5998 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5971 LOG_API(i_isolate, "NumberObject::New"); 5999 LOG_API(i_isolate, "NumberObject::New");
5972 ENTER_V8(i_isolate); 6000 ENTER_V8(i_isolate);
5973 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); 6001 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value);
5974 i::Handle<i::Object> obj = 6002 i::Handle<i::Object> obj =
5975 i::Object::ToObject(i_isolate, number).ToHandleChecked(); 6003 i::Object::ToObject(i_isolate, number).ToHandleChecked();
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
6438 } 6466 }
6439 6467
6440 6468
6441 Local<Promise::Resolver> Promise::Resolver::New(Isolate* isolate) { 6469 Local<Promise::Resolver> Promise::Resolver::New(Isolate* isolate) {
6442 RETURN_TO_LOCAL_UNCHECKED(New(isolate->GetCurrentContext()), 6470 RETURN_TO_LOCAL_UNCHECKED(New(isolate->GetCurrentContext()),
6443 Promise::Resolver); 6471 Promise::Resolver);
6444 } 6472 }
6445 6473
6446 6474
6447 Local<Promise> Promise::Resolver::GetPromise() { 6475 Local<Promise> Promise::Resolver::GetPromise() {
6448 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); 6476 i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this);
6449 return Local<Promise>::Cast(Utils::ToLocal(promise)); 6477 return Local<Promise>::Cast(Utils::ReceiverToLocal(promise));
6450 } 6478 }
6451 6479
6452 6480
6453 Maybe<bool> Promise::Resolver::Resolve(Local<Context> context, 6481 Maybe<bool> Promise::Resolver::Resolve(Local<Context> context,
6454 Local<Value> value) { 6482 Local<Value> value) {
6455 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool); 6483 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool);
6456 auto self = Utils::OpenHandle(this); 6484 auto self = Utils::OpenHandle(this);
6457 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; 6485 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)};
6458 has_pending_exception = 6486 has_pending_exception =
6459 i::Execution::Call(isolate, isolate->promise_resolve(), 6487 i::Execution::Call(isolate, isolate->promise_resolve(),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
6546 } 6574 }
6547 6575
6548 6576
6549 Local<Promise> Promise::Then(Local<Function> handler) { 6577 Local<Promise> Promise::Then(Local<Function> handler) {
6550 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 6578 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
6551 RETURN_TO_LOCAL_UNCHECKED(Then(context, handler), Promise); 6579 RETURN_TO_LOCAL_UNCHECKED(Then(context, handler), Promise);
6552 } 6580 }
6553 6581
6554 6582
6555 bool Promise::HasHandler() { 6583 bool Promise::HasHandler() {
6556 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); 6584 i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this);
6557 i::Isolate* isolate = promise->GetIsolate(); 6585 i::Isolate* isolate = promise->GetIsolate();
6558 LOG_API(isolate, "Promise::HasRejectHandler"); 6586 LOG_API(isolate, "Promise::HasRejectHandler");
6559 ENTER_V8(isolate); 6587 ENTER_V8(isolate);
6560 i::Handle<i::Symbol> key = isolate->factory()->promise_has_handler_symbol(); 6588 i::Handle<i::Symbol> key = isolate->factory()->promise_has_handler_symbol();
6561 return i::JSReceiver::GetDataProperty(promise, key)->IsTrue(); 6589 return i::JSReceiver::GetDataProperty(promise, key)->IsTrue();
6562 } 6590 }
6563 6591
6564 6592
6565 bool v8::ArrayBuffer::IsExternal() const { 6593 bool v8::ArrayBuffer::IsExternal() const {
6566 return Utils::OpenHandle(this)->is_external(); 6594 return Utils::OpenHandle(this)->is_external();
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after
7831 i::Debug* isolate_debug = isolate->debug(); 7859 i::Debug* isolate_debug = isolate->debug();
7832 has_pending_exception = !isolate_debug->Load(); 7860 has_pending_exception = !isolate_debug->Load();
7833 RETURN_ON_FAILED_EXECUTION(Value); 7861 RETURN_ON_FAILED_EXECUTION(Value);
7834 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); 7862 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object());
7835 auto name = isolate->factory()->NewStringFromStaticChars("MakeMirror"); 7863 auto name = isolate->factory()->NewStringFromStaticChars("MakeMirror");
7836 auto fun_obj = i::Object::GetProperty(debug, name).ToHandleChecked(); 7864 auto fun_obj = i::Object::GetProperty(debug, name).ToHandleChecked();
7837 auto v8_fun = Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(fun_obj)); 7865 auto v8_fun = Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(fun_obj));
7838 const int kArgc = 1; 7866 const int kArgc = 1;
7839 v8::Local<v8::Value> argv[kArgc] = {obj}; 7867 v8::Local<v8::Value> argv[kArgc] = {obj};
7840 Local<Value> result; 7868 Local<Value> result;
7841 has_pending_exception = !v8_fun->Call(context, Utils::ToLocal(debug), kArgc, 7869 has_pending_exception =
7842 argv).ToLocal(&result); 7870 !v8_fun->Call(context, Utils::ReceiverToLocal(debug), kArgc, argv)
7871 .ToLocal(&result);
7843 RETURN_ON_FAILED_EXECUTION(Value); 7872 RETURN_ON_FAILED_EXECUTION(Value);
7844 RETURN_ESCAPED(result); 7873 RETURN_ESCAPED(result);
7845 } 7874 }
7846 7875
7847 7876
7848 Local<Value> Debug::GetMirror(v8::Local<v8::Value> obj) { 7877 Local<Value> Debug::GetMirror(v8::Local<v8::Value> obj) {
7849 RETURN_TO_LOCAL_UNCHECKED(GetMirror(Local<Context>(), obj), Value); 7878 RETURN_TO_LOCAL_UNCHECKED(GetMirror(Local<Context>(), obj), Value);
7850 } 7879 }
7851 7880
7852 7881
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
8519 Address callback_address = 8548 Address callback_address =
8520 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8549 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8521 VMState<EXTERNAL> state(isolate); 8550 VMState<EXTERNAL> state(isolate);
8522 ExternalCallbackScope call_scope(isolate, callback_address); 8551 ExternalCallbackScope call_scope(isolate, callback_address);
8523 callback(info); 8552 callback(info);
8524 } 8553 }
8525 8554
8526 8555
8527 } // namespace internal 8556 } // namespace internal
8528 } // namespace v8 8557 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/debug/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698