[wasm][anyref] fix decoding of table index immediates

Before dd6f4d4f4c, this function was reading a single u8 and verifying
that it was 0x00. The referenced commit dropped this check as part of
implementing decoding for table.get, but neglected to change the read type
to u32v, which is the specified type of this immediate. Fix that.

R=ahaas@chromium.org, titzer@chromium.org

Change-Id: Ic2ce795023ec57be2c95aa79e62d3ccd1aa9c43c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1747178
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63281}
This commit is contained in:
Keno Fischer 2019-08-09 19:42:22 -04:00 committed by Commit Bot
parent ec9bc860b4
commit 6ebc808a9b
3 changed files with 5 additions and 1 deletions

View File

@ -39,6 +39,7 @@ Vewd Software AS <*@vewd.com>
Groupon <*@groupon.com>
Meteor Development Group <*@meteor.com>
Cloudflare, Inc. <*@cloudflare.com>
Julia Computing, Inc. <*@juliacomputing.com>
Aaron Bieber <deftly@gmail.com>
Abdulla Kamar <abdulla.kamar@gmail.com>

View File

@ -395,7 +395,7 @@ struct TableIndexImmediate {
unsigned length = 1;
inline TableIndexImmediate() = default;
inline TableIndexImmediate(Decoder* decoder, const byte* pc) {
index = decoder->read_u8<validate>(pc + 1, "table index");
index = decoder->read_u32v<validate>(pc + 1, &length, "table index");
}
};

View File

@ -2104,6 +2104,9 @@ TEST_F(FunctionBodyDecoderTest, TableGet) {
ExpectValidates(
&sig,
{WASM_SET_LOCAL(local_func, WASM_TABLE_GET(tab_func2, WASM_I32V(7)))});
ExpectValidates(
&sig, {WASM_SET_LOCAL(local_ref, WASM_SEQ(WASM_I32V(6), kExprTableGet,
U32V_2(tab_ref1)))});
// We can store funcref values as anyref, but not the other way around.
ExpectFailure(&sig, {WASM_SET_LOCAL(local_func,