Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/builtins/builtins-typedarray.cc

Issue 2761453002: [typedarrays] Implement %TypedArray%.prototype.reverse in C++ (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/builtins/builtins.h ('k') | src/elements.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « src/builtins/builtins.h ('k') | src/elements.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698