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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 LookupIterator it = LookupIterator::PropertyOrElement( | 664 LookupIterator it = LookupIterator::PropertyOrElement( |
665 isolate, object, name, object, LookupIterator::OWN); | 665 isolate, object, name, object, LookupIterator::OWN); |
666 // Cannot fail since this should only be called when | 666 // Cannot fail since this should only be called when |
667 // creating an object literal. | 667 // creating an object literal. |
668 CHECK(JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs, | 668 CHECK(JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs, |
669 Object::DONT_THROW) | 669 Object::DONT_THROW) |
670 .IsJust()); | 670 .IsJust()); |
671 return *object; | 671 return *object; |
672 } | 672 } |
673 | 673 |
674 RUNTIME_FUNCTION(Runtime_DefineDataProperty) { | |
675 HandleScope scope(isolate); | |
676 DCHECK(args.length() == 5); | |
677 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | |
678 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | |
679 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | |
680 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | |
681 CONVERT_SMI_ARG_CHECKED(set_function_name, 4); | |
682 | |
683 if (set_function_name) { | |
684 DCHECK(value->IsJSFunction()); | |
685 JSFunction::SetName(Handle<JSFunction>::cast(value), name, | |
686 isolate->factory()->empty_string()); | |
687 } | |
688 | |
689 PropertyDescriptor desc; | |
690 desc.set_writable(!(attrs & ReadOnly)); | |
691 desc.set_enumerable(!(attrs & DontEnum)); | |
692 desc.set_configurable(!(attrs & DontDelete)); | |
693 desc.set_value(value); | |
694 | |
695 Maybe<bool> result = JSReceiver::DefineOwnProperty(isolate, receiver, name, | |
696 &desc, Object::DONT_THROW); | |
697 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | |
698 if (result.IsNothing()) { | |
699 DCHECK(isolate->has_pending_exception()); | |
700 return isolate->heap()->exception(); | |
701 } | |
702 | |
703 return *receiver; | |
704 } | |
705 | |
706 // Return property without being observable by accessors or interceptors. | 674 // Return property without being observable by accessors or interceptors. |
707 RUNTIME_FUNCTION(Runtime_GetDataProperty) { | 675 RUNTIME_FUNCTION(Runtime_GetDataProperty) { |
708 HandleScope scope(isolate); | 676 HandleScope scope(isolate); |
709 DCHECK(args.length() == 2); | 677 DCHECK(args.length() == 2); |
710 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 678 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
711 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 679 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
712 return *JSReceiver::GetDataProperty(object, name); | 680 return *JSReceiver::GetDataProperty(object, name); |
713 } | 681 } |
714 | 682 |
715 RUNTIME_FUNCTION(Runtime_GetConstructorName) { | 683 RUNTIME_FUNCTION(Runtime_GetConstructorName) { |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 if (!success) return isolate->heap()->exception(); | 925 if (!success) return isolate->heap()->exception(); |
958 MAYBE_RETURN( | 926 MAYBE_RETURN( |
959 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), | 927 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), |
960 isolate->heap()->exception()); | 928 isolate->heap()->exception()); |
961 return *value; | 929 return *value; |
962 } | 930 } |
963 | 931 |
964 | 932 |
965 } // namespace internal | 933 } // namespace internal |
966 } // namespace v8 | 934 } // namespace v8 |
OLD | NEW |