| 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 2928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2939 if (!HasEntryImpl(elements, entry)) continue; | 2939 if (!HasEntryImpl(elements, entry)) continue; |
| 2940 Handle<Object> value = GetImpl(elements, entry); | 2940 Handle<Object> value = GetImpl(elements, entry); |
| 2941 accumulator->AddKey(value, convert); | 2941 accumulator->AddKey(value, convert); |
| 2942 } | 2942 } |
| 2943 } | 2943 } |
| 2944 | 2944 |
| 2945 static bool HasEntryImpl(FixedArrayBase* parameters, uint32_t entry) { | 2945 static bool HasEntryImpl(FixedArrayBase* parameters, uint32_t entry) { |
| 2946 FixedArray* parameter_map = FixedArray::cast(parameters); | 2946 FixedArray* parameter_map = FixedArray::cast(parameters); |
| 2947 uint32_t length = parameter_map->length() - 2; | 2947 uint32_t length = parameter_map->length() - 2; |
| 2948 if (entry < length) { | 2948 if (entry < length) { |
| 2949 return !GetParameterMapArg(parameter_map, entry) | 2949 return HasParameterMapArg(parameter_map, entry); |
| 2950 ->IsTheHole(parameter_map->GetIsolate()); | |
| 2951 } | 2950 } |
| 2952 | 2951 |
| 2953 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); | 2952 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); |
| 2954 return ArgumentsAccessor::HasEntryImpl(arguments, entry - length); | 2953 return ArgumentsAccessor::HasEntryImpl(arguments, entry - length); |
| 2955 } | 2954 } |
| 2956 | 2955 |
| 2957 static bool HasAccessorsImpl(JSObject* holder, | 2956 static bool HasAccessorsImpl(JSObject* holder, |
| 2958 FixedArrayBase* backing_store) { | 2957 FixedArrayBase* backing_store) { |
| 2959 FixedArray* parameter_map = FixedArray::cast(backing_store); | 2958 FixedArray* parameter_map = FixedArray::cast(backing_store); |
| 2960 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); | 2959 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); |
| 2961 return ArgumentsAccessor::HasAccessorsImpl(holder, arguments); | 2960 return ArgumentsAccessor::HasAccessorsImpl(holder, arguments); |
| 2962 } | 2961 } |
| 2963 | 2962 |
| 2964 static uint32_t GetIndexForEntryImpl(FixedArrayBase* parameters, | 2963 static uint32_t GetIndexForEntryImpl(FixedArrayBase* parameters, |
| 2965 uint32_t entry) { | 2964 uint32_t entry) { |
| 2966 FixedArray* parameter_map = FixedArray::cast(parameters); | 2965 FixedArray* parameter_map = FixedArray::cast(parameters); |
| 2967 uint32_t length = parameter_map->length() - 2; | 2966 uint32_t length = parameter_map->length() - 2; |
| 2968 if (entry < length) return entry; | 2967 if (entry < length) return entry; |
| 2969 | 2968 |
| 2970 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 2969 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| 2971 return ArgumentsAccessor::GetIndexForEntryImpl(arguments, entry - length); | 2970 return ArgumentsAccessor::GetIndexForEntryImpl(arguments, entry - length); |
| 2972 } | 2971 } |
| 2973 | 2972 |
| 2974 static uint32_t GetEntryForIndexImpl(JSObject* holder, | 2973 static uint32_t GetEntryForIndexImpl(JSObject* holder, |
| 2975 FixedArrayBase* parameters, | 2974 FixedArrayBase* parameters, |
| 2976 uint32_t index, PropertyFilter filter) { | 2975 uint32_t index, PropertyFilter filter) { |
| 2977 FixedArray* parameter_map = FixedArray::cast(parameters); | 2976 FixedArray* parameter_map = FixedArray::cast(parameters); |
| 2978 Object* probe = GetParameterMapArg(parameter_map, index); | 2977 if (HasParameterMapArg(parameter_map, index)) return index; |
| 2979 if (!probe->IsTheHole(holder->GetIsolate())) return index; | |
| 2980 | 2978 |
| 2981 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 2979 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| 2982 uint32_t entry = ArgumentsAccessor::GetEntryForIndexImpl(holder, arguments, | 2980 uint32_t entry = ArgumentsAccessor::GetEntryForIndexImpl(holder, arguments, |
| 2983 index, filter); | 2981 index, filter); |
| 2984 if (entry == kMaxUInt32) return kMaxUInt32; | 2982 if (entry == kMaxUInt32) return kMaxUInt32; |
| 2985 return (parameter_map->length() - 2) + entry; | 2983 return (parameter_map->length() - 2) + entry; |
| 2986 } | 2984 } |
| 2987 | 2985 |
| 2988 static PropertyDetails GetDetailsImpl(JSObject* holder, uint32_t entry) { | 2986 static PropertyDetails GetDetailsImpl(JSObject* holder, uint32_t entry) { |
| 2989 FixedArray* parameter_map = FixedArray::cast(holder->elements()); | 2987 FixedArray* parameter_map = FixedArray::cast(holder->elements()); |
| 2990 uint32_t length = parameter_map->length() - 2; | 2988 uint32_t length = parameter_map->length() - 2; |
| 2991 if (entry < length) { | 2989 if (entry < length) { |
| 2992 return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell); | 2990 return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell); |
| 2993 } | 2991 } |
| 2994 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 2992 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| 2995 return ArgumentsAccessor::GetDetailsImpl(arguments, entry - length); | 2993 return ArgumentsAccessor::GetDetailsImpl(arguments, entry - length); |
| 2996 } | 2994 } |
| 2997 | 2995 |
| 2998 static Object* GetParameterMapArg(FixedArray* parameter_map, uint32_t index) { | 2996 static bool HasParameterMapArg(FixedArray* parameter_map, uint32_t index) { |
| 2999 uint32_t length = parameter_map->length() - 2; | 2997 uint32_t length = parameter_map->length() - 2; |
| 3000 return index < length | 2998 if (index >= length) return false; |
| 3001 ? parameter_map->get(index + 2) | 2999 return !parameter_map->get(index + 2)->IsTheHole( |
| 3002 : Object::cast(parameter_map->GetHeap()->the_hole_value()); | 3000 parameter_map->GetIsolate()); |
| 3003 } | 3001 } |
| 3004 | 3002 |
| 3005 static void DeleteImpl(Handle<JSObject> obj, uint32_t entry) { | 3003 static void DeleteImpl(Handle<JSObject> obj, uint32_t entry) { |
| 3006 FixedArray* parameter_map = FixedArray::cast(obj->elements()); | 3004 FixedArray* parameter_map = FixedArray::cast(obj->elements()); |
| 3007 uint32_t length = static_cast<uint32_t>(parameter_map->length()) - 2; | 3005 uint32_t length = static_cast<uint32_t>(parameter_map->length()) - 2; |
| 3008 if (entry < length) { | 3006 if (entry < length) { |
| 3009 // TODO(kmillikin): We could check if this was the last aliased | 3007 // TODO(kmillikin): We could check if this was the last aliased |
| 3010 // parameter, and revert to normal elements in that case. That | 3008 // parameter, and revert to normal elements in that case. That |
| 3011 // would enable GC of the context. | 3009 // would enable GC of the context. |
| 3012 parameter_map->set_the_hole(entry + 2); | 3010 parameter_map->set_the_hole(entry + 2); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3095 } | 3093 } |
| 3096 return Just(false); | 3094 return Just(false); |
| 3097 } | 3095 } |
| 3098 | 3096 |
| 3099 static Maybe<int64_t> IndexOfValueImpl(Isolate* isolate, | 3097 static Maybe<int64_t> IndexOfValueImpl(Isolate* isolate, |
| 3100 Handle<JSObject> object, | 3098 Handle<JSObject> object, |
| 3101 Handle<Object> value, | 3099 Handle<Object> value, |
| 3102 uint32_t start_from, uint32_t length) { | 3100 uint32_t start_from, uint32_t length) { |
| 3103 DCHECK(JSObject::PrototypeHasNoElements(isolate, *object)); | 3101 DCHECK(JSObject::PrototypeHasNoElements(isolate, *object)); |
| 3104 Handle<Map> original_map = handle(object->map(), isolate); | 3102 Handle<Map> original_map = handle(object->map(), isolate); |
| 3105 FixedArray* parameter_map = FixedArray::cast(object->elements()); | 3103 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements()), |
| 3104 isolate); |
| 3106 | 3105 |
| 3107 for (uint32_t k = start_from; k < length; ++k) { | 3106 for (uint32_t k = start_from; k < length; ++k) { |
| 3108 uint32_t entry = | 3107 uint32_t entry = |
| 3109 GetEntryForIndexImpl(*object, parameter_map, k, ALL_PROPERTIES); | 3108 GetEntryForIndexImpl(*object, *parameter_map, k, ALL_PROPERTIES); |
| 3110 if (entry == kMaxUInt32) { | 3109 if (entry == kMaxUInt32) { |
| 3111 continue; | 3110 continue; |
| 3112 } | 3111 } |
| 3113 | 3112 |
| 3114 Handle<Object> element_k = GetImpl(parameter_map, entry); | 3113 Handle<Object> element_k = GetImpl(*parameter_map, entry); |
| 3115 | 3114 |
| 3116 if (element_k->IsAccessorPair()) { | 3115 if (element_k->IsAccessorPair()) { |
| 3117 LookupIterator it(isolate, object, k, LookupIterator::OWN); | 3116 LookupIterator it(isolate, object, k, LookupIterator::OWN); |
| 3118 DCHECK(it.IsFound()); | 3117 DCHECK(it.IsFound()); |
| 3119 DCHECK_EQ(it.state(), LookupIterator::ACCESSOR); | 3118 DCHECK_EQ(it.state(), LookupIterator::ACCESSOR); |
| 3120 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, element_k, | 3119 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, element_k, |
| 3121 Object::GetPropertyWithAccessor(&it), | 3120 Object::GetPropertyWithAccessor(&it), |
| 3122 Nothing<int64_t>()); | 3121 Nothing<int64_t>()); |
| 3123 | 3122 |
| 3124 if (value->StrictEquals(*element_k)) { | 3123 if (value->StrictEquals(*element_k)) { |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3735 insertion_index += len; | 3734 insertion_index += len; |
| 3736 } | 3735 } |
| 3737 | 3736 |
| 3738 DCHECK_EQ(insertion_index, result_len); | 3737 DCHECK_EQ(insertion_index, result_len); |
| 3739 return result_array; | 3738 return result_array; |
| 3740 } | 3739 } |
| 3741 | 3740 |
| 3742 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 3741 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
| 3743 } // namespace internal | 3742 } // namespace internal |
| 3744 } // namespace v8 | 3743 } // namespace v8 |
| OLD | NEW |