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

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

Issue 2620943002: [ESnext] Implement Object Rest (Closed)
Patch Set: Remove comment 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 769
770 RETURN_FAILURE_ON_EXCEPTION( 770 RETURN_FAILURE_ON_EXCEPTION(
771 isolate, 771 isolate,
772 JSObject::DefineAccessor(object, name, getter, 772 JSObject::DefineAccessor(object, name, getter,
773 isolate->factory()->null_value(), attrs)); 773 isolate->factory()->null_value(), attrs));
774 return isolate->heap()->undefined_value(); 774 return isolate->heap()->undefined_value();
775 } 775 }
776 776
777 RUNTIME_FUNCTION(Runtime_CopyDataProperties) { 777 RUNTIME_FUNCTION(Runtime_CopyDataProperties) {
778 HandleScope scope(isolate); 778 HandleScope scope(isolate);
779 DCHECK(args.length() == 2); 779 DCHECK_EQ(2, args.length());
780 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0); 780 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0);
781 CONVERT_ARG_HANDLE_CHECKED(Object, source, 1); 781 CONVERT_ARG_HANDLE_CHECKED(Object, source, 1);
782 782
783 // 2. If source is undefined or null, let keys be an empty List. 783 // 2. If source is undefined or null, let keys be an empty List.
784 if (source->IsUndefined(isolate) || source->IsNull(isolate)) { 784 if (source->IsUndefined(isolate) || source->IsNull(isolate)) {
785 return isolate->heap()->undefined_value(); 785 return isolate->heap()->undefined_value();
786 } 786 }
787 787
788 MAYBE_RETURN( 788 MAYBE_RETURN(JSReceiver::SetOrCopyDataProperties(
789 JSReceiver::SetOrCopyDataProperties(isolate, target, source, false), 789 isolate, target, source, MaybeHandle<JSArray>(), false),
790 isolate->heap()->exception()); 790 isolate->heap()->exception());
791 return isolate->heap()->undefined_value(); 791 return isolate->heap()->undefined_value();
792 } 792 }
793 793
794 RUNTIME_FUNCTION(Runtime_CopyDataPropertiesWithExcludedProperties) {
795 HandleScope scope(isolate);
796 DCHECK_EQ(2, args.length());
797 CONVERT_ARG_HANDLE_CHECKED(Object, source, 0);
798 CONVERT_ARG_HANDLE_CHECKED(JSArray, excluded_properties, 1);
adamk 2017/01/10 23:22:56 As discussed, I think it'd be simpler to just pass
799
800 // 2. If source is undefined or null, let keys be an empty List.
801 if (source->IsUndefined(isolate) || source->IsNull(isolate)) {
802 return isolate->heap()->undefined_value();
803 }
804
805 Handle<JSObject> target =
806 isolate->factory()->NewJSObject(isolate->object_function());
807 MAYBE_RETURN(JSReceiver::SetOrCopyDataProperties(isolate, target, source,
808 excluded_properties, false),
809 isolate->heap()->exception());
810 return *target;
811 }
812
794 RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) { 813 RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) {
795 HandleScope scope(isolate); 814 HandleScope scope(isolate);
796 DCHECK_EQ(4, args.length()); 815 DCHECK_EQ(4, args.length());
797 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 816 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
798 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); 817 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
799 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2); 818 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2);
800 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); 819 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3);
801 820
802 if (String::cast(setter->shared()->name())->length() == 0) { 821 if (String::cast(setter->shared()->name())->length() == 0) {
803 JSFunction::SetName(setter, name, isolate->factory()->set_string()); 822 JSFunction::SetName(setter, name, isolate->factory()->set_string());
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 if (!success) return isolate->heap()->exception(); 990 if (!success) return isolate->heap()->exception();
972 MAYBE_RETURN( 991 MAYBE_RETURN(
973 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), 992 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR),
974 isolate->heap()->exception()); 993 isolate->heap()->exception());
975 return *value; 994 return *value;
976 } 995 }
977 996
978 997
979 } // namespace internal 998 } // namespace internal
980 } // namespace v8 999 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698