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/elements.h" | 5 #include "src/elements.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 3016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3027 for (uint32_t i = 0; i < nof_indices; i++) { | 3027 for (uint32_t i = 0; i < nof_indices; i++) { |
3028 keys->AddKey(indices->get(i)); | 3028 keys->AddKey(indices->get(i)); |
3029 } | 3029 } |
3030 } | 3030 } |
3031 | 3031 |
3032 static Handle<FixedArray> DirectCollectElementIndicesImpl( | 3032 static Handle<FixedArray> DirectCollectElementIndicesImpl( |
3033 Isolate* isolate, Handle<JSObject> object, | 3033 Isolate* isolate, Handle<JSObject> object, |
3034 Handle<FixedArrayBase> backing_store, GetKeysConversion convert, | 3034 Handle<FixedArrayBase> backing_store, GetKeysConversion convert, |
3035 PropertyFilter filter, Handle<FixedArray> list, uint32_t* nof_indices, | 3035 PropertyFilter filter, Handle<FixedArray> list, uint32_t* nof_indices, |
3036 uint32_t insertion_index = 0) { | 3036 uint32_t insertion_index = 0) { |
3037 FixedArray* parameter_map = FixedArray::cast(*backing_store); | 3037 Handle<FixedArray> parameter_map(FixedArray::cast(*backing_store), isolate); |
3038 uint32_t length = parameter_map->length() - 2; | 3038 uint32_t length = parameter_map->length() - 2; |
3039 | 3039 |
3040 for (uint32_t i = 0; i < length; ++i) { | 3040 for (uint32_t i = 0; i < length; ++i) { |
3041 if (parameter_map->get(i + 2)->IsTheHole(isolate)) continue; | 3041 if (parameter_map->get(i + 2)->IsTheHole(isolate)) continue; |
3042 if (convert == GetKeysConversion::kConvertToString) { | 3042 if (convert == GetKeysConversion::kConvertToString) { |
3043 Handle<String> index_string = isolate->factory()->Uint32ToString(i); | 3043 Handle<String> index_string = isolate->factory()->Uint32ToString(i); |
3044 list->set(insertion_index, *index_string); | 3044 list->set(insertion_index, *index_string); |
3045 } else { | 3045 } else { |
3046 list->set(insertion_index, Smi::FromInt(i), SKIP_WRITE_BARRIER); | 3046 list->set(insertion_index, Smi::FromInt(i), SKIP_WRITE_BARRIER); |
3047 } | 3047 } |
3048 insertion_index++; | 3048 insertion_index++; |
3049 } | 3049 } |
3050 | 3050 |
3051 Handle<FixedArrayBase> store(FixedArrayBase::cast(parameter_map->get(1))); | 3051 Handle<FixedArrayBase> store(FixedArrayBase::cast(parameter_map->get(1))); |
3052 return ArgumentsAccessor::DirectCollectElementIndicesImpl( | 3052 return ArgumentsAccessor::DirectCollectElementIndicesImpl( |
3053 isolate, object, store, convert, filter, list, nof_indices, | 3053 isolate, object, store, convert, filter, list, nof_indices, |
3054 insertion_index); | 3054 insertion_index); |
3055 } | 3055 } |
3056 | 3056 |
3057 static Maybe<bool> IncludesValueImpl(Isolate* isolate, | 3057 static Maybe<bool> IncludesValueImpl(Isolate* isolate, |
3058 Handle<JSObject> object, | 3058 Handle<JSObject> object, |
3059 Handle<Object> value, | 3059 Handle<Object> value, |
3060 uint32_t start_from, uint32_t length) { | 3060 uint32_t start_from, uint32_t length) { |
3061 DCHECK(JSObject::PrototypeHasNoElements(isolate, *object)); | 3061 DCHECK(JSObject::PrototypeHasNoElements(isolate, *object)); |
3062 Handle<Map> original_map = handle(object->map(), isolate); | 3062 Handle<Map> original_map = handle(object->map(), isolate); |
3063 FixedArray* parameter_map = FixedArray::cast(object->elements()); | 3063 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements()), |
| 3064 isolate); |
3064 bool search_for_hole = value->IsUndefined(isolate); | 3065 bool search_for_hole = value->IsUndefined(isolate); |
3065 | 3066 |
3066 for (uint32_t k = start_from; k < length; ++k) { | 3067 for (uint32_t k = start_from; k < length; ++k) { |
3067 uint32_t entry = | 3068 uint32_t entry = |
3068 GetEntryForIndexImpl(*object, parameter_map, k, ALL_PROPERTIES); | 3069 GetEntryForIndexImpl(*object, *parameter_map, k, ALL_PROPERTIES); |
3069 if (entry == kMaxUInt32) { | 3070 if (entry == kMaxUInt32) { |
3070 if (search_for_hole) return Just(true); | 3071 if (search_for_hole) return Just(true); |
3071 continue; | 3072 continue; |
3072 } | 3073 } |
3073 | 3074 |
3074 Handle<Object> element_k = GetImpl(parameter_map, entry); | 3075 Handle<Object> element_k = GetImpl(*parameter_map, entry); |
3075 | 3076 |
3076 if (element_k->IsAccessorPair()) { | 3077 if (element_k->IsAccessorPair()) { |
3077 LookupIterator it(isolate, object, k, LookupIterator::OWN); | 3078 LookupIterator it(isolate, object, k, LookupIterator::OWN); |
3078 DCHECK(it.IsFound()); | 3079 DCHECK(it.IsFound()); |
3079 DCHECK_EQ(it.state(), LookupIterator::ACCESSOR); | 3080 DCHECK_EQ(it.state(), LookupIterator::ACCESSOR); |
3080 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, element_k, | 3081 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, element_k, |
3081 Object::GetPropertyWithAccessor(&it), | 3082 Object::GetPropertyWithAccessor(&it), |
3082 Nothing<bool>()); | 3083 Nothing<bool>()); |
3083 | 3084 |
3084 if (value->SameValueZero(*element_k)) return Just(true); | 3085 if (value->SameValueZero(*element_k)) return Just(true); |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3734 insertion_index += len; | 3735 insertion_index += len; |
3735 } | 3736 } |
3736 | 3737 |
3737 DCHECK_EQ(insertion_index, result_len); | 3738 DCHECK_EQ(insertion_index, result_len); |
3738 return result_array; | 3739 return result_array; |
3739 } | 3740 } |
3740 | 3741 |
3741 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 3742 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
3742 } // namespace internal | 3743 } // namespace internal |
3743 } // namespace v8 | 3744 } // namespace v8 |
OLD | NEW |