Index: src/runtime/runtime-debug.cc |
diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc |
index 2555086b07e2265ad7da2b00088bdf316b804d5c..5ae797986eefdb93bd0897f7bd2990d30bf09ef1 100644 |
--- a/src/runtime/runtime-debug.cc |
+++ b/src/runtime/runtime-debug.cc |
@@ -861,11 +861,10 @@ static bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info, |
} |
-MUST_USE_RESULT |
-static MaybeHandle<Context> MaterializeReceiver(Isolate* isolate, |
- Handle<Context> target, |
- Handle<JSFunction> function, |
- JavaScriptFrame* frame) { |
+static Handle<Context> MaterializeReceiver(Isolate* isolate, |
+ Handle<Context> target, |
+ Handle<JSFunction> function, |
+ JavaScriptFrame* frame) { |
Handle<SharedFunctionInfo> shared(function->shared()); |
Handle<ScopeInfo> scope_info(shared->scope_info()); |
Handle<Object> receiver; |
@@ -882,14 +881,14 @@ static MaybeHandle<Context> MaterializeReceiver(Isolate* isolate, |
&init_flag, &maybe_assigned_flag) >= 0) { |
return target; |
} |
- receiver = Handle<Object>(frame->receiver(), isolate); |
+ receiver = handle(frame->receiver(), isolate); |
break; |
} |
case MODULE_SCOPE: |
receiver = isolate->factory()->undefined_value(); |
break; |
case SCRIPT_SCOPE: |
- receiver = Handle<Object>(function->global_proxy(), isolate); |
+ receiver = handle(function->global_proxy(), isolate); |
break; |
default: |
// For eval code, arrow functions, and the like, there's no "this" binding |
@@ -904,8 +903,7 @@ static MaybeHandle<Context> MaterializeReceiver(Isolate* isolate, |
// Create a plain JSObject which materializes the local scope for the specified |
// frame. |
-MUST_USE_RESULT |
-static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector( |
+static void MaterializeStackLocalsWithFrameInspector( |
Isolate* isolate, Handle<JSObject> target, Handle<ScopeInfo> scope_info, |
FrameInspector* frame_inspector) { |
// First fill all parameters. |
@@ -923,9 +921,7 @@ static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector( |
isolate); |
DCHECK(!value->IsTheHole()); |
- RETURN_ON_EXCEPTION(isolate, Runtime::SetObjectProperty( |
- isolate, target, name, value, SLOPPY), |
- JSObject); |
+ JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check(); |
} |
// Second fill all stack locals. |
@@ -939,23 +935,18 @@ static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector( |
value = isolate->factory()->undefined_value(); |
} |
- RETURN_ON_EXCEPTION(isolate, Runtime::SetObjectProperty( |
- isolate, target, name, value, SLOPPY), |
- JSObject); |
+ JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check(); |
} |
- |
- return target; |
} |
-MUST_USE_RESULT |
-static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector( |
+static void MaterializeStackLocalsWithFrameInspector( |
Isolate* isolate, Handle<JSObject> target, Handle<JSFunction> function, |
FrameInspector* frame_inspector) { |
Handle<SharedFunctionInfo> shared(function->shared()); |
Handle<ScopeInfo> scope_info(shared->scope_info()); |
- return MaterializeStackLocalsWithFrameInspector(isolate, target, scope_info, |
- frame_inspector); |
+ MaterializeStackLocalsWithFrameInspector(isolate, target, scope_info, |
+ frame_inspector); |
} |
@@ -1008,10 +999,8 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalContext( |
// Third fill all context locals. |
Handle<Context> frame_context(Context::cast(frame->context())); |
Handle<Context> function_context(frame_context->declaration_context()); |
- if (!ScopeInfo::CopyContextLocalsToScopeObject(scope_info, function_context, |
- target)) { |
- return MaybeHandle<JSObject>(); |
- } |
+ ScopeInfo::CopyContextLocalsToScopeObject(scope_info, function_context, |
+ target); |
// Finally copy any properties from the function context extension. |
// These will be variables introduced by eval. |
@@ -1056,10 +1045,8 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeScriptScope( |
Handle<Context> context = |
ScriptContextTable::GetContext(script_contexts, context_index); |
Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); |
- if (!ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context, |
- script_scope)) { |
- return MaybeHandle<JSObject>(); |
- } |
+ ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context, |
+ script_scope); |
} |
return script_scope; |
} |
@@ -1072,11 +1059,8 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalScope( |
Handle<JSObject> local_scope = |
isolate->factory()->NewJSObject(isolate->object_function()); |
- ASSIGN_RETURN_ON_EXCEPTION( |
- isolate, local_scope, |
- MaterializeStackLocalsWithFrameInspector(isolate, local_scope, function, |
- &frame_inspector), |
- JSObject); |
+ MaterializeStackLocalsWithFrameInspector(isolate, local_scope, function, |
+ &frame_inspector); |
return MaterializeLocalContext(isolate, local_scope, function, frame); |
} |
@@ -1196,8 +1180,8 @@ static bool SetBlockVariableValue(Isolate* isolate, |
// Create a plain JSObject which materializes the closure content for the |
// context. |
-MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeClosure( |
- Isolate* isolate, Handle<Context> context) { |
+static Handle<JSObject> MaterializeClosure(Isolate* isolate, |
+ Handle<Context> context) { |
DCHECK(context->IsFunctionContext()); |
Handle<SharedFunctionInfo> shared(context->closure()->shared()); |
@@ -1209,31 +1193,24 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeClosure( |
isolate->factory()->NewJSObject(isolate->object_function()); |
// Fill all context locals to the context extension. |
- if (!ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context, |
- closure_scope)) { |
- return MaybeHandle<JSObject>(); |
- } |
+ ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context, closure_scope); |
// Finally copy any properties from the function context extension. This will |
// be variables introduced by eval. |
if (context->has_extension()) { |
Handle<JSObject> ext(JSObject::cast(context->extension())); |
- Handle<FixedArray> keys; |
- ASSIGN_RETURN_ON_EXCEPTION( |
- isolate, keys, JSReceiver::GetKeys(ext, JSReceiver::INCLUDE_PROTOS), |
- JSObject); |
+ DCHECK(ext->IsJSContextExtensionObject()); |
+ Handle<FixedArray> keys = |
+ JSReceiver::GetKeys(ext, JSReceiver::OWN_ONLY).ToHandleChecked(); |
for (int i = 0; i < keys->length(); i++) { |
HandleScope scope(isolate); |
// Names of variables introduced by eval are strings. |
DCHECK(keys->get(i)->IsString()); |
Handle<String> key(String::cast(keys->get(i))); |
- Handle<Object> value; |
- ASSIGN_RETURN_ON_EXCEPTION( |
- isolate, value, Object::GetPropertyOrElement(ext, key), JSObject); |
- RETURN_ON_EXCEPTION(isolate, Runtime::DefineObjectProperty( |
- closure_scope, key, value, NONE), |
- JSObject); |
+ Handle<Object> value = Object::GetProperty(ext, key).ToHandleChecked(); |
+ JSObject::SetOwnPropertyIgnoreAttributes(closure_scope, key, value, NONE) |
+ .Check(); |
} |
} |
@@ -1260,12 +1237,13 @@ static bool SetClosureVariableValue(Isolate* isolate, Handle<Context> context, |
// be variables introduced by eval. |
if (context->has_extension()) { |
Handle<JSObject> ext(JSObject::cast(context->extension())); |
- Maybe<bool> maybe = JSReceiver::HasProperty(ext, variable_name); |
+ DCHECK(ext->IsJSContextExtensionObject()); |
+ Maybe<bool> maybe = JSReceiver::HasOwnProperty(ext, variable_name); |
DCHECK(maybe.IsJust()); |
if (maybe.FromJust()) { |
// We don't expect this to do anything except replacing property value. |
- Runtime::DefineObjectProperty(ext, variable_name, new_value, NONE) |
- .Assert(); |
+ JSObject::SetOwnPropertyIgnoreAttributes(ext, variable_name, new_value, |
+ NONE).Check(); |
return true; |
} |
} |
@@ -1294,17 +1272,16 @@ static bool SetScriptVariableValue(Handle<Context> context, |
// Create a plain JSObject which materializes the scope for the specified |
// catch context. |
-MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeCatchScope( |
- Isolate* isolate, Handle<Context> context) { |
+static Handle<JSObject> MaterializeCatchScope(Isolate* isolate, |
+ Handle<Context> context) { |
DCHECK(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_ON_EXCEPTION(isolate, Runtime::DefineObjectProperty( |
- catch_scope, name, thrown_object, NONE), |
- JSObject); |
+ JSObject::SetOwnPropertyIgnoreAttributes(catch_scope, name, thrown_object, |
+ NONE).Check(); |
return catch_scope; |
} |
@@ -1324,28 +1301,26 @@ static bool SetCatchVariableValue(Isolate* isolate, Handle<Context> context, |
// Create a plain JSObject which materializes the block scope for the specified |
// block context. |
-MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeBlockScope( |
- Isolate* isolate, Handle<ScopeInfo> scope_info, Handle<Context> context, |
- JavaScriptFrame* frame, int inlined_jsframe_index) { |
+static Handle<JSObject> MaterializeBlockScope(Isolate* isolate, |
+ Handle<ScopeInfo> scope_info, |
+ Handle<Context> context, |
+ JavaScriptFrame* frame, |
+ int inlined_jsframe_index) { |
Handle<JSObject> block_scope = |
isolate->factory()->NewJSObject(isolate->object_function()); |
if (frame != nullptr) { |
FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); |
- RETURN_ON_EXCEPTION(isolate, |
- MaterializeStackLocalsWithFrameInspector( |
- isolate, block_scope, scope_info, &frame_inspector), |
- JSObject); |
+ MaterializeStackLocalsWithFrameInspector(isolate, block_scope, scope_info, |
+ &frame_inspector); |
} |
if (!context.is_null()) { |
Handle<ScopeInfo> scope_info_from_context( |
ScopeInfo::cast(context->extension())); |
// Fill all context locals. |
- if (!ScopeInfo::CopyContextLocalsToScopeObject(scope_info_from_context, |
- context, block_scope)) { |
- return MaybeHandle<JSObject>(); |
- } |
+ ScopeInfo::CopyContextLocalsToScopeObject(scope_info_from_context, context, |
+ block_scope); |
} |
return block_scope; |
@@ -1365,10 +1340,7 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeModuleScope( |
isolate->factory()->NewJSObject(isolate->object_function()); |
// Fill all context locals. |
- if (!ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context, |
- module_scope)) { |
- return MaybeHandle<JSObject>(); |
- } |
+ ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context, module_scope); |
return module_scope; |
} |
@@ -2396,24 +2368,23 @@ RUNTIME_FUNCTION(Runtime_ClearStepping) { |
// Helper function to find or create the arguments object for |
// Runtime_DebugEvaluate. |
-MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeArgumentsObject( |
- Isolate* isolate, Handle<JSObject> target, Handle<JSFunction> function) { |
+static void MaterializeArgumentsObject(Isolate* isolate, |
+ Handle<JSObject> target, |
+ Handle<JSFunction> function) { |
// Do not materialize the arguments object for eval or top-level code. |
// Skip if "arguments" is already taken. |
- if (!function->shared()->is_function()) return target; |
+ if (!function->shared()->is_function()) return; |
Maybe<bool> maybe = JSReceiver::HasOwnProperty( |
target, isolate->factory()->arguments_string()); |
- if (!maybe.IsJust()) return MaybeHandle<JSObject>(); |
- if (maybe.FromJust()) return target; |
+ DCHECK(maybe.IsJust()); |
+ if (maybe.FromJust()) return; |
// FunctionGetArguments can't throw an exception. |
Handle<JSObject> arguments = |
Handle<JSObject>::cast(Accessors::FunctionGetArguments(function)); |
Handle<String> arguments_str = isolate->factory()->arguments_string(); |
- RETURN_ON_EXCEPTION(isolate, Runtime::DefineObjectProperty( |
- target, arguments_str, arguments, NONE), |
- JSObject); |
- return target; |
+ JSObject::SetOwnPropertyIgnoreAttributes(target, arguments_str, arguments, |
+ NONE).Check(); |
} |
@@ -2510,22 +2481,16 @@ class EvaluationContextBuilder { |
// The "this" binding, if any, can't be bound via "with". If we need |
// to, add another node onto the outer context to bind "this". |
- if (!MaterializeReceiver(isolate, parent_context, function, frame) |
- .ToHandle(&parent_context)) |
- return; |
+ parent_context = |
+ MaterializeReceiver(isolate, parent_context, function, frame); |
Handle<JSObject> materialized_function = |
NewJSObjectWithNullProto(isolate); |
- if (!MaterializeStackLocalsWithFrameInspector( |
- isolate, materialized_function, function, &frame_inspector) |
- .ToHandle(&materialized_function)) |
- return; |
+ MaterializeStackLocalsWithFrameInspector(isolate, materialized_function, |
+ function, &frame_inspector); |
- if (!MaterializeArgumentsObject(isolate, materialized_function, |
- function) |
- .ToHandle(&materialized_function)) |
- return; |
+ MaterializeArgumentsObject(isolate, materialized_function, function); |
Handle<Context> with_context = isolate->factory()->NewWithContext( |
function, parent_context, materialized_function); |
@@ -2553,10 +2518,9 @@ class EvaluationContextBuilder { |
} else if (scope_type == ScopeIterator::ScopeTypeBlock) { |
Handle<JSObject> materialized_object = |
NewJSObjectWithNullProto(isolate); |
- if (!MaterializeStackLocalsWithFrameInspector( |
- isolate, materialized_object, it.CurrentScopeInfo(), |
- &frame_inspector).ToHandle(&materialized_object)) |
- return; |
+ MaterializeStackLocalsWithFrameInspector(isolate, materialized_object, |
+ it.CurrentScopeInfo(), |
+ &frame_inspector); |
if (it.HasContext()) { |
Handle<Context> cloned_context = |
Handle<Context>::cast(FixedArray::CopySize( |