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-arguments.h" | 7 #include "src/api-arguments.h" |
8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 */ | 1081 */ |
1082 bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver, | 1082 bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver, |
1083 ArrayConcatVisitor* visitor) { | 1083 ArrayConcatVisitor* visitor) { |
1084 uint32_t length = 0; | 1084 uint32_t length = 0; |
1085 | 1085 |
1086 if (receiver->IsJSArray()) { | 1086 if (receiver->IsJSArray()) { |
1087 Handle<JSArray> array = Handle<JSArray>::cast(receiver); | 1087 Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
1088 length = static_cast<uint32_t>(array->length()->Number()); | 1088 length = static_cast<uint32_t>(array->length()->Number()); |
1089 } else { | 1089 } else { |
1090 Handle<Object> val; | 1090 Handle<Object> val; |
1091 Handle<Object> key = isolate->factory()->length_string(); | |
1092 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 1091 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
1093 isolate, val, Runtime::GetObjectProperty(isolate, receiver, key), | 1092 isolate, val, Object::GetLengthFromArrayLike(isolate, receiver), false); |
1094 false); | |
1095 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, val, | |
1096 Object::ToLength(isolate, val), false); | |
1097 // TODO(caitp): Support larger element indexes (up to 2^53-1). | 1093 // TODO(caitp): Support larger element indexes (up to 2^53-1). |
1098 if (!val->ToUint32(&length)) { | 1094 if (!val->ToUint32(&length)) { |
1099 length = 0; | 1095 length = 0; |
1100 } | 1096 } |
1101 // TODO(cbruni): handle other element kind as well | 1097 // TODO(cbruni): handle other element kind as well |
1102 return IterateElementsSlow(isolate, receiver, length, visitor); | 1098 return IterateElementsSlow(isolate, receiver, length, visitor); |
1103 } | 1099 } |
1104 | 1100 |
1105 if (!HasOnlySimpleElements(isolate, *receiver)) { | 1101 if (!HasOnlySimpleElements(isolate, *receiver)) { |
1106 return IterateElementsSlow(isolate, receiver, length, visitor); | 1102 return IterateElementsSlow(isolate, receiver, length, visitor); |
(...skipping 4413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5520 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) | 5516 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) |
5521 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 5517 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
5522 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 5518 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
5523 #undef DEFINE_BUILTIN_ACCESSOR_C | 5519 #undef DEFINE_BUILTIN_ACCESSOR_C |
5524 #undef DEFINE_BUILTIN_ACCESSOR_A | 5520 #undef DEFINE_BUILTIN_ACCESSOR_A |
5525 #undef DEFINE_BUILTIN_ACCESSOR_T | 5521 #undef DEFINE_BUILTIN_ACCESSOR_T |
5526 #undef DEFINE_BUILTIN_ACCESSOR_H | 5522 #undef DEFINE_BUILTIN_ACCESSOR_H |
5527 | 5523 |
5528 } // namespace internal | 5524 } // namespace internal |
5529 } // namespace v8 | 5525 } // namespace v8 |
OLD | NEW |