diff options
author | Heejin Ahn <aheejin@gmail.com> | 2019-05-21 13:25:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-21 13:25:14 -0700 |
commit | 1a3c1a58cc7e97a846f612baf7f74a370980458f (patch) | |
tree | cbe62ea58b2c0dd6d98225265419fea0b829aeab /src/wasm/wasm-validator.cpp | |
parent | d78be9ac6c02910bbf8ac71118e68adff4fdc570 (diff) | |
download | binaryen-1a3c1a58cc7e97a846f612baf7f74a370980458f.tar.gz binaryen-1a3c1a58cc7e97a846f612baf7f74a370980458f.tar.bz2 binaryen-1a3c1a58cc7e97a846f612baf7f74a370980458f.zip |
Reflect instruction renaming in code (#2128)
- Reflected new renamed instruction names in code and tests:
- `get_local` -> `local.get`
- `set_local` -> `local.set`
- `tee_local` -> `local.tee`
- `get_global` -> `global.get`
- `set_global` -> `global.set`
- `current_memory` -> `memory.size`
- `grow_memory` -> `memory.grow`
- Removed APIs related to old instruction names in Binaryen.js and added
APIs with new names if they are missing.
- Renamed `typedef SortedVector LocalSet` to `SetsOfLocals` to prevent
name clashes.
- Resolved several TODO renaming items in wasm-binary.h:
- `TableSwitch` -> `BrTable`
- `I32ConvertI64` -> `I32WrapI64`
- `I64STruncI32` -> `I64SExtendI32`
- `I64UTruncI32` -> `I64UExtendI32`
- `F32ConvertF64` -> `F32DemoteI64`
- `F64ConvertF32` -> `F64PromoteF32`
- Renamed `BinaryenGetFeatures` and `BinaryenSetFeatures` to
`BinaryenModuleGetFeatures` and `BinaryenModuleSetFeatures` for
consistency.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 7467f1f15..01fe7e976 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -259,10 +259,10 @@ public: void visitCall(Call* curr); void visitCallIndirect(CallIndirect* curr); void visitConst(Const* curr); - void visitGetLocal(GetLocal* curr); - void visitSetLocal(SetLocal* curr); - void visitGetGlobal(GetGlobal* curr); - void visitSetGlobal(SetGlobal* curr); + void visitLocalGet(LocalGet* curr); + void visitLocalSet(LocalSet* curr); + void visitGlobalGet(GlobalGet* curr); + void visitGlobalSet(GlobalSet* curr); void visitLoad(Load* curr); void visitStore(Store* curr); void visitAtomicRMW(AtomicRMW* curr); @@ -624,7 +624,7 @@ void FunctionValidator::visitConst(Const* curr) { "all used features should be allowed"); } -void FunctionValidator::visitGetLocal(GetLocal* curr) { +void FunctionValidator::visitLocalGet(LocalGet* curr) { shouldBeTrue(curr->index < getFunction()->getNumLocals(), curr, "local.get index must be small enough"); @@ -637,7 +637,7 @@ void FunctionValidator::visitGetLocal(GetLocal* curr) { "local.get must have proper type"); } -void FunctionValidator::visitSetLocal(SetLocal* curr) { +void FunctionValidator::visitLocalSet(LocalSet* curr) { shouldBeTrue(curr->index < getFunction()->getNumLocals(), curr, "local.set index must be small enough"); @@ -653,7 +653,7 @@ void FunctionValidator::visitSetLocal(SetLocal* curr) { } } -void FunctionValidator::visitGetGlobal(GetGlobal* curr) { +void FunctionValidator::visitGlobalGet(GlobalGet* curr) { if (!info.validateGlobally) { return; } @@ -662,7 +662,7 @@ void FunctionValidator::visitGetGlobal(GetGlobal* curr) { "global.get name must be valid"); } -void FunctionValidator::visitSetGlobal(SetGlobal* curr) { +void FunctionValidator::visitGlobalSet(GlobalSet* curr) { if (!info.validateGlobally) { return; } @@ -1490,19 +1490,21 @@ void FunctionValidator::visitReturn(Return* curr) { } void FunctionValidator::visitHost(Host* curr) { + shouldBeTrue( + getModule()->memory.exists, curr, "Memory operations require a memory"); switch (curr->op) { - case GrowMemory: { + case MemoryGrow: { shouldBeEqual(curr->operands.size(), size_t(1), curr, - "grow_memory must have 1 operand"); + "memory.grow must have 1 operand"); shouldBeEqualOrFirstIsUnreachable(curr->operands[0]->type, i32, curr, - "grow_memory must have i32 operand"); + "memory.grow must have i32 operand"); break; } - case CurrentMemory: + case MemorySize: break; } } @@ -1563,7 +1565,7 @@ void FunctionValidator::visitFunction(Function* curr) { } static bool checkOffset(Expression* curr, Address add, Address max) { - if (curr->is<GetGlobal>()) { + if (curr->is<GlobalGet>()) { return true; } auto* c = curr->dynCast<Const>(); @@ -1761,7 +1763,8 @@ static void validateGlobals(Module& module, ValidationInfo& info) { "all used types should be allowed"); info.shouldBeTrue( curr->init != nullptr, curr->name, "global init must be non-null"); - info.shouldBeTrue(curr->init->is<Const>() || curr->init->is<GetGlobal>(), + assert(curr->init); + info.shouldBeTrue(curr->init->is<Const>() || curr->init->is<GlobalGet>(), curr->name, "global init must be valid"); if (!info.shouldBeEqual(curr->type, |