OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/builtins.h" | 5 #include "src/builtins.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
11 #include "src/bootstrapper.h" | 11 #include "src/bootstrapper.h" |
12 #include "src/elements.h" | 12 #include "src/elements.h" |
13 #include "src/frames-inl.h" | 13 #include "src/frames-inl.h" |
14 #include "src/gdb-jit.h" | 14 #include "src/gdb-jit.h" |
15 #include "src/ic/handler-compiler.h" | 15 #include "src/ic/handler-compiler.h" |
16 #include "src/ic/ic.h" | 16 #include "src/ic/ic.h" |
17 #include "src/isolate-inl.h" | 17 #include "src/isolate-inl.h" |
18 #include "src/messages.h" | 18 #include "src/messages.h" |
19 #include "src/profiler/cpu-profiler.h" | 19 #include "src/profiler/cpu-profiler.h" |
| 20 #include "src/property-descriptor.h" |
20 #include "src/prototype.h" | 21 #include "src/prototype.h" |
21 #include "src/vm-state-inl.h" | 22 #include "src/vm-state-inl.h" |
22 | 23 |
23 namespace v8 { | 24 namespace v8 { |
24 namespace internal { | 25 namespace internal { |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 // Arguments object passed to C++ builtins. | 29 // Arguments object passed to C++ builtins. |
29 template <BuiltinExtraArguments extra_args> | 30 template <BuiltinExtraArguments extra_args> |
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 | 1438 |
1438 Handle<JSArray> result_array; | 1439 Handle<JSArray> result_array; |
1439 if (Fast_ArrayConcat(isolate, &args).ToHandle(&result_array)) { | 1440 if (Fast_ArrayConcat(isolate, &args).ToHandle(&result_array)) { |
1440 return *result_array; | 1441 return *result_array; |
1441 } | 1442 } |
1442 if (isolate->has_pending_exception()) return isolate->heap()->exception(); | 1443 if (isolate->has_pending_exception()) return isolate->heap()->exception(); |
1443 return Slow_ArrayConcat(&args, isolate); | 1444 return Slow_ArrayConcat(&args, isolate); |
1444 } | 1445 } |
1445 | 1446 |
1446 | 1447 |
| 1448 // ES6 section 26.1.3 Reflect.defineProperty |
| 1449 BUILTIN(ReflectDefineProperty) { |
| 1450 HandleScope scope(isolate); |
| 1451 DCHECK_EQ(4, args.length()); |
| 1452 Handle<Object> target = args.at<Object>(1); |
| 1453 Handle<Object> key = args.at<Object>(2); |
| 1454 Handle<Object> attributes = args.at<Object>(3); |
| 1455 |
| 1456 if (!target->IsJSReceiver()) { |
| 1457 THROW_NEW_ERROR_RETURN_FAILURE( |
| 1458 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, |
| 1459 isolate->factory()->NewStringFromAsciiChecked( |
| 1460 "Reflect.defineProperty"))); |
| 1461 } |
| 1462 |
| 1463 Handle<Name> name; |
| 1464 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
| 1465 Object::ToName(isolate, key)); |
| 1466 |
| 1467 PropertyDescriptor desc; |
| 1468 if (!PropertyDescriptor::ToPropertyDescriptor(isolate, attributes, &desc)) { |
| 1469 return isolate->heap()->exception(); |
| 1470 } |
| 1471 |
| 1472 bool result = |
| 1473 JSReceiver::DefineOwnProperty(isolate, Handle<JSReceiver>::cast(target), |
| 1474 name, &desc, Object::DONT_THROW); |
| 1475 if (isolate->has_pending_exception()) return isolate->heap()->exception(); |
| 1476 // TODO(neis): Make DefineOwnProperty return Maybe<bool>. |
| 1477 return *isolate->factory()->ToBoolean(result); |
| 1478 } |
| 1479 |
| 1480 |
1447 // ES6 section 26.1.4 Reflect.deleteProperty | 1481 // ES6 section 26.1.4 Reflect.deleteProperty |
1448 BUILTIN(ReflectDeleteProperty) { | 1482 BUILTIN(ReflectDeleteProperty) { |
1449 HandleScope scope(isolate); | 1483 HandleScope scope(isolate); |
1450 DCHECK_EQ(3, args.length()); | 1484 DCHECK_EQ(3, args.length()); |
1451 Handle<Object> target = args.at<Object>(1); | 1485 Handle<Object> target = args.at<Object>(1); |
1452 Handle<Object> key = args.at<Object>(2); | 1486 Handle<Object> key = args.at<Object>(2); |
1453 | 1487 |
1454 if (!target->IsJSReceiver()) { | 1488 if (!target->IsJSReceiver()) { |
1455 THROW_NEW_ERROR_RETURN_FAILURE( | 1489 THROW_NEW_ERROR_RETURN_FAILURE( |
1456 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, | 1490 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2265 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 2299 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
2266 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 2300 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
2267 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 2301 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
2268 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 2302 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
2269 #undef DEFINE_BUILTIN_ACCESSOR_C | 2303 #undef DEFINE_BUILTIN_ACCESSOR_C |
2270 #undef DEFINE_BUILTIN_ACCESSOR_A | 2304 #undef DEFINE_BUILTIN_ACCESSOR_A |
2271 | 2305 |
2272 | 2306 |
2273 } // namespace internal | 2307 } // namespace internal |
2274 } // namespace v8 | 2308 } // namespace v8 |
OLD | NEW |