| 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 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 } | 908 } |
| 909 | 909 |
| 910 Handle<Object> result; | 910 Handle<Object> result; |
| 911 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 911 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 912 isolate, result, JSObject::DefineOwnPropertyIgnoreAttributes( | 912 isolate, result, JSObject::DefineOwnPropertyIgnoreAttributes( |
| 913 &it, value, attrs, JSObject::DONT_FORCE_FIELD)); | 913 &it, value, attrs, JSObject::DONT_FORCE_FIELD)); |
| 914 | 914 |
| 915 return *result; | 915 return *result; |
| 916 } | 916 } |
| 917 | 917 |
| 918 RUNTIME_FUNCTION(Runtime_DefineDataPropertyInLiteral) { |
| 919 HandleScope scope(isolate); |
| 920 DCHECK(args.length() == 5); |
| 921 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 922 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 923 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 924 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
| 925 CONVERT_SMI_ARG_CHECKED(set_function_name, 4); |
| 926 |
| 927 if (FLAG_harmony_function_name && set_function_name) { |
| 928 DCHECK(value->IsJSFunction()); |
| 929 JSFunction::SetName(Handle<JSFunction>::cast(value), name, |
| 930 isolate->factory()->empty_string()); |
| 931 } |
| 932 |
| 933 LookupIterator it = LookupIterator::PropertyOrElement(isolate, object, name, |
| 934 LookupIterator::OWN); |
| 935 // Cannot fail since this should only be called when |
| 936 // creating an object literal. |
| 937 CHECK(JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs, |
| 938 Object::DONT_THROW) |
| 939 .IsJust()); |
| 940 return *object; |
| 941 } |
| 918 | 942 |
| 919 // Return property without being observable by accessors or interceptors. | 943 // Return property without being observable by accessors or interceptors. |
| 920 RUNTIME_FUNCTION(Runtime_GetDataProperty) { | 944 RUNTIME_FUNCTION(Runtime_GetDataProperty) { |
| 921 HandleScope scope(isolate); | 945 HandleScope scope(isolate); |
| 922 DCHECK(args.length() == 2); | 946 DCHECK(args.length() == 2); |
| 923 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 947 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
| 924 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 948 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 925 return *JSReceiver::GetDataProperty(object, name); | 949 return *JSReceiver::GetDataProperty(object, name); |
| 926 } | 950 } |
| 927 | 951 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 | 1023 |
| 1000 | 1024 |
| 1001 RUNTIME_FUNCTION(Runtime_DefineGetterPropertyUnchecked) { | 1025 RUNTIME_FUNCTION(Runtime_DefineGetterPropertyUnchecked) { |
| 1002 HandleScope scope(isolate); | 1026 HandleScope scope(isolate); |
| 1003 DCHECK(args.length() == 4); | 1027 DCHECK(args.length() == 4); |
| 1004 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 1028 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 1005 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 1029 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 1006 CONVERT_ARG_HANDLE_CHECKED(JSFunction, getter, 2); | 1030 CONVERT_ARG_HANDLE_CHECKED(JSFunction, getter, 2); |
| 1007 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 1031 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
| 1008 | 1032 |
| 1033 if (FLAG_harmony_function_name && |
| 1034 String::cast(getter->shared()->name())->length() == 0) { |
| 1035 JSFunction::SetName(getter, name, isolate->factory()->get_string()); |
| 1036 } |
| 1037 |
| 1009 RETURN_FAILURE_ON_EXCEPTION( | 1038 RETURN_FAILURE_ON_EXCEPTION( |
| 1010 isolate, | 1039 isolate, |
| 1011 JSObject::DefineAccessor(object, name, getter, | 1040 JSObject::DefineAccessor(object, name, getter, |
| 1012 isolate->factory()->null_value(), attrs)); | 1041 isolate->factory()->null_value(), attrs)); |
| 1013 return isolate->heap()->undefined_value(); | 1042 return isolate->heap()->undefined_value(); |
| 1014 } | 1043 } |
| 1015 | 1044 |
| 1016 | 1045 |
| 1017 RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) { | 1046 RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) { |
| 1018 HandleScope scope(isolate); | 1047 HandleScope scope(isolate); |
| 1019 DCHECK(args.length() == 4); | 1048 DCHECK(args.length() == 4); |
| 1020 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 1049 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 1021 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 1050 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 1022 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2); | 1051 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2); |
| 1023 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 1052 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
| 1024 | 1053 |
| 1054 if (FLAG_harmony_function_name && |
| 1055 String::cast(setter->shared()->name())->length() == 0) { |
| 1056 JSFunction::SetName(setter, name, isolate->factory()->set_string()); |
| 1057 } |
| 1058 |
| 1025 RETURN_FAILURE_ON_EXCEPTION( | 1059 RETURN_FAILURE_ON_EXCEPTION( |
| 1026 isolate, | 1060 isolate, |
| 1027 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), | 1061 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), |
| 1028 setter, attrs)); | 1062 setter, attrs)); |
| 1029 return isolate->heap()->undefined_value(); | 1063 return isolate->heap()->undefined_value(); |
| 1030 } | 1064 } |
| 1031 | 1065 |
| 1032 | 1066 |
| 1033 RUNTIME_FUNCTION(Runtime_ToObject) { | 1067 RUNTIME_FUNCTION(Runtime_ToObject) { |
| 1034 HandleScope scope(isolate); | 1068 HandleScope scope(isolate); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1288 DCHECK(args.length() == 2); | 1322 DCHECK(args.length() == 2); |
| 1289 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); | 1323 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); |
| 1290 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); | 1324 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); |
| 1291 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1325 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1292 isolate, o, JSReceiver::DefineProperties(isolate, o, properties)); | 1326 isolate, o, JSReceiver::DefineProperties(isolate, o, properties)); |
| 1293 return *o; | 1327 return *o; |
| 1294 } | 1328 } |
| 1295 | 1329 |
| 1296 } // namespace internal | 1330 } // namespace internal |
| 1297 } // namespace v8 | 1331 } // namespace v8 |
| OLD | NEW |