diff options
author | Sam Clegg <sbc@chromium.org> | 2022-02-15 08:49:03 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-15 08:49:03 -0800 |
commit | 60050a9525dd076e63de1bb314190b42d6731abb (patch) | |
tree | 0e5c3e6c755fe4bac261a3582b190656c8a34442 /src/shared-validator.cc | |
parent | 30fe5551cf983eb9bd194117caa3f0f4f2bbe865 (diff) | |
download | wabt-60050a9525dd076e63de1bb314190b42d6731abb.tar.gz wabt-60050a9525dd076e63de1bb314190b42d6731abb.tar.bz2 wabt-60050a9525dd076e63de1bb314190b42d6731abb.zip |
Initial implementation of extended-const proposal. (#1824)
The primary changes here are to the interpreter and how it handles
initializer expressions. With this change we model these are normal
function that we run during module initialization.
I imagine we could optimize this further by creating one long function
and encoding the `global.set`/`memory.init`/`table.init` into the
function itself, but this change seems like a good first step to make
the current tests pass.
Diffstat (limited to 'src/shared-validator.cc')
-rw-r--r-- | src/shared-validator.cc | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/shared-validator.cc b/src/shared-validator.cc index 8932012e..68630182 100644 --- a/src/shared-validator.cc +++ b/src/shared-validator.cc @@ -519,11 +519,21 @@ Result SharedValidator::CheckAtomicAlign(const Location& loc, return Result::Ok; } -static bool ValidInitOpcode(Opcode opcode) { - return opcode == Opcode::GlobalGet || opcode == Opcode::I32Const || - opcode == Opcode::I64Const || opcode == Opcode::F32Const || - opcode == Opcode::F64Const || opcode == Opcode::RefFunc || - opcode == Opcode::RefNull; +bool SharedValidator::ValidInitOpcode(Opcode opcode) const { + if (opcode == Opcode::GlobalGet || opcode == Opcode::I32Const || + opcode == Opcode::I64Const || opcode == Opcode::F32Const || + opcode == Opcode::F64Const || opcode == Opcode::RefFunc || + opcode == Opcode::RefNull) { + return true; + } + if (options_.features.extended_const_enabled()) { + if (opcode == Opcode::I32Mul || opcode == Opcode::I64Mul || + opcode == Opcode::I32Sub || opcode == Opcode::I64Sub || + opcode == Opcode::I32Add || opcode == Opcode::I64Add) { + return true; + } + } + return false; } Result SharedValidator::CheckInstr(Opcode opcode, const Location& loc) { |