Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index fa16f31481bdc63dc5ed553cbdf63abf6f063746..c30163b70a8c7c703aebb2d4a7709c3fb99df9dc 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -1973,8 +1973,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); |
} |
@@ -3058,8 +3059,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"); |
} |
@@ -3497,12 +3497,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); |
+ // TODO(jochen): Update to JSReceiver. |
Maybe<bool> result = i::JSObject::CreateDataProperty(&it, value_obj); |
has_pending_exception = result.IsNothing(); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
@@ -3515,10 +3516,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); |
+ // TODO(jochen): Update to JSReceiver. |
Maybe<bool> result = i::JSObject::CreateDataProperty(&it, value_obj); |
has_pending_exception = result.IsNothing(); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
@@ -3537,8 +3539,9 @@ Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, |
auto 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>(); |
} |
@@ -3577,8 +3580,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 = |
@@ -3595,7 +3598,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 = |
@@ -3711,8 +3715,10 @@ 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); |
+ // TODO(jochen): Update to JSReceiver. |
+ auto result = |
+ i::JSObject::SetPrototype(i::Handle<i::JSObject>::cast(self), value_obj, |
+ false, i::Object::THROW_ON_ERROR); |
has_pending_exception = result.IsNothing(); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
return Just(true); |
@@ -3737,7 +3743,8 @@ Local<Object> v8::Object::FindInstanceInPrototypeChain( |
return Local<Object>(); |
} |
} |
- return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate)); |
+ return Utils::ReceiverToLocal( |
+ i::handle(iter.GetCurrent<i::JSReceiver>(), isolate)); |
} |
@@ -3941,24 +3948,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 Nothing<bool>(); |
+ 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); |
} |
@@ -4002,13 +4012,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)); |
} |
@@ -4037,8 +4047,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 Nothing<bool>(); |
rossberg
2015/11/04 10:43:56
Doesn't Nothing indicate an exception? Wouldn't yo
|
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; |
@@ -4056,7 +4068,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 Nothing<bool>(); |
+ 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; |
@@ -4074,8 +4088,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 Nothing<bool>(); |
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; |
@@ -4090,13 +4106,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(); |
} |
@@ -4211,12 +4229,12 @@ 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); |
CHECK(!result.is_null()); |
- return Utils::ToLocal(result); |
+ return Utils::ReceiverToLocal(result); |
} |
@@ -4241,13 +4259,15 @@ bool v8::Object::SetHiddenValue(v8::Local<v8::String> key, |
if (value.IsEmpty()) return DeleteHiddenValue(key); |
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::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
- i::Handle<i::Object> result = |
- i::JSObject::SetHiddenProperty(self, key_string, value_obj); |
+ // TODO(jochen): Update to JSReceiver. |
+ i::Handle<i::Object> result = i::JSObject::SetHiddenProperty( |
+ i::Handle<i::JSObject>::cast(self), key_string, value_obj); |
return *result == *self; |
} |
@@ -4255,11 +4275,15 @@ 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); |
+ // TODO(jochen): Update to JSReceiver. |
+ 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); |
} |
@@ -4269,11 +4293,14 @@ 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); |
+ // TODO(jochen): Update to JSReceiver. |
+ i::JSObject::DeleteHiddenProperty(i::Handle<i::JSObject>::cast(self), |
+ key_string); |
return true; |
} |
@@ -5292,51 +5319,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)); |
} |
@@ -5557,7 +5589,7 @@ v8::Local<v8::Object> Context::Global() { |
global)->IsDetachedFrom(context->global_object())) { |
global = i::Handle<i::Object>(context->global_object(), isolate); |
} |
- return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); |
+ return Utils::ReceiverToLocal(i::Handle<i::JSObject>::cast(global)); |
} |
@@ -5573,7 +5605,7 @@ Local<v8::Object> Context::GetExtrasBindingObject() { |
i::Handle<i::Context> context = Utils::OpenHandle(this); |
i::Isolate* isolate = context->GetIsolate(); |
i::Handle<i::JSObject> binding(context->extras_binding_object(), isolate); |
- return Utils::ToLocal(binding); |
+ return Utils::ReceiverToLocal(binding); |
} |
@@ -5933,7 +5965,7 @@ Local<v8::Object> v8::Object::New(Isolate* isolate) { |
ENTER_V8(i_isolate); |
i::Handle<i::JSObject> obj = |
i_isolate->factory()->NewJSObject(i_isolate->object_function()); |
- return Utils::ToLocal(obj); |
+ return Utils::ReceiverToLocal(obj); |
} |
@@ -6414,8 +6446,8 @@ Local<Promise::Resolver> Promise::Resolver::New(Isolate* isolate) { |
Local<Promise> Promise::Resolver::GetPromise() { |
- i::Handle<i::JSObject> promise = Utils::OpenHandle(this); |
- return Local<Promise>::Cast(Utils::ToLocal(promise)); |
+ i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this); |
+ return Local<Promise>::Cast(Utils::ReceiverToLocal(promise)); |
} |
@@ -6522,7 +6554,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); |
@@ -7781,8 +7813,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::ReceiverToLocal(debug), kArgc, argv) |
+ .ToLocal(&result); |
RETURN_ON_FAILED_EXECUTION(Value); |
RETURN_ESCAPED(result); |
} |