Commit 582f8021 authored by Maya Lekova's avatar Maya Lekova Committed by V8 LUCI CQ

[fastcall] Enhance FastApiTypedArray with aligned data getter

This CL adds a getStorageIfAligned method to obtaining a typed pointer
to the underlying TypedArray data, if the pointer to it is properly
aligned.

Bug: chromium:1052746
Change-Id: Ie8cb3438135b0da060e2b42ec71bba0e72ae4f5e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3195875Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77184}
parent 0195a5eb
......@@ -335,6 +335,14 @@ struct FastApiTypedArray : public FastApiTypedArrayBase {
return tmp;
}
bool getStorageIfAligned(T** elements) const {
if (reinterpret_cast<uintptr_t>(data_) % alignof(T) != 0) {
return false;
}
*elements = reinterpret_cast<T*>(data_);
return true;
}
private:
// This pointer should include the typed array offset applied.
// It's not guaranteed that it's aligned to sizeof(T), it's only
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment