From: yangguo@chromium.org Date: Thu, 17 Apr 2014 08:33:18 +0000 (+0000) Subject: Some MaybeHandles related cleanups. X-Git-Tag: upstream/4.7.83~9545 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c614e2b48833e66d55fd4ad7152adf165626d2b;p=platform%2Fupstream%2Fv8.git Some MaybeHandles related cleanups. R=mvstanton@chromium.org Review URL: https://codereview.chromium.org/240443005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20832 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/api.cc b/src/api.cc index e88e91a..628a3fb 100644 --- a/src/api.cc +++ b/src/api.cc @@ -3398,9 +3398,12 @@ static inline bool ObjectSetAccessor(Object* obj, name, getter, setter, data, settings, attributes, signature); if (info.is_null()) return false; bool fast = Utils::OpenHandle(obj)->HasFastProperties(); - i::Handle result = - i::JSObject::SetAccessor(Utils::OpenHandle(obj), info); - if (result.is_null() || result->IsUndefined()) return false; + i::Handle result; + ASSIGN_RETURN_ON_EXCEPTION_VALUE( + isolate, result, + i::JSObject::SetAccessor(Utils::OpenHandle(obj), info), + false); + if (result->IsUndefined()) return false; if (fast) i::JSObject::TransformToFastProperties(Utils::OpenHandle(obj), 0); return true; } diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 351d14a..c373e52 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -576,7 +576,7 @@ Handle Genesis::GetThrowTypeErrorFunction() { throw_type_error_function->shared()->set_code(*code); throw_type_error_function->shared()->DontAdaptArguments(); - JSObject::PreventExtensions(throw_type_error_function); + JSObject::PreventExtensions(throw_type_error_function).Assert(); } return throw_type_error_function; } diff --git a/src/builtins.cc b/src/builtins.cc index bfbc565..ad3691c 100644 --- a/src/builtins.cc +++ b/src/builtins.cc @@ -529,7 +529,7 @@ BUILTIN(ArrayPop) { } Handle element; ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, element, maybe_element); - RETURN_IF_EMPTY_HANDLE( + RETURN_FAILURE_ON_EXCEPTION( isolate, accessor->SetLength(array, handle(Smi::FromInt(new_length), isolate))); return *element; @@ -1231,7 +1231,7 @@ MUST_USE_RESULT static MaybeObject* HandleApiCallHelper( result->VerifyApiCallResultType(); } - RETURN_IF_SCHEDULED_EXCEPTION(isolate); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); if (!is_construct || result->IsJSObject()) return result; } @@ -1301,7 +1301,7 @@ MUST_USE_RESULT static MaybeObject* HandleApiCallAsFunctionOrConstructor( } } // Check for exceptions and return result. - RETURN_IF_SCHEDULED_EXCEPTION(isolate); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); return result; } diff --git a/src/factory.cc b/src/factory.cc index 9bcbf01..879b9b7 100644 --- a/src/factory.cc +++ b/src/factory.cc @@ -2228,7 +2228,7 @@ Handle Factory::CreateApiFunction( // Install accumulated static accessors for (int i = 0; i < valid_descriptors; i++) { Handle accessor(AccessorInfo::cast(array->get(i))); - JSObject::SetAccessor(result, accessor); + JSObject::SetAccessor(result, accessor).Assert(); } ASSERT(result->shared()->IsApiFunction()); diff --git a/src/isolate.h b/src/isolate.h index afebdf1..5dd4b4e 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -117,7 +117,7 @@ class Simulator; // of handles to the actual constants. typedef ZoneList > ZoneObjectList; -#define RETURN_IF_SCHEDULED_EXCEPTION(isolate) \ +#define RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate) \ do { \ Isolate* __isolate__ = (isolate); \ if (__isolate__->has_scheduled_exception()) { \ @@ -125,15 +125,7 @@ typedef ZoneList > ZoneObjectList; } \ } while (false) -#define RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, T) \ - do { \ - Isolate* __isolate__ = (isolate); \ - if (__isolate__->has_scheduled_exception()) { \ - __isolate__->PromoteScheduledException(); \ - return Handle::null(); \ - } \ - } while (false) - +// TODO(yangguo): Remove after we completely changed to MaybeHandles. #define RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, value) \ do { \ if ((call).is_null()) { \ @@ -142,12 +134,14 @@ typedef ZoneList > ZoneObjectList; } \ } while (false) +// TODO(yangguo): Remove after we completely changed to MaybeHandles. #define CHECK_NOT_EMPTY_HANDLE(isolate, call) \ do { \ ASSERT(!(isolate)->has_pending_exception()); \ CHECK(!(call).is_null()); \ } while (false) +// TODO(yangguo): Remove after we completely changed to MaybeHandles. #define RETURN_IF_EMPTY_HANDLE(isolate, call) \ RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, Failure::Exception()) diff --git a/src/objects.cc b/src/objects.cc index c0c896a..6f2b2a2 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -539,7 +539,7 @@ MaybeHandle JSObject::GetPropertyWithFailedAccessCheck( // No accessible property found. *attributes = ABSENT; isolate->ReportFailedAccessCheck(object, v8::ACCESS_GET); - RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); + RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); return isolate->factory()->undefined_value(); } @@ -884,7 +884,7 @@ MaybeHandle Object::GetElementWithReceiver(Isolate* isolate, if (js_object->IsAccessCheckNeeded()) { if (!isolate->MayIndexedAccess(js_object, index, v8::ACCESS_GET)) { isolate->ReportFailedAccessCheck(js_object, v8::ACCESS_GET); - RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); + RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); return isolate->factory()->undefined_value(); } } @@ -5254,8 +5254,8 @@ Handle JSObject::DeletePropertyPostInterceptor(Handle object, } -Handle JSObject::DeletePropertyWithInterceptor(Handle object, - Handle name) { +MaybeHandle JSObject::DeletePropertyWithInterceptor( + Handle object, Handle name) { Isolate* isolate = object->GetIsolate(); // TODO(rossberg): Support symbols in the API. @@ -5271,7 +5271,7 @@ Handle JSObject::DeletePropertyWithInterceptor(Handle object, isolate, interceptor->data(), *object, *object); v8::Handle result = args.Call(deleter, v8::Utils::ToLocal(Handle::cast(name))); - RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); + RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); if (!result.IsEmpty()) { ASSERT(result->IsBoolean()); Handle result_internal = v8::Utils::OpenHandle(*result); @@ -5282,7 +5282,6 @@ Handle JSObject::DeletePropertyWithInterceptor(Handle object, } Handle result = DeletePropertyPostInterceptor(object, name, NORMAL_DELETION); - RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); return result; } @@ -5306,7 +5305,7 @@ MaybeHandle JSObject::DeleteElementWithInterceptor( PropertyCallbackArguments args( isolate, interceptor->data(), *object, *object); v8::Handle result = args.Call(deleter, index); - RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); + RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); if (!result.IsEmpty()) { ASSERT(result->IsBoolean()); Handle result_internal = v8::Utils::OpenHandle(*result); @@ -5330,7 +5329,7 @@ MaybeHandle JSObject::DeleteElement(Handle object, if (object->IsAccessCheckNeeded() && !isolate->MayIndexedAccess(object, index, v8::ACCESS_DELETE)) { isolate->ReportFailedAccessCheck(object, v8::ACCESS_DELETE); - RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); + RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); return factory->false_value(); } @@ -5399,7 +5398,7 @@ MaybeHandle JSObject::DeleteProperty(Handle object, if (object->IsAccessCheckNeeded() && !isolate->MayNamedAccess(object, name, v8::ACCESS_DELETE)) { isolate->ReportFailedAccessCheck(object, v8::ACCESS_DELETE); - RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); + RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); return isolate->factory()->false_value(); } @@ -5446,7 +5445,10 @@ MaybeHandle JSObject::DeleteProperty(Handle object, if (mode == FORCE_DELETION) { result = DeletePropertyPostInterceptor(object, name, mode); } else { - result = DeletePropertyWithInterceptor(object, name); + ASSIGN_RETURN_ON_EXCEPTION( + isolate, result, + DeletePropertyWithInterceptor(object, name), + Object); } } else { // Normalize object if needed. @@ -5621,7 +5623,7 @@ bool JSObject::ReferencesObject(Object* obj) { } -Handle JSObject::PreventExtensions(Handle object) { +MaybeHandle JSObject::PreventExtensions(Handle object) { Isolate* isolate = object->GetIsolate(); if (!object->map()->is_extensible()) return object; @@ -5630,7 +5632,7 @@ Handle JSObject::PreventExtensions(Handle object) { !isolate->MayNamedAccess( object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { isolate->ReportFailedAccessCheck(object, v8::ACCESS_KEYS); - RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); + RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); return isolate->factory()->false_value(); } @@ -5648,8 +5650,7 @@ Handle JSObject::PreventExtensions(Handle object) { isolate->factory()->NewTypeError( "cant_prevent_ext_external_array_elements", HandleVector(&object, 1)); - isolate->Throw(*error); - return Handle(); + return isolate->Throw(error); } // If there are fast elements we normalize. @@ -6932,8 +6933,8 @@ bool JSObject::DefineFastAccessor(Handle object, } -Handle JSObject::SetAccessor(Handle object, - Handle info) { +MaybeHandle JSObject::SetAccessor(Handle object, + Handle info) { Isolate* isolate = object->GetIsolate(); Factory* factory = isolate->factory(); Handle name(Name::cast(info->name())); @@ -6942,7 +6943,7 @@ Handle JSObject::SetAccessor(Handle object, if (object->IsAccessCheckNeeded() && !isolate->MayNamedAccess(object, name, v8::ACCESS_SET)) { isolate->ReportFailedAccessCheck(object, v8::ACCESS_SET); - RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); + RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); return factory->undefined_value(); } @@ -7015,9 +7016,9 @@ Handle JSObject::SetAccessor(Handle object, } -Handle JSObject::GetAccessor(Handle object, - Handle name, - AccessorComponent component) { +MaybeHandle JSObject::GetAccessor(Handle object, + Handle name, + AccessorComponent component) { Isolate* isolate = object->GetIsolate(); // Make sure that the top context does not change when doing callbacks or @@ -7028,7 +7029,7 @@ Handle JSObject::GetAccessor(Handle object, if (object->IsAccessCheckNeeded() && !isolate->MayNamedAccess(object, name, v8::ACCESS_HAS)) { isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); - RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); + RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); return isolate->factory()->undefined_value(); } @@ -13570,7 +13571,7 @@ MaybeHandle JSObject::GetElementWithInterceptor( PropertyCallbackArguments args(isolate, interceptor->data(), *receiver, *object); v8::Handle result = args.Call(getter, index); - RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); + RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); if (!result.IsEmpty()) { Handle result_internal = v8::Utils::OpenHandle(*result); result_internal->VerifyApiCallResultType(); diff --git a/src/objects.h b/src/objects.h index 6aaf6f2..3af52a4 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2364,9 +2364,10 @@ class JSObject: public JSReceiver { // Retrieves an AccessorPair property from the given object. Might return // undefined if the property doesn't exist or is of a different kind. - static Handle GetAccessor(Handle object, - Handle name, - AccessorComponent component); + MUST_USE_RESULT static MaybeHandle GetAccessor( + Handle object, + Handle name, + AccessorComponent component); // Defines an AccessorPair property on the given object. // TODO(mstarzinger): Rename to SetAccessor() and return empty handle on @@ -2379,8 +2380,9 @@ class JSObject: public JSReceiver { v8::AccessControl access_control = v8::DEFAULT); // Defines an AccessorInfo property on the given object. - static Handle SetAccessor(Handle object, - Handle info); + MUST_USE_RESULT static MaybeHandle SetAccessor( + Handle object, + Handle info); MUST_USE_RESULT static MaybeHandle GetPropertyWithInterceptor( Handle object, @@ -2658,7 +2660,8 @@ class JSObject: public JSReceiver { bool ReferencesObject(Object* obj); // Disalow further properties to be added to the object. - static Handle PreventExtensions(Handle object); + MUST_USE_RESULT static MaybeHandle PreventExtensions( + Handle object); // ES5 Object.freeze MUST_USE_RESULT static MaybeHandle Freeze(Handle object); @@ -2938,8 +2941,9 @@ class JSObject: public JSReceiver { static Handle DeletePropertyPostInterceptor(Handle object, Handle name, DeleteMode mode); - static Handle DeletePropertyWithInterceptor(Handle object, - Handle name); + MUST_USE_RESULT static MaybeHandle DeletePropertyWithInterceptor( + Handle object, + Handle name); // Deletes the named property in a normalized object. static Handle DeleteNormalizedProperty(Handle object, diff --git a/src/runtime.cc b/src/runtime.cc index 405496c..e486b06 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -917,9 +917,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferIsView) { HandleScope scope(isolate); ASSERT(args.length() == 1); CONVERT_ARG_CHECKED(Object, object, 0); - return object->IsJSArrayBufferView() - ? isolate->heap()->true_value() - : isolate->heap()->false_value(); + return isolate->heap()->ToBoolean(object->IsJSArrayBufferView()); } @@ -1137,13 +1135,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitializeFromArrayLike) { buffer->backing_store(), backing_store + source_byte_offset, byte_length); - return *isolate->factory()->true_value(); - } else { - return *isolate->factory()->false_value(); + return isolate->heap()->true_value(); } } - return *isolate->factory()->false_value(); + return isolate->heap()->false_value(); } @@ -1722,7 +1718,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { v8::ACCESS_GET)) { isolate->ReportFailedAccessCheck(Handle::cast(obj), v8::ACCESS_GET); - RETURN_IF_SCHEDULED_EXCEPTION(isolate); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); return isolate->heap()->undefined_value(); } obj = Object::GetPrototype(isolate, obj); @@ -1752,7 +1748,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetPrototype) { !isolate->MayNamedAccess( obj, isolate->factory()->proto_string(), v8::ACCESS_SET)) { isolate->ReportFailedAccessCheck(obj, v8::ACCESS_SET); - RETURN_IF_SCHEDULED_EXCEPTION(isolate); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); return isolate->heap()->undefined_value(); } if (obj->map()->is_observed()) { @@ -1995,8 +1991,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) { HandleScope scope(isolate); ASSERT(args.length() == 1); CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); - Handle result = JSObject::PreventExtensions(obj); - RETURN_IF_EMPTY_HANDLE(isolate, result); + Handle result; + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( + isolate, result, JSObject::PreventExtensions(obj)); return *result; } @@ -2220,7 +2217,7 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareGlobals) { attr = lookup.GetAttributes(); } // Define or redefine own property. - RETURN_IF_EMPTY_HANDLE(isolate, + RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetLocalPropertyIgnoreAttributes( global, name, value, static_cast(attr))); } else { @@ -2326,7 +2323,7 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareContextSlot) { } if (object->IsJSGlobalObject()) { // Define own property on the global object. - RETURN_IF_EMPTY_HANDLE(isolate, + RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetLocalPropertyIgnoreAttributes(object, name, value, mode)); } else { RETURN_FAILURE_ON_EXCEPTION(isolate, @@ -2426,7 +2423,7 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_InitializeConstGlobal) { if (!lookup.IsFound()) { HandleScope handle_scope(isolate); Handle global(isolate->context()->global_object()); - RETURN_IF_EMPTY_HANDLE( + RETURN_FAILURE_ON_EXCEPTION( isolate, JSObject::SetLocalPropertyIgnoreAttributes(global, name, value, attributes)); @@ -2671,16 +2668,16 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { static_cast(DONT_ENUM | DONT_DELETE); Handle zero(Smi::FromInt(0), isolate); Factory* factory = isolate->factory(); - CHECK_NOT_EMPTY_HANDLE(isolate, JSObject::SetLocalPropertyIgnoreAttributes( - regexp, factory->source_string(), source, final)); - CHECK_NOT_EMPTY_HANDLE(isolate, JSObject::SetLocalPropertyIgnoreAttributes( - regexp, factory->global_string(), global, final)); - CHECK_NOT_EMPTY_HANDLE(isolate, JSObject::SetLocalPropertyIgnoreAttributes( - regexp, factory->ignore_case_string(), ignoreCase, final)); - CHECK_NOT_EMPTY_HANDLE(isolate, JSObject::SetLocalPropertyIgnoreAttributes( - regexp, factory->multiline_string(), multiline, final)); - CHECK_NOT_EMPTY_HANDLE(isolate, JSObject::SetLocalPropertyIgnoreAttributes( - regexp, factory->last_index_string(), zero, writable)); + JSObject::SetLocalPropertyIgnoreAttributes( + regexp, factory->source_string(), source, final).Check(); + JSObject::SetLocalPropertyIgnoreAttributes( + regexp, factory->global_string(), global, final).Check(); + JSObject::SetLocalPropertyIgnoreAttributes( + regexp, factory->ignore_case_string(), ignoreCase, final).Check(); + JSObject::SetLocalPropertyIgnoreAttributes( + regexp, factory->multiline_string(), multiline, final).Check(); + JSObject::SetLocalPropertyIgnoreAttributes( + regexp, factory->last_index_string(), zero, writable).Check(); return *regexp; } @@ -4857,11 +4854,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_IsValidSmi) { ASSERT(args.length() == 1); CONVERT_NUMBER_CHECKED(int32_t, number, Int32, args[0]); - if (Smi::IsValid(number)) { - return isolate->heap()->true_value(); - } else { - return isolate->heap()->false_value(); - } + return isolate->heap()->ToBoolean(Smi::IsValid(number)); } @@ -5070,8 +5063,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { Handle str = args.at(0); int index = args.smi_at(1); if (index >= 0 && index < str->length()) { - Handle result = GetCharAt(str, index); - return *result; + return *GetCharAt(str, index); } } @@ -5113,7 +5105,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineAccessorProperty) { bool fast = obj->HasFastProperties(); JSObject::DefineAccessor(obj, name, getter, setter, attr); - RETURN_IF_SCHEDULED_EXCEPTION(isolate); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); if (fast) JSObject::TransformToFastProperties(obj, 0); return isolate->heap()->undefined_value(); } @@ -5221,8 +5213,7 @@ MaybeHandle Runtime::SetObjectProperty(Isolate* isolate, Handle error = isolate->factory()->NewTypeError("non_object_property_store", HandleVector(args, 2)); - isolate->Throw(*error); - return Handle(); + return isolate->Throw(error); } if (object->IsJSProxy()) { @@ -5541,10 +5532,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugCallbackSupportsStepping) { } CONVERT_ARG_CHECKED(Object, callback, 0); // We do not step into the callback if it's a builtin or not even a function. - if (!callback->IsJSFunction() || JSFunction::cast(callback)->IsBuiltin()) { - return isolate->heap()->false_value(); - } - return isolate->heap()->true_value(); + return isolate->heap()->ToBoolean( + callback->IsJSFunction() && !JSFunction::cast(callback)->IsBuiltin()); #else return isolate->heap()->false_value(); #endif // ENABLE_DEBUGGER_SUPPORT @@ -5628,7 +5617,7 @@ static MaybeObject* HasLocalPropertyImplementation(Isolate* isolate, Handle::cast(proto), key); } - RETURN_IF_SCHEDULED_EXCEPTION(isolate); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); return isolate->heap()->false_value(); } @@ -5652,7 +5641,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { ASSERT(!isolate->has_scheduled_exception()); return isolate->heap()->true_value(); } else { - RETURN_IF_SCHEDULED_EXCEPTION(isolate); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); } Map* map = js_obj->map(); if (!key_is_array_index && @@ -5682,7 +5671,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); bool result = JSReceiver::HasProperty(receiver, key); - RETURN_IF_SCHEDULED_EXCEPTION(isolate); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); if (isolate->has_pending_exception()) return Failure::Exception(); return isolate->heap()->ToBoolean(result); } @@ -5695,8 +5684,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { CONVERT_SMI_ARG_CHECKED(index, 1); bool result = JSReceiver::HasElement(receiver, index); - RETURN_IF_SCHEDULED_EXCEPTION(isolate); - if (isolate->has_pending_exception()) return Failure::Exception(); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); return isolate->heap()->ToBoolean(result); } @@ -5710,7 +5698,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { PropertyAttributes att = JSReceiver::GetLocalPropertyAttribute(object, key); if (att == ABSENT || (att & DONT_ENUM) != 0) { - RETURN_IF_SCHEDULED_EXCEPTION(isolate); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); return isolate->heap()->false_value(); } ASSERT(!isolate->has_scheduled_exception()); @@ -5796,7 +5784,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) { !isolate->MayNamedAccess( obj, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { isolate->ReportFailedAccessCheck(obj, v8::ACCESS_KEYS); - RETURN_IF_SCHEDULED_EXCEPTION(isolate); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); return *isolate->factory()->NewJSArray(0); } obj = Handle(JSObject::cast(obj->GetPrototype())); @@ -5815,7 +5803,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) { !isolate->MayNamedAccess( jsproto, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { isolate->ReportFailedAccessCheck(jsproto, v8::ACCESS_KEYS); - RETURN_IF_SCHEDULED_EXCEPTION(isolate); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); return *isolate->factory()->NewJSArray(0); } int n; @@ -5971,7 +5959,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) { !isolate->MayNamedAccess( object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { isolate->ReportFailedAccessCheck(object, v8::ACCESS_KEYS); - RETURN_IF_SCHEDULED_EXCEPTION(isolate); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); return *isolate->factory()->NewJSArray(0); } @@ -8290,7 +8278,6 @@ static MaybeObject* Runtime_NewObjectHelper(Isolate* isolate, } else { result = isolate->factory()->NewJSObjectWithMemento(function, site); } - RETURN_IF_EMPTY_HANDLE(isolate, result); isolate->counters()->constructed_objects()->Increment(); isolate->counters()->constructed_objects_runtime()->Increment(); @@ -9064,8 +9051,9 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareModules) { IsImmutableVariableMode(mode) ? FROZEN : SEALED; Handle info = Accessors::MakeModuleExport(name, index, attr); - Handle result = JSObject::SetAccessor(module, info); - ASSERT(!(result.is_null() || result->IsUndefined())); + Handle result = + JSObject::SetAccessor(module, info).ToHandleChecked(); + ASSERT(!result->IsUndefined()); USE(result); break; } @@ -9084,7 +9072,7 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareModules) { } } - JSObject::PreventExtensions(module); + JSObject::PreventExtensions(module).Assert(); } ASSERT(!isolate->has_pending_exception()); @@ -10641,9 +10629,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) { CONVERT_SMI_ARG_CHECKED(flag, 2); AccessorComponent component = flag == 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER; if (!receiver->IsJSObject()) return isolate->heap()->undefined_value(); - Handle result = - JSObject::GetAccessor(Handle::cast(receiver), name, component); - RETURN_IF_EMPTY_HANDLE(isolate, result); + Handle result; + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( + isolate, result, + JSObject::GetAccessor(Handle::cast(receiver), name, component)); return *result; } @@ -12376,7 +12365,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionScopeDetails) { Handle details; ASSIGN_RETURN_FAILURE_ON_EXCEPTION( isolate, details, MaterializeScopeDetails(isolate, &it)); - RETURN_IF_EMPTY_HANDLE(isolate, details); return *details; } @@ -13692,7 +13680,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_AvailableLocalesOf) { continue; } - RETURN_IF_EMPTY_HANDLE(isolate, + RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetLocalPropertyIgnoreAttributes( locales, isolate->factory()->NewStringFromAscii(CStrVector(result)), @@ -13796,13 +13784,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLanguageTagVariants) { Handle result = isolate->factory()->NewJSObject(isolate->object_function()); - RETURN_IF_EMPTY_HANDLE(isolate, + RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetLocalPropertyIgnoreAttributes( result, maximized, isolate->factory()->NewStringFromAscii(CStrVector(base_max_locale)), NONE)); - RETURN_IF_EMPTY_HANDLE(isolate, + RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetLocalPropertyIgnoreAttributes( result, base, @@ -13924,7 +13912,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateDateTimeFormat) { local_object->SetInternalField(0, reinterpret_cast(date_format)); - RETURN_IF_EMPTY_HANDLE(isolate, + RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetLocalPropertyIgnoreAttributes( local_object, isolate->factory()->NewStringFromAscii(CStrVector("dateFormat")), @@ -14019,7 +14007,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateNumberFormat) { local_object->SetInternalField(0, reinterpret_cast(number_format)); - RETURN_IF_EMPTY_HANDLE(isolate, + RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetLocalPropertyIgnoreAttributes( local_object, isolate->factory()->NewStringFromAscii(CStrVector("numberFormat")), @@ -14123,7 +14111,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateCollator) { local_object->SetInternalField(0, reinterpret_cast(collator)); - RETURN_IF_EMPTY_HANDLE(isolate, + RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetLocalPropertyIgnoreAttributes( local_object, isolate->factory()->NewStringFromAscii(CStrVector("collator")), @@ -14223,7 +14211,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) { // Make sure that the pointer to adopted text is NULL. local_object->SetInternalField(1, reinterpret_cast(NULL)); - RETURN_IF_EMPTY_HANDLE(isolate, + RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetLocalPropertyIgnoreAttributes( local_object, isolate->factory()->NewStringFromAscii(CStrVector("breakIterator")), diff --git a/src/stub-cache.cc b/src/stub-cache.cc index 91d31ea..5f3a74c 100644 --- a/src/stub-cache.cc +++ b/src/stub-cache.cc @@ -499,7 +499,7 @@ RUNTIME_FUNCTION(MaybeObject*, StoreCallbackProperty) { PropertyCallbackArguments custom_args(isolate, callback->data(), receiver, holder); custom_args.Call(fun, v8::Utils::ToLocal(str), v8::Utils::ToLocal(value)); - RETURN_IF_SCHEDULED_EXCEPTION(isolate); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); return *value; } @@ -539,7 +539,7 @@ RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly) { HandleScope scope(isolate); v8::Handle r = callback_args.Call(getter, v8::Utils::ToLocal(name)); - RETURN_IF_SCHEDULED_EXCEPTION(isolate); + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); if (!r.IsEmpty()) { Handle result = v8::Utils::OpenHandle(*r); result->VerifyApiCallResultType();