Commit d91e9e4f authored by neis's avatar neis Committed by Commit bot

Restructure Object::SetProperty and related functions.

This is in preparation of implementing Reflect.set.

R=rossberg
BUG=

Review URL: https://codereview.chromium.org/1394983005

Cr-Commit-Position: refs/heads/master@{#31501}
parent 1c50fc11
...@@ -300,7 +300,7 @@ MaybeHandle<JSFunction> InstantiateFunction(Isolate* isolate, ...@@ -300,7 +300,7 @@ MaybeHandle<JSFunction> InstantiateFunction(Isolate* isolate,
isolate->factory()->prototype_string()), isolate->factory()->prototype_string()),
JSFunction); JSFunction);
MAYBE_RETURN(JSObject::SetPrototype(prototype, parent_prototype, false, MAYBE_RETURN(JSObject::SetPrototype(prototype, parent_prototype, false,
THROW_ON_ERROR), Object::THROW_ON_ERROR),
MaybeHandle<JSFunction>()); MaybeHandle<JSFunction>());
} }
} }
......
...@@ -3709,8 +3709,8 @@ Maybe<bool> v8::Object::SetPrototype(Local<Context> context, ...@@ -3709,8 +3709,8 @@ Maybe<bool> v8::Object::SetPrototype(Local<Context> context,
// We do not allow exceptions thrown while setting the prototype // We do not allow exceptions thrown while setting the prototype
// to propagate outside. // to propagate outside.
TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
auto result = auto result = i::JSObject::SetPrototype(self, value_obj, false,
i::JSObject::SetPrototype(self, value_obj, false, i::THROW_ON_ERROR); i::Object::THROW_ON_ERROR);
has_pending_exception = result.IsNothing(); has_pending_exception = result.IsNothing();
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return Just(true); return Just(true);
......
...@@ -701,7 +701,7 @@ Handle<JSFunction> Genesis::GetThrowTypeErrorIntrinsic( ...@@ -701,7 +701,7 @@ Handle<JSFunction> Genesis::GetThrowTypeErrorIntrinsic(
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY)) static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY))
.Assert(); .Assert();
if (JSObject::PreventExtensions(function, THROW_ON_ERROR).IsNothing()) if (JSObject::PreventExtensions(function, Object::THROW_ON_ERROR).IsNothing())
DCHECK(false); DCHECK(false);
return function; return function;
......
...@@ -1585,7 +1585,7 @@ BUILTIN(ReflectPreventExtensions) { ...@@ -1585,7 +1585,7 @@ BUILTIN(ReflectPreventExtensions) {
} }
Maybe<bool> result = JSReceiver::PreventExtensions( Maybe<bool> result = JSReceiver::PreventExtensions(
Handle<JSReceiver>::cast(target), DONT_THROW); Handle<JSReceiver>::cast(target), Object::DONT_THROW);
return result.IsJust() ? *isolate->factory()->ToBoolean(result.FromJust()) return result.IsJust() ? *isolate->factory()->ToBoolean(result.FromJust())
: isolate->heap()->exception(); : isolate->heap()->exception();
} }
...@@ -1611,7 +1611,7 @@ BUILTIN(ReflectSetPrototypeOf) { ...@@ -1611,7 +1611,7 @@ BUILTIN(ReflectSetPrototypeOf) {
} }
Maybe<bool> result = JSReceiver::SetPrototype( Maybe<bool> result = JSReceiver::SetPrototype(
Handle<JSReceiver>::cast(target), proto, true, DONT_THROW); Handle<JSReceiver>::cast(target), proto, true, Object::DONT_THROW);
MAYBE_RETURN(result, isolate->heap()->exception()); MAYBE_RETURN(result, isolate->heap()->exception());
return *isolate->factory()->ToBoolean(result.FromJust()); return *isolate->factory()->ToBoolean(result.FromJust());
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -320,9 +320,9 @@ static Object* ArrayConstructorCommon(Isolate* isolate, ...@@ -320,9 +320,9 @@ static Object* ArrayConstructorCommon(Isolate* isolate,
if (original_constructor->has_instance_prototype()) { if (original_constructor->has_instance_prototype()) {
Handle<Object> prototype = Handle<Object> prototype =
handle(original_constructor->instance_prototype(), isolate); handle(original_constructor->instance_prototype(), isolate);
MAYBE_RETURN( MAYBE_RETURN(JSObject::SetPrototype(array, prototype, false,
JSObject::SetPrototype(array, prototype, false, THROW_ON_ERROR), Object::THROW_ON_ERROR),
isolate->heap()->exception()); isolate->heap()->exception());
} }
} }
......
...@@ -163,7 +163,7 @@ static MaybeHandle<Object> DefineClass(Isolate* isolate, Handle<Object> name, ...@@ -163,7 +163,7 @@ static MaybeHandle<Object> DefineClass(Isolate* isolate, Handle<Object> name,
if (!constructor_parent.is_null()) { if (!constructor_parent.is_null()) {
MAYBE_RETURN_NULL(JSObject::SetPrototype(constructor, constructor_parent, MAYBE_RETURN_NULL(JSObject::SetPrototype(constructor, constructor_parent,
false, THROW_ON_ERROR)); false, Object::THROW_ON_ERROR));
} }
JSObject::AddProperty(prototype, isolate->factory()->constructor_string(), JSObject::AddProperty(prototype, isolate->factory()->constructor_string(),
......
...@@ -166,8 +166,9 @@ RUNTIME_FUNCTION(Runtime_InternalSetPrototype) { ...@@ -166,8 +166,9 @@ RUNTIME_FUNCTION(Runtime_InternalSetPrototype) {
DCHECK(args.length() == 2); DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1);
MAYBE_RETURN(JSReceiver::SetPrototype(obj, prototype, false, THROW_ON_ERROR), MAYBE_RETURN(
isolate->heap()->exception()); JSReceiver::SetPrototype(obj, prototype, false, Object::THROW_ON_ERROR),
isolate->heap()->exception());
return *obj; return *obj;
} }
...@@ -177,8 +178,9 @@ RUNTIME_FUNCTION(Runtime_SetPrototype) { ...@@ -177,8 +178,9 @@ RUNTIME_FUNCTION(Runtime_SetPrototype) {
DCHECK(args.length() == 2); DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1);
MAYBE_RETURN(JSReceiver::SetPrototype(obj, prototype, true, THROW_ON_ERROR), MAYBE_RETURN(
isolate->heap()->exception()); JSReceiver::SetPrototype(obj, prototype, true, Object::THROW_ON_ERROR),
isolate->heap()->exception());
return *obj; return *obj;
} }
...@@ -263,7 +265,7 @@ RUNTIME_FUNCTION(Runtime_PreventExtensions) { ...@@ -263,7 +265,7 @@ RUNTIME_FUNCTION(Runtime_PreventExtensions) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK(args.length() == 1); DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0);
if (JSReceiver::PreventExtensions(obj, THROW_ON_ERROR).IsNothing()) if (JSReceiver::PreventExtensions(obj, Object::THROW_ON_ERROR).IsNothing())
return isolate->heap()->exception(); return isolate->heap()->exception();
return *obj; return *obj;
} }
...@@ -1025,9 +1027,9 @@ static Object* Runtime_NewObjectHelper(Isolate* isolate, ...@@ -1025,9 +1027,9 @@ static Object* Runtime_NewObjectHelper(Isolate* isolate,
if (original_function->has_instance_prototype()) { if (original_function->has_instance_prototype()) {
Handle<Object> prototype = Handle<Object> prototype =
handle(original_function->instance_prototype(), isolate); handle(original_function->instance_prototype(), isolate);
MAYBE_RETURN( MAYBE_RETURN(JSObject::SetPrototype(result, prototype, false,
JSObject::SetPrototype(result, prototype, false, THROW_ON_ERROR), Object::THROW_ON_ERROR),
isolate->heap()->exception()); isolate->heap()->exception());
} }
} }
......
...@@ -864,7 +864,7 @@ RUNTIME_FUNCTION(Runtime_DeclareModules) { ...@@ -864,7 +864,7 @@ RUNTIME_FUNCTION(Runtime_DeclareModules) {
} }
} }
if (JSObject::PreventExtensions(module, THROW_ON_ERROR).IsNothing()) if (JSObject::PreventExtensions(module, Object::THROW_ON_ERROR).IsNothing())
DCHECK(false); DCHECK(false);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment