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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 | 267 |
268 | 268 |
269 // ES6 19.1.2.6 | 269 // ES6 19.1.2.6 |
270 RUNTIME_FUNCTION(Runtime_GetOwnProperty) { | 270 RUNTIME_FUNCTION(Runtime_GetOwnProperty) { |
271 HandleScope scope(isolate); | 271 HandleScope scope(isolate); |
272 DCHECK(args.length() == 2); | 272 DCHECK(args.length() == 2); |
273 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 273 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
274 CONVERT_ARG_HANDLE_CHECKED(Object, raw_name, 1); | 274 CONVERT_ARG_HANDLE_CHECKED(Object, raw_name, 1); |
275 // 1. Let obj be ? ToObject(O). | 275 // 1. Let obj be ? ToObject(O). |
276 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, object, | 276 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, object, |
277 Execution::ToObject(isolate, object)); | 277 Object::ToObject(isolate, object)); |
278 // 2. Let key be ? ToPropertyKey(P). | 278 // 2. Let key be ? ToPropertyKey(P). |
279 Handle<Name> key; | 279 Handle<Name> key; |
280 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, key, | 280 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, key, |
281 Object::ToName(isolate, raw_name)); | 281 Object::ToName(isolate, raw_name)); |
282 | 282 |
283 // 3. Let desc be ? obj.[[GetOwnProperty]](key). | 283 // 3. Let desc be ? obj.[[GetOwnProperty]](key). |
284 PropertyDescriptor desc; | 284 PropertyDescriptor desc; |
285 Maybe<bool> found = JSReceiver::GetOwnPropertyDescriptor( | 285 Maybe<bool> found = JSReceiver::GetOwnPropertyDescriptor( |
286 isolate, Handle<JSReceiver>::cast(object), key, &desc); | 286 isolate, Handle<JSReceiver>::cast(object), key, &desc); |
287 MAYBE_RETURN(found, isolate->heap()->exception()); | 287 MAYBE_RETURN(found, isolate->heap()->exception()); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 return *result; | 556 return *result; |
557 } | 557 } |
558 | 558 |
559 | 559 |
560 namespace { | 560 namespace { |
561 | 561 |
562 // ES6 section 12.5.4. | 562 // ES6 section 12.5.4. |
563 Object* DeleteProperty(Isolate* isolate, Handle<Object> object, | 563 Object* DeleteProperty(Isolate* isolate, Handle<Object> object, |
564 Handle<Object> key, LanguageMode language_mode) { | 564 Handle<Object> key, LanguageMode language_mode) { |
565 Handle<JSReceiver> receiver; | 565 Handle<JSReceiver> receiver; |
566 if (!JSReceiver::ToObject(isolate, object).ToHandle(&receiver)) { | 566 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
567 THROW_NEW_ERROR_RETURN_FAILURE( | 567 Object::ToObject(isolate, object)); |
568 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject)); | |
569 } | |
570 Maybe<bool> result = | 568 Maybe<bool> result = |
571 Runtime::DeleteObjectProperty(isolate, receiver, key, language_mode); | 569 Runtime::DeleteObjectProperty(isolate, receiver, key, language_mode); |
572 MAYBE_RETURN(result, isolate->heap()->exception()); | 570 MAYBE_RETURN(result, isolate->heap()->exception()); |
573 return isolate->heap()->ToBoolean(result.FromJust()); | 571 return isolate->heap()->ToBoolean(result.FromJust()); |
574 } | 572 } |
575 | 573 |
576 } // namespace | 574 } // namespace |
577 | 575 |
578 | 576 |
579 RUNTIME_FUNCTION(Runtime_DeleteProperty_Sloppy) { | 577 RUNTIME_FUNCTION(Runtime_DeleteProperty_Sloppy) { |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 setter, attrs)); | 1054 setter, attrs)); |
1057 return isolate->heap()->undefined_value(); | 1055 return isolate->heap()->undefined_value(); |
1058 } | 1056 } |
1059 | 1057 |
1060 | 1058 |
1061 RUNTIME_FUNCTION(Runtime_ToObject) { | 1059 RUNTIME_FUNCTION(Runtime_ToObject) { |
1062 HandleScope scope(isolate); | 1060 HandleScope scope(isolate); |
1063 DCHECK_EQ(1, args.length()); | 1061 DCHECK_EQ(1, args.length()); |
1064 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 1062 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
1065 Handle<JSReceiver> receiver; | 1063 Handle<JSReceiver> receiver; |
1066 if (JSReceiver::ToObject(isolate, object).ToHandle(&receiver)) { | 1064 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
1067 return *receiver; | 1065 Object::ToObject(isolate, object)); |
1068 } | 1066 return *receiver; |
1069 THROW_NEW_ERROR_RETURN_FAILURE( | |
1070 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject)); | |
1071 } | 1067 } |
1072 | 1068 |
1073 | 1069 |
1074 RUNTIME_FUNCTION(Runtime_ToPrimitive) { | 1070 RUNTIME_FUNCTION(Runtime_ToPrimitive) { |
1075 HandleScope scope(isolate); | 1071 HandleScope scope(isolate); |
1076 DCHECK_EQ(1, args.length()); | 1072 DCHECK_EQ(1, args.length()); |
1077 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 1073 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
1078 Handle<Object> result; | 1074 Handle<Object> result; |
1079 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 1075 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
1080 Object::ToPrimitive(input)); | 1076 Object::ToPrimitive(input)); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 DCHECK(args.length() == 2); | 1314 DCHECK(args.length() == 2); |
1319 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); | 1315 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); |
1320 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); | 1316 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); |
1321 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1317 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1322 isolate, o, JSReceiver::DefineProperties(isolate, o, properties)); | 1318 isolate, o, JSReceiver::DefineProperties(isolate, o, properties)); |
1323 return *o; | 1319 return *o; |
1324 } | 1320 } |
1325 | 1321 |
1326 } // namespace internal | 1322 } // namespace internal |
1327 } // namespace v8 | 1323 } // namespace v8 |
OLD | NEW |