Skip to content

Commit 75ef3f7

Browse files
committed
Bug 1992130 - Fix arguments types for std::copy. r=rhunt
Differential Revision: https://phabricator.services.mozilla.com/D267284
1 parent 5f2a12b commit 75ef3f7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

js/src/wasm/WasmGcObject.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ class WasmArrayObject : public WasmGcObject,
160160
return offsetToPointer<uint8_t>(offsetOfInlineStorage());
161161
}
162162

163+
// Actual array data that follows DataHeader. The array data is a part of the
164+
// `inlineStorage`.
165+
template <typename T>
166+
T* inlineArrayElements() {
167+
return offsetToPointer<T>(offsetOfInlineArrayData());
168+
}
169+
163170
// AllocKind for object creation
164171
static inline gc::AllocKind allocKindForOOL();
165172
static inline gc::AllocKind allocKindForIL(uint32_t storageBytes);
@@ -507,9 +514,8 @@ class MOZ_RAII StableWasmArrayObjectElements {
507514
// elements.
508515
MOZ_CRASH();
509516
}
510-
std::copy(array->inlineStorage(),
511-
array->inlineStorage() + array->numElements_ * sizeof(T),
512-
ownElements_->begin());
517+
const T* src = array->inlineArrayElements<T>();
518+
std::copy(src, src + array->numElements_, ownElements_->begin());
513519
elements_ = ownElements_->begin();
514520
} else {
515521
elements_ = reinterpret_cast<T*>(array->data_);

0 commit comments

Comments
 (0)