Mercurial > hg > truffle
changeset 18662:c9d57a5fb655
Added PIC support for metaspace access
author | adlertz |
---|---|
date | Thu, 11 Dec 2014 19:35:25 +0100 |
parents | aa4f2e3629ca |
children | 058cbb02b58c |
files | graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCompare.java graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java |
diffstat | 2 files changed, 45 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCompare.java Thu Dec 11 19:35:02 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCompare.java Thu Dec 11 19:35:25 2014 +0100 @@ -25,6 +25,7 @@ import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; +import com.oracle.graal.hotspot.HotSpotGraalRuntime; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; import com.oracle.graal.asm.amd64.*; @@ -66,14 +67,31 @@ masm.cmpq(asRegister(x), patch); } } else if (y instanceof HotSpotMetaspaceConstant) { + boolean isImmutable = GraalOptions.ImmutableCode.getValue(); + boolean generatePIC = GraalOptions.GeneratePIC.getValue(); if (y.getKind() == Kind.Int) { // compressed metaspace pointer crb.recordInlineDataInCode(y); - masm.cmpl(asRegister(x), y.asInt()); + if (isImmutable && generatePIC) { + Kind hostWordKind = HotSpotGraalRuntime.getHostWordKind(); + int alignment = hostWordKind.getBitCount() / Byte.SIZE; + // recordDataReferenceInCode forces the mov to be rip-relative + masm.cmpl(asRegister(x), (AMD64Address) crb.recordDataReferenceInCode(JavaConstant.INT_0, alignment)); + } else { + masm.cmpl(asRegister(x), y.asInt()); + } } else { // uncompressed metaspace pointer - AMD64Address patch = (AMD64Address) crb.recordDataReferenceInCode(y, 8); - masm.cmpq(asRegister(x), patch); + if (isImmutable && generatePIC) { + crb.recordInlineDataInCode(y); + Kind hostWordKind = HotSpotGraalRuntime.getHostWordKind(); + int alignment = hostWordKind.getBitCount() / Byte.SIZE; + // recordDataReferenceInCode forces the mov to be rip-relative + masm.cmpq(asRegister(x), (AMD64Address) crb.recordDataReferenceInCode(JavaConstant.INT_0, alignment)); + } else { + AMD64Address patch = (AMD64Address) crb.recordDataReferenceInCode(y, 8); + masm.cmpq(asRegister(x), patch); + } } } else { throw GraalInternalError.shouldNotReachHere();
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java Thu Dec 11 19:35:02 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java Thu Dec 11 19:35:25 2014 +0100 @@ -32,6 +32,7 @@ import com.oracle.graal.asm.amd64.*; import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.lir.*; @@ -94,17 +95,37 @@ } else if (input instanceof HotSpotMetaspaceConstant) { assert input.getKind() == Kind.Int || input.getKind() == Kind.Long; boolean compressed = input.getKind() == Kind.Int; + boolean isImmutable = GraalOptions.ImmutableCode.getValue(); + boolean generatePIC = GraalOptions.GeneratePIC.getValue(); crb.recordInlineDataInCode(input); if (isRegister(result)) { if (compressed) { - masm.movl(asRegister(result), input.asInt()); + if (isImmutable && generatePIC) { + Kind hostWordKind = HotSpotGraalRuntime.getHostWordKind(); + int alignment = hostWordKind.getBitCount() / Byte.SIZE; + // recordDataReferenceInCode forces the mov to be rip-relative + masm.movl(asRegister(result), (AMD64Address) crb.recordDataReferenceInCode(JavaConstant.INT_0, alignment)); + } else { + masm.movl(asRegister(result), input.asInt()); + } } else { - masm.movq(asRegister(result), input.asLong()); + if (isImmutable && generatePIC) { + Kind hostWordKind = HotSpotGraalRuntime.getHostWordKind(); + int alignment = hostWordKind.getBitCount() / Byte.SIZE; + // recordDataReferenceInCode forces the mov to be rip-relative + masm.movq(asRegister(result), (AMD64Address) crb.recordDataReferenceInCode(JavaConstant.INT_0, alignment)); + } else { + masm.movq(asRegister(result), input.asLong()); + } } } else { assert isStackSlot(result); if (compressed) { - masm.movl((AMD64Address) crb.asAddress(result), input.asInt()); + if (isImmutable && generatePIC) { + throw GraalInternalError.shouldNotReachHere("Unsupported operation offset(%rip) -> mem (mem -> mem)"); + } else { + masm.movl((AMD64Address) crb.asAddress(result), input.asInt()); + } } else { throw GraalInternalError.shouldNotReachHere("Cannot store 64-bit constants to memory"); }