Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 5d4c9c0c415ac558747dfa55b25b19a02c9187b4..8634a2bbd16320799487ebf9890f24bf2496cd60 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -1956,8 +1956,9 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext( |
i::Handle<i::SharedFunctionInfo> outer_info(context->closure()->shared(), |
isolate); |
for (size_t i = 0; i < context_extension_count; ++i) { |
- i::Handle<i::JSObject> extension = |
+ i::Handle<i::JSReceiver> extension = |
Utils::OpenHandle(*context_extensions[i]); |
+ if (!extension->IsJSObject()) return Local<Function>(); |
i::Handle<i::JSFunction> closure(context->closure(), isolate); |
context = factory->NewWithContext(closure, context, extension); |
} |
@@ -3041,8 +3042,7 @@ void External::CheckCast(v8::Value* that) { |
void v8::Object::CheckCast(Value* that) { |
i::Handle<i::Object> obj = Utils::OpenHandle(that); |
- Utils::ApiCheck(obj->IsJSObject(), |
- "v8::Object::Cast()", |
+ Utils::ApiCheck(obj->IsJSReceiver(), "v8::Object::Cast()", |
"Could not convert to object"); |
} |
@@ -3480,13 +3480,13 @@ Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, |
v8::Local<Value> value) { |
PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", |
bool); |
- i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
+ i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
isolate, self, key_obj, i::LookupIterator::OWN); |
- Maybe<bool> result = i::JSObject::CreateDataProperty(&it, value_obj); |
+ Maybe<bool> result = i::JSReceiver::CreateDataProperty(&it, value_obj); |
has_pending_exception = result.IsNothing(); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
return result; |
@@ -3498,11 +3498,11 @@ Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, |
v8::Local<Value> value) { |
PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", |
bool); |
- i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
+ i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
i::LookupIterator it(isolate, self, index, i::LookupIterator::OWN); |
- Maybe<bool> result = i::JSObject::CreateDataProperty(&it, value_obj); |
+ Maybe<bool> result = i::JSReceiver::CreateDataProperty(&it, value_obj); |
has_pending_exception = result.IsNothing(); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
return result; |
@@ -3515,13 +3515,14 @@ Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, |
v8::PropertyAttribute attributes) { |
PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DefineOwnProperty()", |
bool); |
- i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
+ i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
if (self->IsAccessCheckNeeded() && |
- !isolate->MayAccess(handle(isolate->context()), self)) { |
- isolate->ReportFailedAccessCheck(self); |
+ !isolate->MayAccess(handle(isolate->context()), |
+ i::Handle<i::JSObject>::cast(self))) { |
+ isolate->ReportFailedAccessCheck(i::Handle<i::JSObject>::cast(self)); |
return Nothing<bool>(); |
} |
@@ -3555,8 +3556,8 @@ static i::MaybeHandle<i::Object> DefineObjectProperty( |
Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, |
v8::Local<Value> key, v8::Local<Value> value, |
v8::PropertyAttribute attribs) { |
- PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); |
- auto self = Utils::OpenHandle(this); |
+ PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::ForceSet()", bool); |
+ auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); |
auto key_obj = Utils::OpenHandle(*key); |
auto value_obj = Utils::OpenHandle(*value); |
has_pending_exception = |
@@ -3573,7 +3574,8 @@ bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value, |
PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), |
"v8::Object::ForceSet", false, i::HandleScope, |
false); |
- i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
+ i::Handle<i::JSObject> self = |
+ i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); |
i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
has_pending_exception = |
@@ -3702,8 +3704,8 @@ Maybe<bool> v8::Object::SetPrototype(Local<Context> context, |
// We do not allow exceptions thrown while setting the prototype |
// to propagate outside. |
TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); |
- auto result = i::JSObject::SetPrototype(self, value_obj, false, |
- i::Object::THROW_ON_ERROR); |
+ auto result = i::JSReceiver::SetPrototype(self, value_obj, false, |
+ i::Object::THROW_ON_ERROR); |
has_pending_exception = result.IsNothing(); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
return Just(true); |
@@ -3944,24 +3946,27 @@ bool v8::Object::Has(uint32_t index) { |
template <typename Getter, typename Setter, typename Data> |
-static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* obj, |
+static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* self, |
Local<Name> name, Getter getter, |
Setter setter, Data data, |
AccessControl settings, |
PropertyAttribute attributes) { |
PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetAccessor()", bool); |
+ if (!Utils::OpenHandle(self)->IsJSObject()) return Just(false); |
+ i::Handle<i::JSObject> obj = |
+ i::Handle<i::JSObject>::cast(Utils::OpenHandle(self)); |
v8::Local<AccessorSignature> signature; |
auto info = MakeAccessorInfo(name, getter, setter, data, settings, attributes, |
signature); |
if (info.is_null()) return Nothing<bool>(); |
- bool fast = Utils::OpenHandle(obj)->HasFastProperties(); |
+ bool fast = obj->HasFastProperties(); |
i::Handle<i::Object> result; |
has_pending_exception = |
- !i::JSObject::SetAccessor(Utils::OpenHandle(obj), info).ToHandle(&result); |
+ !i::JSObject::SetAccessor(obj, info).ToHandle(&result); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
if (result->IsUndefined()) return Nothing<bool>(); |
if (fast) { |
- i::JSObject::MigrateSlowToFast(Utils::OpenHandle(obj), 0, "APISetAccessor"); |
+ i::JSObject::MigrateSlowToFast(obj, 0, "APISetAccessor"); |
} |
return Just(true); |
} |
@@ -4005,13 +4010,13 @@ void Object::SetAccessorProperty(Local<Name> name, Local<Function> getter, |
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
ENTER_V8(isolate); |
i::HandleScope scope(isolate); |
+ auto self = Utils::OpenHandle(this); |
+ if (!self->IsJSObject()) return; |
i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter); |
i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); |
if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); |
- i::JSObject::DefineAccessor(v8::Utils::OpenHandle(this), |
- v8::Utils::OpenHandle(*name), |
- getter_i, |
- setter_i, |
+ i::JSObject::DefineAccessor(i::Handle<i::JSObject>::cast(self), |
+ v8::Utils::OpenHandle(*name), getter_i, setter_i, |
static_cast<PropertyAttributes>(attribute)); |
} |
@@ -4040,8 +4045,10 @@ Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context, |
PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasRealNamedProperty()", |
bool); |
auto self = Utils::OpenHandle(this); |
+ if (!self->IsJSObject()) return Just(false); |
auto key_val = Utils::OpenHandle(*key); |
- auto result = i::JSObject::HasRealNamedProperty(self, key_val); |
+ auto result = i::JSObject::HasRealNamedProperty( |
+ i::Handle<i::JSObject>::cast(self), key_val); |
has_pending_exception = result.IsNothing(); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
return result; |
@@ -4059,7 +4066,9 @@ Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context, |
PREPARE_FOR_EXECUTION_PRIMITIVE(context, |
"v8::Object::HasRealIndexedProperty()", bool); |
auto self = Utils::OpenHandle(this); |
- auto result = i::JSObject::HasRealElementProperty(self, index); |
+ if (!self->IsJSObject()) return Just(false); |
+ auto result = i::JSObject::HasRealElementProperty( |
+ i::Handle<i::JSObject>::cast(self), index); |
has_pending_exception = result.IsNothing(); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
return result; |
@@ -4077,8 +4086,10 @@ Maybe<bool> v8::Object::HasRealNamedCallbackProperty(Local<Context> context, |
PREPARE_FOR_EXECUTION_PRIMITIVE( |
context, "v8::Object::HasRealNamedCallbackProperty()", bool); |
auto self = Utils::OpenHandle(this); |
+ if (!self->IsJSObject()) return Just(false); |
auto key_val = Utils::OpenHandle(*key); |
- auto result = i::JSObject::HasRealNamedCallbackProperty(self, key_val); |
+ auto result = i::JSObject::HasRealNamedCallbackProperty( |
+ i::Handle<i::JSObject>::cast(self), key_val); |
has_pending_exception = result.IsNothing(); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
return result; |
@@ -4093,13 +4104,15 @@ bool v8::Object::HasRealNamedCallbackProperty(Local<String> key) { |
bool v8::Object::HasNamedLookupInterceptor() { |
auto self = Utils::OpenHandle(this); |
- return self->HasNamedInterceptor(); |
+ return self->IsJSObject() && |
+ i::Handle<i::JSObject>::cast(self)->HasNamedInterceptor(); |
} |
bool v8::Object::HasIndexedLookupInterceptor() { |
auto self = Utils::OpenHandle(this); |
- return self->HasIndexedInterceptor(); |
+ return self->IsJSObject() && |
+ i::Handle<i::JSObject>::cast(self)->HasIndexedInterceptor(); |
} |
@@ -4107,7 +4120,8 @@ MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
Local<Context> context, Local<Name> key) { |
PREPARE_FOR_EXECUTION( |
context, "v8::Object::GetRealNamedPropertyInPrototypeChain()", Value); |
- i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
+ i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
+ if (!self->IsJSObject()) return MaybeLocal<Value>(); |
i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
i::PrototypeIterator iter(isolate, self); |
if (iter.IsAtEnd()) return MaybeLocal<Value>(); |
@@ -4138,7 +4152,8 @@ v8::Object::GetRealNamedPropertyAttributesInPrototypeChain( |
PREPARE_FOR_EXECUTION_PRIMITIVE( |
context, "v8::Object::GetRealNamedPropertyAttributesInPrototypeChain()", |
PropertyAttribute); |
- i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
+ i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
+ if (!self->IsJSObject()) return Nothing<PropertyAttribute>(); |
i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
i::PrototypeIterator iter(isolate, self); |
if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); |
@@ -4213,7 +4228,7 @@ Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( |
Local<v8::Object> v8::Object::Clone() { |
- auto self = Utils::OpenHandle(this); |
+ auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); |
auto isolate = self->GetIsolate(); |
ENTER_V8(isolate); |
auto result = isolate->factory()->CopyJSObject(self); |
@@ -4242,17 +4257,19 @@ bool v8::Object::SetHiddenValue(v8::Local<v8::String> key, |
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
ENTER_V8(isolate); |
i::HandleScope scope(isolate); |
- i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
+ i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
+ if (!self->IsJSObject()) return false; |
i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
i::Handle<i::String> key_string = |
isolate->factory()->InternalizeString(key_obj); |
if (value.IsEmpty()) { |
- i::JSObject::DeleteHiddenProperty(self, key_string); |
+ i::JSObject::DeleteHiddenProperty(i::Handle<i::JSObject>::cast(self), |
+ key_string); |
return true; |
} |
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
- i::Handle<i::Object> result = |
- i::JSObject::SetHiddenProperty(self, key_string, value_obj); |
+ i::Handle<i::Object> result = i::JSObject::SetHiddenProperty( |
+ i::Handle<i::JSObject>::cast(self), key_string, value_obj); |
return *result == *self; |
} |
@@ -4260,11 +4277,14 @@ bool v8::Object::SetHiddenValue(v8::Local<v8::String> key, |
v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Local<v8::String> key) { |
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
ENTER_V8(isolate); |
- i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
+ i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
+ if (!self->IsJSObject()) return v8::Local<v8::Value>(); |
i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
i::Handle<i::String> key_string = |
isolate->factory()->InternalizeString(key_obj); |
- i::Handle<i::Object> result(self->GetHiddenProperty(key_string), isolate); |
+ i::Handle<i::Object> result( |
+ i::Handle<i::JSObject>::cast(self)->GetHiddenProperty(key_string), |
+ isolate); |
if (result->IsTheHole()) return v8::Local<v8::Value>(); |
return Utils::ToLocal(result); |
} |
@@ -4274,11 +4294,13 @@ bool v8::Object::DeleteHiddenValue(v8::Local<v8::String> key) { |
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
ENTER_V8(isolate); |
i::HandleScope scope(isolate); |
- i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
+ i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
+ if (!self->IsJSObject()) return false; |
i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
i::Handle<i::String> key_string = |
isolate->factory()->InternalizeString(key_obj); |
- i::JSObject::DeleteHiddenProperty(self, key_string); |
+ i::JSObject::DeleteHiddenProperty(i::Handle<i::JSObject>::cast(self), |
+ key_string); |
return true; |
} |
@@ -5302,51 +5324,56 @@ uint32_t Uint32::Value() const { |
int v8::Object::InternalFieldCount() { |
- i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
- return obj->GetInternalFieldCount(); |
+ i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
+ if (!self->IsJSObject()) return 0; |
+ return i::Handle<i::JSObject>::cast(self)->GetInternalFieldCount(); |
} |
-static bool InternalFieldOK(i::Handle<i::JSObject> obj, |
- int index, |
+static bool InternalFieldOK(i::Handle<i::JSReceiver> obj, int index, |
const char* location) { |
- return Utils::ApiCheck(index < obj->GetInternalFieldCount(), |
- location, |
- "Internal field out of bounds"); |
+ return Utils::ApiCheck( |
+ obj->IsJSObject() && |
+ (index < i::Handle<i::JSObject>::cast(obj)->GetInternalFieldCount()), |
+ location, "Internal field out of bounds"); |
} |
Local<Value> v8::Object::SlowGetInternalField(int index) { |
- i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
+ i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this); |
const char* location = "v8::Object::GetInternalField()"; |
if (!InternalFieldOK(obj, index, location)) return Local<Value>(); |
- i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate()); |
+ i::Handle<i::Object> value( |
+ i::Handle<i::JSObject>::cast(obj)->GetInternalField(index), |
+ obj->GetIsolate()); |
return Utils::ToLocal(value); |
} |
void v8::Object::SetInternalField(int index, v8::Local<Value> value) { |
- i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
+ i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this); |
const char* location = "v8::Object::SetInternalField()"; |
if (!InternalFieldOK(obj, index, location)) return; |
i::Handle<i::Object> val = Utils::OpenHandle(*value); |
- obj->SetInternalField(index, *val); |
+ i::Handle<i::JSObject>::cast(obj)->SetInternalField(index, *val); |
} |
void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) { |
- i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
+ i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this); |
const char* location = "v8::Object::GetAlignedPointerFromInternalField()"; |
if (!InternalFieldOK(obj, index, location)) return NULL; |
- return DecodeSmiToAligned(obj->GetInternalField(index), location); |
+ return DecodeSmiToAligned( |
+ i::Handle<i::JSObject>::cast(obj)->GetInternalField(index), location); |
} |
void v8::Object::SetAlignedPointerInInternalField(int index, void* value) { |
- i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
+ i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this); |
const char* location = "v8::Object::SetAlignedPointerInInternalField()"; |
if (!InternalFieldOK(obj, index, location)) return; |
- obj->SetInternalField(index, EncodeAlignedAsSmi(value, location)); |
+ i::Handle<i::JSObject>::cast(obj) |
+ ->SetInternalField(index, EncodeAlignedAsSmi(value, location)); |
DCHECK_EQ(value, GetAlignedPointerFromInternalField(index)); |
} |
@@ -6426,7 +6453,7 @@ Local<Promise::Resolver> Promise::Resolver::New(Isolate* isolate) { |
Local<Promise> Promise::Resolver::GetPromise() { |
- i::Handle<i::JSObject> promise = Utils::OpenHandle(this); |
+ i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this); |
return Local<Promise>::Cast(Utils::ToLocal(promise)); |
} |
@@ -6534,7 +6561,7 @@ Local<Promise> Promise::Then(Local<Function> handler) { |
bool Promise::HasHandler() { |
- i::Handle<i::JSObject> promise = Utils::OpenHandle(this); |
+ i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this); |
i::Isolate* isolate = promise->GetIsolate(); |
LOG_API(isolate, "Promise::HasRejectHandler"); |
ENTER_V8(isolate); |
@@ -7819,8 +7846,9 @@ MaybeLocal<Value> Debug::GetMirror(Local<Context> context, |
const int kArgc = 1; |
v8::Local<v8::Value> argv[kArgc] = {obj}; |
Local<Value> result; |
- has_pending_exception = !v8_fun->Call(context, Utils::ToLocal(debug), kArgc, |
- argv).ToLocal(&result); |
+ has_pending_exception = |
+ !v8_fun->Call(context, Utils::ToLocal(debug), kArgc, argv) |
+ .ToLocal(&result); |
RETURN_ON_FAILED_EXECUTION(Value); |
RETURN_ESCAPED(result); |
} |