summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-06-01 21:55:14 +0430
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-06-02 16:09:16 +0430
commit02b3238c41efb80df52d4d7962c11bd39d1fc84c (patch)
treee59cba2c1d9a3aeefce230eba4fa03e8f0ea3abb /Userland/Libraries
parent6b5d1eedcbc15077efa7c6188d34dcf2c13251be (diff)
downloadserenity-02b3238c41efb80df52d4d7962c11bd39d1fc84c.zip
LibWasm: Parse the "extend" set of instructions
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWasm/AbstractMachine/Interpreter.cpp5
-rw-r--r--Userland/Libraries/LibWasm/Opcode.h5
-rw-r--r--Userland/Libraries/LibWasm/Parser/Parser.cpp5
-rw-r--r--Userland/Libraries/LibWasm/Printer/Printer.cpp5
4 files changed, 20 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.cpp b/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.cpp
index eb08889d25..758d2ddddd 100644
--- a/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.cpp
+++ b/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.cpp
@@ -900,6 +900,11 @@ void BytecodeInterpreter::interpret(Configuration& configuration, InstructionPoi
case Instructions::table_grow.value():
case Instructions::table_size.value():
case Instructions::table_fill.value():
+ case Instructions::i32_extend8_s.value():
+ case Instructions::i32_extend16_s.value():
+ case Instructions::i64_extend8_s.value():
+ case Instructions::i64_extend16_s.value():
+ case Instructions::i64_extend32_s.value():
default:
unimplemented:;
dbgln("Instruction '{}' not implemented", instruction_name(instruction.opcode()));
diff --git a/Userland/Libraries/LibWasm/Opcode.h b/Userland/Libraries/LibWasm/Opcode.h
index 97d6ae6184..b2b6ec3a2a 100644
--- a/Userland/Libraries/LibWasm/Opcode.h
+++ b/Userland/Libraries/LibWasm/Opcode.h
@@ -187,6 +187,11 @@ static constexpr OpCode unreachable = 0x00,
i64_reinterpret_f64 = 0xbd,
f32_reinterpret_i32 = 0xbe,
f64_reinterpret_i64 = 0xbf,
+ i32_extend8_s = 0xc0,
+ i32_extend16_s = 0xc1,
+ i64_extend8_s = 0xc2,
+ i64_extend16_s = 0xc3,
+ i64_extend32_s = 0xc4,
ref_null = 0xd0,
ref_is_null = 0xd1,
ref_func = 0xd2;
diff --git a/Userland/Libraries/LibWasm/Parser/Parser.cpp b/Userland/Libraries/LibWasm/Parser/Parser.cpp
index 43c9a98263..797e9367dc 100644
--- a/Userland/Libraries/LibWasm/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWasm/Parser/Parser.cpp
@@ -631,6 +631,11 @@ ParseResult<Vector<Instruction>> Instruction::parse(InputStream& stream, Instruc
case Instructions::i64_reinterpret_f64.value():
case Instructions::f32_reinterpret_i32.value():
case Instructions::f64_reinterpret_i64.value():
+ case Instructions::i32_extend8_s.value():
+ case Instructions::i32_extend16_s.value():
+ case Instructions::i64_extend8_s.value():
+ case Instructions::i64_extend16_s.value():
+ case Instructions::i64_extend32_s.value():
return Vector { Instruction { opcode } };
case 0xfc: {
// These are multibyte instructions.
diff --git a/Userland/Libraries/LibWasm/Printer/Printer.cpp b/Userland/Libraries/LibWasm/Printer/Printer.cpp
index 0fb8ff4412..e720d61fbd 100644
--- a/Userland/Libraries/LibWasm/Printer/Printer.cpp
+++ b/Userland/Libraries/LibWasm/Printer/Printer.cpp
@@ -798,6 +798,11 @@ HashMap<Wasm::OpCode, String> Wasm::Names::instruction_names {
{ Instructions::i64_reinterpret_f64, "i64.reinterpret.f64" },
{ Instructions::f32_reinterpret_i32, "f32.reinterpret.i32" },
{ Instructions::f64_reinterpret_i64, "f64.reinterpret.i64" },
+ { Instructions::i32_extend8_s, "i32.extend8_s" },
+ { Instructions::i32_extend16_s, "i32.extend16_s" },
+ { Instructions::i64_extend8_s, "i64.extend8_s" },
+ { Instructions::i64_extend16_s, "i64.extend16_s" },
+ { Instructions::i64_extend32_s, "i64.extend32_s" },
{ Instructions::ref_null, "ref.null" },
{ Instructions::ref_is_null, "ref.is.null" },
{ Instructions::ref_func, "ref.func" },