Commit 1d32a398 authored by littledan's avatar littledan Committed by Commit bot

Revert of [wasm] Enforce that function bodies end with the \"end\" opcode....

Revert of [wasm] Enforce that function bodies end with the \"end\" opcode. (patchset #3 id:40001 of https://codereview.chromium.org/2630553002/ )

Reason for revert:
Caused tree to close by failing compilation:

https://build.chromium.org/p/client.v8/builders/V8%20Win64%20-%20clang/builds/4451

Original issue's description:
> [wasm] Enforce that function bodies end with the \"end\" opcode.
>
> R=rossberg@chromium.org
> BUG=chromium:575167
>
> Review-Url: https://codereview.chromium.org/2630553002
> Cr-Commit-Position: refs/heads/master@{#42286}
> Committed: https://chromium.googlesource.com/v8/v8/+/fcc6e85ec6b01e5367795f98aff104b1ff23f619

TBR=mtrofin@chromium.org,rossberg@chromium.org,jbroman@chromium.org,titzer@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=chromium:575167

Review-Url: https://codereview.chromium.org/2628883006
Cr-Commit-Position: refs/heads/master@{#42287}
parent fcc6e85e
......@@ -101,7 +101,6 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
uint32_t index = LookupOrInsertGlobal(fv->var, fv->type);
foreign_init_function_->EmitWithVarInt(kExprSetGlobal, index);
}
foreign_init_function_->Emit(kExprEnd);
}
Handle<FixedArray> GetForeignArgs() {
......@@ -132,7 +131,6 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
return false;
}
BuildForeignInitFunction();
init_function_->Emit(kExprEnd); // finish init function.
return true;
}
......@@ -545,10 +543,6 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
RECURSE(VisitDeclarations(scope->declarations()));
if (typer_failed_) return;
RECURSE(VisitStatements(expr->body()));
if (scope_ == kFuncScope) {
// Finish the function-body scope block.
current_function_builder_->Emit(kExprEnd);
}
}
void VisitNativeFunctionLiteral(NativeFunctionLiteral* expr) {
......
......@@ -39,6 +39,8 @@ namespace wasm {
error("Invalid opcode (enable with --" #flag ")"); \
break; \
}
// TODO(titzer): this is only for intermediate migration.
#define IMPLICIT_FUNCTION_END 1
// An SsaEnv environment carries the current local variable renaming
// as well as the current effect and control dependency in the TF graph.
......@@ -491,14 +493,41 @@ class WasmFullDecoder : public WasmDecoder {
if (failed()) return TraceFailed();
if (!control_.empty()) {
// Generate a better error message whether the unterminated control
// structure is the function body block or an innner structure.
if (control_.size() > 1) {
error(pc_, control_.back().pc, "unterminated control structure");
} else {
error("function body must end with \"end\" opcode.");
#if IMPLICIT_FUNCTION_END
// With implicit end support (old style), the function block
// remains on the stack. Other control blocks are an error.
if (control_.size() > 1) {
error(pc_, control_.back().pc, "unterminated control structure");
return TraceFailed();
}
// Assume an implicit end to the function body block.
if (control_.size() == 1) {
Control* c = &control_.back();
if (ssa_env_->go()) {
FallThruTo(c);
}
if (c->end_env->go()) {
// Push the end values onto the stack.
stack_.resize(c->stack_depth);
if (c->merge.arity == 1) {
stack_.push_back(c->merge.vals.first);
} else {
for (unsigned i = 0; i < c->merge.arity; i++) {
stack_.push_back(c->merge.vals.array[i]);
}
}
TRACE(" @%-8d #xx:%-20s|", startrel(pc_), "ImplicitReturn");
SetEnv("function:end", c->end_env);
DoReturn();
TRACE("\n");
}
}
#else
if (!control_.empty()) {
error(pc_, control_.back().pc, "unterminated control structure");
return TraceFailed();
}
......@@ -506,6 +535,7 @@ class WasmFullDecoder : public WasmDecoder {
error("function body must end with \"end\" opcode.");
return false;
}
#endif
if (FLAG_trace_wasm_decode_time) {
double ms = decode_timer.Elapsed().InMillisecondsF();
......
......@@ -59,7 +59,6 @@
// Control.
//------------------------------------------------------------------------------
#define WASM_NOP kExprNop
#define WASM_END kExprEnd
#define ARITY_0 0
#define ARITY_1 1
......
......@@ -141,7 +141,7 @@ void wasm::PrintWasmText(const WasmModule *module,
AccountingAllocator allocator;
Zone zone(&allocator, ZONE_NAME);
int line_nr = 0;
int control_depth = 1;
int control_depth = 0;
// Print the function signature.
os << "func";
......
......@@ -219,7 +219,7 @@ TEST(Breakpoint_I32Add) {
}
TEST(Step_I32Mul) {
static const int kTraceLength = 5;
static const int kTraceLength = 4;
byte code[] = {WASM_I32_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))};
WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteInterpreted);
......
......@@ -63,12 +63,6 @@ void TestModuleException(Zone* zone, WasmModuleBuilder* builder) {
void ExportAsMain(WasmFunctionBuilder* f) { f->ExportAs(CStrVector("main")); }
#define EMIT_CODE_WITH_END(f, code) \
do { \
f->EmitCode(code, sizeof(code)); \
f->Emit(kExprEnd); \
} while (false)
} // namespace
TEST(Run_WasmModule_Return114) {
......@@ -82,7 +76,7 @@ TEST(Run_WasmModule_Return114) {
WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
ExportAsMain(f);
byte code[] = {WASM_I32V_2(kReturnValue)};
EMIT_CODE_WITH_END(f, code);
f->EmitCode(code, sizeof(code));
TestModule(&zone, builder, kReturnValue);
}
Cleanup();
......@@ -101,14 +95,14 @@ TEST(Run_WasmModule_CallAdd) {
uint16_t param2 = 1;
byte code1[] = {
WASM_I32_ADD(WASM_GET_LOCAL(param1), WASM_GET_LOCAL(param2))};
EMIT_CODE_WITH_END(f1, code1);
f1->EmitCode(code1, sizeof(code1));
WasmFunctionBuilder* f2 = builder->AddFunction(sigs.i_v());
ExportAsMain(f2);
byte code2[] = {
WASM_CALL_FUNCTION(f1->func_index(), WASM_I32V_2(77), WASM_I32V_1(22))};
EMIT_CODE_WITH_END(f2, code2);
f2->EmitCode(code2, sizeof(code2));
TestModule(&zone, builder, 99);
}
Cleanup();
......@@ -127,7 +121,7 @@ TEST(Run_WasmModule_ReadLoadedDataSegment) {
ExportAsMain(f);
byte code[] = {
WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V_1(kDataSegmentDest0))};
EMIT_CODE_WITH_END(f, code);
f->EmitCode(code, sizeof(code));
byte data[] = {0xaa, 0xbb, 0xcc, 0xdd};
builder->AddDataSegment(data, sizeof(data), kDataSegmentDest0);
TestModule(&zone, builder, 0xddccbbaa);
......@@ -155,7 +149,7 @@ TEST(Run_WasmModule_CheckMemoryIsZero) {
WASM_BRV(3, WASM_I32V_1(-1)),
WASM_INC_LOCAL_BY(localIndex, 4))),
WASM_I32V_1(11))};
EMIT_CODE_WITH_END(f, code);
f->EmitCode(code, sizeof(code));
TestModule(&zone, builder, 11);
}
Cleanup();
......@@ -180,7 +174,7 @@ TEST(Run_WasmModule_CallMain_recursive) {
WASM_INC_LOCAL(localIndex)),
WASM_CALL_FUNCTION0(0)),
WASM_I32V_1(55))};
EMIT_CODE_WITH_END(f, code);
f->EmitCode(code, sizeof(code));
TestModule(&zone, builder, 55);
}
Cleanup();
......@@ -198,13 +192,13 @@ TEST(Run_WasmModule_Global) {
WasmFunctionBuilder* f1 = builder->AddFunction(sigs.i_v());
byte code1[] = {
WASM_I32_ADD(WASM_GET_GLOBAL(global1), WASM_GET_GLOBAL(global2))};
EMIT_CODE_WITH_END(f1, code1);
f1->EmitCode(code1, sizeof(code1));
WasmFunctionBuilder* f2 = builder->AddFunction(sigs.i_v());
ExportAsMain(f2);
byte code2[] = {WASM_SET_GLOBAL(global1, WASM_I32V_1(56)),
WASM_SET_GLOBAL(global2, WASM_I32V_1(41)),
WASM_RETURN1(WASM_CALL_FUNCTION0(f1->func_index()))};
EMIT_CODE_WITH_END(f2, code2);
f2->EmitCode(code2, sizeof(code2));
TestModule(&zone, builder, 97);
}
Cleanup();
......@@ -299,7 +293,7 @@ class WasmSerializationTest {
WasmFunctionBuilder* f = builder->AddFunction(sigs.i_i());
byte code[] = {WASM_GET_LOCAL(0), kExprI32Const, 1, kExprI32Add};
EMIT_CODE_WITH_END(f, code);
f->EmitCode(code, sizeof(code));
f->ExportAs(CStrVector(kFunctionName));
ZoneBuffer buffer(&zone_);
......@@ -431,7 +425,7 @@ TEST(MemorySize) {
WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
ExportAsMain(f);
byte code[] = {WASM_MEMORY_SIZE};
EMIT_CODE_WITH_END(f, code);
f->EmitCode(code, sizeof(code));
TestModule(&zone, builder, kExpectedValue);
}
Cleanup();
......@@ -450,7 +444,7 @@ TEST(Run_WasmModule_MemSize_GrowMem) {
ExportAsMain(f);
byte code[] = {WASM_GROW_MEMORY(WASM_I32V_1(10)), WASM_DROP,
WASM_MEMORY_SIZE};
EMIT_CODE_WITH_END(f, code);
f->EmitCode(code, sizeof(code));
TestModule(&zone, builder, kExpectedValue);
}
Cleanup();
......@@ -468,7 +462,7 @@ TEST(GrowMemoryZero) {
WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
ExportAsMain(f);
byte code[] = {WASM_GROW_MEMORY(WASM_I32V(0))};
EMIT_CODE_WITH_END(f, code);
f->EmitCode(code, sizeof(code));
TestModule(&zone, builder, kExpectedValue);
}
Cleanup();
......@@ -539,7 +533,7 @@ TEST(TestInterruptLoop) {
WASM_I32V(InterruptThread::signal_value_)),
WASM_BR(1))),
WASM_I32V(121)};
EMIT_CODE_WITH_END(f, code);
f->EmitCode(code, sizeof(code));
ZoneBuffer buffer(&zone);
builder->WriteTo(buffer);
......@@ -578,7 +572,7 @@ TEST(Run_WasmModule_GrowMemoryInIf) {
ExportAsMain(f);
byte code[] = {WASM_IF_ELSE_I(WASM_I32V(0), WASM_GROW_MEMORY(WASM_I32V(1)),
WASM_I32V(12))};
EMIT_CODE_WITH_END(f, code);
f->EmitCode(code, sizeof(code));
TestModule(&zone, builder, 12);
}
Cleanup();
......@@ -600,7 +594,7 @@ TEST(Run_WasmModule_GrowMemOobOffset) {
byte code[] = {WASM_GROW_MEMORY(WASM_I32V_1(1)),
WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index),
WASM_I32V(value))};
EMIT_CODE_WITH_END(f, code);
f->EmitCode(code, sizeof(code));
TestModuleException(&zone, builder);
}
Cleanup();
......@@ -623,7 +617,7 @@ TEST(Run_WasmModule_GrowMemOobFixedIndex) {
WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index),
WASM_I32V(value)),
WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V(index))};
EMIT_CODE_WITH_END(f, code);
f->EmitCode(code, sizeof(code));
HandleScope scope(isolate);
ZoneBuffer buffer(&zone);
......@@ -671,7 +665,7 @@ TEST(Run_WasmModule_GrowMemOobVariableIndex) {
WASM_STORE_MEM(MachineType::Int32(), WASM_GET_LOCAL(0),
WASM_I32V(value)),
WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0))};
EMIT_CODE_WITH_END(f, code);
f->EmitCode(code, sizeof(code));
HandleScope scope(isolate);
ZoneBuffer buffer(&zone);
......@@ -730,7 +724,7 @@ TEST(Run_WasmModule_Global_init) {
WasmFunctionBuilder* f1 = builder->AddFunction(sigs.i_v());
byte code[] = {
WASM_I32_ADD(WASM_GET_GLOBAL(global1), WASM_GET_GLOBAL(global2))};
EMIT_CODE_WITH_END(f1, code);
f1->EmitCode(code, sizeof(code));
ExportAsMain(f1);
TestModule(&zone, builder, 999999);
}
......@@ -762,7 +756,7 @@ static void RunWasmModuleGlobalInitTest(ValueType type, CType expected) {
WasmFunctionBuilder* f1 = builder->AddFunction(&sig);
byte code[] = {WASM_GET_GLOBAL(global)};
EMIT_CODE_WITH_END(f1, code);
f1->EmitCode(code, sizeof(code));
ExportAsMain(f1);
TestModule(&zone, builder, expected);
}
......
......@@ -1851,19 +1851,13 @@ static void TestBuildGraphForSimpleExpression(WasmOpcode opcode) {
FunctionSig* sig = WasmOpcodes::Signature(opcode);
if (sig->parameter_count() == 1) {
byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, static_cast<byte>(opcode),
WASM_END};
byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, static_cast<byte>(opcode)};
TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code,
code + arraysize(code));
} else {
CHECK_EQ(2, sig->parameter_count());
byte code[] = {WASM_NO_LOCALS,
kExprGetLocal,
0,
kExprGetLocal,
1,
static_cast<byte>(opcode),
WASM_END};
byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, kExprGetLocal, 1,
static_cast<byte>(opcode)};
TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code,
code + arraysize(code));
}
......
......@@ -60,11 +60,11 @@ TEST(CollectPossibleBreakpoints) {
Handle<WasmInstanceObject> instance = runner.module().instance_object();
std::vector<debug::Location> locations;
CheckLocations(instance->compiled_module(), {0, 0}, {1, 0},
{{0, 1}, {0, 2}, {0, 4}, {0, 6}, {0, 7}});
{{0, 1}, {0, 2}, {0, 4}, {0, 6}});
CheckLocations(instance->compiled_module(), {0, 2}, {0, 4}, {{0, 2}});
CheckLocations(instance->compiled_module(), {0, 2}, {0, 5}, {{0, 2}, {0, 4}});
CheckLocations(instance->compiled_module(), {0, 7}, {0, 8}, {{0, 7}});
CheckLocations(instance->compiled_module(), {0, 7}, {1, 0}, {{0, 7}});
CheckLocations(instance->compiled_module(), {0, 8}, {1, 0}, {});
CheckLocationsFail(instance->compiled_module(), {0, 9}, {1, 0});
CheckLocations(instance->compiled_module(), {0, 6}, {0, 7}, {{0, 6}});
CheckLocations(instance->compiled_module(), {0, 6}, {1, 0}, {{0, 6}});
CheckLocations(instance->compiled_module(), {0, 7}, {1, 0}, {});
CheckLocationsFail(instance->compiled_module(), {0, 8}, {1, 0});
}
......@@ -509,18 +509,7 @@ class WasmFunctionCompiler : private GraphAndBuilders {
uint32_t function_index() { return function_->func_index; }
void Build(const byte* start, const byte* end) {
size_t locals_size = local_decls.Size();
size_t total_size = end - start + locals_size + 1;
byte* buffer = static_cast<byte*>(zone()->New(total_size));
// Prepend the local decls to the code.
local_decls.Emit(buffer);
// Emit the code.
memcpy(buffer + locals_size, start, end - start);
// Append an extra end opcode.
buffer[total_size - 1] = kExprEnd;
start = buffer;
end = buffer + total_size;
local_decls.Prepend(zone(), &start, &end);
CHECK_GE(kMaxInt, end - start);
int len = static_cast<int>(end - start);
......
......@@ -15,8 +15,8 @@ var break_count = 0;
const expected_frames = [
// func-name; wasm?; pos; line; col
['call_debugger', false], // --
['wasm_2', true, 56, 2, 2], // --
['wasm_1', true, 52, 3, 2], // --
['wasm_2', true, 56, 2, 0], // --
['wasm_1', true, 52, 3, 0], // --
['testFrameInspection', false], // --
['', false]
];
......
Check that inspector gets two wasm scripts at module creation time.
Script #0 parsed. URL: v8://test/testFunction
Script #1 parsed. URL: v8://test/runTestRunction
Script #2 parsed. URL: wasm://wasm/wasm-e783515e/wasm-e783515e-0
Script #3 parsed. URL: wasm://wasm/wasm-e783515e/wasm-e783515e-1
Source for wasm://wasm/wasm-e783515e/wasm-e783515e-0:
Script #2 parsed. URL: wasm://wasm/wasm-911a065e/wasm-911a065e-0
Script #3 parsed. URL: wasm://wasm/wasm-911a065e/wasm-911a065e-1
Source for wasm://wasm/wasm-911a065e/wasm-911a065e-0:
func $nopFunction
nop
end
nop
Source for wasm://wasm/wasm-e783515e/wasm-e783515e-1:
Source for wasm://wasm/wasm-911a065e/wasm-911a065e-1:
func $main
block
i32.const 2
drop
end
block
i32.const 2
drop
end
......@@ -2,8 +2,8 @@ Check that inspector gets disassembled wasm code
Paused on debugger!
Number of frames: 5
[0] debugger;
[1] call 0
[2] call_indirect 2
[1] call 0
[2] call_indirect 2
[3] instance.exports.main();
[4] testFunction(module_bytes)
Finished.
......@@ -2,8 +2,8 @@ Running testFunction with generated WASM bytes...
Paused on 'debugger;'
Number of frames: 5
- [0] {"functionName":"call_debugger","function_lineNumber":1,"function_columnNumber":24,"lineNumber":2,"columnNumber":4}
- [1] {"functionName":"call_func","lineNumber":1,"columnNumber":2}
- [2] {"functionName":"main","lineNumber":2,"columnNumber":4}
- [1] {"functionName":"call_func","lineNumber":1,"columnNumber":0}
- [2] {"functionName":"main","lineNumber":2,"columnNumber":2}
- [3] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":14,"columnNumber":19}
- [4] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0}
Getting v8-generated stack trace...
......
......@@ -152,7 +152,7 @@ function assertTableIsValid(table) {
(function TestSet() {
let builder = new WasmModuleBuilder;
builder.addExport("wasm", builder.addFunction("", kSig_v_v).addBody([]));
builder.addExport("wasm", builder.addFunction("", kSig_v_v));
builder.addExport("host", builder.addImport("test", "f", kSig_v_v));
let {wasm, host} = builder.instantiate({test: {f() {}}}).exports;
......@@ -200,7 +200,7 @@ function assertTableIsValid(table) {
(function TestIndexing() {
let builder = new WasmModuleBuilder;
builder.addExport("wasm", builder.addFunction("", kSig_v_v).addBody([]));
builder.addExport("wasm", builder.addFunction("", kSig_v_v));
builder.addExport("host", builder.addImport("test", "f", kSig_v_v));
let {wasm, host} = builder.instantiate({test: {f() {}}}).exports;
......@@ -223,7 +223,7 @@ function assertTableIsValid(table) {
(function TestGrow() {
let builder = new WasmModuleBuilder;
builder.addExport("wasm", builder.addFunction("", kSig_v_v).addBody([]));
builder.addExport("wasm", builder.addFunction("", kSig_v_v));
builder.addExport("host", builder.addImport("test", "f", kSig_v_v));
let {wasm, host} = builder.instantiate({test: {f() {}}}).exports;
......
......@@ -98,8 +98,6 @@ class WasmFunctionBuilder {
addBody(body) {
this.body = body;
// Automatically add the end for the function block to the body.
body.push(kExprEnd);
return this;
}
......
......@@ -2439,10 +2439,10 @@ bool ValueSerializerTestWithWasm::g_saved_flag = false;
// A simple module which exports an "increment" function.
// Copied from test/mjsunit/wasm/incrementer.wasm.
const unsigned char kIncrementerWasm[] = {
0, 97, 115, 109, 13, 0, 0, 0, 1, 6, 1, 96, 1, 127, 1, 127,
3, 2, 1, 0, 7, 13, 1, 9, 105, 110, 99, 114, 101, 109, 101, 110,
116, 0, 0, 10, 9, 1, 7, 0, 32, 0, 65, 1, 106, 11,
};
0x00, 0x61, 0x73, 0x6d, 0x0d, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x60,
0x01, 0x7f, 0x01, 0x7f, 0x03, 0x02, 0x01, 0x00, 0x07, 0x0d, 0x01, 0x09,
0x69, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x00, 0x00, 0x0a,
0x08, 0x01, 0x06, 0x00, 0x20, 0x00, 0x41, 0x01, 0x6a};
TEST_F(ValueSerializerTestWithWasm, RoundTripWasmModule) {
RoundTripTest(
......@@ -2521,7 +2521,6 @@ const unsigned char kSerializedIncrementerWasm[] = {
0x2f, 0x2f};
TEST_F(ValueSerializerTestWithWasm, DecodeWasmModule) {
if (true) return; // TODO(mtrofin): fix this test
std::vector<uint8_t> raw(
kSerializedIncrementerWasm,
kSerializedIncrementerWasm + sizeof(kSerializedIncrementerWasm));
......@@ -2542,7 +2541,6 @@ const unsigned char kSerializedIncrementerWasmWithInvalidCompiledData[] = {
0x01, 0x06, 0x00, 0x20, 0x00, 0x41, 0x01, 0x6a, 0x00};
TEST_F(ValueSerializerTestWithWasm, DecodeWasmModuleWithInvalidCompiledData) {
if (true) return; // TODO(titzer): regenerate this test
std::vector<uint8_t> raw(
kSerializedIncrementerWasmWithInvalidCompiledData,
kSerializedIncrementerWasmWithInvalidCompiledData +
......
......@@ -108,19 +108,7 @@ class FunctionBodyDecoderTest : public TestWithZone {
// verification failures.
void Verify(ErrorCode expected, FunctionSig* sig, const byte* start,
const byte* end) {
size_t locals_size = local_decls.Size();
size_t total_size = end - start + locals_size + 1;
byte* buffer = static_cast<byte*>(zone()->New(total_size));
// Prepend the local decls to the code.
local_decls.Emit(buffer);
// Emit the code.
memcpy(buffer + locals_size, start, end - start);
// Append an extra end opcode.
buffer[total_size - 1] = kExprEnd;
start = buffer;
end = buffer + total_size;
local_decls.Prepend(zone(), &start, &end);
// Verify the code.
DecodeResult result = VerifyWasmCode(
zone()->allocator(), module == nullptr ? nullptr : module->module, sig,
......@@ -473,7 +461,11 @@ TEST_F(FunctionBodyDecoderTest, Block0Block0) {
}
TEST_F(FunctionBodyDecoderTest, Block0_end) {
EXPECT_FAILURE(v_v, WASM_EMPTY_BLOCK, kExprEnd);
EXPECT_VERIFIES(v_v, WASM_EMPTY_BLOCK, kExprEnd);
}
TEST_F(FunctionBodyDecoderTest, Block0_end_end) {
EXPECT_FAILURE(v_v, WASM_EMPTY_BLOCK, kExprEnd, kExprEnd);
}
TEST_F(FunctionBodyDecoderTest, Block1) {
......@@ -726,13 +718,14 @@ TEST_F(FunctionBodyDecoderTest, IfNopElseNop) {
EXPECT_VERIFIES(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_NOP));
}
TEST_F(FunctionBodyDecoderTest, If_end) {
static const byte code[] = {kExprGetLocal, 0, WASM_IF_OP, kExprEnd};
TEST_F(FunctionBodyDecoderTest, If_end_end) {
static const byte code[] = {kExprGetLocal, 0, WASM_IF_OP, kExprEnd, kExprEnd};
EXPECT_VERIFIES_C(v_i, code);
}
TEST_F(FunctionBodyDecoderTest, If_end_end) {
static const byte code[] = {kExprGetLocal, 0, WASM_IF_OP, kExprEnd, kExprEnd};
TEST_F(FunctionBodyDecoderTest, If_end_end_end) {
static const byte code[] = {kExprGetLocal, 0, WASM_IF_OP,
kExprEnd, kExprEnd, kExprEnd};
EXPECT_FAILURE_C(v_i, code);
}
......
......@@ -933,7 +933,7 @@ TEST_F(WasmFunctionVerifyTest, Ok_v_v_empty) {
kLocalF32, // --
6,
kLocalF64, // --
kExprEnd // body
kExprNop // body
};
FunctionResult result =
......
......@@ -49,7 +49,6 @@ TEST_F(WasmMacroGenTest, Constants) {
TEST_F(WasmMacroGenTest, Statements) {
EXPECT_SIZE(1, WASM_NOP);
EXPECT_SIZE(1, WASM_END);
EXPECT_SIZE(4, WASM_SET_LOCAL(0, WASM_ZERO));
......
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