| Index: src/builtins/builtins-object.cc
|
| diff --git a/src/builtins/builtins-object.cc b/src/builtins/builtins-object.cc
|
| index fd08f3757ffe729176b0b00ee1d60dea6e1b4c66..5899879778ad95eb83d51b3fd13e6c354518b5c0 100644
|
| --- a/src/builtins/builtins-object.cc
|
| +++ b/src/builtins/builtins-object.cc
|
| @@ -688,6 +688,40 @@ BUILTIN(ObjectGetPrototypeOf) {
|
| JSReceiver::GetPrototype(isolate, receiver));
|
| }
|
|
|
| +// ES6 section 19.1.2.21 Object.setPrototypeOf ( O, proto )
|
| +BUILTIN(ObjectSetPrototypeOf) {
|
| + HandleScope scope(isolate);
|
| +
|
| + // 1. Let O be ? RequireObjectCoercible(O).
|
| + Handle<Object> object = args.atOrUndefined(isolate, 1);
|
| + if (object->IsNull(isolate) || object->IsUndefined(isolate)) {
|
| + THROW_NEW_ERROR_RETURN_FAILURE(
|
| + isolate, NewTypeError(MessageTemplate::kCalledOnNullOrUndefined,
|
| + isolate->factory()->NewStringFromAsciiChecked(
|
| + "Object.setPrototypeOf")));
|
| + }
|
| +
|
| + // 2. If Type(proto) is neither Object nor Null, throw a TypeError exception.
|
| + Handle<Object> proto = args.atOrUndefined(isolate, 2);
|
| + if (!proto->IsNull(isolate) && !proto->IsJSReceiver()) {
|
| + THROW_NEW_ERROR_RETURN_FAILURE(
|
| + isolate, NewTypeError(MessageTemplate::kProtoObjectOrNull, proto));
|
| + }
|
| +
|
| + // 3. If Type(O) is not Object, return O.
|
| + if (!object->IsJSReceiver()) return *object;
|
| + Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(object);
|
| +
|
| + // 4. Let status be ? O.[[SetPrototypeOf]](proto).
|
| + // 5. If status is false, throw a TypeError exception.
|
| + MAYBE_RETURN(
|
| + JSReceiver::SetPrototype(receiver, proto, true, Object::THROW_ON_ERROR),
|
| + isolate->heap()->exception());
|
| +
|
| + // 6. Return O.
|
| + return *receiver;
|
| +}
|
| +
|
| // ES6 section 19.1.2.6 Object.getOwnPropertyDescriptor ( O, P )
|
| BUILTIN(ObjectGetOwnPropertyDescriptor) {
|
| HandleScope scope(isolate);
|
|
|