| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/builtins/builtins-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
| 6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/code-stub-assembler.h" | 8 #include "src/code-stub-assembler.h" |
| 9 #include "src/property-descriptor.h" | 9 #include "src/property-descriptor.h" |
| 10 | 10 |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 RETURN_RESULT_OR_FAILURE(isolate, | 629 RETURN_RESULT_OR_FAILURE(isolate, |
| 630 JSReceiver::GetPrototype(isolate, receiver)); | 630 JSReceiver::GetPrototype(isolate, receiver)); |
| 631 } | 631 } |
| 632 | 632 |
| 633 // ES6 section 19.1.2.21 Object.setPrototypeOf ( O, proto ) | 633 // ES6 section 19.1.2.21 Object.setPrototypeOf ( O, proto ) |
| 634 BUILTIN(ObjectSetPrototypeOf) { | 634 BUILTIN(ObjectSetPrototypeOf) { |
| 635 HandleScope scope(isolate); | 635 HandleScope scope(isolate); |
| 636 | 636 |
| 637 // 1. Let O be ? RequireObjectCoercible(O). | 637 // 1. Let O be ? RequireObjectCoercible(O). |
| 638 Handle<Object> object = args.atOrUndefined(isolate, 1); | 638 Handle<Object> object = args.atOrUndefined(isolate, 1); |
| 639 if (object->IsNull(isolate) || object->IsUndefined(isolate)) { | 639 if (object->IsNullOrUndefined(isolate)) { |
| 640 THROW_NEW_ERROR_RETURN_FAILURE( | 640 THROW_NEW_ERROR_RETURN_FAILURE( |
| 641 isolate, NewTypeError(MessageTemplate::kCalledOnNullOrUndefined, | 641 isolate, NewTypeError(MessageTemplate::kCalledOnNullOrUndefined, |
| 642 isolate->factory()->NewStringFromAsciiChecked( | 642 isolate->factory()->NewStringFromAsciiChecked( |
| 643 "Object.setPrototypeOf"))); | 643 "Object.setPrototypeOf"))); |
| 644 } | 644 } |
| 645 | 645 |
| 646 // 2. If Type(proto) is neither Object nor Null, throw a TypeError exception. | 646 // 2. If Type(proto) is neither Object nor Null, throw a TypeError exception. |
| 647 Handle<Object> proto = args.atOrUndefined(isolate, 2); | 647 Handle<Object> proto = args.atOrUndefined(isolate, 2); |
| 648 if (!proto->IsNull(isolate) && !proto->IsJSReceiver()) { | 648 if (!proto->IsNull(isolate) && !proto->IsJSReceiver()) { |
| 649 THROW_NEW_ERROR_RETURN_FAILURE( | 649 THROW_NEW_ERROR_RETURN_FAILURE( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 675 // 2. Return ? O.[[GetPrototypeOf]](). | 675 // 2. Return ? O.[[GetPrototypeOf]](). |
| 676 RETURN_RESULT_OR_FAILURE(isolate, | 676 RETURN_RESULT_OR_FAILURE(isolate, |
| 677 JSReceiver::GetPrototype(isolate, receiver)); | 677 JSReceiver::GetPrototype(isolate, receiver)); |
| 678 } | 678 } |
| 679 | 679 |
| 680 // ES6 section B.2.2.1.2 set Object.prototype.__proto__ | 680 // ES6 section B.2.2.1.2 set Object.prototype.__proto__ |
| 681 BUILTIN(ObjectPrototypeSetProto) { | 681 BUILTIN(ObjectPrototypeSetProto) { |
| 682 HandleScope scope(isolate); | 682 HandleScope scope(isolate); |
| 683 // 1. Let O be ? RequireObjectCoercible(this value). | 683 // 1. Let O be ? RequireObjectCoercible(this value). |
| 684 Handle<Object> object = args.receiver(); | 684 Handle<Object> object = args.receiver(); |
| 685 if (object->IsNull(isolate) || object->IsUndefined(isolate)) { | 685 if (object->IsNullOrUndefined(isolate)) { |
| 686 THROW_NEW_ERROR_RETURN_FAILURE( | 686 THROW_NEW_ERROR_RETURN_FAILURE( |
| 687 isolate, NewTypeError(MessageTemplate::kCalledOnNullOrUndefined, | 687 isolate, NewTypeError(MessageTemplate::kCalledOnNullOrUndefined, |
| 688 isolate->factory()->NewStringFromAsciiChecked( | 688 isolate->factory()->NewStringFromAsciiChecked( |
| 689 "set Object.prototype.__proto__"))); | 689 "set Object.prototype.__proto__"))); |
| 690 } | 690 } |
| 691 | 691 |
| 692 // 2. If Type(proto) is neither Object nor Null, return undefined. | 692 // 2. If Type(proto) is neither Object nor Null, return undefined. |
| 693 Handle<Object> proto = args.at(1); | 693 Handle<Object> proto = args.at(1); |
| 694 if (!proto->IsNull(isolate) && !proto->IsJSReceiver()) { | 694 if (!proto->IsNull(isolate) && !proto->IsJSReceiver()) { |
| 695 return isolate->heap()->undefined_value(); | 695 return isolate->heap()->undefined_value(); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 CodeStubAssembler assembler(state); | 985 CodeStubAssembler assembler(state); |
| 986 | 986 |
| 987 Node* object = assembler.Parameter(Descriptor::kObject); | 987 Node* object = assembler.Parameter(Descriptor::kObject); |
| 988 Node* context = assembler.Parameter(Descriptor::kContext); | 988 Node* context = assembler.Parameter(Descriptor::kContext); |
| 989 | 989 |
| 990 assembler.Return(assembler.GetSuperConstructor(object, context)); | 990 assembler.Return(assembler.GetSuperConstructor(object, context)); |
| 991 } | 991 } |
| 992 | 992 |
| 993 } // namespace internal | 993 } // namespace internal |
| 994 } // namespace v8 | 994 } // namespace v8 |
| OLD | NEW |