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 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 UNREACHABLE(); | 1254 UNREACHABLE(); |
1255 return Just<int64_t>(-1); | 1255 return Just<int64_t>(-1); |
1256 } | 1256 } |
1257 | 1257 |
1258 Maybe<int64_t> LastIndexOfValue(Isolate* isolate, Handle<JSObject> receiver, | 1258 Maybe<int64_t> LastIndexOfValue(Isolate* isolate, Handle<JSObject> receiver, |
1259 Handle<Object> value, | 1259 Handle<Object> value, |
1260 uint32_t start_from) final { | 1260 uint32_t start_from) final { |
1261 return Subclass::LastIndexOfValueImpl(isolate, receiver, value, start_from); | 1261 return Subclass::LastIndexOfValueImpl(isolate, receiver, value, start_from); |
1262 } | 1262 } |
1263 | 1263 |
| 1264 static void ReverseImpl(JSObject* receiver) { UNREACHABLE(); } |
| 1265 |
| 1266 void Reverse(JSObject* receiver) final { Subclass::ReverseImpl(receiver); } |
| 1267 |
1264 static uint32_t GetIndexForEntryImpl(FixedArrayBase* backing_store, | 1268 static uint32_t GetIndexForEntryImpl(FixedArrayBase* backing_store, |
1265 uint32_t entry) { | 1269 uint32_t entry) { |
1266 return entry; | 1270 return entry; |
1267 } | 1271 } |
1268 | 1272 |
1269 static uint32_t GetEntryForIndexImpl(Isolate* isolate, JSObject* holder, | 1273 static uint32_t GetEntryForIndexImpl(Isolate* isolate, JSObject* holder, |
1270 FixedArrayBase* backing_store, | 1274 FixedArrayBase* backing_store, |
1271 uint32_t index, PropertyFilter filter) { | 1275 uint32_t index, PropertyFilter filter) { |
1272 uint32_t length = Subclass::GetMaxIndex(holder, backing_store); | 1276 uint32_t length = Subclass::GetMaxIndex(holder, backing_store); |
1273 if (IsHoleyElementsKind(kind())) { | 1277 if (IsHoleyElementsKind(kind())) { |
(...skipping 1754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3028 | 3032 |
3029 DCHECK_LT(start_from, elements->length()); | 3033 DCHECK_LT(start_from, elements->length()); |
3030 | 3034 |
3031 uint32_t k = start_from; | 3035 uint32_t k = start_from; |
3032 do { | 3036 do { |
3033 ctype element_k = elements->get_scalar(k); | 3037 ctype element_k = elements->get_scalar(k); |
3034 if (element_k == typed_search_value) return Just<int64_t>(k); | 3038 if (element_k == typed_search_value) return Just<int64_t>(k); |
3035 } while (k-- != 0); | 3039 } while (k-- != 0); |
3036 return Just<int64_t>(-1); | 3040 return Just<int64_t>(-1); |
3037 } | 3041 } |
| 3042 |
| 3043 static void ReverseImpl(JSObject* receiver) { |
| 3044 DisallowHeapAllocation no_gc; |
| 3045 DCHECK(!WasNeutered(receiver)); |
| 3046 |
| 3047 BackingStore* elements = BackingStore::cast(receiver->elements()); |
| 3048 |
| 3049 uint32_t len = elements->length(); |
| 3050 if (len == 0) return; |
| 3051 |
| 3052 ctype* data = static_cast<ctype*>(elements->DataPtr()); |
| 3053 std::reverse(data, data + len); |
| 3054 } |
3038 }; | 3055 }; |
3039 | 3056 |
3040 #define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \ | 3057 #define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \ |
3041 typedef TypedElementsAccessor<TYPE##_ELEMENTS, ctype> \ | 3058 typedef TypedElementsAccessor<TYPE##_ELEMENTS, ctype> \ |
3042 Fixed##Type##ElementsAccessor; | 3059 Fixed##Type##ElementsAccessor; |
3043 | 3060 |
3044 TYPED_ARRAYS(FIXED_ELEMENTS_ACCESSOR) | 3061 TYPED_ARRAYS(FIXED_ELEMENTS_ACCESSOR) |
3045 #undef FIXED_ELEMENTS_ACCESSOR | 3062 #undef FIXED_ELEMENTS_ACCESSOR |
3046 | 3063 |
3047 template <typename Subclass, typename ArgumentsAccessor, typename KindTraits> | 3064 template <typename Subclass, typename ArgumentsAccessor, typename KindTraits> |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3983 insertion_index += len; | 4000 insertion_index += len; |
3984 } | 4001 } |
3985 | 4002 |
3986 DCHECK_EQ(insertion_index, result_len); | 4003 DCHECK_EQ(insertion_index, result_len); |
3987 return result_array; | 4004 return result_array; |
3988 } | 4005 } |
3989 | 4006 |
3990 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 4007 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
3991 } // namespace internal | 4008 } // namespace internal |
3992 } // namespace v8 | 4009 } // namespace v8 |
OLD | NEW |