Closed Bug 1464790 Opened 6 years ago Closed 6 years ago

js/src/wasm/WasmTypes.h: define MaxMemoryAccessSize correctly

Categories

(Core :: JavaScript Engine: JIT, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla62
Tracking Status
firefox62 --- fixed

People

(Reporter: jseward, Assigned: jseward)

Details

Attachments

(1 file)

I was studying the bounds-check stuff some more and noticed that
we have MaxMemoryAccessSize = sizeof(Val).  And I was wondering
if that is really intended, 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 gets me 24 on x86_64 and 20 on x86.

It's not harmful, since it overstates the size of the largest access
(16, unless we're doing x86 YMM loads/stores), but IIUC it is
misleading.
A possible fix.  Unfortunately the obvious scheme of using 'sizeof(Val::u)'
doesn't work because |u| is a private field.  The solution of extracting
the size with a constexpr method is the least-worst think I could think of.
Better solutions welcomed.
Attachment #8981122 - Flags: feedback?(lhansen)
Comment on attachment 8981122 [details] [diff] [review]
bug1464790-fix-MaxMemoryAccessSize-1.diff

Review of attachment 8981122 [details] [diff] [review]:
-----------------------------------------------------------------

You should ask Luke for review.
Attachment #8981122 - Flags: feedback?(lhansen) → feedback+
Attachment #8981122 - Flags: review?(luke)
Comment on attachment 8981122 [details] [diff] [review]
bug1464790-fix-MaxMemoryAccessSize-1.diff

Review of attachment 8981122 [details] [diff] [review]:
-----------------------------------------------------------------

Ah right, I suppose it is overly-conservative which can cause confusion.

::: js/src/wasm/WasmTypes.h
@@ +1866,5 @@
> +// 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");

Usually we statically assert something because the correctness of some other piece of code depends on it (in which case we comment what that code is so we can go fix it later if need be), but I can't think of how we depend on any of these 3 conditions holding.  If you can, that might be the appropriate comment for the static asserts; otherwise, if you think they are valuable as sanity checks, maybe just stick it in WasmTypes.cpp (to avoid cluttering the header) and comment that they are just sanity asserts.
Attachment #8981122 - Flags: review?(luke) → review+
Priority: -- → P3
Is there anything blocking landing here?
Flags: needinfo?(jseward)
Pushed by jseward@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/24d8e05af3d9
js/src/wasm/WasmTypes.h: define MaxMemoryAccessSize correctly.  r=luke.
https://hg.mozilla.org/mozilla-central/rev/24d8e05af3d9
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla62
Flags: needinfo?(jseward)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: