Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 959a04242cba1ab7689449d1c01ef1066c011e16..6a0f13765da6721df504eb2ba33024b495e645be 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -213,13 +213,13 @@ static Handle<Map> ComputeObjectLiteralMap( |
} |
-static Handle<Object> CreateLiteralBoilerplate( |
+MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( |
Isolate* isolate, |
Handle<FixedArray> literals, |
Handle<FixedArray> constant_properties); |
-static Handle<Object> CreateObjectLiteralBoilerplate( |
+MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate( |
Isolate* isolate, |
Handle<FixedArray> literals, |
Handle<FixedArray> constant_properties, |
@@ -274,27 +274,29 @@ static Handle<Object> CreateObjectLiteralBoilerplate( |
// The value contains the constant_properties of a |
// simple object or array literal. |
Handle<FixedArray> array = Handle<FixedArray>::cast(value); |
- value = CreateLiteralBoilerplate(isolate, literals, array); |
- if (value.is_null()) return value; |
+ ASSIGN_RETURN_ON_EXCEPTION( |
+ isolate, value, |
+ CreateLiteralBoilerplate(isolate, literals, array), |
+ Object); |
} |
- Handle<Object> result; |
+ MaybeHandle<Object> maybe_result; |
uint32_t element_index = 0; |
StoreMode mode = value->IsJSObject() ? FORCE_FIELD : ALLOW_AS_CONSTANT; |
if (key->IsInternalizedString()) { |
if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { |
// Array index as string (uint32). |
- result = JSObject::SetOwnElement( |
+ maybe_result = JSObject::SetOwnElement( |
boilerplate, element_index, value, SLOPPY); |
} else { |
Handle<String> name(String::cast(*key)); |
ASSERT(!name->AsArrayIndex(&element_index)); |
- result = JSObject::SetLocalPropertyIgnoreAttributes( |
+ maybe_result = JSObject::SetLocalPropertyIgnoreAttributes( |
boilerplate, name, value, NONE, |
Object::OPTIMAL_REPRESENTATION, mode); |
} |
} else if (key->ToArrayIndex(&element_index)) { |
// Array index (uint32). |
- result = JSObject::SetOwnElement( |
+ maybe_result = JSObject::SetOwnElement( |
boilerplate, element_index, value, SLOPPY); |
} else { |
// Non-uint32 number. |
@@ -305,7 +307,7 @@ static Handle<Object> CreateObjectLiteralBoilerplate( |
const char* str = DoubleToCString(num, buffer); |
Handle<String> name = |
isolate->factory()->NewStringFromAscii(CStrVector(str)); |
- result = JSObject::SetLocalPropertyIgnoreAttributes( |
+ maybe_result = JSObject::SetLocalPropertyIgnoreAttributes( |
boilerplate, name, value, NONE, |
Object::OPTIMAL_REPRESENTATION, mode); |
} |
@@ -313,7 +315,7 @@ static Handle<Object> CreateObjectLiteralBoilerplate( |
// exception, the exception is converted to an empty handle in |
// the handle based operations. In that case, we need to |
// convert back to an exception. |
- if (result.is_null()) return result; |
+ RETURN_ON_EXCEPTION(isolate, maybe_result, Object); |
} |
// Transform to fast properties if necessary. For object literals with |
@@ -347,7 +349,7 @@ MaybeObject* TransitionElements(Handle<Object> object, |
static const int kSmiLiteralMinimumLength = 1024; |
-Handle<Object> Runtime::CreateArrayLiteralBoilerplate( |
+MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate( |
Isolate* isolate, |
Handle<FixedArray> literals, |
Handle<FixedArray> elements) { |
@@ -406,9 +408,11 @@ Handle<Object> Runtime::CreateArrayLiteralBoilerplate( |
// The value contains the constant_properties of a |
// simple object or array literal. |
Handle<FixedArray> fa(FixedArray::cast(fixed_array_values->get(i))); |
- Handle<Object> result = |
- CreateLiteralBoilerplate(isolate, literals, fa); |
- if (result.is_null()) return result; |
+ Handle<Object> result; |
+ ASSIGN_RETURN_ON_EXCEPTION( |
+ isolate, result, |
+ CreateLiteralBoilerplate(isolate, literals, fa), |
+ Object); |
fixed_array_values_copy->set(i, *result); |
} |
} |
@@ -437,7 +441,7 @@ Handle<Object> Runtime::CreateArrayLiteralBoilerplate( |
} |
-static Handle<Object> CreateLiteralBoilerplate( |
+MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( |
Isolate* isolate, |
Handle<FixedArray> literals, |
Handle<FixedArray> array) { |
@@ -461,7 +465,7 @@ static Handle<Object> CreateLiteralBoilerplate( |
isolate, literals, elements); |
default: |
UNREACHABLE(); |
- return Handle<Object>::null(); |
+ return MaybeHandle<Object>(); |
} |
} |
@@ -481,13 +485,15 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CreateObjectLiteral) { |
Handle<AllocationSite> site; |
Handle<JSObject> boilerplate; |
if (*literal_site == isolate->heap()->undefined_value()) { |
- Handle<Object> raw_boilerplate = CreateObjectLiteralBoilerplate( |
- isolate, |
- literals, |
- constant_properties, |
- should_have_fast_elements, |
- has_function_literal); |
- RETURN_IF_EMPTY_HANDLE(isolate, raw_boilerplate); |
+ Handle<Object> raw_boilerplate; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, raw_boilerplate, |
+ CreateObjectLiteralBoilerplate( |
+ isolate, |
+ literals, |
+ constant_properties, |
+ should_have_fast_elements, |
+ has_function_literal)); |
boilerplate = Handle<JSObject>::cast(raw_boilerplate); |
AllocationSiteCreationContext creation_context(isolate); |
@@ -513,7 +519,7 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CreateObjectLiteral) { |
} |
-static Handle<AllocationSite> GetLiteralAllocationSite( |
+MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite( |
Isolate* isolate, |
Handle<FixedArray> literals, |
int literals_index, |
@@ -523,9 +529,11 @@ static Handle<AllocationSite> GetLiteralAllocationSite( |
Handle<AllocationSite> site; |
if (*literal_site == isolate->heap()->undefined_value()) { |
ASSERT(*elements != isolate->heap()->empty_fixed_array()); |
- Handle<Object> boilerplate = |
- Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements); |
- if (boilerplate.is_null()) return Handle<AllocationSite>::null(); |
+ Handle<Object> boilerplate; |
+ ASSIGN_RETURN_ON_EXCEPTION( |
+ isolate, boilerplate, |
+ Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements), |
+ AllocationSite); |
AllocationSiteCreationContext creation_context(isolate); |
site = creation_context.EnterNewScope(); |
@@ -549,9 +557,10 @@ static MaybeObject* CreateArrayLiteralImpl(Isolate* isolate, |
int literals_index, |
Handle<FixedArray> elements, |
int flags) { |
- Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, |
- literals_index, elements); |
- RETURN_IF_EMPTY_HANDLE(isolate, site); |
+ Handle<AllocationSite> site; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, site, |
+ GetLiteralAllocationSite(isolate, literals, literals_index, elements)); |
bool enable_mementos = (flags & ArrayLiteral::kDisableMementos) == 0; |
Handle<JSObject> boilerplate(JSObject::cast(site->transition_info())); |
@@ -632,7 +641,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateGlobalPrivateSymbol) { |
ASSERT(symbol->IsUndefined()); |
symbol = isolate->factory()->NewPrivateSymbol(); |
Handle<Symbol>::cast(symbol)->set_name(*name); |
- JSObject::SetProperty(privates, name, symbol, NONE, STRICT); |
+ JSObject::SetProperty(privates, name, symbol, NONE, STRICT).Assert(); |
} |
return *symbol; |
} |
@@ -2207,7 +2216,8 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareGlobals) { |
global, name, value, static_cast<PropertyAttributes>(attr))); |
} else { |
// Do a [[Put]] on the existing (own) property. |
- RETURN_IF_EMPTY_HANDLE(isolate, |
+ RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, |
JSObject::SetProperty( |
global, name, value, static_cast<PropertyAttributes>(attr), |
strict_mode)); |
@@ -2263,7 +2273,7 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareContextSlot) { |
// Slow case: The property is in the context extension object of a |
// function context or the global object of a native context. |
Handle<JSObject> object = Handle<JSObject>::cast(holder); |
- RETURN_IF_EMPTY_HANDLE( |
+ RETURN_FAILURE_ON_EXCEPTION( |
isolate, |
JSReceiver::SetProperty(object, name, initial_value, mode, SLOPPY)); |
} |
@@ -2310,7 +2320,7 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareContextSlot) { |
RETURN_IF_EMPTY_HANDLE(isolate, |
JSObject::SetLocalPropertyIgnoreAttributes(object, name, value, mode)); |
} else { |
- RETURN_IF_EMPTY_HANDLE(isolate, |
+ RETURN_FAILURE_ON_EXCEPTION(isolate, |
JSReceiver::SetProperty(object, name, value, mode, SLOPPY)); |
} |
} |
@@ -2355,9 +2365,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { |
// Found an interceptor that's not read only. |
if (assign) { |
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
- Handle<Object> result = JSObject::SetPropertyForResult( |
- holder, &lookup, name, value, attributes, strict_mode); |
- RETURN_IF_EMPTY_HANDLE(isolate, result); |
+ Handle<Object> result; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, result, |
+ JSObject::SetPropertyForResult( |
+ holder, &lookup, name, value, attributes, strict_mode)); |
return *result; |
} else { |
return isolate->heap()->undefined_value(); |
@@ -2368,9 +2380,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { |
if (assign) { |
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
Handle<GlobalObject> global(isolate->context()->global_object()); |
- Handle<Object> result = JSReceiver::SetProperty( |
- global, name, value, attributes, strict_mode); |
- RETURN_IF_EMPTY_HANDLE(isolate, result); |
+ Handle<Object> result; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, result, |
+ JSReceiver::SetProperty(global, name, value, attributes, strict_mode)); |
return *result; |
} |
return isolate->heap()->undefined_value(); |
@@ -2421,7 +2434,7 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_InitializeConstGlobal) { |
// property through an interceptor and only do it if it's |
// uninitialized, e.g. the hole. Nirk... |
// Passing sloppy mode because the property is writable. |
- RETURN_IF_EMPTY_HANDLE( |
+ RETURN_FAILURE_ON_EXCEPTION( |
isolate, |
JSReceiver::SetProperty(global, name, value, attributes, SLOPPY)); |
return *value; |
@@ -2491,7 +2504,7 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_InitializeConstContextSlot) { |
Handle<JSObject> global = Handle<JSObject>( |
isolate->context()->global_object()); |
// Strict mode not needed (const disallowed in strict mode). |
- RETURN_IF_EMPTY_HANDLE( |
+ RETURN_FAILURE_ON_EXCEPTION( |
isolate, |
JSReceiver::SetProperty(global, name, value, NONE, SLOPPY)); |
return *value; |
@@ -2542,7 +2555,7 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_InitializeConstContextSlot) { |
// read-only property. |
if ((attributes & READ_ONLY) == 0) { |
// Strict mode not needed (const disallowed in strict mode). |
- RETURN_IF_EMPTY_HANDLE( |
+ RETURN_FAILURE_ON_EXCEPTION( |
isolate, |
JSReceiver::SetProperty(object, name, value, attributes, SLOPPY)); |
} |
@@ -2704,7 +2717,7 @@ static Handle<JSFunction> InstallBuiltin(Isolate* isolate, |
code, |
false); |
optimized->shared()->DontAdaptArguments(); |
- JSReceiver::SetProperty(holder, key, optimized, NONE, STRICT); |
+ JSReceiver::SetProperty(holder, key, optimized, NONE, STRICT).Assert(); |
return optimized; |
} |
@@ -5165,14 +5178,15 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) { |
// TODO(mstarzinger): So far this only works if property attributes don't |
// change, this should be fixed once we cleanup the underlying code. |
if (callback->IsForeign() && lookup.GetAttributes() == attr) { |
- Handle<Object> result_object = |
+ Handle<Object> result_object; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, result_object, |
JSObject::SetPropertyWithCallback(js_object, |
callback, |
name, |
obj_value, |
handle(lookup.holder()), |
- STRICT); |
- RETURN_IF_EMPTY_HANDLE(isolate, result_object); |
+ STRICT)); |
return *result_object; |
} |
} |
@@ -5194,17 +5208,18 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) { |
JSObject::NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); |
// Use IgnoreAttributes version since a readonly property may be |
// overridden and SetProperty does not allow this. |
- Handle<Object> result = JSObject::SetLocalPropertyIgnoreAttributes( |
- js_object, name, obj_value, attr); |
- RETURN_IF_EMPTY_HANDLE(isolate, result); |
+ Handle<Object> result; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, result, |
+ JSObject::SetLocalPropertyIgnoreAttributes( |
+ js_object, name, obj_value, attr)); |
return *result; |
} |
- Handle<Object> result = Runtime::ForceSetObjectProperty(isolate, js_object, |
- name, |
- obj_value, |
- attr); |
- RETURN_IF_EMPTY_HANDLE(isolate, result); |
+ Handle<Object> result; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, result, |
+ Runtime::ForceSetObjectProperty(js_object, name, obj_value, attr)); |
return *result; |
} |
@@ -5239,12 +5254,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDataProperty) { |
} |
-Handle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
- Handle<Object> object, |
- Handle<Object> key, |
- Handle<Object> value, |
- PropertyAttributes attr, |
- StrictMode strict_mode) { |
+MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
+ Handle<Object> object, |
+ Handle<Object> key, |
+ Handle<Object> value, |
+ PropertyAttributes attr, |
+ StrictMode strict_mode) { |
SetPropertyMode set_mode = attr == NONE ? SET_PROPERTY : DEFINE_PROPERTY; |
if (object->IsUndefined() || object->IsNull()) { |
@@ -5343,11 +5358,11 @@ Handle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
} |
-Handle<Object> Runtime::ForceSetObjectProperty(Isolate* isolate, |
- Handle<JSObject> js_object, |
- Handle<Object> key, |
- Handle<Object> value, |
- PropertyAttributes attr) { |
+MaybeHandle<Object> Runtime::ForceSetObjectProperty(Handle<JSObject> js_object, |
+ Handle<Object> key, |
+ Handle<Object> value, |
+ PropertyAttributes attr) { |
+ Isolate* isolate = js_object->GetIsolate(); |
// Check if the given key is an array index. |
uint32_t index; |
if (key->ToArrayIndex(&index)) { |
@@ -5472,11 +5487,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { |
strict_mode = strict_mode_arg; |
} |
- Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key, |
- value, |
- attributes, |
- strict_mode); |
- RETURN_IF_EMPTY_HANDLE(isolate, result); |
+ Handle<Object> result; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, result, |
+ Runtime::SetObjectProperty( |
+ isolate, object, key, value, attributes, strict_mode)); |
return *result; |
} |
@@ -5635,9 +5650,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { |
(unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
attributes = static_cast<PropertyAttributes>(unchecked_value); |
} |
- Handle<Object> result = JSObject::SetLocalPropertyIgnoreAttributes( |
- object, name, value, attributes); |
- RETURN_IF_EMPTY_HANDLE(isolate, result); |
+ Handle<Object> result; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, result, |
+ JSObject::SetLocalPropertyIgnoreAttributes( |
+ object, name, value, attributes)); |
return *result; |
} |
@@ -8237,7 +8254,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionBindArguments) { |
Handle<Object> new_length(args.at<Object>(3)); |
PropertyAttributes attr = |
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY); |
- ForceSetProperty(bound_function, length_string, new_length, attr); |
+ Runtime::ForceSetObjectProperty( |
+ bound_function, length_string, new_length, attr).Assert(); |
return *bound_function; |
} |
@@ -9172,7 +9190,7 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareModules) { |
case MODULE: { |
Object* referenced_context = Context::cast(host_context)->get(index); |
Handle<JSModule> value(Context::cast(referenced_context)->module()); |
- JSReceiver::SetProperty(module, name, value, FROZEN, STRICT); |
+ JSReceiver::SetProperty(module, name, value, FROZEN, STRICT).Assert(); |
break; |
} |
case INTERNAL: |
@@ -9459,7 +9477,7 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StoreContextSlot) { |
// Set the property if it's not read only or doesn't yet exist. |
if ((attributes & READ_ONLY) == 0 || |
(JSReceiver::GetLocalPropertyAttribute(object, name) == ABSENT)) { |
- RETURN_IF_EMPTY_HANDLE( |
+ RETURN_FAILURE_ON_EXCEPTION( |
isolate, |
JSReceiver::SetProperty(object, name, value, NONE, strict_mode)); |
} else if (strict_mode == STRICT && (attributes & READ_ONLY) != 0) { |
@@ -11444,7 +11462,8 @@ static bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info, |
// Create a plain JSObject which materializes the local scope for the specified |
// frame. |
-static Handle<JSObject> MaterializeStackLocalsWithFrameInspector( |
+MUST_USE_RESULT |
+static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector( |
Isolate* isolate, |
Handle<JSObject> target, |
Handle<JSFunction> function, |
@@ -11465,10 +11484,10 @@ static Handle<JSObject> MaterializeStackLocalsWithFrameInspector( |
ASSERT(!value->IsTheHole()); |
Handle<String> name(scope_info->ParameterName(i)); |
- RETURN_IF_EMPTY_HANDLE_VALUE( |
+ RETURN_ON_EXCEPTION( |
isolate, |
Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), |
- Handle<JSObject>()); |
+ JSObject); |
} |
// Second fill all stack locals. |
@@ -11477,10 +11496,10 @@ static Handle<JSObject> MaterializeStackLocalsWithFrameInspector( |
Handle<Object> value(frame_inspector->GetExpression(i), isolate); |
if (value->IsTheHole()) continue; |
- RETURN_IF_EMPTY_HANDLE_VALUE( |
+ RETURN_ON_EXCEPTION( |
isolate, |
Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), |
- Handle<JSObject>()); |
+ JSObject); |
} |
return target; |
@@ -11525,10 +11544,11 @@ static void UpdateStackLocalsFromMaterializedObject(Isolate* isolate, |
} |
-static Handle<JSObject> MaterializeLocalContext(Isolate* isolate, |
- Handle<JSObject> target, |
- Handle<JSFunction> function, |
- JavaScriptFrame* frame) { |
+MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalContext( |
+ Isolate* isolate, |
+ Handle<JSObject> target, |
+ Handle<JSFunction> function, |
+ JavaScriptFrame* frame) { |
HandleScope scope(isolate); |
Handle<SharedFunctionInfo> shared(function->shared()); |
Handle<ScopeInfo> scope_info(shared->scope_info()); |
@@ -11540,7 +11560,7 @@ static Handle<JSObject> MaterializeLocalContext(Isolate* isolate, |
Handle<Context> function_context(frame_context->declaration_context()); |
if (!ScopeInfo::CopyContextLocalsToScopeObject( |
scope_info, function_context, target)) { |
- return Handle<JSObject>(); |
+ return MaybeHandle<JSObject>(); |
} |
// Finally copy any properties from the function context extension. |
@@ -11558,7 +11578,7 @@ static Handle<JSObject> MaterializeLocalContext(Isolate* isolate, |
// Names of variables introduced by eval are strings. |
ASSERT(keys->get(i)->IsString()); |
Handle<String> key(String::cast(keys->get(i))); |
- RETURN_IF_EMPTY_HANDLE_VALUE( |
+ RETURN_ON_EXCEPTION( |
isolate, |
Runtime::SetObjectProperty(isolate, |
target, |
@@ -11566,7 +11586,7 @@ static Handle<JSObject> MaterializeLocalContext(Isolate* isolate, |
Object::GetPropertyOrElement(ext, key), |
NONE, |
SLOPPY), |
- Handle<JSObject>()); |
+ JSObject); |
} |
} |
} |
@@ -11575,7 +11595,7 @@ static Handle<JSObject> MaterializeLocalContext(Isolate* isolate, |
} |
-static Handle<JSObject> MaterializeLocalScope( |
+MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalScope( |
Isolate* isolate, |
JavaScriptFrame* frame, |
int inlined_jsframe_index) { |
@@ -11584,9 +11604,11 @@ static Handle<JSObject> MaterializeLocalScope( |
Handle<JSObject> local_scope = |
isolate->factory()->NewJSObject(isolate->object_function()); |
- local_scope = MaterializeStackLocalsWithFrameInspector( |
- isolate, local_scope, function, &frame_inspector); |
- RETURN_IF_EMPTY_HANDLE_VALUE(isolate, local_scope, Handle<JSObject>()); |
+ ASSIGN_RETURN_ON_EXCEPTION( |
+ isolate, local_scope, |
+ MaterializeStackLocalsWithFrameInspector( |
+ isolate, local_scope, function, &frame_inspector), |
+ JSObject); |
return MaterializeLocalContext(isolate, local_scope, function, frame); |
} |
@@ -11666,7 +11688,7 @@ static bool SetLocalVariableValue(Isolate* isolate, |
// We don't expect this to do anything except replacing |
// property value. |
Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, |
- NONE, SLOPPY); |
+ NONE, SLOPPY).Assert(); |
return true; |
} |
} |
@@ -11679,8 +11701,9 @@ static bool SetLocalVariableValue(Isolate* isolate, |
// Create a plain JSObject which materializes the closure content for the |
// context. |
-static Handle<JSObject> MaterializeClosure(Isolate* isolate, |
- Handle<Context> context) { |
+MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeClosure( |
+ Isolate* isolate, |
+ Handle<Context> context) { |
ASSERT(context->IsFunctionContext()); |
Handle<SharedFunctionInfo> shared(context->closure()->shared()); |
@@ -11694,7 +11717,7 @@ static Handle<JSObject> MaterializeClosure(Isolate* isolate, |
// Fill all context locals to the context extension. |
if (!ScopeInfo::CopyContextLocalsToScopeObject( |
scope_info, context, closure_scope)) { |
- return Handle<JSObject>(); |
+ return MaybeHandle<JSObject>(); |
} |
// Finally copy any properties from the function context extension. This will |
@@ -11710,12 +11733,12 @@ static Handle<JSObject> MaterializeClosure(Isolate* isolate, |
// Names of variables introduced by eval are strings. |
ASSERT(keys->get(i)->IsString()); |
Handle<String> key(String::cast(keys->get(i))); |
- RETURN_IF_EMPTY_HANDLE_VALUE( |
+ RETURN_ON_EXCEPTION( |
isolate, |
Runtime::SetObjectProperty(isolate, closure_scope, key, |
Object::GetPropertyOrElement(ext, key), |
NONE, SLOPPY), |
- Handle<JSObject>()); |
+ JSObject); |
} |
} |
@@ -11746,7 +11769,7 @@ static bool SetClosureVariableValue(Isolate* isolate, |
if (JSReceiver::HasProperty(ext, variable_name)) { |
// We don't expect this to do anything except replacing property value. |
Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, |
- NONE, SLOPPY); |
+ NONE, SLOPPY).Assert(); |
return true; |
} |
} |
@@ -11757,19 +11780,20 @@ static bool SetClosureVariableValue(Isolate* isolate, |
// Create a plain JSObject which materializes the scope for the specified |
// catch context. |
-static Handle<JSObject> MaterializeCatchScope(Isolate* isolate, |
- Handle<Context> context) { |
+MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeCatchScope( |
+ Isolate* isolate, |
+ Handle<Context> context) { |
ASSERT(context->IsCatchContext()); |
Handle<String> name(String::cast(context->extension())); |
Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX), |
isolate); |
Handle<JSObject> catch_scope = |
isolate->factory()->NewJSObject(isolate->object_function()); |
- RETURN_IF_EMPTY_HANDLE_VALUE( |
+ RETURN_ON_EXCEPTION( |
isolate, |
Runtime::SetObjectProperty(isolate, catch_scope, name, thrown_object, |
NONE, SLOPPY), |
- Handle<JSObject>()); |
+ JSObject); |
return catch_scope; |
} |
@@ -11790,7 +11814,7 @@ static bool SetCatchVariableValue(Isolate* isolate, |
// Create a plain JSObject which materializes the block scope for the specified |
// block context. |
-static Handle<JSObject> MaterializeBlockScope( |
+MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeBlockScope( |
Isolate* isolate, |
Handle<Context> context) { |
ASSERT(context->IsBlockContext()); |
@@ -11804,7 +11828,7 @@ static Handle<JSObject> MaterializeBlockScope( |
// Fill all context locals. |
if (!ScopeInfo::CopyContextLocalsToScopeObject( |
scope_info, context, block_scope)) { |
- return Handle<JSObject>(); |
+ return MaybeHandle<JSObject>(); |
} |
return block_scope; |
@@ -11813,7 +11837,7 @@ static Handle<JSObject> MaterializeBlockScope( |
// Create a plain JSObject which materializes the module scope for the specified |
// module context. |
-static Handle<JSObject> MaterializeModuleScope( |
+MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeModuleScope( |
Isolate* isolate, |
Handle<Context> context) { |
ASSERT(context->IsModuleContext()); |
@@ -11827,7 +11851,7 @@ static Handle<JSObject> MaterializeModuleScope( |
// Fill all context locals. |
if (!ScopeInfo::CopyContextLocalsToScopeObject( |
scope_info, context, module_scope)) { |
- return Handle<JSObject>(); |
+ return MaybeHandle<JSObject>(); |
} |
return module_scope; |
@@ -12037,7 +12061,7 @@ class ScopeIterator { |
} |
// Return the JavaScript object with the content of the current scope. |
- Handle<JSObject> ScopeObject() { |
+ MaybeHandle<JSObject> ScopeObject() { |
ASSERT(!failed_); |
switch (Type()) { |
case ScopeIterator::ScopeTypeGlobal: |
@@ -12314,7 +12338,8 @@ static const int kScopeDetailsObjectIndex = 1; |
static const int kScopeDetailsSize = 2; |
-static Handle<JSObject> MaterializeScopeDetails(Isolate* isolate, |
+MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeScopeDetails( |
+ Isolate* isolate, |
ScopeIterator* it) { |
// Calculate the size of the result. |
int details_size = kScopeDetailsSize; |
@@ -12322,8 +12347,9 @@ static Handle<JSObject> MaterializeScopeDetails(Isolate* isolate, |
// Fill in scope details. |
details->set(kScopeDetailsTypeIndex, Smi::FromInt(it->Type())); |
- Handle<JSObject> scope_object = it->ScopeObject(); |
- RETURN_IF_EMPTY_HANDLE_VALUE(isolate, scope_object, Handle<JSObject>()); |
+ Handle<JSObject> scope_object; |
+ ASSIGN_RETURN_ON_EXCEPTION( |
+ isolate, scope_object, it->ScopeObject(), JSObject); |
details->set(kScopeDetailsObjectIndex, *scope_object); |
return isolate->factory()->NewJSArrayWithElements(details); |
@@ -12367,8 +12393,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) { |
if (it.Done()) { |
return isolate->heap()->undefined_value(); |
} |
- Handle<JSObject> details = MaterializeScopeDetails(isolate, &it); |
- RETURN_IF_EMPTY_HANDLE(isolate, details); |
+ Handle<JSObject> details; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, details, MaterializeScopeDetails(isolate, &it)); |
return *details; |
} |
@@ -12409,8 +12436,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetAllScopesDetails) { |
List<Handle<JSObject> > result(4); |
ScopeIterator it(isolate, frame, inlined_jsframe_index, ignore_nested_scopes); |
for (; !it.Done(); it.Next()) { |
- Handle<JSObject> details = MaterializeScopeDetails(isolate, &it); |
- RETURN_IF_EMPTY_HANDLE(isolate, details); |
+ Handle<JSObject> details; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, details, MaterializeScopeDetails(isolate, &it)); |
result.Add(details); |
} |
@@ -12457,7 +12485,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionScopeDetails) { |
return isolate->heap()->undefined_value(); |
} |
- Handle<JSObject> details = MaterializeScopeDetails(isolate, &it); |
+ Handle<JSObject> details; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, details, MaterializeScopeDetails(isolate, &it)); |
RETURN_IF_EMPTY_HANDLE(isolate, details); |
return *details; |
} |
@@ -12837,7 +12867,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearStepping) { |
// Helper function to find or create the arguments object for |
// Runtime_DebugEvaluate. |
-static Handle<JSObject> MaterializeArgumentsObject( |
+MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeArgumentsObject( |
Isolate* isolate, |
Handle<JSObject> target, |
Handle<JSFunction> function) { |
@@ -12852,11 +12882,12 @@ static Handle<JSObject> MaterializeArgumentsObject( |
// FunctionGetArguments can't throw an exception. |
Handle<JSObject> arguments = Handle<JSObject>::cast( |
Accessors::FunctionGetArguments(function)); |
- Runtime::SetObjectProperty(isolate, target, |
- isolate->factory()->arguments_string(), |
- arguments, |
- ::NONE, |
- SLOPPY); |
+ Handle<String> arguments_str = isolate->factory()->arguments_string(); |
+ RETURN_ON_EXCEPTION( |
+ isolate, |
+ Runtime::SetObjectProperty( |
+ isolate, target, arguments_str, arguments, ::NONE, SLOPPY), |
+ JSObject); |
return target; |
} |
@@ -12946,12 +12977,14 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) { |
Handle<JSObject> materialized = |
isolate->factory()->NewJSObject(isolate->object_function()); |
- materialized = MaterializeStackLocalsWithFrameInspector( |
- isolate, materialized, function, &frame_inspector); |
- RETURN_IF_EMPTY_HANDLE(isolate, materialized); |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, materialized, |
+ MaterializeStackLocalsWithFrameInspector( |
+ isolate, materialized, function, &frame_inspector)); |
- materialized = MaterializeArgumentsObject(isolate, materialized, function); |
- RETURN_IF_EMPTY_HANDLE(isolate, materialized); |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, materialized, |
+ MaterializeArgumentsObject(isolate, materialized, function)); |
// Add the materialized object in a with-scope to shadow the stack locals. |
context = isolate->factory()->NewWithContext(function, context, materialized); |