From 85e05aae80cc85eb76dca7c77e2915f6925219c0 Mon Sep 17 00:00:00 2001 From: Katelyn Gadd Date: Tue, 6 Aug 2024 10:09:12 -0700 Subject: [PATCH 1/4] Can't build locally, so let's see if this works. Who knows --- src/mono/browser/runtime/jiterpreter-trace-generator.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mono/browser/runtime/jiterpreter-trace-generator.ts b/src/mono/browser/runtime/jiterpreter-trace-generator.ts index dab0be4b2abed0..742cf675d5641a 100644 --- a/src/mono/browser/runtime/jiterpreter-trace-generator.ts +++ b/src/mono/browser/runtime/jiterpreter-trace-generator.ts @@ -2874,9 +2874,6 @@ function emit_branch ( if (relopbranchTable[opcode] === undefined) throw new Error(`Unsupported relop branch opcode: ${getOpcodeName(opcode)}`); - if (cwraps.mono_jiterp_get_opcode_info(opcode, OpcodeInfoType.Length) !== 4) - throw new Error(`Unsupported long branch opcode: ${getOpcodeName(opcode)}`); - break; } } From 7b5b0c7075bedbbdf1a49fdeeb546f05ae8b17cd Mon Sep 17 00:00:00 2001 From: Katelyn Gadd Date: Tue, 6 Aug 2024 12:53:18 -0700 Subject: [PATCH 2/4] Fix long branches with immediates --- .../browser/runtime/jiterpreter-opcodes.ts | 1 - .../browser/runtime/jiterpreter-tables.ts | 64 +++++++++---------- .../runtime/jiterpreter-trace-generator.ts | 35 ++++++++-- 3 files changed, 63 insertions(+), 37 deletions(-) diff --git a/src/mono/browser/runtime/jiterpreter-opcodes.ts b/src/mono/browser/runtime/jiterpreter-opcodes.ts index 1680016d2a670f..de98528709353a 100644 --- a/src/mono/browser/runtime/jiterpreter-opcodes.ts +++ b/src/mono/browser/runtime/jiterpreter-opcodes.ts @@ -36,7 +36,6 @@ export const enum MintOpArgType { MintOpFloat, MintOpDouble, MintOpBranch, - MintOpShortBranch, MintOpSwitch, MintOpMethodToken, MintOpFieldToken, diff --git a/src/mono/browser/runtime/jiterpreter-tables.ts b/src/mono/browser/runtime/jiterpreter-tables.ts index 76a76798f7ea87..bfcb12b98f6693 100644 --- a/src/mono/browser/runtime/jiterpreter-tables.ts +++ b/src/mono/browser/runtime/jiterpreter-tables.ts @@ -193,7 +193,7 @@ export const binopTable: { [opcode: number]: OpRec3 | OpRec4 | undefined } = { }; -export const relopbranchTable: { [opcode: number]: [comparisonOpcode: MintOpcode, immediateOpcode: WasmOpcode | false, isSafepoint: boolean] | MintOpcode | undefined } = { +export const relopbranchTable: { [opcode: number]: [comparisonOpcode: MintOpcode, immediateOpcode: WasmOpcode | false, isSafepoint: boolean, immediateIsUnsigned: boolean] | MintOpcode | undefined } = { [MintOpcode.MINT_BEQ_I4]: MintOpcode.MINT_CEQ_I4, [MintOpcode.MINT_BNE_UN_I4]: MintOpcode.MINT_CNE_I4, [MintOpcode.MINT_BGT_I4]: MintOpcode.MINT_CGT_I4, @@ -205,27 +205,27 @@ export const relopbranchTable: { [opcode: number]: [comparisonOpcode: MintOpcode [MintOpcode.MINT_BLE_I4]: MintOpcode.MINT_CLE_I4, [MintOpcode.MINT_BLE_UN_I4]: MintOpcode.MINT_CLE_UN_I4, - [MintOpcode.MINT_BEQ_I4_SP]: [MintOpcode.MINT_CEQ_I4, false, true], - [MintOpcode.MINT_BNE_UN_I4_SP]: [MintOpcode.MINT_CNE_I4, false, true], - [MintOpcode.MINT_BGT_I4_SP]: [MintOpcode.MINT_CGT_I4, false, true], - [MintOpcode.MINT_BGT_UN_I4_SP]: [MintOpcode.MINT_CGT_UN_I4, false, true], - [MintOpcode.MINT_BLT_I4_SP]: [MintOpcode.MINT_CLT_I4, false, true], - [MintOpcode.MINT_BLT_UN_I4_SP]: [MintOpcode.MINT_CLT_UN_I4, false, true], - [MintOpcode.MINT_BGE_I4_SP]: [MintOpcode.MINT_CGE_I4, false, true], - [MintOpcode.MINT_BGE_UN_I4_SP]: [MintOpcode.MINT_CGE_UN_I4, false, true], - [MintOpcode.MINT_BLE_I4_SP]: [MintOpcode.MINT_CLE_I4, false, true], - [MintOpcode.MINT_BLE_UN_I4_SP]: [MintOpcode.MINT_CLE_UN_I4, false, true], - - [MintOpcode.MINT_BEQ_I4_IMM_SP]: [MintOpcode.MINT_CEQ_I4, WasmOpcode.i32_const, true], - [MintOpcode.MINT_BNE_UN_I4_IMM_SP]: [MintOpcode.MINT_CNE_I4, WasmOpcode.i32_const, true], - [MintOpcode.MINT_BGT_I4_IMM_SP]: [MintOpcode.MINT_CGT_I4, WasmOpcode.i32_const, true], - [MintOpcode.MINT_BGT_UN_I4_IMM_SP]: [MintOpcode.MINT_CGT_UN_I4, WasmOpcode.i32_const, true], - [MintOpcode.MINT_BLT_I4_IMM_SP]: [MintOpcode.MINT_CLT_I4, WasmOpcode.i32_const, true], - [MintOpcode.MINT_BLT_UN_I4_IMM_SP]: [MintOpcode.MINT_CLT_UN_I4, WasmOpcode.i32_const, true], - [MintOpcode.MINT_BGE_I4_IMM_SP]: [MintOpcode.MINT_CGE_I4, WasmOpcode.i32_const, true], - [MintOpcode.MINT_BGE_UN_I4_IMM_SP]: [MintOpcode.MINT_CGE_UN_I4, WasmOpcode.i32_const, true], - [MintOpcode.MINT_BLE_I4_IMM_SP]: [MintOpcode.MINT_CLE_I4, WasmOpcode.i32_const, true], - [MintOpcode.MINT_BLE_UN_I4_IMM_SP]: [MintOpcode.MINT_CLE_UN_I4, WasmOpcode.i32_const, true], + [MintOpcode.MINT_BEQ_I4_SP]: [MintOpcode.MINT_CEQ_I4, false, true, false], + [MintOpcode.MINT_BNE_UN_I4_SP]: [MintOpcode.MINT_CNE_I4, false, true, false], + [MintOpcode.MINT_BGT_I4_SP]: [MintOpcode.MINT_CGT_I4, false, true, false], + [MintOpcode.MINT_BGT_UN_I4_SP]: [MintOpcode.MINT_CGT_UN_I4, false, true, false], + [MintOpcode.MINT_BLT_I4_SP]: [MintOpcode.MINT_CLT_I4, false, true, false], + [MintOpcode.MINT_BLT_UN_I4_SP]: [MintOpcode.MINT_CLT_UN_I4, false, true, false], + [MintOpcode.MINT_BGE_I4_SP]: [MintOpcode.MINT_CGE_I4, false, true, false], + [MintOpcode.MINT_BGE_UN_I4_SP]: [MintOpcode.MINT_CGE_UN_I4, false, true, false], + [MintOpcode.MINT_BLE_I4_SP]: [MintOpcode.MINT_CLE_I4, false, true, false], + [MintOpcode.MINT_BLE_UN_I4_SP]: [MintOpcode.MINT_CLE_UN_I4, false, true, false], + + [MintOpcode.MINT_BEQ_I4_IMM_SP]: [MintOpcode.MINT_CEQ_I4, WasmOpcode.i32_const, true, false], + [MintOpcode.MINT_BNE_UN_I4_IMM_SP]: [MintOpcode.MINT_CNE_I4, WasmOpcode.i32_const, true, true], + [MintOpcode.MINT_BGT_I4_IMM_SP]: [MintOpcode.MINT_CGT_I4, WasmOpcode.i32_const, true, false], + [MintOpcode.MINT_BGT_UN_I4_IMM_SP]: [MintOpcode.MINT_CGT_UN_I4, WasmOpcode.i32_const, true, true], + [MintOpcode.MINT_BLT_I4_IMM_SP]: [MintOpcode.MINT_CLT_I4, WasmOpcode.i32_const, true, false], + [MintOpcode.MINT_BLT_UN_I4_IMM_SP]: [MintOpcode.MINT_CLT_UN_I4, WasmOpcode.i32_const, true, true], + [MintOpcode.MINT_BGE_I4_IMM_SP]: [MintOpcode.MINT_CGE_I4, WasmOpcode.i32_const, true, false], + [MintOpcode.MINT_BGE_UN_I4_IMM_SP]: [MintOpcode.MINT_CGE_UN_I4, WasmOpcode.i32_const, true, true], + [MintOpcode.MINT_BLE_I4_IMM_SP]: [MintOpcode.MINT_CLE_I4, WasmOpcode.i32_const, true, false], + [MintOpcode.MINT_BLE_UN_I4_IMM_SP]: [MintOpcode.MINT_CLE_UN_I4, WasmOpcode.i32_const, true, true], [MintOpcode.MINT_BEQ_I8]: MintOpcode.MINT_CEQ_I8, [MintOpcode.MINT_BNE_UN_I8]: MintOpcode.MINT_CNE_I8, @@ -238,17 +238,17 @@ export const relopbranchTable: { [opcode: number]: [comparisonOpcode: MintOpcode [MintOpcode.MINT_BLE_I8]: MintOpcode.MINT_CLE_I8, [MintOpcode.MINT_BLE_UN_I8]: MintOpcode.MINT_CLE_UN_I8, - [MintOpcode.MINT_BEQ_I8_IMM_SP]: [MintOpcode.MINT_CEQ_I8, WasmOpcode.i64_const, true], + [MintOpcode.MINT_BEQ_I8_IMM_SP]: [MintOpcode.MINT_CEQ_I8, WasmOpcode.i64_const, true, false], // FIXME: Missing compare opcode - // [MintOpcode.MINT_BNE_UN_I8_IMM_SP]: [MintOpcode.MINT_CNE_UN_I8, WasmOpcode.i64_const, true], - [MintOpcode.MINT_BGT_I8_IMM_SP]: [MintOpcode.MINT_CGT_I8, WasmOpcode.i64_const, true], - [MintOpcode.MINT_BGT_UN_I8_IMM_SP]: [MintOpcode.MINT_CGT_UN_I8, WasmOpcode.i64_const, true], - [MintOpcode.MINT_BLT_I8_IMM_SP]: [MintOpcode.MINT_CLT_I8, WasmOpcode.i64_const, true], - [MintOpcode.MINT_BLT_UN_I8_IMM_SP]: [MintOpcode.MINT_CLT_UN_I8, WasmOpcode.i64_const, true], - [MintOpcode.MINT_BGE_I8_IMM_SP]: [MintOpcode.MINT_CGE_I8, WasmOpcode.i64_const, true], - [MintOpcode.MINT_BGE_UN_I8_IMM_SP]: [MintOpcode.MINT_CGE_UN_I8, WasmOpcode.i64_const, true], - [MintOpcode.MINT_BLE_I8_IMM_SP]: [MintOpcode.MINT_CLE_I8, WasmOpcode.i64_const, true], - [MintOpcode.MINT_BLE_UN_I8_IMM_SP]: [MintOpcode.MINT_CLE_UN_I8, WasmOpcode.i64_const, true], + // [MintOpcode.MINT_BNE_UN_I8_IMM_SP]: [MintOpcode.MINT_CNE_UN_I8, WasmOpcode.i64_const, true, true], + [MintOpcode.MINT_BGT_I8_IMM_SP]: [MintOpcode.MINT_CGT_I8, WasmOpcode.i64_const, true, false], + [MintOpcode.MINT_BGT_UN_I8_IMM_SP]: [MintOpcode.MINT_CGT_UN_I8, WasmOpcode.i64_const, true, true], + [MintOpcode.MINT_BLT_I8_IMM_SP]: [MintOpcode.MINT_CLT_I8, WasmOpcode.i64_const, true, false], + [MintOpcode.MINT_BLT_UN_I8_IMM_SP]: [MintOpcode.MINT_CLT_UN_I8, WasmOpcode.i64_const, true, true], + [MintOpcode.MINT_BGE_I8_IMM_SP]: [MintOpcode.MINT_CGE_I8, WasmOpcode.i64_const, true, false], + [MintOpcode.MINT_BGE_UN_I8_IMM_SP]: [MintOpcode.MINT_CGE_UN_I8, WasmOpcode.i64_const, true, true], + [MintOpcode.MINT_BLE_I8_IMM_SP]: [MintOpcode.MINT_CLE_I8, WasmOpcode.i64_const, true, false], + [MintOpcode.MINT_BLE_UN_I8_IMM_SP]: [MintOpcode.MINT_CLE_UN_I8, WasmOpcode.i64_const, true, true], [MintOpcode.MINT_BEQ_R4]: MintOpcode.MINT_CEQ_R4, [MintOpcode.MINT_BNE_UN_R4]: JiterpSpecialOpcode.CNE_UN_R4, diff --git a/src/mono/browser/runtime/jiterpreter-trace-generator.ts b/src/mono/browser/runtime/jiterpreter-trace-generator.ts index 742cf675d5641a..90e18cd659b1b3 100644 --- a/src/mono/browser/runtime/jiterpreter-trace-generator.ts +++ b/src/mono/browser/runtime/jiterpreter-trace-generator.ts @@ -2752,6 +2752,25 @@ function append_call_handler_store_ret_ip ( builder.callHandlerReturnAddresses.push(retIp); } +function getBranchImmediate ( + ip: MintOpcodePtr, opcode: MintOpcode, unsigned: boolean +): number | undefined { + const opArgType = cwraps.mono_jiterp_get_opcode_info(opcode, OpcodeInfoType.OpArgType), + payloadOffset = cwraps.mono_jiterp_get_opcode_info(opcode, OpcodeInfoType.Sregs), + payloadAddress = ip + 2 + (payloadOffset * 2); + + let result: number; + switch (opArgType) { + case MintOpArgType.MintOpShortAndBranch: + result = unsigned ? getU16(payloadAddress) : getI16(payloadAddress); + break; + default: + return undefined; + } + + return result; +} + function getBranchDisplacement ( ip: MintOpcodePtr, opcode: MintOpcode ): number | undefined { @@ -2785,8 +2804,10 @@ function emit_branch ( (opcode <= MintOpcode.MINT_BLT_UN_I8_IMM_SP); const displacement = getBranchDisplacement(ip, opcode); - if (typeof (displacement) !== "number") + if (typeof (displacement) !== "number") { + mono_log_info(`Failed to decode branch displacement for ${getOpcodeName(opcode)}`); return false; + } // If the branch is taken we bail out to allow the interpreter to do it. // So for brtrue, we want to do 'cond == 0' to produce a bailout only @@ -2917,8 +2938,10 @@ function emit_relop_branch ( frame: NativePointer, opcode: MintOpcode ): boolean { const relopBranchInfo = relopbranchTable[opcode]; - if (!relopBranchInfo) + if (!relopBranchInfo) { + // mono_log_info(`No info for relop branch ${getOpcodeName(opcode)}`); return false; + } const relop = Array.isArray(relopBranchInfo) ? relopBranchInfo[0] @@ -2927,8 +2950,10 @@ function emit_relop_branch ( const relopInfo = binopTable[relop]; const intrinsicFpBinop = intrinsicFpBinops[relop]; - if (!relopInfo && !intrinsicFpBinop) + if (!relopInfo && !intrinsicFpBinop) { + // mono_log_info(`No info for relop ${getOpcodeName(opcode)} -> ${getOpcodeName(relop)}`); return false; + } const operandLoadOp = relopInfo ? relopInfo[1] @@ -2945,11 +2970,13 @@ function emit_relop_branch ( // Compare with immediate if (Array.isArray(relopBranchInfo) && relopBranchInfo[1]) { + const immediate = getBranchImmediate(ip, opcode, relopBranchInfo[3]); + mono_assert(immediate !== undefined, `Failed to decode immediate for branch opcode ${getOpcodeName(opcode)}`); // For i8 immediates we need to generate an i64.const even though // the immediate is 16 bits, so we store the relevant opcode // in the relop branch info table builder.appendU8(relopBranchInfo[1]); - builder.appendLeb(getArgI16(ip, 2)); + builder.appendLeb(immediate); } else append_ldloc(builder, getArgU16(ip, 2), operandLoadOp); From 6e235912ff2deff87c1adcec4a8cd9eab4e22181 Mon Sep 17 00:00:00 2001 From: Katelyn Gadd Date: Tue, 6 Aug 2024 14:02:19 -0700 Subject: [PATCH 3/4] Add comment --- src/mono/browser/runtime/jiterpreter-trace-generator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/browser/runtime/jiterpreter-trace-generator.ts b/src/mono/browser/runtime/jiterpreter-trace-generator.ts index 90e18cd659b1b3..f73e2d98a314bf 100644 --- a/src/mono/browser/runtime/jiterpreter-trace-generator.ts +++ b/src/mono/browser/runtime/jiterpreter-trace-generator.ts @@ -2805,7 +2805,7 @@ function emit_branch ( const displacement = getBranchDisplacement(ip, opcode); if (typeof (displacement) !== "number") { - mono_log_info(`Failed to decode branch displacement for ${getOpcodeName(opcode)}`); + // mono_log_info(`Failed to decode branch displacement for ${getOpcodeName(opcode)}`); return false; } From f80726db4f9210ebf5ef4a7f2e83be2de940a95f Mon Sep 17 00:00:00 2001 From: Katelyn Gadd Date: Tue, 6 Aug 2024 19:01:55 -0700 Subject: [PATCH 4/4] Fix handling of unsigned branch immediates --- .../browser/runtime/jiterpreter-tables.ts | 64 +++++++++---------- .../runtime/jiterpreter-trace-generator.ts | 10 +-- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/src/mono/browser/runtime/jiterpreter-tables.ts b/src/mono/browser/runtime/jiterpreter-tables.ts index bfcb12b98f6693..76a76798f7ea87 100644 --- a/src/mono/browser/runtime/jiterpreter-tables.ts +++ b/src/mono/browser/runtime/jiterpreter-tables.ts @@ -193,7 +193,7 @@ export const binopTable: { [opcode: number]: OpRec3 | OpRec4 | undefined } = { }; -export const relopbranchTable: { [opcode: number]: [comparisonOpcode: MintOpcode, immediateOpcode: WasmOpcode | false, isSafepoint: boolean, immediateIsUnsigned: boolean] | MintOpcode | undefined } = { +export const relopbranchTable: { [opcode: number]: [comparisonOpcode: MintOpcode, immediateOpcode: WasmOpcode | false, isSafepoint: boolean] | MintOpcode | undefined } = { [MintOpcode.MINT_BEQ_I4]: MintOpcode.MINT_CEQ_I4, [MintOpcode.MINT_BNE_UN_I4]: MintOpcode.MINT_CNE_I4, [MintOpcode.MINT_BGT_I4]: MintOpcode.MINT_CGT_I4, @@ -205,27 +205,27 @@ export const relopbranchTable: { [opcode: number]: [comparisonOpcode: MintOpcode [MintOpcode.MINT_BLE_I4]: MintOpcode.MINT_CLE_I4, [MintOpcode.MINT_BLE_UN_I4]: MintOpcode.MINT_CLE_UN_I4, - [MintOpcode.MINT_BEQ_I4_SP]: [MintOpcode.MINT_CEQ_I4, false, true, false], - [MintOpcode.MINT_BNE_UN_I4_SP]: [MintOpcode.MINT_CNE_I4, false, true, false], - [MintOpcode.MINT_BGT_I4_SP]: [MintOpcode.MINT_CGT_I4, false, true, false], - [MintOpcode.MINT_BGT_UN_I4_SP]: [MintOpcode.MINT_CGT_UN_I4, false, true, false], - [MintOpcode.MINT_BLT_I4_SP]: [MintOpcode.MINT_CLT_I4, false, true, false], - [MintOpcode.MINT_BLT_UN_I4_SP]: [MintOpcode.MINT_CLT_UN_I4, false, true, false], - [MintOpcode.MINT_BGE_I4_SP]: [MintOpcode.MINT_CGE_I4, false, true, false], - [MintOpcode.MINT_BGE_UN_I4_SP]: [MintOpcode.MINT_CGE_UN_I4, false, true, false], - [MintOpcode.MINT_BLE_I4_SP]: [MintOpcode.MINT_CLE_I4, false, true, false], - [MintOpcode.MINT_BLE_UN_I4_SP]: [MintOpcode.MINT_CLE_UN_I4, false, true, false], - - [MintOpcode.MINT_BEQ_I4_IMM_SP]: [MintOpcode.MINT_CEQ_I4, WasmOpcode.i32_const, true, false], - [MintOpcode.MINT_BNE_UN_I4_IMM_SP]: [MintOpcode.MINT_CNE_I4, WasmOpcode.i32_const, true, true], - [MintOpcode.MINT_BGT_I4_IMM_SP]: [MintOpcode.MINT_CGT_I4, WasmOpcode.i32_const, true, false], - [MintOpcode.MINT_BGT_UN_I4_IMM_SP]: [MintOpcode.MINT_CGT_UN_I4, WasmOpcode.i32_const, true, true], - [MintOpcode.MINT_BLT_I4_IMM_SP]: [MintOpcode.MINT_CLT_I4, WasmOpcode.i32_const, true, false], - [MintOpcode.MINT_BLT_UN_I4_IMM_SP]: [MintOpcode.MINT_CLT_UN_I4, WasmOpcode.i32_const, true, true], - [MintOpcode.MINT_BGE_I4_IMM_SP]: [MintOpcode.MINT_CGE_I4, WasmOpcode.i32_const, true, false], - [MintOpcode.MINT_BGE_UN_I4_IMM_SP]: [MintOpcode.MINT_CGE_UN_I4, WasmOpcode.i32_const, true, true], - [MintOpcode.MINT_BLE_I4_IMM_SP]: [MintOpcode.MINT_CLE_I4, WasmOpcode.i32_const, true, false], - [MintOpcode.MINT_BLE_UN_I4_IMM_SP]: [MintOpcode.MINT_CLE_UN_I4, WasmOpcode.i32_const, true, true], + [MintOpcode.MINT_BEQ_I4_SP]: [MintOpcode.MINT_CEQ_I4, false, true], + [MintOpcode.MINT_BNE_UN_I4_SP]: [MintOpcode.MINT_CNE_I4, false, true], + [MintOpcode.MINT_BGT_I4_SP]: [MintOpcode.MINT_CGT_I4, false, true], + [MintOpcode.MINT_BGT_UN_I4_SP]: [MintOpcode.MINT_CGT_UN_I4, false, true], + [MintOpcode.MINT_BLT_I4_SP]: [MintOpcode.MINT_CLT_I4, false, true], + [MintOpcode.MINT_BLT_UN_I4_SP]: [MintOpcode.MINT_CLT_UN_I4, false, true], + [MintOpcode.MINT_BGE_I4_SP]: [MintOpcode.MINT_CGE_I4, false, true], + [MintOpcode.MINT_BGE_UN_I4_SP]: [MintOpcode.MINT_CGE_UN_I4, false, true], + [MintOpcode.MINT_BLE_I4_SP]: [MintOpcode.MINT_CLE_I4, false, true], + [MintOpcode.MINT_BLE_UN_I4_SP]: [MintOpcode.MINT_CLE_UN_I4, false, true], + + [MintOpcode.MINT_BEQ_I4_IMM_SP]: [MintOpcode.MINT_CEQ_I4, WasmOpcode.i32_const, true], + [MintOpcode.MINT_BNE_UN_I4_IMM_SP]: [MintOpcode.MINT_CNE_I4, WasmOpcode.i32_const, true], + [MintOpcode.MINT_BGT_I4_IMM_SP]: [MintOpcode.MINT_CGT_I4, WasmOpcode.i32_const, true], + [MintOpcode.MINT_BGT_UN_I4_IMM_SP]: [MintOpcode.MINT_CGT_UN_I4, WasmOpcode.i32_const, true], + [MintOpcode.MINT_BLT_I4_IMM_SP]: [MintOpcode.MINT_CLT_I4, WasmOpcode.i32_const, true], + [MintOpcode.MINT_BLT_UN_I4_IMM_SP]: [MintOpcode.MINT_CLT_UN_I4, WasmOpcode.i32_const, true], + [MintOpcode.MINT_BGE_I4_IMM_SP]: [MintOpcode.MINT_CGE_I4, WasmOpcode.i32_const, true], + [MintOpcode.MINT_BGE_UN_I4_IMM_SP]: [MintOpcode.MINT_CGE_UN_I4, WasmOpcode.i32_const, true], + [MintOpcode.MINT_BLE_I4_IMM_SP]: [MintOpcode.MINT_CLE_I4, WasmOpcode.i32_const, true], + [MintOpcode.MINT_BLE_UN_I4_IMM_SP]: [MintOpcode.MINT_CLE_UN_I4, WasmOpcode.i32_const, true], [MintOpcode.MINT_BEQ_I8]: MintOpcode.MINT_CEQ_I8, [MintOpcode.MINT_BNE_UN_I8]: MintOpcode.MINT_CNE_I8, @@ -238,17 +238,17 @@ export const relopbranchTable: { [opcode: number]: [comparisonOpcode: MintOpcode [MintOpcode.MINT_BLE_I8]: MintOpcode.MINT_CLE_I8, [MintOpcode.MINT_BLE_UN_I8]: MintOpcode.MINT_CLE_UN_I8, - [MintOpcode.MINT_BEQ_I8_IMM_SP]: [MintOpcode.MINT_CEQ_I8, WasmOpcode.i64_const, true, false], + [MintOpcode.MINT_BEQ_I8_IMM_SP]: [MintOpcode.MINT_CEQ_I8, WasmOpcode.i64_const, true], // FIXME: Missing compare opcode - // [MintOpcode.MINT_BNE_UN_I8_IMM_SP]: [MintOpcode.MINT_CNE_UN_I8, WasmOpcode.i64_const, true, true], - [MintOpcode.MINT_BGT_I8_IMM_SP]: [MintOpcode.MINT_CGT_I8, WasmOpcode.i64_const, true, false], - [MintOpcode.MINT_BGT_UN_I8_IMM_SP]: [MintOpcode.MINT_CGT_UN_I8, WasmOpcode.i64_const, true, true], - [MintOpcode.MINT_BLT_I8_IMM_SP]: [MintOpcode.MINT_CLT_I8, WasmOpcode.i64_const, true, false], - [MintOpcode.MINT_BLT_UN_I8_IMM_SP]: [MintOpcode.MINT_CLT_UN_I8, WasmOpcode.i64_const, true, true], - [MintOpcode.MINT_BGE_I8_IMM_SP]: [MintOpcode.MINT_CGE_I8, WasmOpcode.i64_const, true, false], - [MintOpcode.MINT_BGE_UN_I8_IMM_SP]: [MintOpcode.MINT_CGE_UN_I8, WasmOpcode.i64_const, true, true], - [MintOpcode.MINT_BLE_I8_IMM_SP]: [MintOpcode.MINT_CLE_I8, WasmOpcode.i64_const, true, false], - [MintOpcode.MINT_BLE_UN_I8_IMM_SP]: [MintOpcode.MINT_CLE_UN_I8, WasmOpcode.i64_const, true, true], + // [MintOpcode.MINT_BNE_UN_I8_IMM_SP]: [MintOpcode.MINT_CNE_UN_I8, WasmOpcode.i64_const, true], + [MintOpcode.MINT_BGT_I8_IMM_SP]: [MintOpcode.MINT_CGT_I8, WasmOpcode.i64_const, true], + [MintOpcode.MINT_BGT_UN_I8_IMM_SP]: [MintOpcode.MINT_CGT_UN_I8, WasmOpcode.i64_const, true], + [MintOpcode.MINT_BLT_I8_IMM_SP]: [MintOpcode.MINT_CLT_I8, WasmOpcode.i64_const, true], + [MintOpcode.MINT_BLT_UN_I8_IMM_SP]: [MintOpcode.MINT_CLT_UN_I8, WasmOpcode.i64_const, true], + [MintOpcode.MINT_BGE_I8_IMM_SP]: [MintOpcode.MINT_CGE_I8, WasmOpcode.i64_const, true], + [MintOpcode.MINT_BGE_UN_I8_IMM_SP]: [MintOpcode.MINT_CGE_UN_I8, WasmOpcode.i64_const, true], + [MintOpcode.MINT_BLE_I8_IMM_SP]: [MintOpcode.MINT_CLE_I8, WasmOpcode.i64_const, true], + [MintOpcode.MINT_BLE_UN_I8_IMM_SP]: [MintOpcode.MINT_CLE_UN_I8, WasmOpcode.i64_const, true], [MintOpcode.MINT_BEQ_R4]: MintOpcode.MINT_CEQ_R4, [MintOpcode.MINT_BNE_UN_R4]: JiterpSpecialOpcode.CNE_UN_R4, diff --git a/src/mono/browser/runtime/jiterpreter-trace-generator.ts b/src/mono/browser/runtime/jiterpreter-trace-generator.ts index f73e2d98a314bf..2a4471b20899a9 100644 --- a/src/mono/browser/runtime/jiterpreter-trace-generator.ts +++ b/src/mono/browser/runtime/jiterpreter-trace-generator.ts @@ -2753,22 +2753,18 @@ function append_call_handler_store_ret_ip ( } function getBranchImmediate ( - ip: MintOpcodePtr, opcode: MintOpcode, unsigned: boolean + ip: MintOpcodePtr, opcode: MintOpcode ): number | undefined { const opArgType = cwraps.mono_jiterp_get_opcode_info(opcode, OpcodeInfoType.OpArgType), payloadOffset = cwraps.mono_jiterp_get_opcode_info(opcode, OpcodeInfoType.Sregs), payloadAddress = ip + 2 + (payloadOffset * 2); - let result: number; switch (opArgType) { case MintOpArgType.MintOpShortAndBranch: - result = unsigned ? getU16(payloadAddress) : getI16(payloadAddress); - break; + return getI16(payloadAddress); default: return undefined; } - - return result; } function getBranchDisplacement ( @@ -2970,7 +2966,7 @@ function emit_relop_branch ( // Compare with immediate if (Array.isArray(relopBranchInfo) && relopBranchInfo[1]) { - const immediate = getBranchImmediate(ip, opcode, relopBranchInfo[3]); + const immediate = getBranchImmediate(ip, opcode); mono_assert(immediate !== undefined, `Failed to decode immediate for branch opcode ${getOpcodeName(opcode)}`); // For i8 immediates we need to generate an i64.const even though // the immediate is 16 bits, so we store the relevant opcode