| OLD | NEW |
| 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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 | 739 |
| 740 RETURN_FAILURE_ON_EXCEPTION( | 740 RETURN_FAILURE_ON_EXCEPTION( |
| 741 isolate, | 741 isolate, |
| 742 JSObject::DefineAccessor(object, name, getter, | 742 JSObject::DefineAccessor(object, name, getter, |
| 743 isolate->factory()->null_value(), attrs)); | 743 isolate->factory()->null_value(), attrs)); |
| 744 return isolate->heap()->undefined_value(); | 744 return isolate->heap()->undefined_value(); |
| 745 } | 745 } |
| 746 | 746 |
| 747 RUNTIME_FUNCTION(Runtime_CopyDataProperties) { | 747 RUNTIME_FUNCTION(Runtime_CopyDataProperties) { |
| 748 HandleScope scope(isolate); | 748 HandleScope scope(isolate); |
| 749 DCHECK(args.length() == 2); | 749 DCHECK_EQ(2, args.length()); |
| 750 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0); | 750 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0); |
| 751 CONVERT_ARG_HANDLE_CHECKED(Object, source, 1); | 751 CONVERT_ARG_HANDLE_CHECKED(Object, source, 1); |
| 752 | 752 |
| 753 // 2. If source is undefined or null, let keys be an empty List. | 753 // 2. If source is undefined or null, let keys be an empty List. |
| 754 if (source->IsUndefined(isolate) || source->IsNull(isolate)) { | 754 if (source->IsUndefined(isolate) || source->IsNull(isolate)) { |
| 755 return isolate->heap()->undefined_value(); | 755 return isolate->heap()->undefined_value(); |
| 756 } | 756 } |
| 757 | 757 |
| 758 MAYBE_RETURN( | 758 MAYBE_RETURN(JSReceiver::SetOrCopyDataProperties(isolate, target, source, |
| 759 JSReceiver::SetOrCopyDataProperties(isolate, target, source, false), | 759 nullptr, false), |
| 760 isolate->heap()->exception()); | 760 isolate->heap()->exception()); |
| 761 return isolate->heap()->undefined_value(); | 761 return isolate->heap()->undefined_value(); |
| 762 } | 762 } |
| 763 | 763 |
| 764 RUNTIME_FUNCTION(Runtime_CopyDataPropertiesWithExcludedProperties) { |
| 765 HandleScope scope(isolate); |
| 766 DCHECK_LE(1, args.length()); |
| 767 CONVERT_ARG_HANDLE_CHECKED(Object, source, 0); |
| 768 |
| 769 // 2. If source is undefined or null, let keys be an empty List. |
| 770 if (source->IsUndefined(isolate) || source->IsNull(isolate)) { |
| 771 return isolate->heap()->undefined_value(); |
| 772 } |
| 773 |
| 774 ScopedVector<Handle<Name>> excluded_properties(args.length() - 1); |
| 775 for (int i = 1; i < args.length(); i++) { |
| 776 excluded_properties[i - 1] = args.at<Name>(i); |
| 777 } |
| 778 |
| 779 Handle<JSObject> target = |
| 780 isolate->factory()->NewJSObject(isolate->object_function()); |
| 781 MAYBE_RETURN(JSReceiver::SetOrCopyDataProperties(isolate, target, source, |
| 782 &excluded_properties, false), |
| 783 isolate->heap()->exception()); |
| 784 return *target; |
| 785 } |
| 786 |
| 764 RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) { | 787 RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) { |
| 765 HandleScope scope(isolate); | 788 HandleScope scope(isolate); |
| 766 DCHECK_EQ(4, args.length()); | 789 DCHECK_EQ(4, args.length()); |
| 767 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 790 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 768 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 791 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 769 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2); | 792 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2); |
| 770 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 793 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
| 771 | 794 |
| 772 if (String::cast(setter->shared()->name())->length() == 0) { | 795 if (String::cast(setter->shared()->name())->length() == 0) { |
| 773 JSFunction::SetName(setter, name, isolate->factory()->set_string()); | 796 JSFunction::SetName(setter, name, isolate->factory()->set_string()); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 if (!success) return isolate->heap()->exception(); | 964 if (!success) return isolate->heap()->exception(); |
| 942 MAYBE_RETURN( | 965 MAYBE_RETURN( |
| 943 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), | 966 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), |
| 944 isolate->heap()->exception()); | 967 isolate->heap()->exception()); |
| 945 return *value; | 968 return *value; |
| 946 } | 969 } |
| 947 | 970 |
| 948 | 971 |
| 949 } // namespace internal | 972 } // namespace internal |
| 950 } // namespace v8 | 973 } // namespace v8 |
| OLD | NEW |