OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/builtins/builtins-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
7 #include "src/counters.h" | 7 #include "src/counters.h" |
8 #include "src/elements.h" | 8 #include "src/elements.h" |
9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
10 | 10 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 if (V8_UNLIKELY(array->WasNeutered())) return Smi::FromInt(-1); | 199 if (V8_UNLIKELY(array->WasNeutered())) return Smi::FromInt(-1); |
200 | 200 |
201 Handle<Object> search_element = args.atOrUndefined(isolate, 1); | 201 Handle<Object> search_element = args.atOrUndefined(isolate, 1); |
202 ElementsAccessor* elements = array->GetElementsAccessor(); | 202 ElementsAccessor* elements = array->GetElementsAccessor(); |
203 Maybe<int64_t> result = elements->LastIndexOfValue( | 203 Maybe<int64_t> result = elements->LastIndexOfValue( |
204 isolate, array, search_element, static_cast<uint32_t>(index)); | 204 isolate, array, search_element, static_cast<uint32_t>(index)); |
205 MAYBE_RETURN(result, isolate->heap()->exception()); | 205 MAYBE_RETURN(result, isolate->heap()->exception()); |
206 return *isolate->factory()->NewNumberFromInt64(result.FromJust()); | 206 return *isolate->factory()->NewNumberFromInt64(result.FromJust()); |
207 } | 207 } |
208 | 208 |
| 209 BUILTIN(TypedArrayPrototypeReverse) { |
| 210 HandleScope scope(isolate); |
| 211 |
| 212 Handle<JSTypedArray> array; |
| 213 const char* method = "%TypedArray%.prototype.reverse"; |
| 214 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 215 isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method)); |
| 216 |
| 217 if (V8_UNLIKELY(array->WasNeutered())) return *array; |
| 218 |
| 219 ElementsAccessor* elements = array->GetElementsAccessor(); |
| 220 elements->Reverse(array); |
| 221 return *array; |
| 222 } |
| 223 |
209 } // namespace internal | 224 } // namespace internal |
210 } // namespace v8 | 225 } // namespace v8 |
OLD | NEW |