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

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: 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
« src/api.h ('K') | « 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 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 // Include \n in case the source contains a line end comment. 1966 // Include \n in case the source contains a line end comment.
1967 auto brackets = factory->NewStringFromStaticChars("\n})"); 1967 auto brackets = factory->NewStringFromStaticChars("\n})");
1968 has_pending_exception = 1968 has_pending_exception =
1969 !factory->NewConsString(source_string, brackets).ToHandle(&source_string); 1969 !factory->NewConsString(source_string, brackets).ToHandle(&source_string);
1970 RETURN_ON_FAILED_EXECUTION(Function); 1970 RETURN_ON_FAILED_EXECUTION(Function);
1971 1971
1972 i::Handle<i::Context> context = Utils::OpenHandle(*v8_context); 1972 i::Handle<i::Context> context = Utils::OpenHandle(*v8_context);
1973 i::Handle<i::SharedFunctionInfo> outer_info(context->closure()->shared(), 1973 i::Handle<i::SharedFunctionInfo> outer_info(context->closure()->shared(),
1974 isolate); 1974 isolate);
1975 for (size_t i = 0; i < context_extension_count; ++i) { 1975 for (size_t i = 0; i < context_extension_count; ++i) {
1976 i::Handle<i::JSObject> extension = 1976 i::Handle<i::JSReceiver> extension =
1977 Utils::OpenHandle(*context_extensions[i]); 1977 Utils::OpenHandle(*context_extensions[i]);
1978 if (!extension->IsJSObject()) return Local<Function>();
1978 i::Handle<i::JSFunction> closure(context->closure(), isolate); 1979 i::Handle<i::JSFunction> closure(context->closure(), isolate);
1979 context = factory->NewWithContext(closure, context, extension); 1980 context = factory->NewWithContext(closure, context, extension);
1980 } 1981 }
1981 1982
1982 i::Handle<i::Object> name_obj; 1983 i::Handle<i::Object> name_obj;
1983 int line_offset = 0; 1984 int line_offset = 0;
1984 int column_offset = 0; 1985 int column_offset = 0;
1985 if (!source->resource_name.IsEmpty()) { 1986 if (!source->resource_name.IsEmpty()) {
1986 name_obj = Utils::OpenHandle(*(source->resource_name)); 1987 name_obj = Utils::OpenHandle(*(source->resource_name));
1987 } 1988 }
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
3051 3052
3052 void External::CheckCast(v8::Value* that) { 3053 void External::CheckCast(v8::Value* that) {
3053 Utils::ApiCheck(Utils::OpenHandle(that)->IsExternal(), 3054 Utils::ApiCheck(Utils::OpenHandle(that)->IsExternal(),
3054 "v8::External::Cast()", 3055 "v8::External::Cast()",
3055 "Could not convert to external"); 3056 "Could not convert to external");
3056 } 3057 }
3057 3058
3058 3059
3059 void v8::Object::CheckCast(Value* that) { 3060 void v8::Object::CheckCast(Value* that) {
3060 i::Handle<i::Object> obj = Utils::OpenHandle(that); 3061 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3061 Utils::ApiCheck(obj->IsJSObject(), 3062 Utils::ApiCheck(obj->IsJSReceiver(), "v8::Object::Cast()",
3062 "v8::Object::Cast()",
3063 "Could not convert to object"); 3063 "Could not convert to object");
3064 } 3064 }
3065 3065
3066 3066
3067 void v8::Function::CheckCast(Value* that) { 3067 void v8::Function::CheckCast(Value* that) {
3068 i::Handle<i::Object> obj = Utils::OpenHandle(that); 3068 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3069 Utils::ApiCheck(obj->IsCallable(), "v8::Function::Cast()", 3069 Utils::ApiCheck(obj->IsCallable(), "v8::Function::Cast()",
3070 "Could not convert to function"); 3070 "Could not convert to function");
3071 } 3071 }
3072 3072
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
3490 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 3490 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
3491 return Set(context, index, value).FromMaybe(false); 3491 return Set(context, index, value).FromMaybe(false);
3492 } 3492 }
3493 3493
3494 3494
3495 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, 3495 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context,
3496 v8::Local<Name> key, 3496 v8::Local<Name> key,
3497 v8::Local<Value> value) { 3497 v8::Local<Value> value) {
3498 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", 3498 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()",
3499 bool); 3499 bool);
3500 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3500 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
3501 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); 3501 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
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 = i::LookupIterator::PropertyOrElement( 3504 i::LookupIterator it = i::LookupIterator::PropertyOrElement(
3505 isolate, self, key_obj, i::LookupIterator::OWN); 3505 isolate, self, key_obj, i::LookupIterator::OWN);
3506 // TODO(jochen): Update to JSReceiver.
3506 Maybe<bool> result = i::JSObject::CreateDataProperty(&it, value_obj); 3507 Maybe<bool> result = i::JSObject::CreateDataProperty(&it, value_obj);
3507 has_pending_exception = result.IsNothing(); 3508 has_pending_exception = result.IsNothing();
3508 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3509 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3509 return result; 3510 return result;
3510 } 3511 }
3511 3512
3512 3513
3513 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, 3514 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context,
3514 uint32_t index, 3515 uint32_t index,
3515 v8::Local<Value> value) { 3516 v8::Local<Value> value) {
3516 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", 3517 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()",
3517 bool); 3518 bool);
3518 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3519 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
3519 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 3520 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3520 3521
3521 i::LookupIterator it(isolate, self, index, i::LookupIterator::OWN); 3522 i::LookupIterator it(isolate, self, index, i::LookupIterator::OWN);
3523 // TODO(jochen): Update to JSReceiver.
3522 Maybe<bool> result = i::JSObject::CreateDataProperty(&it, value_obj); 3524 Maybe<bool> result = i::JSObject::CreateDataProperty(&it, value_obj);
3523 has_pending_exception = result.IsNothing(); 3525 has_pending_exception = result.IsNothing();
3524 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3526 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3525 return result; 3527 return result;
3526 } 3528 }
3527 3529
3528 3530
3529 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, 3531 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context,
3530 v8::Local<Name> key, 3532 v8::Local<Name> key,
3531 v8::Local<Value> value, 3533 v8::Local<Value> value,
3532 v8::PropertyAttribute attributes) { 3534 v8::PropertyAttribute attributes) {
3533 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DefineOwnProperty()", 3535 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DefineOwnProperty()",
3534 bool); 3536 bool);
3535 auto self = Utils::OpenHandle(this); 3537 auto self = Utils::OpenHandle(this);
3536 auto key_obj = Utils::OpenHandle(*key); 3538 auto key_obj = Utils::OpenHandle(*key);
3537 auto value_obj = Utils::OpenHandle(*value); 3539 auto value_obj = Utils::OpenHandle(*value);
3538 3540
3539 if (self->IsAccessCheckNeeded() && 3541 if (self->IsAccessCheckNeeded() &&
3540 !isolate->MayAccess(handle(isolate->context()), self)) { 3542 !isolate->MayAccess(handle(isolate->context()),
3541 isolate->ReportFailedAccessCheck(self); 3543 i::Handle<i::JSObject>::cast(self))) {
3544 isolate->ReportFailedAccessCheck(i::Handle<i::JSObject>::cast(self));
3542 return Nothing<bool>(); 3545 return Nothing<bool>();
3543 } 3546 }
3544 3547
3545 i::Handle<i::FixedArray> desc = isolate->factory()->NewFixedArray(3); 3548 i::Handle<i::FixedArray> desc = isolate->factory()->NewFixedArray(3);
3546 desc->set(0, isolate->heap()->ToBoolean(!(attributes & v8::ReadOnly))); 3549 desc->set(0, isolate->heap()->ToBoolean(!(attributes & v8::ReadOnly)));
3547 desc->set(1, isolate->heap()->ToBoolean(!(attributes & v8::DontEnum))); 3550 desc->set(1, isolate->heap()->ToBoolean(!(attributes & v8::DontEnum)));
3548 desc->set(2, isolate->heap()->ToBoolean(!(attributes & v8::DontDelete))); 3551 desc->set(2, isolate->heap()->ToBoolean(!(attributes & v8::DontDelete)));
3549 i::Handle<i::JSArray> desc_array = 3552 i::Handle<i::JSArray> desc_array =
3550 isolate->factory()->NewJSArrayWithElements(desc, i::FAST_ELEMENTS, 3); 3553 isolate->factory()->NewJSArrayWithElements(desc, i::FAST_ELEMENTS, 3);
3551 i::Handle<i::Object> args[] = {self, key_obj, value_obj, desc_array}; 3554 i::Handle<i::Object> args[] = {self, key_obj, value_obj, desc_array};
(...skipping 18 matching lines...) Expand all
3570 isolate, js_object, key, &success, i::LookupIterator::OWN); 3573 isolate, js_object, key, &success, i::LookupIterator::OWN);
3571 if (!success) return i::MaybeHandle<i::Object>(); 3574 if (!success) return i::MaybeHandle<i::Object>();
3572 3575
3573 return i::JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs); 3576 return i::JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs);
3574 } 3577 }
3575 3578
3576 3579
3577 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, 3580 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context,
3578 v8::Local<Value> key, v8::Local<Value> value, 3581 v8::Local<Value> key, v8::Local<Value> value,
3579 v8::PropertyAttribute attribs) { 3582 v8::PropertyAttribute attribs) {
3580 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); 3583 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::ForceSet()", bool);
3581 auto self = Utils::OpenHandle(this); 3584 auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
3582 auto key_obj = Utils::OpenHandle(*key); 3585 auto key_obj = Utils::OpenHandle(*key);
3583 auto value_obj = Utils::OpenHandle(*value); 3586 auto value_obj = Utils::OpenHandle(*value);
3584 has_pending_exception = 3587 has_pending_exception =
3585 DefineObjectProperty(self, key_obj, value_obj, 3588 DefineObjectProperty(self, key_obj, value_obj,
3586 static_cast<PropertyAttributes>(attribs)).is_null(); 3589 static_cast<PropertyAttributes>(attribs)).is_null();
3587 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3590 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3588 return Just(true); 3591 return Just(true);
3589 } 3592 }
3590 3593
3591 3594
3592 bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value, 3595 bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value,
3593 v8::PropertyAttribute attribs) { 3596 v8::PropertyAttribute attribs) {
3594 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3597 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3595 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), 3598 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(),
3596 "v8::Object::ForceSet", false, i::HandleScope, 3599 "v8::Object::ForceSet", false, i::HandleScope,
3597 false); 3600 false);
3598 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3601 i::Handle<i::JSObject> self =
3602 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
3599 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3603 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3600 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 3604 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3601 has_pending_exception = 3605 has_pending_exception =
3602 DefineObjectProperty(self, key_obj, value_obj, 3606 DefineObjectProperty(self, key_obj, value_obj,
3603 static_cast<PropertyAttributes>(attribs)).is_null(); 3607 static_cast<PropertyAttributes>(attribs)).is_null();
3604 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); 3608 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false);
3605 return true; 3609 return true;
3606 } 3610 }
3607 3611
3608 3612
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
3704 3708
3705 3709
3706 Maybe<bool> v8::Object::SetPrototype(Local<Context> context, 3710 Maybe<bool> v8::Object::SetPrototype(Local<Context> context,
3707 Local<Value> value) { 3711 Local<Value> value) {
3708 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetPrototype()", bool); 3712 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetPrototype()", bool);
3709 auto self = Utils::OpenHandle(this); 3713 auto self = Utils::OpenHandle(this);
3710 auto value_obj = Utils::OpenHandle(*value); 3714 auto value_obj = Utils::OpenHandle(*value);
3711 // We do not allow exceptions thrown while setting the prototype 3715 // We do not allow exceptions thrown while setting the prototype
3712 // to propagate outside. 3716 // to propagate outside.
3713 TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); 3717 TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
3714 auto result = i::JSObject::SetPrototype(self, value_obj, false, 3718 // TODO(jochen): Update to JSReceiver.
3715 i::Object::THROW_ON_ERROR); 3719 auto result =
3720 i::JSObject::SetPrototype(i::Handle<i::JSObject>::cast(self), value_obj,
3721 false, i::Object::THROW_ON_ERROR);
3716 has_pending_exception = result.IsNothing(); 3722 has_pending_exception = result.IsNothing();
3717 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3723 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3718 return Just(true); 3724 return Just(true);
3719 } 3725 }
3720 3726
3721 3727
3722 bool v8::Object::SetPrototype(Local<Value> value) { 3728 bool v8::Object::SetPrototype(Local<Value> value) {
3723 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 3729 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
3724 return SetPrototype(context, value).FromMaybe(false); 3730 return SetPrototype(context, value).FromMaybe(false);
3725 } 3731 }
3726 3732
3727 3733
3728 Local<Object> v8::Object::FindInstanceInPrototypeChain( 3734 Local<Object> v8::Object::FindInstanceInPrototypeChain(
3729 v8::Local<FunctionTemplate> tmpl) { 3735 v8::Local<FunctionTemplate> tmpl) {
3730 auto isolate = Utils::OpenHandle(this)->GetIsolate(); 3736 auto isolate = Utils::OpenHandle(this)->GetIsolate();
3731 i::PrototypeIterator iter(isolate, *Utils::OpenHandle(this), 3737 i::PrototypeIterator iter(isolate, *Utils::OpenHandle(this),
3732 i::PrototypeIterator::START_AT_RECEIVER); 3738 i::PrototypeIterator::START_AT_RECEIVER);
3733 auto tmpl_info = *Utils::OpenHandle(*tmpl); 3739 auto tmpl_info = *Utils::OpenHandle(*tmpl);
3734 while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) { 3740 while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) {
3735 iter.Advance(); 3741 iter.Advance();
3736 if (iter.IsAtEnd()) { 3742 if (iter.IsAtEnd()) {
3737 return Local<Object>(); 3743 return Local<Object>();
3738 } 3744 }
3739 } 3745 }
3740 return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate)); 3746 return Utils::ReceiverToLocal(
3747 i::handle(iter.GetCurrent<i::JSReceiver>(), isolate));
3741 } 3748 }
3742 3749
3743 3750
3744 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) { 3751 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) {
3745 PREPARE_FOR_EXECUTION(context, "v8::Object::GetPropertyNames()", Array); 3752 PREPARE_FOR_EXECUTION(context, "v8::Object::GetPropertyNames()", Array);
3746 auto self = Utils::OpenHandle(this); 3753 auto self = Utils::OpenHandle(this);
3747 i::Handle<i::FixedArray> value; 3754 i::Handle<i::FixedArray> value;
3748 has_pending_exception = !i::JSReceiver::GetKeys( 3755 has_pending_exception = !i::JSReceiver::GetKeys(
3749 self, i::JSReceiver::INCLUDE_PROTOS).ToHandle(&value); 3756 self, i::JSReceiver::INCLUDE_PROTOS).ToHandle(&value);
3750 RETURN_ON_FAILED_EXECUTION(Array); 3757 RETURN_ON_FAILED_EXECUTION(Array);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
3934 } 3941 }
3935 3942
3936 3943
3937 bool v8::Object::Has(uint32_t index) { 3944 bool v8::Object::Has(uint32_t index) {
3938 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 3945 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
3939 return Has(context, index).FromMaybe(false); 3946 return Has(context, index).FromMaybe(false);
3940 } 3947 }
3941 3948
3942 3949
3943 template <typename Getter, typename Setter, typename Data> 3950 template <typename Getter, typename Setter, typename Data>
3944 static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* obj, 3951 static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* self,
3945 Local<Name> name, Getter getter, 3952 Local<Name> name, Getter getter,
3946 Setter setter, Data data, 3953 Setter setter, Data data,
3947 AccessControl settings, 3954 AccessControl settings,
3948 PropertyAttribute attributes) { 3955 PropertyAttribute attributes) {
3949 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetAccessor()", bool); 3956 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetAccessor()", bool);
3957 if (!Utils::OpenHandle(self)->IsJSObject()) return Nothing<bool>();
3958 i::Handle<i::JSObject> obj =
3959 i::Handle<i::JSObject>::cast(Utils::OpenHandle(self));
3950 v8::Local<AccessorSignature> signature; 3960 v8::Local<AccessorSignature> signature;
3951 auto info = MakeAccessorInfo(name, getter, setter, data, settings, attributes, 3961 auto info = MakeAccessorInfo(name, getter, setter, data, settings, attributes,
3952 signature); 3962 signature);
3953 if (info.is_null()) return Nothing<bool>(); 3963 if (info.is_null()) return Nothing<bool>();
3954 bool fast = Utils::OpenHandle(obj)->HasFastProperties(); 3964 bool fast = obj->HasFastProperties();
3955 i::Handle<i::Object> result; 3965 i::Handle<i::Object> result;
3956 has_pending_exception = 3966 has_pending_exception =
3957 !i::JSObject::SetAccessor(Utils::OpenHandle(obj), info).ToHandle(&result); 3967 !i::JSObject::SetAccessor(obj, info).ToHandle(&result);
3958 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3968 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3959 if (result->IsUndefined()) return Nothing<bool>(); 3969 if (result->IsUndefined()) return Nothing<bool>();
3960 if (fast) { 3970 if (fast) {
3961 i::JSObject::MigrateSlowToFast(Utils::OpenHandle(obj), 0, "APISetAccessor"); 3971 i::JSObject::MigrateSlowToFast(obj, 0, "APISetAccessor");
3962 } 3972 }
3963 return Just(true); 3973 return Just(true);
3964 } 3974 }
3965 3975
3966 3976
3967 Maybe<bool> Object::SetAccessor(Local<Context> context, Local<Name> name, 3977 Maybe<bool> Object::SetAccessor(Local<Context> context, Local<Name> name,
3968 AccessorNameGetterCallback getter, 3978 AccessorNameGetterCallback getter,
3969 AccessorNameSetterCallback setter, 3979 AccessorNameSetterCallback setter,
3970 MaybeLocal<Value> data, AccessControl settings, 3980 MaybeLocal<Value> data, AccessControl settings,
3971 PropertyAttribute attribute) { 3981 PropertyAttribute attribute) {
(...skipping 23 matching lines...) Expand all
3995 4005
3996 void Object::SetAccessorProperty(Local<Name> name, Local<Function> getter, 4006 void Object::SetAccessorProperty(Local<Name> name, Local<Function> getter,
3997 Local<Function> setter, 4007 Local<Function> setter,
3998 PropertyAttribute attribute, 4008 PropertyAttribute attribute,
3999 AccessControl settings) { 4009 AccessControl settings) {
4000 // TODO(verwaest): Remove |settings|. 4010 // TODO(verwaest): Remove |settings|.
4001 DCHECK_EQ(v8::DEFAULT, settings); 4011 DCHECK_EQ(v8::DEFAULT, settings);
4002 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4012 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4003 ENTER_V8(isolate); 4013 ENTER_V8(isolate);
4004 i::HandleScope scope(isolate); 4014 i::HandleScope scope(isolate);
4015 auto self = Utils::OpenHandle(this);
4016 if (!self->IsJSObject()) return;
4005 i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter); 4017 i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter);
4006 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); 4018 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true);
4007 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); 4019 if (setter_i.is_null()) setter_i = isolate->factory()->null_value();
4008 i::JSObject::DefineAccessor(v8::Utils::OpenHandle(this), 4020 i::JSObject::DefineAccessor(i::Handle<i::JSObject>::cast(self),
4009 v8::Utils::OpenHandle(*name), 4021 v8::Utils::OpenHandle(*name), getter_i, setter_i,
4010 getter_i,
4011 setter_i,
4012 static_cast<PropertyAttributes>(attribute)); 4022 static_cast<PropertyAttributes>(attribute));
4013 } 4023 }
4014 4024
4015 4025
4016 Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context, 4026 Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context,
4017 Local<Name> key) { 4027 Local<Name> key) {
4018 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasOwnProperty()", 4028 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasOwnProperty()",
4019 bool); 4029 bool);
4020 auto self = Utils::OpenHandle(this); 4030 auto self = Utils::OpenHandle(this);
4021 auto key_val = Utils::OpenHandle(*key); 4031 auto key_val = Utils::OpenHandle(*key);
4022 auto result = i::JSReceiver::HasOwnProperty(self, key_val); 4032 auto result = i::JSReceiver::HasOwnProperty(self, key_val);
4023 has_pending_exception = result.IsNothing(); 4033 has_pending_exception = result.IsNothing();
4024 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 4034 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
4025 return result; 4035 return result;
4026 } 4036 }
4027 4037
4028 4038
4029 bool v8::Object::HasOwnProperty(Local<String> key) { 4039 bool v8::Object::HasOwnProperty(Local<String> key) {
4030 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4040 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4031 return HasOwnProperty(context, key).FromMaybe(false); 4041 return HasOwnProperty(context, key).FromMaybe(false);
4032 } 4042 }
4033 4043
4034 4044
4035 Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context, 4045 Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context,
4036 Local<Name> key) { 4046 Local<Name> key) {
4037 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasRealNamedProperty()", 4047 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasRealNamedProperty()",
4038 bool); 4048 bool);
4039 auto self = Utils::OpenHandle(this); 4049 auto self = Utils::OpenHandle(this);
4050 if (!self->IsJSObject()) return Nothing<bool>();
rossberg 2015/11/04 10:43:56 Doesn't Nothing indicate an exception? Wouldn't yo
4040 auto key_val = Utils::OpenHandle(*key); 4051 auto key_val = Utils::OpenHandle(*key);
4041 auto result = i::JSObject::HasRealNamedProperty(self, key_val); 4052 auto result = i::JSObject::HasRealNamedProperty(
4053 i::Handle<i::JSObject>::cast(self), key_val);
4042 has_pending_exception = result.IsNothing(); 4054 has_pending_exception = result.IsNothing();
4043 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 4055 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
4044 return result; 4056 return result;
4045 } 4057 }
4046 4058
4047 4059
4048 bool v8::Object::HasRealNamedProperty(Local<String> key) { 4060 bool v8::Object::HasRealNamedProperty(Local<String> key) {
4049 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4061 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4050 return HasRealNamedProperty(context, key).FromMaybe(false); 4062 return HasRealNamedProperty(context, key).FromMaybe(false);
4051 } 4063 }
4052 4064
4053 4065
4054 Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context, 4066 Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context,
4055 uint32_t index) { 4067 uint32_t index) {
4056 PREPARE_FOR_EXECUTION_PRIMITIVE(context, 4068 PREPARE_FOR_EXECUTION_PRIMITIVE(context,
4057 "v8::Object::HasRealIndexedProperty()", bool); 4069 "v8::Object::HasRealIndexedProperty()", bool);
4058 auto self = Utils::OpenHandle(this); 4070 auto self = Utils::OpenHandle(this);
4059 auto result = i::JSObject::HasRealElementProperty(self, index); 4071 if (!self->IsJSObject()) return Nothing<bool>();
4072 auto result = i::JSObject::HasRealElementProperty(
4073 i::Handle<i::JSObject>::cast(self), index);
4060 has_pending_exception = result.IsNothing(); 4074 has_pending_exception = result.IsNothing();
4061 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 4075 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
4062 return result; 4076 return result;
4063 } 4077 }
4064 4078
4065 4079
4066 bool v8::Object::HasRealIndexedProperty(uint32_t index) { 4080 bool v8::Object::HasRealIndexedProperty(uint32_t index) {
4067 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4081 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4068 return HasRealIndexedProperty(context, index).FromMaybe(false); 4082 return HasRealIndexedProperty(context, index).FromMaybe(false);
4069 } 4083 }
4070 4084
4071 4085
4072 Maybe<bool> v8::Object::HasRealNamedCallbackProperty(Local<Context> context, 4086 Maybe<bool> v8::Object::HasRealNamedCallbackProperty(Local<Context> context,
4073 Local<Name> key) { 4087 Local<Name> key) {
4074 PREPARE_FOR_EXECUTION_PRIMITIVE( 4088 PREPARE_FOR_EXECUTION_PRIMITIVE(
4075 context, "v8::Object::HasRealNamedCallbackProperty()", bool); 4089 context, "v8::Object::HasRealNamedCallbackProperty()", bool);
4076 auto self = Utils::OpenHandle(this); 4090 auto self = Utils::OpenHandle(this);
4091 if (!self->IsJSObject()) return Nothing<bool>();
4077 auto key_val = Utils::OpenHandle(*key); 4092 auto key_val = Utils::OpenHandle(*key);
4078 auto result = i::JSObject::HasRealNamedCallbackProperty(self, key_val); 4093 auto result = i::JSObject::HasRealNamedCallbackProperty(
4094 i::Handle<i::JSObject>::cast(self), key_val);
4079 has_pending_exception = result.IsNothing(); 4095 has_pending_exception = result.IsNothing();
4080 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 4096 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
4081 return result; 4097 return result;
4082 } 4098 }
4083 4099
4084 4100
4085 bool v8::Object::HasRealNamedCallbackProperty(Local<String> key) { 4101 bool v8::Object::HasRealNamedCallbackProperty(Local<String> key) {
4086 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4102 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4087 return HasRealNamedCallbackProperty(context, key).FromMaybe(false); 4103 return HasRealNamedCallbackProperty(context, key).FromMaybe(false);
4088 } 4104 }
4089 4105
4090 4106
4091 bool v8::Object::HasNamedLookupInterceptor() { 4107 bool v8::Object::HasNamedLookupInterceptor() {
4092 auto self = Utils::OpenHandle(this); 4108 auto self = Utils::OpenHandle(this);
4093 return self->HasNamedInterceptor(); 4109 return self->IsJSObject() &&
4110 i::Handle<i::JSObject>::cast(self)->HasNamedInterceptor();
4094 } 4111 }
4095 4112
4096 4113
4097 bool v8::Object::HasIndexedLookupInterceptor() { 4114 bool v8::Object::HasIndexedLookupInterceptor() {
4098 auto self = Utils::OpenHandle(this); 4115 auto self = Utils::OpenHandle(this);
4099 return self->HasIndexedInterceptor(); 4116 return self->IsJSObject() &&
4117 i::Handle<i::JSObject>::cast(self)->HasIndexedInterceptor();
4100 } 4118 }
4101 4119
4102 4120
4103 MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( 4121 MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
4104 Local<Context> context, Local<Name> key) { 4122 Local<Context> context, Local<Name> key) {
4105 PREPARE_FOR_EXECUTION( 4123 PREPARE_FOR_EXECUTION(
4106 context, "v8::Object::GetRealNamedPropertyInPrototypeChain()", Value); 4124 context, "v8::Object::GetRealNamedPropertyInPrototypeChain()", Value);
4107 auto self = Utils::OpenHandle(this); 4125 auto self = Utils::OpenHandle(this);
4108 auto key_obj = Utils::OpenHandle(*key); 4126 auto key_obj = Utils::OpenHandle(*key);
4109 i::PrototypeIterator iter(isolate, self); 4127 i::PrototypeIterator iter(isolate, self);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
4204 4222
4205 4223
4206 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( 4224 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes(
4207 Local<String> key) { 4225 Local<String> key) {
4208 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4226 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4209 return GetRealNamedPropertyAttributes(context, key); 4227 return GetRealNamedPropertyAttributes(context, key);
4210 } 4228 }
4211 4229
4212 4230
4213 Local<v8::Object> v8::Object::Clone() { 4231 Local<v8::Object> v8::Object::Clone() {
4214 auto self = Utils::OpenHandle(this); 4232 auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
4215 auto isolate = self->GetIsolate(); 4233 auto isolate = self->GetIsolate();
4216 ENTER_V8(isolate); 4234 ENTER_V8(isolate);
4217 auto result = isolate->factory()->CopyJSObject(self); 4235 auto result = isolate->factory()->CopyJSObject(self);
4218 CHECK(!result.is_null()); 4236 CHECK(!result.is_null());
4219 return Utils::ToLocal(result); 4237 return Utils::ReceiverToLocal(result);
4220 } 4238 }
4221 4239
4222 4240
4223 Local<v8::Context> v8::Object::CreationContext() { 4241 Local<v8::Context> v8::Object::CreationContext() {
4224 auto self = Utils::OpenHandle(this); 4242 auto self = Utils::OpenHandle(this);
4225 auto context = handle(self->GetCreationContext()); 4243 auto context = handle(self->GetCreationContext());
4226 return Utils::ToLocal(context); 4244 return Utils::ToLocal(context);
4227 } 4245 }
4228 4246
4229 4247
4230 int v8::Object::GetIdentityHash() { 4248 int v8::Object::GetIdentityHash() {
4231 auto isolate = Utils::OpenHandle(this)->GetIsolate(); 4249 auto isolate = Utils::OpenHandle(this)->GetIsolate();
4232 i::HandleScope scope(isolate); 4250 i::HandleScope scope(isolate);
4233 auto self = Utils::OpenHandle(this); 4251 auto self = Utils::OpenHandle(this);
4234 return i::JSReceiver::GetOrCreateIdentityHash(self)->value(); 4252 return i::JSReceiver::GetOrCreateIdentityHash(self)->value();
4235 } 4253 }
4236 4254
4237 4255
4238 bool v8::Object::SetHiddenValue(v8::Local<v8::String> key, 4256 bool v8::Object::SetHiddenValue(v8::Local<v8::String> key,
4239 v8::Local<v8::Value> value) { 4257 v8::Local<v8::Value> value) {
4240 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4258 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4241 if (value.IsEmpty()) return DeleteHiddenValue(key); 4259 if (value.IsEmpty()) return DeleteHiddenValue(key);
4242 ENTER_V8(isolate); 4260 ENTER_V8(isolate);
4243 i::HandleScope scope(isolate); 4261 i::HandleScope scope(isolate);
4244 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 4262 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
4263 if (!self->IsJSObject()) return false;
4245 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 4264 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
4246 i::Handle<i::String> key_string = 4265 i::Handle<i::String> key_string =
4247 isolate->factory()->InternalizeString(key_obj); 4266 isolate->factory()->InternalizeString(key_obj);
4248 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 4267 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
4249 i::Handle<i::Object> result = 4268 // TODO(jochen): Update to JSReceiver.
4250 i::JSObject::SetHiddenProperty(self, key_string, value_obj); 4269 i::Handle<i::Object> result = i::JSObject::SetHiddenProperty(
4270 i::Handle<i::JSObject>::cast(self), key_string, value_obj);
4251 return *result == *self; 4271 return *result == *self;
4252 } 4272 }
4253 4273
4254 4274
4255 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Local<v8::String> key) { 4275 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Local<v8::String> key) {
4256 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4276 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4257 ENTER_V8(isolate); 4277 ENTER_V8(isolate);
4258 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 4278 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
4279 if (!self->IsJSObject()) return v8::Local<v8::Value>();
4259 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 4280 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
4260 i::Handle<i::String> key_string = 4281 i::Handle<i::String> key_string =
4261 isolate->factory()->InternalizeString(key_obj); 4282 isolate->factory()->InternalizeString(key_obj);
4262 i::Handle<i::Object> result(self->GetHiddenProperty(key_string), isolate); 4283 // TODO(jochen): Update to JSReceiver.
4284 i::Handle<i::Object> result(
4285 i::Handle<i::JSObject>::cast(self)->GetHiddenProperty(key_string),
4286 isolate);
4263 if (result->IsTheHole()) return v8::Local<v8::Value>(); 4287 if (result->IsTheHole()) return v8::Local<v8::Value>();
4264 return Utils::ToLocal(result); 4288 return Utils::ToLocal(result);
4265 } 4289 }
4266 4290
4267 4291
4268 bool v8::Object::DeleteHiddenValue(v8::Local<v8::String> key) { 4292 bool v8::Object::DeleteHiddenValue(v8::Local<v8::String> key) {
4269 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4293 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4270 ENTER_V8(isolate); 4294 ENTER_V8(isolate);
4271 i::HandleScope scope(isolate); 4295 i::HandleScope scope(isolate);
4272 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 4296 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
4297 if (!self->IsJSObject()) return false;
4273 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 4298 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
4274 i::Handle<i::String> key_string = 4299 i::Handle<i::String> key_string =
4275 isolate->factory()->InternalizeString(key_obj); 4300 isolate->factory()->InternalizeString(key_obj);
4276 i::JSObject::DeleteHiddenProperty(self, key_string); 4301 // TODO(jochen): Update to JSReceiver.
4302 i::JSObject::DeleteHiddenProperty(i::Handle<i::JSObject>::cast(self),
4303 key_string);
4277 return true; 4304 return true;
4278 } 4305 }
4279 4306
4280 4307
4281 bool v8::Object::IsCallable() { 4308 bool v8::Object::IsCallable() {
4282 auto self = Utils::OpenHandle(this); 4309 auto self = Utils::OpenHandle(this);
4283 return self->IsCallable(); 4310 return self->IsCallable();
4284 } 4311 }
4285 4312
4286 4313
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
5285 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5312 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5286 if (obj->IsSmi()) { 5313 if (obj->IsSmi()) {
5287 return i::Smi::cast(*obj)->value(); 5314 return i::Smi::cast(*obj)->value();
5288 } else { 5315 } else {
5289 return static_cast<uint32_t>(obj->Number()); 5316 return static_cast<uint32_t>(obj->Number());
5290 } 5317 }
5291 } 5318 }
5292 5319
5293 5320
5294 int v8::Object::InternalFieldCount() { 5321 int v8::Object::InternalFieldCount() {
5295 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 5322 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
5296 return obj->GetInternalFieldCount(); 5323 if (!self->IsJSObject()) return 0;
5324 return i::Handle<i::JSObject>::cast(self)->GetInternalFieldCount();
5297 } 5325 }
5298 5326
5299 5327
5300 static bool InternalFieldOK(i::Handle<i::JSObject> obj, 5328 static bool InternalFieldOK(i::Handle<i::JSReceiver> obj, int index,
5301 int index,
5302 const char* location) { 5329 const char* location) {
5303 return Utils::ApiCheck(index < obj->GetInternalFieldCount(), 5330 return Utils::ApiCheck(
5304 location, 5331 obj->IsJSObject() &&
5305 "Internal field out of bounds"); 5332 (index < i::Handle<i::JSObject>::cast(obj)->GetInternalFieldCount()),
5333 location, "Internal field out of bounds");
5306 } 5334 }
5307 5335
5308 5336
5309 Local<Value> v8::Object::SlowGetInternalField(int index) { 5337 Local<Value> v8::Object::SlowGetInternalField(int index) {
5310 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 5338 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
5311 const char* location = "v8::Object::GetInternalField()"; 5339 const char* location = "v8::Object::GetInternalField()";
5312 if (!InternalFieldOK(obj, index, location)) return Local<Value>(); 5340 if (!InternalFieldOK(obj, index, location)) return Local<Value>();
5313 i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate()); 5341 i::Handle<i::Object> value(
5342 i::Handle<i::JSObject>::cast(obj)->GetInternalField(index),
5343 obj->GetIsolate());
5314 return Utils::ToLocal(value); 5344 return Utils::ToLocal(value);
5315 } 5345 }
5316 5346
5317 5347
5318 void v8::Object::SetInternalField(int index, v8::Local<Value> value) { 5348 void v8::Object::SetInternalField(int index, v8::Local<Value> value) {
5319 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 5349 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
5320 const char* location = "v8::Object::SetInternalField()"; 5350 const char* location = "v8::Object::SetInternalField()";
5321 if (!InternalFieldOK(obj, index, location)) return; 5351 if (!InternalFieldOK(obj, index, location)) return;
5322 i::Handle<i::Object> val = Utils::OpenHandle(*value); 5352 i::Handle<i::Object> val = Utils::OpenHandle(*value);
5323 obj->SetInternalField(index, *val); 5353 i::Handle<i::JSObject>::cast(obj)->SetInternalField(index, *val);
5324 } 5354 }
5325 5355
5326 5356
5327 void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) { 5357 void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) {
5328 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 5358 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
5329 const char* location = "v8::Object::GetAlignedPointerFromInternalField()"; 5359 const char* location = "v8::Object::GetAlignedPointerFromInternalField()";
5330 if (!InternalFieldOK(obj, index, location)) return NULL; 5360 if (!InternalFieldOK(obj, index, location)) return NULL;
5331 return DecodeSmiToAligned(obj->GetInternalField(index), location); 5361 return DecodeSmiToAligned(
5362 i::Handle<i::JSObject>::cast(obj)->GetInternalField(index), location);
5332 } 5363 }
5333 5364
5334 5365
5335 void v8::Object::SetAlignedPointerInInternalField(int index, void* value) { 5366 void v8::Object::SetAlignedPointerInInternalField(int index, void* value) {
5336 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 5367 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
5337 const char* location = "v8::Object::SetAlignedPointerInInternalField()"; 5368 const char* location = "v8::Object::SetAlignedPointerInInternalField()";
5338 if (!InternalFieldOK(obj, index, location)) return; 5369 if (!InternalFieldOK(obj, index, location)) return;
5339 obj->SetInternalField(index, EncodeAlignedAsSmi(value, location)); 5370 i::Handle<i::JSObject>::cast(obj)
5371 ->SetInternalField(index, EncodeAlignedAsSmi(value, location));
5340 DCHECK_EQ(value, GetAlignedPointerFromInternalField(index)); 5372 DCHECK_EQ(value, GetAlignedPointerFromInternalField(index));
5341 } 5373 }
5342 5374
5343 5375
5344 static void* ExternalValue(i::Object* obj) { 5376 static void* ExternalValue(i::Object* obj) {
5345 // Obscure semantics for undefined, but somehow checked in our unit tests... 5377 // Obscure semantics for undefined, but somehow checked in our unit tests...
5346 if (obj->IsUndefined()) return NULL; 5378 if (obj->IsUndefined()) return NULL;
5347 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0); 5379 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0);
5348 return i::Foreign::cast(foreign)->foreign_address(); 5380 return i::Foreign::cast(foreign)->foreign_address();
5349 } 5381 }
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
5550 v8::Local<v8::Object> Context::Global() { 5582 v8::Local<v8::Object> Context::Global() {
5551 i::Handle<i::Context> context = Utils::OpenHandle(this); 5583 i::Handle<i::Context> context = Utils::OpenHandle(this);
5552 i::Isolate* isolate = context->GetIsolate(); 5584 i::Isolate* isolate = context->GetIsolate();
5553 i::Handle<i::Object> global(context->global_proxy(), isolate); 5585 i::Handle<i::Object> global(context->global_proxy(), isolate);
5554 // TODO(dcarney): This should always return the global proxy 5586 // TODO(dcarney): This should always return the global proxy
5555 // but can't presently as calls to GetProtoype will return the wrong result. 5587 // but can't presently as calls to GetProtoype will return the wrong result.
5556 if (i::Handle<i::JSGlobalProxy>::cast( 5588 if (i::Handle<i::JSGlobalProxy>::cast(
5557 global)->IsDetachedFrom(context->global_object())) { 5589 global)->IsDetachedFrom(context->global_object())) {
5558 global = i::Handle<i::Object>(context->global_object(), isolate); 5590 global = i::Handle<i::Object>(context->global_object(), isolate);
5559 } 5591 }
5560 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); 5592 return Utils::ReceiverToLocal(i::Handle<i::JSObject>::cast(global));
5561 } 5593 }
5562 5594
5563 5595
5564 void Context::DetachGlobal() { 5596 void Context::DetachGlobal() {
5565 i::Handle<i::Context> context = Utils::OpenHandle(this); 5597 i::Handle<i::Context> context = Utils::OpenHandle(this);
5566 i::Isolate* isolate = context->GetIsolate(); 5598 i::Isolate* isolate = context->GetIsolate();
5567 ENTER_V8(isolate); 5599 ENTER_V8(isolate);
5568 isolate->bootstrapper()->DetachGlobal(context); 5600 isolate->bootstrapper()->DetachGlobal(context);
5569 } 5601 }
5570 5602
5571 5603
5572 Local<v8::Object> Context::GetExtrasBindingObject() { 5604 Local<v8::Object> Context::GetExtrasBindingObject() {
5573 i::Handle<i::Context> context = Utils::OpenHandle(this); 5605 i::Handle<i::Context> context = Utils::OpenHandle(this);
5574 i::Isolate* isolate = context->GetIsolate(); 5606 i::Isolate* isolate = context->GetIsolate();
5575 i::Handle<i::JSObject> binding(context->extras_binding_object(), isolate); 5607 i::Handle<i::JSObject> binding(context->extras_binding_object(), isolate);
5576 return Utils::ToLocal(binding); 5608 return Utils::ReceiverToLocal(binding);
5577 } 5609 }
5578 5610
5579 5611
5580 void Context::AllowCodeGenerationFromStrings(bool allow) { 5612 void Context::AllowCodeGenerationFromStrings(bool allow) {
5581 i::Handle<i::Context> context = Utils::OpenHandle(this); 5613 i::Handle<i::Context> context = Utils::OpenHandle(this);
5582 i::Isolate* isolate = context->GetIsolate(); 5614 i::Isolate* isolate = context->GetIsolate();
5583 ENTER_V8(isolate); 5615 ENTER_V8(isolate);
5584 context->set_allow_code_gen_from_strings( 5616 context->set_allow_code_gen_from_strings(
5585 allow ? isolate->heap()->true_value() : isolate->heap()->false_value()); 5617 allow ? isolate->heap()->true_value() : isolate->heap()->false_value());
5586 } 5618 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
5926 return reinterpret_cast<Isolate*>(i_isolate); 5958 return reinterpret_cast<Isolate*>(i_isolate);
5927 } 5959 }
5928 5960
5929 5961
5930 Local<v8::Object> v8::Object::New(Isolate* isolate) { 5962 Local<v8::Object> v8::Object::New(Isolate* isolate) {
5931 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5963 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5932 LOG_API(i_isolate, "Object::New"); 5964 LOG_API(i_isolate, "Object::New");
5933 ENTER_V8(i_isolate); 5965 ENTER_V8(i_isolate);
5934 i::Handle<i::JSObject> obj = 5966 i::Handle<i::JSObject> obj =
5935 i_isolate->factory()->NewJSObject(i_isolate->object_function()); 5967 i_isolate->factory()->NewJSObject(i_isolate->object_function());
5936 return Utils::ToLocal(obj); 5968 return Utils::ReceiverToLocal(obj);
5937 } 5969 }
5938 5970
5939 5971
5940 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) { 5972 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) {
5941 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5973 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5942 LOG_API(i_isolate, "NumberObject::New"); 5974 LOG_API(i_isolate, "NumberObject::New");
5943 ENTER_V8(i_isolate); 5975 ENTER_V8(i_isolate);
5944 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); 5976 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value);
5945 i::Handle<i::Object> obj = 5977 i::Handle<i::Object> obj =
5946 i::Object::ToObject(i_isolate, number).ToHandleChecked(); 5978 i::Object::ToObject(i_isolate, number).ToHandleChecked();
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
6407 } 6439 }
6408 6440
6409 6441
6410 Local<Promise::Resolver> Promise::Resolver::New(Isolate* isolate) { 6442 Local<Promise::Resolver> Promise::Resolver::New(Isolate* isolate) {
6411 RETURN_TO_LOCAL_UNCHECKED(New(isolate->GetCurrentContext()), 6443 RETURN_TO_LOCAL_UNCHECKED(New(isolate->GetCurrentContext()),
6412 Promise::Resolver); 6444 Promise::Resolver);
6413 } 6445 }
6414 6446
6415 6447
6416 Local<Promise> Promise::Resolver::GetPromise() { 6448 Local<Promise> Promise::Resolver::GetPromise() {
6417 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); 6449 i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this);
6418 return Local<Promise>::Cast(Utils::ToLocal(promise)); 6450 return Local<Promise>::Cast(Utils::ReceiverToLocal(promise));
6419 } 6451 }
6420 6452
6421 6453
6422 Maybe<bool> Promise::Resolver::Resolve(Local<Context> context, 6454 Maybe<bool> Promise::Resolver::Resolve(Local<Context> context,
6423 Local<Value> value) { 6455 Local<Value> value) {
6424 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool); 6456 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool);
6425 auto self = Utils::OpenHandle(this); 6457 auto self = Utils::OpenHandle(this);
6426 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; 6458 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)};
6427 has_pending_exception = 6459 has_pending_exception =
6428 i::Execution::Call(isolate, isolate->promise_resolve(), 6460 i::Execution::Call(isolate, isolate->promise_resolve(),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
6515 } 6547 }
6516 6548
6517 6549
6518 Local<Promise> Promise::Then(Local<Function> handler) { 6550 Local<Promise> Promise::Then(Local<Function> handler) {
6519 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 6551 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
6520 RETURN_TO_LOCAL_UNCHECKED(Then(context, handler), Promise); 6552 RETURN_TO_LOCAL_UNCHECKED(Then(context, handler), Promise);
6521 } 6553 }
6522 6554
6523 6555
6524 bool Promise::HasHandler() { 6556 bool Promise::HasHandler() {
6525 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); 6557 i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this);
6526 i::Isolate* isolate = promise->GetIsolate(); 6558 i::Isolate* isolate = promise->GetIsolate();
6527 LOG_API(isolate, "Promise::HasRejectHandler"); 6559 LOG_API(isolate, "Promise::HasRejectHandler");
6528 ENTER_V8(isolate); 6560 ENTER_V8(isolate);
6529 i::Handle<i::Symbol> key = isolate->factory()->promise_has_handler_symbol(); 6561 i::Handle<i::Symbol> key = isolate->factory()->promise_has_handler_symbol();
6530 return i::JSReceiver::GetDataProperty(promise, key)->IsTrue(); 6562 return i::JSReceiver::GetDataProperty(promise, key)->IsTrue();
6531 } 6563 }
6532 6564
6533 6565
6534 bool v8::ArrayBuffer::IsExternal() const { 6566 bool v8::ArrayBuffer::IsExternal() const {
6535 return Utils::OpenHandle(this)->is_external(); 6567 return Utils::OpenHandle(this)->is_external();
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
7774 i::Debug* isolate_debug = isolate->debug(); 7806 i::Debug* isolate_debug = isolate->debug();
7775 has_pending_exception = !isolate_debug->Load(); 7807 has_pending_exception = !isolate_debug->Load();
7776 RETURN_ON_FAILED_EXECUTION(Value); 7808 RETURN_ON_FAILED_EXECUTION(Value);
7777 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); 7809 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object());
7778 auto name = isolate->factory()->NewStringFromStaticChars("MakeMirror"); 7810 auto name = isolate->factory()->NewStringFromStaticChars("MakeMirror");
7779 auto fun_obj = i::Object::GetProperty(debug, name).ToHandleChecked(); 7811 auto fun_obj = i::Object::GetProperty(debug, name).ToHandleChecked();
7780 auto v8_fun = Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(fun_obj)); 7812 auto v8_fun = Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(fun_obj));
7781 const int kArgc = 1; 7813 const int kArgc = 1;
7782 v8::Local<v8::Value> argv[kArgc] = {obj}; 7814 v8::Local<v8::Value> argv[kArgc] = {obj};
7783 Local<Value> result; 7815 Local<Value> result;
7784 has_pending_exception = !v8_fun->Call(context, Utils::ToLocal(debug), kArgc, 7816 has_pending_exception =
7785 argv).ToLocal(&result); 7817 !v8_fun->Call(context, Utils::ReceiverToLocal(debug), kArgc, argv)
7818 .ToLocal(&result);
7786 RETURN_ON_FAILED_EXECUTION(Value); 7819 RETURN_ON_FAILED_EXECUTION(Value);
7787 RETURN_ESCAPED(result); 7820 RETURN_ESCAPED(result);
7788 } 7821 }
7789 7822
7790 7823
7791 Local<Value> Debug::GetMirror(v8::Local<v8::Value> obj) { 7824 Local<Value> Debug::GetMirror(v8::Local<v8::Value> obj) {
7792 RETURN_TO_LOCAL_UNCHECKED(GetMirror(Local<Context>(), obj), Value); 7825 RETURN_TO_LOCAL_UNCHECKED(GetMirror(Local<Context>(), obj), Value);
7793 } 7826 }
7794 7827
7795 7828
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
8462 Address callback_address = 8495 Address callback_address =
8463 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8496 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8464 VMState<EXTERNAL> state(isolate); 8497 VMState<EXTERNAL> state(isolate);
8465 ExternalCallbackScope call_scope(isolate, callback_address); 8498 ExternalCallbackScope call_scope(isolate, callback_address);
8466 callback(info); 8499 callback(info);
8467 } 8500 }
8468 8501
8469 8502
8470 } // namespace internal 8503 } // namespace internal
8471 } // namespace v8 8504 } // namespace v8
OLDNEW
« src/api.h ('K') | « src/api.h ('k') | src/debug/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698