Skip to content

Commit

Permalink
Merge branch 'feature/riscv-fixes' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkak committed Mar 27, 2020
2 parents 21aafb6 + fca42fe commit 0ab4793
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private static void patchDisp32(byte[] code, int pos, int offset) {
assert pos + RISCV64MacroAssembler.INSTRUCTION_SIZE *
RISCV64MacroAssembler.PLACEHOLDER_INSTRUCTIONS_FOR_LONG_OFFSETS <= code.length;

pos += 4; //skip asm.auipc(scratch, 0);
pos += RISCV64MacroAssembler.INSTRUCTION_SIZE; //skip asm.auipc(scratch, 0);

//Nop everything except the asm.auipc(scratch, 0);
int instruction = RISCV64MacroAssembler.addImmediateHelper(RISCV64.x0, RISCV64.x0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@
import com.sun.cri.ri.RiRegisterConfig;

public class RISCV64MacroAssembler extends RISCV64Assembler {
public static final int PLACEHOLDER_INSTRUCTIONS_FOR_LONG_OFFSETS = 15;
/**
* Reserved space for worst case scenario.
*
* <code>
* lui x29, %hi(offset)
* addi x29, x29, %lo(offset)
* add x28, x28, x29
* </code>
*/
public static final int PLACEHOLDER_INSTRUCTIONS_FOR_LONG_OFFSETS = 3;
public static final int INSTRUCTION_SIZE = 4;

public static final int CALL_TRAMPOLINE_INSTRUCTIONS = 6;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -918,8 +918,8 @@ public static int[] findDataPatchPosns(MaxTargetMethod source, int dispFromCodeS
}
}
asm.add(scratch, scratch, scratch1);
// movInstr.length + RISCV64MacroAssembler.INSTRUCTION_SIZE to account for the mov32bitConstant and add above.
asm.nop(RISCV64MacroAssembler.PLACEHOLDER_INSTRUCTIONS_FOR_LONG_OFFSETS - (movInstr.length + RISCV64MacroAssembler.INSTRUCTION_SIZE));
// movInstr.length + 1 to account for the mov32bitConstant and add above.
asm.nop(RISCV64MacroAssembler.PLACEHOLDER_INSTRUCTIONS_FOR_LONG_OFFSETS - (movInstr.length + 1));
asm.ldru(64, reg, RISCV64Address.createBaseRegisterOnlyAddress(scratch));
byte[] patternMov32BitConstant = asm.codeBuffer.close(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,7 @@ public void emitXirInstructions(LIRXirInstruction xir, XirInstruction[] instruct
int afterLea = masm.codeBuffer.position();
masm.codeBuffer.setPosition(beforeLea);
masm.auipc(dst, 0);
masm.mov64BitConstant(scratchRegister, beforeLea - afterLea);
masm.mov32BitConstant(scratchRegister, beforeLea - afterLea);
masm.add(dst, dst, scratchRegister);
masm.codeBuffer.setPosition(afterLea);
break;
Expand Down

0 comments on commit 0ab4793

Please sign in to comment.