Chromium Code Reviews| 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(); } | |
| 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 for (uint32_t i = 0, j = len - 1; i < j; i++, j--) { | |
| 2990 ctype element_i = elements->get_scalar(i); | |
| 2991 ctype element_j = elements->get_scalar(j); | |
| 2992 elements->set(i, element_j); | |
| 2993 elements->set(j, element_i); | |
| 2994 } | |
|
rongjie
2017/03/19 06:47:52
Why not try to use std::reverse on elements->DataP
Choongwoo Han
2017/03/19 09:30:31
Done.
| |
| 2995 } | |
| 2973 }; | 2996 }; |
| 2974 | 2997 |
| 2975 #define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \ | 2998 #define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \ |
| 2976 typedef TypedElementsAccessor<TYPE##_ELEMENTS, ctype> \ | 2999 typedef TypedElementsAccessor<TYPE##_ELEMENTS, ctype> \ |
| 2977 Fixed##Type##ElementsAccessor; | 3000 Fixed##Type##ElementsAccessor; |
| 2978 | 3001 |
| 2979 TYPED_ARRAYS(FIXED_ELEMENTS_ACCESSOR) | 3002 TYPED_ARRAYS(FIXED_ELEMENTS_ACCESSOR) |
| 2980 #undef FIXED_ELEMENTS_ACCESSOR | 3003 #undef FIXED_ELEMENTS_ACCESSOR |
| 2981 | 3004 |
| 2982 template <typename Subclass, typename ArgumentsAccessor, typename KindTraits> | 3005 template <typename Subclass, typename ArgumentsAccessor, typename KindTraits> |
| (...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3918 insertion_index += len; | 3941 insertion_index += len; |
| 3919 } | 3942 } |
| 3920 | 3943 |
| 3921 DCHECK_EQ(insertion_index, result_len); | 3944 DCHECK_EQ(insertion_index, result_len); |
| 3922 return result_array; | 3945 return result_array; |
| 3923 } | 3946 } |
| 3924 | 3947 |
| 3925 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 3948 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
| 3926 } // namespace internal | 3949 } // namespace internal |
| 3927 } // namespace v8 | 3950 } // namespace v8 |
| OLD | NEW |