diff --git a/src/interpreter/ByteCode.h b/src/interpreter/ByteCode.h index f2f2e44d6..4cc6c664a 100644 --- a/src/interpreter/ByteCode.h +++ b/src/interpreter/ByteCode.h @@ -677,6 +677,23 @@ class ByteCodeOffset2 : public ByteCode { ByteCodeStackOffset m_stackOffset2; }; +class ByteCodeOffset3 : public ByteCode { +public: + ByteCodeOffset3(Opcode opcode, ByteCodeStackOffset stackOffset1, ByteCodeStackOffset stackOffset2, ByteCodeStackOffset stackOffset3) + : ByteCode(opcode) + , m_stackOffsets{ stackOffset1, stackOffset2, stackOffset3 } + { + } + + const ByteCodeStackOffset* stackOffsets() const { return m_stackOffsets; } + ByteCodeStackOffset stackOffset1() const { return m_stackOffsets[0]; } + ByteCodeStackOffset stackOffset2() const { return m_stackOffsets[1]; } + ByteCodeStackOffset stackOffset3() const { return m_stackOffsets[2]; } + +protected: + ByteCodeStackOffset m_stackOffsets[3]; +}; + class ByteCodeOffsetValue : public ByteCode { public: ByteCodeOffsetValue(Opcode opcode, ByteCodeStackOffset stackOffset, uint32_t value) @@ -695,6 +712,27 @@ class ByteCodeOffsetValue : public ByteCode { uint32_t m_value; }; +class ByteCodeOffset2Value : public ByteCode { +public: + ByteCodeOffset2Value(Opcode opcode, ByteCodeStackOffset stackOffset1, ByteCodeStackOffset stackOffset2, uint32_t value) + : ByteCode(opcode) + , m_stackOffset1(stackOffset1) + , m_stackOffset2(stackOffset2) + , m_value(value) + { + } + + ByteCodeStackOffset stackOffset1() const { return m_stackOffset1; } + ByteCodeStackOffset stackOffset2() const { return m_stackOffset2; } + uint32_t uint32Value() const { return m_value; } + int32_t int32Value() const { return static_cast(m_value); } + +protected: + ByteCodeStackOffset m_stackOffset1; + ByteCodeStackOffset m_stackOffset2; + uint32_t m_value; +}; + class ByteCodeTable { public: ByteCodeTable(); @@ -790,34 +828,28 @@ class Const128 : public ByteCode { }; // dummy ByteCode for binary operation -class BinaryOperation : public ByteCode { +class BinaryOperation : public ByteCodeOffset3 { public: BinaryOperation(Opcode code, ByteCodeStackOffset src0Offset, ByteCodeStackOffset src1Offset, ByteCodeStackOffset dstOffset) - : ByteCode(code) - , m_srcOffset{ src0Offset, src1Offset } - , m_dstOffset(dstOffset) + : ByteCodeOffset3(code, src0Offset, src1Offset, dstOffset) { } - const ByteCodeStackOffset* srcOffset() const { return m_srcOffset; } - ByteCodeStackOffset dstOffset() const { return m_dstOffset; } - void setDstOffset(ByteCodeStackOffset o) { m_dstOffset = o; } + const ByteCodeStackOffset* srcOffset() const { return stackOffsets(); } + ByteCodeStackOffset dstOffset() const { return stackOffset3(); } + void setDstOffset(ByteCodeStackOffset o) { m_stackOffsets[2] = o; } #if !defined(NDEBUG) void dump(size_t pos) { } #endif - -protected: - ByteCodeStackOffset m_srcOffset[2]; - ByteCodeStackOffset m_dstOffset; }; #if !defined(NDEBUG) -#define DEFINE_BINARY_BYTECODE_DUMP(name) \ - void dump(size_t pos) \ - { \ - printf(#name " src1: %" PRIu32 " src2: %" PRIu32 " dst: %" PRIu32, (uint32_t)m_srcOffset[0], (uint32_t)m_srcOffset[1], (uint32_t)m_dstOffset); \ +#define DEFINE_BINARY_BYTECODE_DUMP(name) \ + void dump(size_t pos) \ + { \ + printf(#name " src1: %" PRIu32 " src2: %" PRIu32 " dst: %" PRIu32, (uint32_t)m_stackOffsets[0], (uint32_t)m_stackOffsets[1], (uint32_t)m_stackOffsets[2]); \ } #else #define DEFINE_BINARY_BYTECODE_DUMP(name) @@ -1312,11 +1344,10 @@ class MemoryInit : public ByteCode { ByteCodeStackOffset m_srcOffsets[3]; }; -class MemoryCopy : public ByteCode { +class MemoryCopy : public ByteCodeOffset3 { public: MemoryCopy(uint32_t srcIndex, uint32_t dstIndex, ByteCodeStackOffset src0, ByteCodeStackOffset src1, ByteCodeStackOffset src2) - : ByteCode(Opcode::MemoryCopyOpcode) - , m_srcOffsets{ src0, src1, src2 } + : ByteCodeOffset3(Opcode::MemoryCopyOpcode, src0, src1, src2) { ASSERT(srcIndex == 0); ASSERT(dstIndex == 0); @@ -1324,47 +1355,42 @@ class MemoryCopy : public ByteCode { const ByteCodeStackOffset* srcOffsets() const { - return m_srcOffsets; + return stackOffsets(); } #if !defined(NDEBUG) void dump(size_t pos) { printf("memory.copy "); - DUMP_BYTECODE_OFFSET(srcOffsets[0]); - DUMP_BYTECODE_OFFSET(srcOffsets[1]); - DUMP_BYTECODE_OFFSET(srcOffsets[2]); + DUMP_BYTECODE_OFFSET(stackOffsets[0]); + DUMP_BYTECODE_OFFSET(stackOffsets[1]); + DUMP_BYTECODE_OFFSET(stackOffsets[2]); } #endif -protected: - ByteCodeStackOffset m_srcOffsets[3]; }; -class MemoryFill : public ByteCode { +class MemoryFill : public ByteCodeOffset3 { public: MemoryFill(uint32_t memIdx, ByteCodeStackOffset src0, ByteCodeStackOffset src1, ByteCodeStackOffset src2) - : ByteCode(Opcode::MemoryFillOpcode) - , m_srcOffsets{ src0, src1, src2 } + : ByteCodeOffset3(Opcode::MemoryFillOpcode, src0, src1, src2) { ASSERT(memIdx == 0); } const ByteCodeStackOffset* srcOffsets() const { - return m_srcOffsets; + return stackOffsets(); } #if !defined(NDEBUG) void dump(size_t pos) { printf("memory.fill "); - DUMP_BYTECODE_OFFSET(srcOffsets[0]); - DUMP_BYTECODE_OFFSET(srcOffsets[1]); - DUMP_BYTECODE_OFFSET(srcOffsets[2]); + DUMP_BYTECODE_OFFSET(stackOffsets[0]); + DUMP_BYTECODE_OFFSET(stackOffsets[1]); + DUMP_BYTECODE_OFFSET(stackOffsets[2]); } #endif -protected: - ByteCodeStackOffset m_srcOffsets[3]; }; class DataDrop : public ByteCode { @@ -1392,57 +1418,44 @@ class DataDrop : public ByteCode { uint32_t m_segmentIndex; }; -class MemoryGrow : public ByteCode { +class MemoryGrow : public ByteCodeOffset2 { public: MemoryGrow(uint32_t index, ByteCodeStackOffset srcOffset, ByteCodeStackOffset dstOffset) - : ByteCode(Opcode::MemoryGrowOpcode) - , m_srcOffset(srcOffset) - , m_dstOffset(dstOffset) + : ByteCodeOffset2(Opcode::MemoryGrowOpcode, srcOffset, dstOffset) { ASSERT(index == 0); } - ByteCodeStackOffset srcOffset() const { return m_srcOffset; } - ByteCodeStackOffset dstOffset() const { return m_dstOffset; } + ByteCodeStackOffset srcOffset() const { return stackOffset1(); } + ByteCodeStackOffset dstOffset() const { return stackOffset2(); } #if !defined(NDEBUG) void dump(size_t pos) { printf("memory.grow "); - DUMP_BYTECODE_OFFSET(srcOffset); - DUMP_BYTECODE_OFFSET(dstOffset); + DUMP_BYTECODE_OFFSET(stackOffset1); + DUMP_BYTECODE_OFFSET(stackOffset2); } #endif - -protected: - ByteCodeStackOffset m_srcOffset; - ByteCodeStackOffset m_dstOffset; }; // dummy ByteCode for memory load operation -class MemoryLoad : public ByteCode { +class MemoryLoad : public ByteCodeOffset2Value { public: MemoryLoad(Opcode code, uint32_t offset, ByteCodeStackOffset srcOffset, ByteCodeStackOffset dstOffset) - : ByteCode(code) - , m_offset(offset) - , m_srcOffset(srcOffset) - , m_dstOffset(dstOffset) + : ByteCodeOffset2Value(code, srcOffset, dstOffset, offset) { } - uint32_t offset() const { return m_offset; } - ByteCodeStackOffset srcOffset() const { return m_srcOffset; } - ByteCodeStackOffset dstOffset() const { return m_dstOffset; } + uint32_t offset() const { return uint32Value(); } + ByteCodeStackOffset srcOffset() const { return stackOffset1(); } + ByteCodeStackOffset dstOffset() const { return stackOffset2(); } #if !defined(NDEBUG) void dump(size_t pos) { } #endif -protected: - uint32_t m_offset; - ByteCodeStackOffset m_srcOffset; - ByteCodeStackOffset m_dstOffset; }; // dummy ByteCode for simd memory load operation @@ -1481,7 +1494,7 @@ class SIMDMemoryLoad : public ByteCode { #define DEFINE_LOAD_BYTECODE_DUMP(name) \ void dump(size_t pos) \ { \ - printf(#name " src: %" PRIu32 " dst: %" PRIu32 " offset: %" PRIu32, (uint32_t)m_srcOffset, (uint32_t)m_dstOffset, (uint32_t)m_offset); \ + printf(#name " src: %" PRIu32 " dst: %" PRIu32 " offset: %" PRIu32, (uint32_t)srcOffset(), (uint32_t)dstOffset(), offset()); \ } #else #define DEFINE_LOAD_BYTECODE_DUMP(name) @@ -1518,29 +1531,22 @@ class SIMDMemoryLoad : public ByteCode { }; // dummy ByteCode for memory store operation -class MemoryStore : public ByteCode { +class MemoryStore : public ByteCodeOffset2Value { public: MemoryStore(Opcode opcode, uint32_t offset, ByteCodeStackOffset src0, ByteCodeStackOffset src1) - : ByteCode(opcode) - , m_offset(offset) - , m_src0Offset(src0) - , m_src1Offset(src1) + : ByteCodeOffset2Value(opcode, src0, src1, offset) { } - uint32_t offset() const { return m_offset; } - ByteCodeStackOffset src0Offset() const { return m_src0Offset; } - ByteCodeStackOffset src1Offset() const { return m_src1Offset; } + uint32_t offset() const { return uint32Value(); } + ByteCodeStackOffset src0Offset() const { return stackOffset1(); } + ByteCodeStackOffset src1Offset() const { return stackOffset2(); } #if !defined(NDEBUG) void dump(size_t pos) { } #endif -protected: - uint32_t m_offset; - ByteCodeStackOffset m_src0Offset; - ByteCodeStackOffset m_src1Offset; }; // dummy ByteCode for simd memory store operation @@ -1628,7 +1634,7 @@ class SIMDReplaceLane : public ByteCode { #define DEFINE_STORE_BYTECODE_DUMP(name) \ void dump(size_t pos) \ { \ - printf(#name " src0: %" PRIu32 " src1: %" PRIu32 " offset: %" PRIu32, (uint32_t)m_src0Offset, (uint32_t)m_src1Offset, (uint32_t)m_offset); \ + printf(#name " src0: %" PRIu32 " src1: %" PRIu32 " offset: %" PRIu32, (uint32_t)src0Offset(), (uint32_t)src1Offset(), offset()); \ } #else #define DEFINE_STORE_BYTECODE_DUMP(name) @@ -1958,7 +1964,7 @@ class V128Load32Zero : public MemoryLoad { #if !defined(NDEBUG) void dump(size_t pos) { - printf("V128Load32Zero src: %" PRIu32 " dst: %" PRIu32 " offset: %" PRIu32, (uint32_t)m_srcOffset, (uint32_t)m_dstOffset, (uint32_t)m_offset); + printf("V128Load32Zero src: %" PRIu32 " dst: %" PRIu32 " offset: %" PRIu32, (uint32_t)srcOffset(), (uint32_t)dstOffset(), offset()); } #endif }; @@ -1973,7 +1979,7 @@ class V128Load64Zero : public MemoryLoad { #if !defined(NDEBUG) void dump(size_t pos) { - printf("V128Load64Zero src: %" PRIu32 " dst: %" PRIu32 " offset: %" PRIu32, (uint32_t)m_srcOffset, (uint32_t)m_dstOffset, (uint32_t)m_offset); + printf("V128Load64Zero src: %" PRIu32 " dst: %" PRIu32 " offset: %" PRIu32, (uint32_t)srcOffset(), (uint32_t)dstOffset(), offset()); } #endif }; @@ -2005,64 +2011,48 @@ class I8X16Shuffle : public ByteCode { uint8_t m_value[16]; }; -class TableGet : public ByteCode { +class TableGet : public ByteCodeOffset2Value { public: TableGet(uint32_t index, ByteCodeStackOffset srcOffset, ByteCodeStackOffset dstOffset) - : ByteCode(Opcode::TableGetOpcode) - , m_tableIndex(index) - , m_srcOffset(srcOffset) - , m_dstOffset(dstOffset) + : ByteCodeOffset2Value(Opcode::TableGetOpcode, srcOffset, dstOffset, index) { } - uint32_t tableIndex() const { return m_tableIndex; } - ByteCodeStackOffset srcOffset() const { return m_srcOffset; } - ByteCodeStackOffset dstOffset() const { return m_dstOffset; } + ByteCodeStackOffset srcOffset() const { return stackOffset1(); } + ByteCodeStackOffset dstOffset() const { return stackOffset2(); } + uint32_t tableIndex() const { return uint32Value(); } #if !defined(NDEBUG) void dump(size_t pos) { printf("table.get "); - DUMP_BYTECODE_OFFSET(srcOffset); - DUMP_BYTECODE_OFFSET(dstOffset); - printf("tableIndex: %" PRIu32, m_tableIndex); + DUMP_BYTECODE_OFFSET(stackOffset1); + DUMP_BYTECODE_OFFSET(stackOffset2); + printf("tableIndex: %" PRIu32, tableIndex()); } #endif - -protected: - uint32_t m_tableIndex; - ByteCodeStackOffset m_srcOffset; - ByteCodeStackOffset m_dstOffset; }; -class TableSet : public ByteCode { +class TableSet : public ByteCodeOffset2Value { public: TableSet(uint32_t index, ByteCodeStackOffset src0, ByteCodeStackOffset src1) - : ByteCode(Opcode::TableSetOpcode) - , m_tableIndex(index) - , m_src0Offset(src0) - , m_src1Offset(src1) + : ByteCodeOffset2Value(Opcode::TableSetOpcode, src0, src1, index) { } - ByteCodeStackOffset src0Offset() const { return m_src0Offset; } - ByteCodeStackOffset src1Offset() const { return m_src1Offset; } - uint32_t tableIndex() const { return m_tableIndex; } + ByteCodeStackOffset src0Offset() const { return stackOffset1(); } + ByteCodeStackOffset src1Offset() const { return stackOffset2(); } + uint32_t tableIndex() const { return uint32Value(); } #if !defined(NDEBUG) void dump(size_t pos) { printf("table.set "); - DUMP_BYTECODE_OFFSET(src0Offset); - DUMP_BYTECODE_OFFSET(src1Offset); - printf("tableIndex: %" PRIu32, m_tableIndex); + DUMP_BYTECODE_OFFSET(stackOffset1); + DUMP_BYTECODE_OFFSET(stackOffset2); + printf("tableIndex: %" PRIu32, tableIndex()); } #endif - -protected: - uint32_t m_tableIndex; - ByteCodeStackOffset m_src0Offset; - ByteCodeStackOffset m_src1Offset; }; class TableGrow : public ByteCode { @@ -2378,10 +2368,6 @@ class GlobalSet128 : public ByteCodeOffsetValue { printf("index: %" PRId32, uint32Value()); } #endif - -protected: - ByteCodeStackOffset m_srcOffset; - uint32_t m_index; }; class Throw : public ByteCode { diff --git a/src/jit/ByteCodeParser.cpp b/src/jit/ByteCodeParser.cpp index cb877c60a..f44fbedf0 100644 --- a/src/jit/ByteCodeParser.cpp +++ b/src/jit/ByteCodeParser.cpp @@ -376,7 +376,10 @@ enum ParamTypes { ParamDst, ParamSrcDst, ParamSrc2, + ParamSrcDstValue, + ParamSrc2Value, ParamSrc2Dst, + ParamSrc3, }; static void compileFunction(JITCompiler* compiler) @@ -1018,13 +1021,11 @@ static void compileFunction(JITCompiler* compiler) case ByteCode::I64Load16UOpcode: case ByteCode::I64Load32SOpcode: case ByteCode::I64Load32UOpcode: { - MemoryLoad* loadOperation = reinterpret_cast(byteCode); - Instruction* instr = compiler->append(byteCode, Instruction::Load, opcode, 1, 1); - instr->setRequiredRegsDescriptor(requiredInit != OTNone ? requiredInit : OTLoadI64); - - Operand* operands = instr->operands(); - operands[0] = STACK_OFFSET(loadOperation->srcOffset()); - operands[1] = STACK_OFFSET(loadOperation->dstOffset()); + group = Instruction::Load; + paramType = ParamTypes::ParamSrcDstValue; + if (requiredInit == OTNone) { + requiredInit = OTLoadI64; + } break; } case ByteCode::F32LoadOpcode: @@ -1042,8 +1043,8 @@ static void compileFunction(JITCompiler* compiler) case ByteCode::V128Load32X2UOpcode: case ByteCode::V128Load32ZeroOpcode: case ByteCode::V128Load64ZeroOpcode: { - MemoryLoad* loadOperation = reinterpret_cast(byteCode); - Instruction* instr = compiler->append(byteCode, Instruction::Load, opcode, 1, 1); + group = Instruction::Load; + paramType = ParamTypes::ParamSrcDstValue; if (opcode == ByteCode::F32LoadOpcode) requiredInit = OTLoadF32; @@ -1051,12 +1052,6 @@ static void compileFunction(JITCompiler* compiler) requiredInit = OTLoadF64; else requiredInit = OTLoadV128; - - instr->setRequiredRegsDescriptor(requiredInit); - - Operand* operands = instr->operands(); - operands[0] = STACK_OFFSET(loadOperation->srcOffset()); - operands[1] = STACK_OFFSET(loadOperation->dstOffset()); break; } case ByteCode::V128Load8LaneOpcode: @@ -1099,20 +1094,18 @@ static void compileFunction(JITCompiler* compiler) FALLTHROUGH; #endif /* SLJIT_32BIT_ARCHITECTURE */ case ByteCode::I64StoreOpcode: { - MemoryStore* storeOperation = reinterpret_cast(byteCode); - Instruction* instr = compiler->append(byteCode, Instruction::Store, opcode, 2, 0); - instr->setRequiredRegsDescriptor(requiredInit != OTNone ? requiredInit : OTStoreI64); - - Operand* operands = instr->operands(); - operands[0] = STACK_OFFSET(storeOperation->src0Offset()); - operands[1] = STACK_OFFSET(storeOperation->src1Offset()); + group = Instruction::Store; + paramType = ParamTypes::ParamSrc2Value; + if (requiredInit == OTNone) { + requiredInit = OTStoreI64; + } break; } case ByteCode::F32StoreOpcode: case ByteCode::F64StoreOpcode: case ByteCode::V128StoreOpcode: { - MemoryStore* storeOperation = reinterpret_cast(byteCode); - Instruction* instr = compiler->append(byteCode, Instruction::Store, opcode, 2, 0); + group = Instruction::Store; + paramType = ParamTypes::ParamSrc2Value; if (opcode == ByteCode::F32StoreOpcode) requiredInit = OTStoreF32; @@ -1120,12 +1113,6 @@ static void compileFunction(JITCompiler* compiler) requiredInit = OTStoreF64; else requiredInit = OTStoreV128; - - instr->setRequiredRegsDescriptor(requiredInit); - - Operand* operands = instr->operands(); - operands[0] = STACK_OFFSET(storeOperation->src0Offset()); - operands[1] = STACK_OFFSET(storeOperation->src1Offset()); break; } case ByteCode::V128Store8LaneOpcode: @@ -1290,25 +1277,15 @@ static void compileFunction(JITCompiler* compiler) break; } case ByteCode::TableSetOpcode: { - auto tableSet = reinterpret_cast(byteCode); - - Instruction* instr = compiler->append(byteCode, Instruction::Table, opcode, 2, 0); - instr->setRequiredRegsDescriptor(OTTableSet); - - Operand* operands = instr->operands(); - operands[0] = STACK_OFFSET(tableSet->src0Offset()); - operands[1] = STACK_OFFSET(tableSet->src1Offset()); + group = Instruction::Table; + paramType = ParamTypes::ParamSrc2Value; + requiredInit = OTTableSet; break; } case ByteCode::TableGetOpcode: { - auto tableGet = reinterpret_cast(byteCode); - - Instruction* instr = compiler->append(byteCode, Instruction::Table, opcode, 1, 1); - instr->setRequiredRegsDescriptor(OTTableGet); - - Operand* operands = instr->operands(); - operands[0] = STACK_OFFSET(tableGet->srcOffset()); - operands[1] = STACK_OFFSET(tableGet->dstOffset()); + group = Instruction::Table; + paramType = ParamTypes::ParamSrcDstValue; + requiredInit = OTTableGet; break; } case ByteCode::MemorySizeOpcode: { @@ -1333,42 +1310,19 @@ static void compileFunction(JITCompiler* compiler) operands[2] = STACK_OFFSET(memoryInit->srcOffsets()[2]); break; } - case ByteCode::MemoryCopyOpcode: { - MemoryCopy* memoryCopy = reinterpret_cast(byteCode); - - Instruction* instr = compiler->append(byteCode, Instruction::Memory, opcode, 3, 0); - instr->addInfo(Instruction::kIsCallback); - instr->setRequiredRegsDescriptor(OTCallback3Arg); - - Operand* operands = instr->operands(); - operands[0] = STACK_OFFSET(memoryCopy->srcOffsets()[0]); - operands[1] = STACK_OFFSET(memoryCopy->srcOffsets()[1]); - operands[2] = STACK_OFFSET(memoryCopy->srcOffsets()[2]); - break; - } + case ByteCode::MemoryCopyOpcode: case ByteCode::MemoryFillOpcode: { - MemoryFill* memoryFill = reinterpret_cast(byteCode); - - Instruction* instr = compiler->append(byteCode, Instruction::Memory, opcode, 3, 0); - instr->addInfo(Instruction::kIsCallback); - instr->setRequiredRegsDescriptor(OTCallback3Arg); - - Operand* operands = instr->operands(); - operands[0] = STACK_OFFSET(memoryFill->srcOffsets()[0]); - operands[1] = STACK_OFFSET(memoryFill->srcOffsets()[1]); - operands[2] = STACK_OFFSET(memoryFill->srcOffsets()[2]); + group = Instruction::Memory; + paramType = ParamTypes::ParamSrc3; + info = Instruction::kIsCallback; + requiredInit = OTCallback3Arg; break; } case ByteCode::MemoryGrowOpcode: { - MemoryGrow* memoryGrow = reinterpret_cast(byteCode); - - Instruction* instr = compiler->append(byteCode, Instruction::Memory, opcode, 1, 1); - instr->addInfo(Instruction::kIsCallback); - instr->setRequiredRegsDescriptor(OTOp1I32); - - Operand* operands = instr->operands(); - operands[0] = STACK_OFFSET(memoryGrow->srcOffset()); - operands[1] = STACK_OFFSET(memoryGrow->dstOffset()); + group = Instruction::Memory; + paramType = ParamTypes::ParamSrcDst; + info = Instruction::kIsCallback; + requiredInit = OTOp1I32; break; } case ByteCode::DataDropOpcode: { @@ -1865,20 +1819,16 @@ static void compileFunction(JITCompiler* compiler) case ByteCode::I64AtomicLoad8UOpcode: case ByteCode::I64AtomicLoad16UOpcode: case ByteCode::I64AtomicLoad32UOpcode: { - Instruction* instr = compiler->append(byteCode, Instruction::Load, opcode, 1, 1); + group = Instruction::Load; + paramType = ParamTypes::ParamSrcDstValue; #if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE) if (opcode == ByteCode::I64AtomicLoadOpcode) { info = Instruction::kIsCallback; } #endif /* SLJIT_32BIT_ARCHITECTURE */ - instr->addInfo(info); - instr->setRequiredRegsDescriptor(requiredInit != OTNone ? requiredInit : OTLoadI64); - - MemoryLoad* loadOperation = reinterpret_cast(byteCode); - Operand* operands = instr->operands(); - - operands[0] = STACK_OFFSET(loadOperation->srcOffset()); - operands[1] = STACK_OFFSET(loadOperation->dstOffset()); + if (requiredInit == OTNone) { + requiredInit = OTLoadI64; + } break; } case ByteCode::I32AtomicStoreOpcode: @@ -1892,20 +1842,16 @@ static void compileFunction(JITCompiler* compiler) case ByteCode::I64AtomicStore8Opcode: case ByteCode::I64AtomicStore16Opcode: case ByteCode::I64AtomicStore32Opcode: { - Instruction* instr = compiler->append(byteCode, Instruction::Store, opcode, 2, 0); + group = Instruction::Store; + paramType = ParamTypes::ParamSrc2Value; #if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE) if (opcode == ByteCode::I64AtomicStoreOpcode) { info = Instruction::kIsCallback; } #endif /* SLJIT_32BIT_ARCHITECTURE */ - instr->addInfo(info); - instr->setRequiredRegsDescriptor(requiredInit != OTNone ? requiredInit : OTStoreI64); - - MemoryStore* atomicStore = reinterpret_cast(byteCode); - Operand* operands = instr->operands(); - - operands[0] = STACK_OFFSET(atomicStore->src0Offset()); - operands[1] = STACK_OFFSET(atomicStore->src1Offset()); + if (requiredInit == OTNone) { + requiredInit = OTStoreI64; + } break; } case ByteCode::I32AtomicRmwAddOpcode: @@ -2009,19 +1955,37 @@ static void compileFunction(JITCompiler* compiler) operands[1] = STACK_OFFSET(offset2Operation->stackOffset2()); break; } - case ParamTypes::ParamSrc2Dst: { + case ParamTypes::ParamSrcDstValue: + case ParamTypes::ParamSrc2Value: { + ASSERT(group != Instruction::Any); + + uint32_t resultCount = (paramType == ParamTypes::ParamSrcDstValue) ? 1 : 0; + Instruction* instr = compiler->append(byteCode, group, opcode, 2 - resultCount, resultCount); + instr->addInfo(info); + instr->setRequiredRegsDescriptor(requiredInit); + + ByteCodeOffset2Value* offset2Operation = reinterpret_cast(byteCode); + + Operand* operands = instr->operands(); + operands[0] = STACK_OFFSET(offset2Operation->stackOffset1()); + operands[1] = STACK_OFFSET(offset2Operation->stackOffset2()); + break; + } + case ParamTypes::ParamSrc2Dst: + case ParamTypes::ParamSrc3: { ASSERT(group != Instruction::Any); - Instruction* instr = compiler->append(byteCode, group, opcode, 2, 1); + uint32_t resultCount = (paramType == ParamTypes::ParamSrc2Dst) ? 1 : 0; + Instruction* instr = compiler->append(byteCode, group, opcode, 3 - resultCount, resultCount); instr->addInfo(info); instr->setRequiredRegsDescriptor(requiredInit); - BinaryOperation* binaryOperation = reinterpret_cast(byteCode); + ByteCodeOffset3* offset3Operation = reinterpret_cast(byteCode); Operand* operands = instr->operands(); - operands[0] = STACK_OFFSET(binaryOperation->srcOffset()[0]); - operands[1] = STACK_OFFSET(binaryOperation->srcOffset()[1]); - operands[2] = STACK_OFFSET(binaryOperation->dstOffset()); + operands[0] = STACK_OFFSET(offset3Operation->stackOffset1()); + operands[1] = STACK_OFFSET(offset3Operation->stackOffset2()); + operands[2] = STACK_OFFSET(offset3Operation->stackOffset3()); break; } default: { diff --git a/src/jit/MemoryInl.h b/src/jit/MemoryInl.h index 1c45f2402..1c246d3bd 100644 --- a/src/jit/MemoryInl.h +++ b/src/jit/MemoryInl.h @@ -850,7 +850,7 @@ static void emitStore(sljit_compiler* compiler, Instruction* instr) if (instr->opcode() != ByteCode::Store32Opcode && instr->opcode() != ByteCode::Store64Opcode) { #ifdef HAS_SIMD - if (opcode != 0) { + if (opcode != 0 || size == 16) { #endif /* HAS_SIMD */ MemoryStore* storeOperation = reinterpret_cast(instr->byteCode()); offset = storeOperation->offset();