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 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1226 UNREACHABLE(); | 1226 UNREACHABLE(); |
1227 return Just<int64_t>(-1); | 1227 return Just<int64_t>(-1); |
1228 } | 1228 } |
1229 | 1229 |
1230 Maybe<int64_t> LastIndexOfValue(Isolate* isolate, Handle<JSObject> receiver, | 1230 Maybe<int64_t> LastIndexOfValue(Isolate* isolate, Handle<JSObject> receiver, |
1231 Handle<Object> value, | 1231 Handle<Object> value, |
1232 uint32_t start_from) final { | 1232 uint32_t start_from) final { |
1233 return Subclass::LastIndexOfValueImpl(isolate, receiver, value, start_from); | 1233 return Subclass::LastIndexOfValueImpl(isolate, receiver, value, start_from); |
1234 } | 1234 } |
1235 | 1235 |
1236 static void ReverseImpl(Handle<JSObject> receiver) { UNREACHABLE(); } | |
Camillo Bruni
2017/03/20 13:17:19
nit: directly use "JSObject* receiver"
There is no
Choongwoo Han
2017/03/20 13:54:21
Done.
| |
1237 | |
1238 void Reverse(Handle<JSObject> receiver) final { | |
1239 Subclass::ReverseImpl(receiver); | |
1240 } | |
1241 | |
1236 static uint32_t GetIndexForEntryImpl(FixedArrayBase* backing_store, | 1242 static uint32_t GetIndexForEntryImpl(FixedArrayBase* backing_store, |
1237 uint32_t entry) { | 1243 uint32_t entry) { |
1238 return entry; | 1244 return entry; |
1239 } | 1245 } |
1240 | 1246 |
1241 static uint32_t GetEntryForIndexImpl(Isolate* isolate, JSObject* holder, | 1247 static uint32_t GetEntryForIndexImpl(Isolate* isolate, JSObject* holder, |
1242 FixedArrayBase* backing_store, | 1248 FixedArrayBase* backing_store, |
1243 uint32_t index, PropertyFilter filter) { | 1249 uint32_t index, PropertyFilter filter) { |
1244 uint32_t length = Subclass::GetMaxIndex(holder, backing_store); | 1250 uint32_t length = Subclass::GetMaxIndex(holder, backing_store); |
1245 if (IsHoleyElementsKind(kind())) { | 1251 if (IsHoleyElementsKind(kind())) { |
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2963 | 2969 |
2964 DCHECK_LT(start_from, elements->length()); | 2970 DCHECK_LT(start_from, elements->length()); |
2965 | 2971 |
2966 uint32_t k = start_from; | 2972 uint32_t k = start_from; |
2967 do { | 2973 do { |
2968 ctype element_k = elements->get_scalar(k); | 2974 ctype element_k = elements->get_scalar(k); |
2969 if (element_k == typed_search_value) return Just<int64_t>(k); | 2975 if (element_k == typed_search_value) return Just<int64_t>(k); |
2970 } while (k-- != 0); | 2976 } while (k-- != 0); |
2971 return Just<int64_t>(-1); | 2977 return Just<int64_t>(-1); |
2972 } | 2978 } |
2979 | |
2980 static void ReverseImpl(Handle<JSObject> receiver) { | |
2981 DisallowHeapAllocation no_gc; | |
2982 DCHECK(!WasNeutered(*receiver)); | |
2983 | |
2984 BackingStore* elements = BackingStore::cast(receiver->elements()); | |
2985 | |
2986 uint32_t len = elements->length(); | |
2987 if (len == 0) return; | |
2988 | |
2989 ctype* data = static_cast<ctype*>(elements->DataPtr()); | |
2990 std::reverse(data, data + len); | |
2991 } | |
2973 }; | 2992 }; |
2974 | 2993 |
2975 #define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \ | 2994 #define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \ |
2976 typedef TypedElementsAccessor<TYPE##_ELEMENTS, ctype> \ | 2995 typedef TypedElementsAccessor<TYPE##_ELEMENTS, ctype> \ |
2977 Fixed##Type##ElementsAccessor; | 2996 Fixed##Type##ElementsAccessor; |
2978 | 2997 |
2979 TYPED_ARRAYS(FIXED_ELEMENTS_ACCESSOR) | 2998 TYPED_ARRAYS(FIXED_ELEMENTS_ACCESSOR) |
2980 #undef FIXED_ELEMENTS_ACCESSOR | 2999 #undef FIXED_ELEMENTS_ACCESSOR |
2981 | 3000 |
2982 template <typename Subclass, typename ArgumentsAccessor, typename KindTraits> | 3001 template <typename Subclass, typename ArgumentsAccessor, typename KindTraits> |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3918 insertion_index += len; | 3937 insertion_index += len; |
3919 } | 3938 } |
3920 | 3939 |
3921 DCHECK_EQ(insertion_index, result_len); | 3940 DCHECK_EQ(insertion_index, result_len); |
3922 return result_array; | 3941 return result_array; |
3923 } | 3942 } |
3924 | 3943 |
3925 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 3944 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
3926 } // namespace internal | 3945 } // namespace internal |
3927 } // namespace v8 | 3946 } // namespace v8 |
OLD | NEW |