Changeset 285971 in webkit
- Timestamp:
- Nov 17, 2021, 6:47:45 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/microbenchmarks/typed-array-set-uint8-and-uint8clamped.js (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r285850 r285971 1 2021-11-17 Saam Barati <sbarati@apple.com> 2 3 Run the memmove fast path in JSGenericTypedArrayView<Adaptor>::set when using a combination of Uint8 and Uint8Clamped 4 https://bugs.webkit.org/show_bug.cgi?id=233271 5 <rdar://85259288> 6 7 Reviewed by Yusuke Suzuki. 8 9 * microbenchmarks/typed-array-set-uint8-and-uint8clamped.js: Added. 10 1 11 2021-11-15 Yusuke Suzuki <ysuzuki@apple.com> 2 12 -
trunk/Source/JavaScriptCore/ChangeLog
r285955 r285971 1 2021-11-17 Saam Barati <sbarati@apple.com> 2 3 Run the memmove fast path in JSGenericTypedArrayView<Adaptor>::set when using a combination of Uint8 and Uint8Clamped 4 https://bugs.webkit.org/show_bug.cgi?id=233271 5 <rdar://85259288> 6 7 Reviewed by Yusuke Suzuki. 8 9 We have a fast path for running memmove when both the thing being 10 copied from and the thing being copied to have the same typed array 11 type. However, when copying from a Uint8Array into a Uint8ClampedArray, 12 or vice versa, we were going down the slow path. In this case, 13 we can still take the fast path, since we're guaranteed that storing 14 into a Uint8ClampedArray from a Uint8Array will never actually need 15 to clamp values. And when storing from a Uint8ClampedArray into a 16 Uint8Array, the values can trivially be copied over. 17 18 This patch is a 100x speedup on the attached microbenchmark. 19 20 * runtime/JSGenericTypedArrayViewInlines.h: 21 (JSC::JSGenericTypedArrayView<Adaptor>::set): 22 1 23 2021-11-17 Yusuke Suzuki <ysuzuki@apple.com> 2 24 -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h
r285730 r285971 256 256 auto scope = DECLARE_THROW_SCOPE(vm); 257 257 258 const ClassInfo* ci = object->classInfo(vm); 259 if (ci->typedArrayStorageType == Adaptor::typeValue) { 260 // The super fast case: we can just memmove since we're the same type. 261 JSGenericTypedArrayView* other = jsCast<JSGenericTypedArrayView*>(object); 258 auto memmoveFastPath = [&] (auto* other) { 259 // The super fast case: we can just memmove since we're the same underlying storage type. 262 260 length = std::min(length, other->length()); 263 261 … … 268 266 return false; 269 267 268 RELEASE_ASSERT((std::is_same_v<decltype(typedVector()), decltype(other->typedVector())>)); 270 269 memmove(typedVector() + offset, other->typedVector() + objectOffset, length * elementSize); 271 270 return true; 271 }; 272 273 const ClassInfo* ci = object->classInfo(vm); 274 if (ci->typedArrayStorageType == Adaptor::typeValue) 275 return memmoveFastPath(jsCast<JSGenericTypedArrayView*>(object)); 276 277 auto isSomeUint8 = [] (TypedArrayType type) { 278 return type == TypedArrayType::TypeUint8 || type == TypedArrayType::TypeUint8Clamped; 279 }; 280 if (isSomeUint8(ci->typedArrayStorageType) && isSomeUint8(Adaptor::typeValue)) { 281 if (ci->typedArrayStorageType == TypedArrayType::TypeUint8) 282 return memmoveFastPath(jsCast<JSGenericTypedArrayView<Uint8Adaptor>*>(object)); 283 return memmoveFastPath(jsCast<JSGenericTypedArrayView<Uint8ClampedAdaptor>*>(object)); 272 284 } 273 285
Note:
See TracChangeset
for help on using the changeset viewer.