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

Side by Side Diff: src/builtins/builtins-object.cc

Issue 2601503002: Add Object::IsNullOrUndefined(Isolate*) helper method (Closed)
Patch Set: fixing merge conflicts Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « src/builtins/builtins-array.cc ('k') | src/builtins/builtins-utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « src/builtins/builtins-array.cc ('k') | src/builtins/builtins-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698