wasm_module: unsafe From<u8> for Opcode takes 6% off Zig test time

This commit is contained in:
Brian Carroll 2022-12-07 00:02:41 +00:00
parent d43129d578
commit 1f90286d64
No known key found for this signature in database
GPG Key ID: 5C7B2EC4101703C0

View File

@ -187,188 +187,190 @@ pub enum OpCode {
impl From<u8> for OpCode {
fn from(x: u8) -> Self {
use OpCode::*;
match x {
0x00 => UNREACHABLE,
0x01 => NOP,
0x02 => BLOCK,
0x03 => LOOP,
0x04 => IF,
0x05 => ELSE,
0x0b => END,
0x0c => BR,
0x0d => BRIF,
0x0e => BRTABLE,
0x0f => RETURN,
0x10 => CALL,
0x11 => CALLINDIRECT,
0x1a => DROP,
0x1b => SELECT,
0x20 => GETLOCAL,
0x21 => SETLOCAL,
0x22 => TEELOCAL,
0x23 => GETGLOBAL,
0x24 => SETGLOBAL,
0x28 => I32LOAD,
0x29 => I64LOAD,
0x2a => F32LOAD,
0x2b => F64LOAD,
0x2c => I32LOAD8S,
0x2d => I32LOAD8U,
0x2e => I32LOAD16S,
0x2f => I32LOAD16U,
0x30 => I64LOAD8S,
0x31 => I64LOAD8U,
0x32 => I64LOAD16S,
0x33 => I64LOAD16U,
0x34 => I64LOAD32S,
0x35 => I64LOAD32U,
0x36 => I32STORE,
0x37 => I64STORE,
0x38 => F32STORE,
0x39 => F64STORE,
0x3a => I32STORE8,
0x3b => I32STORE16,
0x3c => I64STORE8,
0x3d => I64STORE16,
0x3e => I64STORE32,
0x3f => CURRENTMEMORY,
0x40 => GROWMEMORY,
0x41 => I32CONST,
0x42 => I64CONST,
0x43 => F32CONST,
0x44 => F64CONST,
0x45 => I32EQZ,
0x46 => I32EQ,
0x47 => I32NE,
0x48 => I32LTS,
0x49 => I32LTU,
0x4a => I32GTS,
0x4b => I32GTU,
0x4c => I32LES,
0x4d => I32LEU,
0x4e => I32GES,
0x4f => I32GEU,
0x50 => I64EQZ,
0x51 => I64EQ,
0x52 => I64NE,
0x53 => I64LTS,
0x54 => I64LTU,
0x55 => I64GTS,
0x56 => I64GTU,
0x57 => I64LES,
0x58 => I64LEU,
0x59 => I64GES,
0x5a => I64GEU,
unsafe { std::mem::transmute(x) }
0x5b => F32EQ,
0x5c => F32NE,
0x5d => F32LT,
0x5e => F32GT,
0x5f => F32LE,
0x60 => F32GE,
// use OpCode::*;
// match x {
// 0x00 => UNREACHABLE,
// 0x01 => NOP,
// 0x02 => BLOCK,
// 0x03 => LOOP,
// 0x04 => IF,
// 0x05 => ELSE,
// 0x0b => END,
// 0x0c => BR,
// 0x0d => BRIF,
// 0x0e => BRTABLE,
// 0x0f => RETURN,
// 0x10 => CALL,
// 0x11 => CALLINDIRECT,
// 0x1a => DROP,
// 0x1b => SELECT,
// 0x20 => GETLOCAL,
// 0x21 => SETLOCAL,
// 0x22 => TEELOCAL,
// 0x23 => GETGLOBAL,
// 0x24 => SETGLOBAL,
// 0x28 => I32LOAD,
// 0x29 => I64LOAD,
// 0x2a => F32LOAD,
// 0x2b => F64LOAD,
// 0x2c => I32LOAD8S,
// 0x2d => I32LOAD8U,
// 0x2e => I32LOAD16S,
// 0x2f => I32LOAD16U,
// 0x30 => I64LOAD8S,
// 0x31 => I64LOAD8U,
// 0x32 => I64LOAD16S,
// 0x33 => I64LOAD16U,
// 0x34 => I64LOAD32S,
// 0x35 => I64LOAD32U,
// 0x36 => I32STORE,
// 0x37 => I64STORE,
// 0x38 => F32STORE,
// 0x39 => F64STORE,
// 0x3a => I32STORE8,
// 0x3b => I32STORE16,
// 0x3c => I64STORE8,
// 0x3d => I64STORE16,
// 0x3e => I64STORE32,
// 0x3f => CURRENTMEMORY,
// 0x40 => GROWMEMORY,
// 0x41 => I32CONST,
// 0x42 => I64CONST,
// 0x43 => F32CONST,
// 0x44 => F64CONST,
// 0x45 => I32EQZ,
// 0x46 => I32EQ,
// 0x47 => I32NE,
// 0x48 => I32LTS,
// 0x49 => I32LTU,
// 0x4a => I32GTS,
// 0x4b => I32GTU,
// 0x4c => I32LES,
// 0x4d => I32LEU,
// 0x4e => I32GES,
// 0x4f => I32GEU,
// 0x50 => I64EQZ,
// 0x51 => I64EQ,
// 0x52 => I64NE,
// 0x53 => I64LTS,
// 0x54 => I64LTU,
// 0x55 => I64GTS,
// 0x56 => I64GTU,
// 0x57 => I64LES,
// 0x58 => I64LEU,
// 0x59 => I64GES,
// 0x5a => I64GEU,
0x61 => F64EQ,
0x62 => F64NE,
0x63 => F64LT,
0x64 => F64GT,
0x65 => F64LE,
0x66 => F64GE,
// 0x5b => F32EQ,
// 0x5c => F32NE,
// 0x5d => F32LT,
// 0x5e => F32GT,
// 0x5f => F32LE,
// 0x60 => F32GE,
0x67 => I32CLZ,
0x68 => I32CTZ,
0x69 => I32POPCNT,
0x6a => I32ADD,
0x6b => I32SUB,
0x6c => I32MUL,
0x6d => I32DIVS,
0x6e => I32DIVU,
0x6f => I32REMS,
0x70 => I32REMU,
0x71 => I32AND,
0x72 => I32OR,
0x73 => I32XOR,
0x74 => I32SHL,
0x75 => I32SHRS,
0x76 => I32SHRU,
0x77 => I32ROTL,
0x78 => I32ROTR,
// 0x61 => F64EQ,
// 0x62 => F64NE,
// 0x63 => F64LT,
// 0x64 => F64GT,
// 0x65 => F64LE,
// 0x66 => F64GE,
0x79 => I64CLZ,
0x7a => I64CTZ,
0x7b => I64POPCNT,
0x7c => I64ADD,
0x7d => I64SUB,
0x7e => I64MUL,
0x7f => I64DIVS,
0x80 => I64DIVU,
0x81 => I64REMS,
0x82 => I64REMU,
0x83 => I64AND,
0x84 => I64OR,
0x85 => I64XOR,
0x86 => I64SHL,
0x87 => I64SHRS,
0x88 => I64SHRU,
0x89 => I64ROTL,
0x8a => I64ROTR,
0x8b => F32ABS,
0x8c => F32NEG,
0x8d => F32CEIL,
0x8e => F32FLOOR,
0x8f => F32TRUNC,
0x90 => F32NEAREST,
0x91 => F32SQRT,
0x92 => F32ADD,
0x93 => F32SUB,
0x94 => F32MUL,
0x95 => F32DIV,
0x96 => F32MIN,
0x97 => F32MAX,
0x98 => F32COPYSIGN,
0x99 => F64ABS,
0x9a => F64NEG,
0x9b => F64CEIL,
0x9c => F64FLOOR,
0x9d => F64TRUNC,
0x9e => F64NEAREST,
0x9f => F64SQRT,
0xa0 => F64ADD,
0xa1 => F64SUB,
0xa2 => F64MUL,
0xa3 => F64DIV,
0xa4 => F64MIN,
0xa5 => F64MAX,
0xa6 => F64COPYSIGN,
// 0x67 => I32CLZ,
// 0x68 => I32CTZ,
// 0x69 => I32POPCNT,
// 0x6a => I32ADD,
// 0x6b => I32SUB,
// 0x6c => I32MUL,
// 0x6d => I32DIVS,
// 0x6e => I32DIVU,
// 0x6f => I32REMS,
// 0x70 => I32REMU,
// 0x71 => I32AND,
// 0x72 => I32OR,
// 0x73 => I32XOR,
// 0x74 => I32SHL,
// 0x75 => I32SHRS,
// 0x76 => I32SHRU,
// 0x77 => I32ROTL,
// 0x78 => I32ROTR,
0xa7 => I32WRAPI64,
0xa8 => I32TRUNCSF32,
0xa9 => I32TRUNCUF32,
0xaa => I32TRUNCSF64,
0xab => I32TRUNCUF64,
0xac => I64EXTENDSI32,
0xad => I64EXTENDUI32,
0xae => I64TRUNCSF32,
0xaf => I64TRUNCUF32,
0xb0 => I64TRUNCSF64,
0xb1 => I64TRUNCUF64,
0xb2 => F32CONVERTSI32,
0xb3 => F32CONVERTUI32,
0xb4 => F32CONVERTSI64,
0xb5 => F32CONVERTUI64,
0xb6 => F32DEMOTEF64,
0xb7 => F64CONVERTSI32,
0xb8 => F64CONVERTUI32,
0xb9 => F64CONVERTSI64,
0xba => F64CONVERTUI64,
0xbb => F64PROMOTEF32,
// 0x79 => I64CLZ,
// 0x7a => I64CTZ,
// 0x7b => I64POPCNT,
// 0x7c => I64ADD,
// 0x7d => I64SUB,
// 0x7e => I64MUL,
// 0x7f => I64DIVS,
// 0x80 => I64DIVU,
// 0x81 => I64REMS,
// 0x82 => I64REMU,
// 0x83 => I64AND,
// 0x84 => I64OR,
// 0x85 => I64XOR,
// 0x86 => I64SHL,
// 0x87 => I64SHRS,
// 0x88 => I64SHRU,
// 0x89 => I64ROTL,
// 0x8a => I64ROTR,
// 0x8b => F32ABS,
// 0x8c => F32NEG,
// 0x8d => F32CEIL,
// 0x8e => F32FLOOR,
// 0x8f => F32TRUNC,
// 0x90 => F32NEAREST,
// 0x91 => F32SQRT,
// 0x92 => F32ADD,
// 0x93 => F32SUB,
// 0x94 => F32MUL,
// 0x95 => F32DIV,
// 0x96 => F32MIN,
// 0x97 => F32MAX,
// 0x98 => F32COPYSIGN,
// 0x99 => F64ABS,
// 0x9a => F64NEG,
// 0x9b => F64CEIL,
// 0x9c => F64FLOOR,
// 0x9d => F64TRUNC,
// 0x9e => F64NEAREST,
// 0x9f => F64SQRT,
// 0xa0 => F64ADD,
// 0xa1 => F64SUB,
// 0xa2 => F64MUL,
// 0xa3 => F64DIV,
// 0xa4 => F64MIN,
// 0xa5 => F64MAX,
// 0xa6 => F64COPYSIGN,
0xbc => I32REINTERPRETF32,
0xbd => I64REINTERPRETF64,
0xbe => F32REINTERPRETI32,
0xbf => F64REINTERPRETI64,
_ => unreachable!(),
}
// 0xa7 => I32WRAPI64,
// 0xa8 => I32TRUNCSF32,
// 0xa9 => I32TRUNCUF32,
// 0xaa => I32TRUNCSF64,
// 0xab => I32TRUNCUF64,
// 0xac => I64EXTENDSI32,
// 0xad => I64EXTENDUI32,
// 0xae => I64TRUNCSF32,
// 0xaf => I64TRUNCUF32,
// 0xb0 => I64TRUNCSF64,
// 0xb1 => I64TRUNCUF64,
// 0xb2 => F32CONVERTSI32,
// 0xb3 => F32CONVERTUI32,
// 0xb4 => F32CONVERTSI64,
// 0xb5 => F32CONVERTUI64,
// 0xb6 => F32DEMOTEF64,
// 0xb7 => F64CONVERTSI32,
// 0xb8 => F64CONVERTUI32,
// 0xb9 => F64CONVERTSI64,
// 0xba => F64CONVERTUI64,
// 0xbb => F64PROMOTEF32,
// 0xbc => I32REINTERPRETF32,
// 0xbd => I64REINTERPRETF64,
// 0xbe => F32REINTERPRETI32,
// 0xbf => F64REINTERPRETI64,
// _ => unreachable!(),
// }
}
}