| 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" |
| (...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 { | 1482 { |
| 1483 DisallowHeapAllocation no_gc; | 1483 DisallowHeapAllocation no_gc; |
| 1484 Object* array_proto = isolate->array_function()->prototype(); | 1484 Object* array_proto = isolate->array_function()->prototype(); |
| 1485 // Iterate through all the arguments performing checks | 1485 // Iterate through all the arguments performing checks |
| 1486 // and calculating total length. | 1486 // and calculating total length. |
| 1487 for (int i = 0; i < n_arguments; i++) { | 1487 for (int i = 0; i < n_arguments; i++) { |
| 1488 Object* arg = (*args)[i]; | 1488 Object* arg = (*args)[i]; |
| 1489 if (!arg->IsJSArray()) return MaybeHandle<JSArray>(); | 1489 if (!arg->IsJSArray()) return MaybeHandle<JSArray>(); |
| 1490 Handle<JSArray> array(JSArray::cast(arg), isolate); | 1490 Handle<JSArray> array(JSArray::cast(arg), isolate); |
| 1491 if (!array->HasFastElements()) return MaybeHandle<JSArray>(); | 1491 if (!array->HasFastElements()) return MaybeHandle<JSArray>(); |
| 1492 PrototypeIterator iter(isolate, arg); | 1492 PrototypeIterator iter(isolate, *array); |
| 1493 if (iter.GetCurrent() != array_proto) return MaybeHandle<JSArray>(); | 1493 if (iter.GetCurrent() != array_proto) return MaybeHandle<JSArray>(); |
| 1494 if (HasConcatSpreadableModifier(isolate, array)) { | 1494 if (HasConcatSpreadableModifier(isolate, array)) { |
| 1495 return MaybeHandle<JSArray>(); | 1495 return MaybeHandle<JSArray>(); |
| 1496 } | 1496 } |
| 1497 int len = Smi::cast(array->length())->value(); | 1497 int len = Smi::cast(array->length())->value(); |
| 1498 | 1498 |
| 1499 // We shouldn't overflow when adding another len. | 1499 // We shouldn't overflow when adding another len. |
| 1500 const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2); | 1500 const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2); |
| 1501 STATIC_ASSERT(FixedArray::kMaxLength < kHalfOfMaxInt); | 1501 STATIC_ASSERT(FixedArray::kMaxLength < kHalfOfMaxInt); |
| 1502 USE(kHalfOfMaxInt); | 1502 USE(kHalfOfMaxInt); |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2072 DCHECK_EQ(2, args.length()); | 2072 DCHECK_EQ(2, args.length()); |
| 2073 Handle<Object> target = args.at<Object>(1); | 2073 Handle<Object> target = args.at<Object>(1); |
| 2074 | 2074 |
| 2075 if (!target->IsJSReceiver()) { | 2075 if (!target->IsJSReceiver()) { |
| 2076 THROW_NEW_ERROR_RETURN_FAILURE( | 2076 THROW_NEW_ERROR_RETURN_FAILURE( |
| 2077 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, | 2077 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, |
| 2078 isolate->factory()->NewStringFromAsciiChecked( | 2078 isolate->factory()->NewStringFromAsciiChecked( |
| 2079 "Reflect.getPrototypeOf"))); | 2079 "Reflect.getPrototypeOf"))); |
| 2080 } | 2080 } |
| 2081 Handle<Object> prototype; | 2081 Handle<Object> prototype; |
| 2082 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, prototype, | 2082 Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(target); |
| 2083 Object::GetPrototype(isolate, target)); | 2083 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2084 isolate, prototype, JSReceiver::GetPrototype(isolate, receiver)); |
| 2084 return *prototype; | 2085 return *prototype; |
| 2085 } | 2086 } |
| 2086 | 2087 |
| 2087 | 2088 |
| 2088 // ES6 section 26.1.9 Reflect.has | 2089 // ES6 section 26.1.9 Reflect.has |
| 2089 BUILTIN(ReflectHas) { | 2090 BUILTIN(ReflectHas) { |
| 2090 HandleScope scope(isolate); | 2091 HandleScope scope(isolate); |
| 2091 DCHECK_EQ(3, args.length()); | 2092 DCHECK_EQ(3, args.length()); |
| 2092 Handle<Object> target = args.at<Object>(1); | 2093 Handle<Object> target = args.at<Object>(1); |
| 2093 Handle<Object> key = args.at<Object>(2); | 2094 Handle<Object> key = args.at<Object>(2); |
| (...skipping 2163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4257 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 4258 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
| 4258 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 4259 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 4259 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 4260 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 4260 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 4261 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 4261 #undef DEFINE_BUILTIN_ACCESSOR_C | 4262 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 4262 #undef DEFINE_BUILTIN_ACCESSOR_A | 4263 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 4263 | 4264 |
| 4264 | 4265 |
| 4265 } // namespace internal | 4266 } // namespace internal |
| 4266 } // namespace v8 | 4267 } // namespace v8 |
| OLD | NEW |