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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 if (V8_UNLIKELY(array->WasNeutered())) return Smi::FromInt(-1); | 248 if (V8_UNLIKELY(array->WasNeutered())) return Smi::FromInt(-1); |
249 | 249 |
250 Handle<Object> search_element = args.atOrUndefined(isolate, 1); | 250 Handle<Object> search_element = args.atOrUndefined(isolate, 1); |
251 ElementsAccessor* elements = array->GetElementsAccessor(); | 251 ElementsAccessor* elements = array->GetElementsAccessor(); |
252 Maybe<int64_t> result = elements->LastIndexOfValue( | 252 Maybe<int64_t> result = elements->LastIndexOfValue( |
253 isolate, array, search_element, static_cast<uint32_t>(index)); | 253 isolate, array, search_element, static_cast<uint32_t>(index)); |
254 MAYBE_RETURN(result, isolate->heap()->exception()); | 254 MAYBE_RETURN(result, isolate->heap()->exception()); |
255 return *isolate->factory()->NewNumberFromInt64(result.FromJust()); | 255 return *isolate->factory()->NewNumberFromInt64(result.FromJust()); |
256 } | 256 } |
257 | 257 |
| 258 BUILTIN(TypedArrayPrototypeReverse) { |
| 259 HandleScope scope(isolate); |
| 260 |
| 261 Handle<JSTypedArray> array; |
| 262 const char* method = "%TypedArray%.prototype.reverse"; |
| 263 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 264 isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method)); |
| 265 |
| 266 if (V8_UNLIKELY(array->WasNeutered())) return *array; |
| 267 |
| 268 ElementsAccessor* elements = array->GetElementsAccessor(); |
| 269 elements->Reverse(*array); |
| 270 return *array; |
| 271 } |
| 272 |
258 } // namespace internal | 273 } // namespace internal |
259 } // namespace v8 | 274 } // namespace v8 |
OLD | NEW |