Commit dd8a1249 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] memory.grow cannot happen in asm.js code

We do not emit this opcode in the asm.js to wasm translator, hence we do
not need to handle this case in the function body decoder.
Replace it by a DCHECK to catch bugs where we might accidentally emit
the opcode.

R=thibaudm@chromium.org

Change-Id: Ibaa07099f30b871c28e3d3cebae96277f46e3164
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2768619Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73513}
parent d95b1645
......@@ -3184,10 +3184,8 @@ class WasmFullDecoder : public WasmDecoder<validate> {
DECODE(MemoryGrow) {
if (!CheckHasMemory()) return 0;
MemoryIndexImmediate<validate> imm(this, this->pc_ + 1);
if (!VALIDATE(this->module_->origin == kWasmOrigin)) {
this->DecodeError("grow_memory is not supported for asmjs modules");
return 0;
}
// This opcode will not be emitted by the asm translator.
DCHECK_EQ(kWasmOrigin, this->module_->origin);
Value value = Peek(0, 0, kWasmI32);
Value result = CreateValue(kWasmI32);
CALL_INTERFACE_IF_REACHABLE(MemoryGrow, value, &result);
......
......@@ -2239,14 +2239,6 @@ TEST_F(FunctionBodyDecoderTest, WasmMemoryGrow) {
ExpectFailure(sigs.i_d(), code);
}
TEST_F(FunctionBodyDecoderTest, AsmJsMemoryGrow) {
module->origin = kAsmJsSloppyOrigin;
builder.InitializeMemory();
byte code[] = {WASM_LOCAL_GET(0), kExprMemoryGrow, 0};
ExpectFailure(sigs.i_i(), code);
}
TEST_F(FunctionBodyDecoderTest, AsmJsBinOpsCheckOrigin) {
ValueType float32int32float32[] = {kWasmF32, kWasmI32, kWasmF32};
FunctionSig sig_f_if(1, 2, float32int32float32);
......
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