Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: src/runtime/runtime-debug.cc

Issue 1181733002: Revert of Replace SetObjectProperty / DefineObjectProperty with less powerful alternatives where relevant. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime-classes.cc ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-debug.cc
diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc
index 5ae797986eefdb93bd0897f7bd2990d30bf09ef1..2555086b07e2265ad7da2b00088bdf316b804d5c 100644
--- a/src/runtime/runtime-debug.cc
+++ b/src/runtime/runtime-debug.cc
@@ -861,10 +861,11 @@
}
-static Handle<Context> MaterializeReceiver(Isolate* isolate,
- Handle<Context> target,
- Handle<JSFunction> function,
- JavaScriptFrame* frame) {
+MUST_USE_RESULT
+static MaybeHandle<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;
@@ -881,14 +882,14 @@
&init_flag, &maybe_assigned_flag) >= 0) {
return target;
}
- receiver = handle(frame->receiver(), isolate);
+ receiver = Handle<Object>(frame->receiver(), isolate);
break;
}
case MODULE_SCOPE:
receiver = isolate->factory()->undefined_value();
break;
case SCRIPT_SCOPE:
- receiver = handle(function->global_proxy(), isolate);
+ receiver = Handle<Object>(function->global_proxy(), isolate);
break;
default:
// For eval code, arrow functions, and the like, there's no "this" binding
@@ -903,7 +904,8 @@
// Create a plain JSObject which materializes the local scope for the specified
// frame.
-static void MaterializeStackLocalsWithFrameInspector(
+MUST_USE_RESULT
+static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector(
Isolate* isolate, Handle<JSObject> target, Handle<ScopeInfo> scope_info,
FrameInspector* frame_inspector) {
// First fill all parameters.
@@ -921,7 +923,9 @@
isolate);
DCHECK(!value->IsTheHole());
- JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check();
+ RETURN_ON_EXCEPTION(isolate, Runtime::SetObjectProperty(
+ isolate, target, name, value, SLOPPY),
+ JSObject);
}
// Second fill all stack locals.
@@ -935,18 +939,23 @@
value = isolate->factory()->undefined_value();
}
- JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check();
- }
-}
-
-static void MaterializeStackLocalsWithFrameInspector(
+ RETURN_ON_EXCEPTION(isolate, Runtime::SetObjectProperty(
+ isolate, target, name, value, SLOPPY),
+ JSObject);
+ }
+
+ return target;
+}
+
+MUST_USE_RESULT
+static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector(
Isolate* isolate, Handle<JSObject> target, Handle<JSFunction> function,
FrameInspector* frame_inspector) {
Handle<SharedFunctionInfo> shared(function->shared());
Handle<ScopeInfo> scope_info(shared->scope_info());
- MaterializeStackLocalsWithFrameInspector(isolate, target, scope_info,
- frame_inspector);
+ return MaterializeStackLocalsWithFrameInspector(isolate, target, scope_info,
+ frame_inspector);
}
@@ -999,8 +1008,10 @@
// Third fill all context locals.
Handle<Context> frame_context(Context::cast(frame->context()));
Handle<Context> function_context(frame_context->declaration_context());
- ScopeInfo::CopyContextLocalsToScopeObject(scope_info, function_context,
- target);
+ if (!ScopeInfo::CopyContextLocalsToScopeObject(scope_info, function_context,
+ target)) {
+ return MaybeHandle<JSObject>();
+ }
// Finally copy any properties from the function context extension.
// These will be variables introduced by eval.
@@ -1045,8 +1056,10 @@
Handle<Context> context =
ScriptContextTable::GetContext(script_contexts, context_index);
Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension()));
- ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context,
- script_scope);
+ if (!ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context,
+ script_scope)) {
+ return MaybeHandle<JSObject>();
+ }
}
return script_scope;
}
@@ -1059,8 +1072,11 @@
Handle<JSObject> local_scope =
isolate->factory()->NewJSObject(isolate->object_function());
- MaterializeStackLocalsWithFrameInspector(isolate, local_scope, function,
- &frame_inspector);
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, local_scope,
+ MaterializeStackLocalsWithFrameInspector(isolate, local_scope, function,
+ &frame_inspector),
+ JSObject);
return MaterializeLocalContext(isolate, local_scope, function, frame);
}
@@ -1180,8 +1196,8 @@
// 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) {
DCHECK(context->IsFunctionContext());
Handle<SharedFunctionInfo> shared(context->closure()->shared());
@@ -1193,24 +1209,31 @@
isolate->factory()->NewJSObject(isolate->object_function());
// Fill all context locals to the context extension.
- ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context, closure_scope);
+ if (!ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context,
+ closure_scope)) {
+ return MaybeHandle<JSObject>();
+ }
// 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()));
- DCHECK(ext->IsJSContextExtensionObject());
- Handle<FixedArray> keys =
- JSReceiver::GetKeys(ext, JSReceiver::OWN_ONLY).ToHandleChecked();
+ Handle<FixedArray> keys;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, keys, JSReceiver::GetKeys(ext, JSReceiver::INCLUDE_PROTOS),
+ JSObject);
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 = Object::GetProperty(ext, key).ToHandleChecked();
- JSObject::SetOwnPropertyIgnoreAttributes(closure_scope, key, value, NONE)
- .Check();
+ 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);
}
}
@@ -1237,13 +1260,12 @@
// be variables introduced by eval.
if (context->has_extension()) {
Handle<JSObject> ext(JSObject::cast(context->extension()));
- DCHECK(ext->IsJSContextExtensionObject());
- Maybe<bool> maybe = JSReceiver::HasOwnProperty(ext, variable_name);
+ Maybe<bool> maybe = JSReceiver::HasProperty(ext, variable_name);
DCHECK(maybe.IsJust());
if (maybe.FromJust()) {
// We don't expect this to do anything except replacing property value.
- JSObject::SetOwnPropertyIgnoreAttributes(ext, variable_name, new_value,
- NONE).Check();
+ Runtime::DefineObjectProperty(ext, variable_name, new_value, NONE)
+ .Assert();
return true;
}
}
@@ -1272,16 +1294,17 @@
// 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) {
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());
- JSObject::SetOwnPropertyIgnoreAttributes(catch_scope, name, thrown_object,
- NONE).Check();
+ RETURN_ON_EXCEPTION(isolate, Runtime::DefineObjectProperty(
+ catch_scope, name, thrown_object, NONE),
+ JSObject);
return catch_scope;
}
@@ -1301,26 +1324,28 @@
// Create a plain JSObject which materializes the block scope for the specified
// block context.
-static Handle<JSObject> MaterializeBlockScope(Isolate* isolate,
- Handle<ScopeInfo> scope_info,
- Handle<Context> context,
- JavaScriptFrame* frame,
- int inlined_jsframe_index) {
+MUST_USE_RESULT static MaybeHandle<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);
- MaterializeStackLocalsWithFrameInspector(isolate, block_scope, scope_info,
- &frame_inspector);
+ RETURN_ON_EXCEPTION(isolate,
+ MaterializeStackLocalsWithFrameInspector(
+ isolate, block_scope, scope_info, &frame_inspector),
+ JSObject);
}
if (!context.is_null()) {
Handle<ScopeInfo> scope_info_from_context(
ScopeInfo::cast(context->extension()));
// Fill all context locals.
- ScopeInfo::CopyContextLocalsToScopeObject(scope_info_from_context, context,
- block_scope);
+ if (!ScopeInfo::CopyContextLocalsToScopeObject(scope_info_from_context,
+ context, block_scope)) {
+ return MaybeHandle<JSObject>();
+ }
}
return block_scope;
@@ -1340,7 +1365,10 @@
isolate->factory()->NewJSObject(isolate->object_function());
// Fill all context locals.
- ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context, module_scope);
+ if (!ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context,
+ module_scope)) {
+ return MaybeHandle<JSObject>();
+ }
return module_scope;
}
@@ -2368,23 +2396,24 @@
// Helper function to find or create the arguments object for
// Runtime_DebugEvaluate.
-static void MaterializeArgumentsObject(Isolate* isolate,
- Handle<JSObject> target,
- Handle<JSFunction> function) {
+MUST_USE_RESULT static MaybeHandle<JSObject> 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;
+ if (!function->shared()->is_function()) return target;
Maybe<bool> maybe = JSReceiver::HasOwnProperty(
target, isolate->factory()->arguments_string());
- DCHECK(maybe.IsJust());
- if (maybe.FromJust()) return;
+ if (!maybe.IsJust()) return MaybeHandle<JSObject>();
+ if (maybe.FromJust()) return target;
// FunctionGetArguments can't throw an exception.
Handle<JSObject> arguments =
Handle<JSObject>::cast(Accessors::FunctionGetArguments(function));
Handle<String> arguments_str = isolate->factory()->arguments_string();
- JSObject::SetOwnPropertyIgnoreAttributes(target, arguments_str, arguments,
- NONE).Check();
+ RETURN_ON_EXCEPTION(isolate, Runtime::DefineObjectProperty(
+ target, arguments_str, arguments, NONE),
+ JSObject);
+ return target;
}
@@ -2481,16 +2510,22 @@
// 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".
- parent_context =
- MaterializeReceiver(isolate, parent_context, function, frame);
+ if (!MaterializeReceiver(isolate, parent_context, function, frame)
+ .ToHandle(&parent_context))
+ return;
Handle<JSObject> materialized_function =
NewJSObjectWithNullProto(isolate);
- MaterializeStackLocalsWithFrameInspector(isolate, materialized_function,
- function, &frame_inspector);
-
- MaterializeArgumentsObject(isolate, materialized_function, function);
+ if (!MaterializeStackLocalsWithFrameInspector(
+ isolate, materialized_function, function, &frame_inspector)
+ .ToHandle(&materialized_function))
+ return;
+
+ if (!MaterializeArgumentsObject(isolate, materialized_function,
+ function)
+ .ToHandle(&materialized_function))
+ return;
Handle<Context> with_context = isolate->factory()->NewWithContext(
function, parent_context, materialized_function);
@@ -2518,9 +2553,10 @@
} else if (scope_type == ScopeIterator::ScopeTypeBlock) {
Handle<JSObject> materialized_object =
NewJSObjectWithNullProto(isolate);
- MaterializeStackLocalsWithFrameInspector(isolate, materialized_object,
- it.CurrentScopeInfo(),
- &frame_inspector);
+ if (!MaterializeStackLocalsWithFrameInspector(
+ isolate, materialized_object, it.CurrentScopeInfo(),
+ &frame_inspector).ToHandle(&materialized_object))
+ return;
if (it.HasContext()) {
Handle<Context> cloned_context =
Handle<Context>::cast(FixedArray::CopySize(
« no previous file with comments | « src/runtime/runtime-classes.cc ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698