зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1464790 - js/src/wasm/WasmTypes.h: define MaxMemoryAccessSize correctly. r=luke.
Currently we have MaxMemoryAccessSize = sizeof(Val). That doesn't seem right, since it includes not only the size of the largest underlying value, but also the size of the tag (Val::type_) field. Indeed, printing MaxMemoryAccessSize produces 24 on x86_64 and 20 on x86. This patch fixes it, and adds some sanity checks too. --HG-- extra : rebase_source : edef632fee092f03b325565cb4d6a8d78e8d8721
This commit is contained in:
Родитель
dfb24605c3
Коммит
974bd72b3c
|
@ -47,11 +47,19 @@ using mozilla::MakeEnumeratedRange;
|
|||
# endif
|
||||
#endif
|
||||
|
||||
// Another sanity check.
|
||||
// More sanity checks.
|
||||
|
||||
static_assert(MaxMemoryInitialPages <= ArrayBufferObject::MaxBufferByteLength / PageSize,
|
||||
"Memory sizing constraint");
|
||||
|
||||
// All plausible targets must be able to do at least IEEE754 double
|
||||
// loads/stores, hence the lower limit of 8. Some Intel processors support
|
||||
// AVX-512 loads/stores, hence the upper limit of 64.
|
||||
static_assert(MaxMemoryAccessSize >= 8, "MaxMemoryAccessSize too low");
|
||||
static_assert(MaxMemoryAccessSize <= 64, "MaxMemoryAccessSize too high");
|
||||
static_assert((MaxMemoryAccessSize & (MaxMemoryAccessSize-1)) == 0,
|
||||
"MaxMemoryAccessSize is not a power of two");
|
||||
|
||||
void
|
||||
Val::writePayload(uint8_t* dst) const
|
||||
{
|
||||
|
|
|
@ -653,6 +653,7 @@ class Val
|
|||
|
||||
ValType type() const { return type_; }
|
||||
bool isSimd() const { return IsSimdType(type()); }
|
||||
static constexpr size_t sizeofLargestValue() { return sizeof(u); }
|
||||
|
||||
uint32_t i32() const { MOZ_ASSERT(type_ == ValType::I32); return u.i32_; }
|
||||
uint64_t i64() const { MOZ_ASSERT(type_ == ValType::I64); return u.i64_; }
|
||||
|
@ -1993,7 +1994,7 @@ static const unsigned PageSize = 64 * 1024;
|
|||
// catch the overflow. MaxMemoryAccessSize is a conservative approximation of
|
||||
// the maximum guard space needed to catch all unaligned overflows.
|
||||
|
||||
static const unsigned MaxMemoryAccessSize = sizeof(Val);
|
||||
static const unsigned MaxMemoryAccessSize = Val::sizeofLargestValue();
|
||||
|
||||
#ifdef WASM_HUGE_MEMORY
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче