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

Unified Diff: src/runtime/runtime-typedarray.cc

Issue 2733393002: [typedarrays] check byte offset for fast typedarray sort (Closed)
Patch Set: Use DataPtr 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/es6/typedarray-sort.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-typedarray.cc
diff --git a/src/runtime/runtime-typedarray.cc b/src/runtime/runtime-typedarray.cc
index a057fc69bd40bf38efb561ed1480259d1779d680..1ea42109b4988f6dabee20fbd37dac2a24c65fc9 100644
--- a/src/runtime/runtime-typedarray.cc
+++ b/src/runtime/runtime-typedarray.cc
@@ -375,17 +375,18 @@ RUNTIME_FUNCTION(Runtime_TypedArraySortFast) {
size_t length = array->length_value();
if (length <= 1) return *array;
+ Handle<FixedTypedArrayBase> elements(
+ FixedTypedArrayBase::cast(array->elements()));
switch (array->type()) {
-#define TYPED_ARRAY_SORT(Type, type, TYPE, ctype, size) \
- case kExternal##Type##Array: { \
- ctype* backing_store = \
- static_cast<ctype*>(array->GetBuffer()->backing_store()); \
- if (kExternal##Type##Array == kExternalFloat64Array || \
- kExternal##Type##Array == kExternalFloat32Array) \
- std::sort(backing_store, backing_store + length, CompareNum<ctype>); \
- else \
- std::sort(backing_store, backing_store + length); \
- break; \
+#define TYPED_ARRAY_SORT(Type, type, TYPE, ctype, size) \
+ case kExternal##Type##Array: { \
+ ctype* data = static_cast<ctype*>(elements->DataPtr()); \
+ if (kExternal##Type##Array == kExternalFloat64Array || \
+ kExternal##Type##Array == kExternalFloat32Array) \
+ std::sort(data, data + length, CompareNum<ctype>); \
+ else \
+ std::sort(data, data + length); \
+ break; \
}
TYPED_ARRAYS(TYPED_ARRAY_SORT)
« no previous file with comments | « no previous file | test/mjsunit/es6/typedarray-sort.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698