# HG changeset patch # User Roland Schatz # Date 1401272204 -7200 # Node ID 3eedf7a653ea3259e2d06d02d6c5d8c6088d341c # Parent b2c18c498f139554a13e57ab6b5ee30e53431267 Remove unused oop compression code from backends. diff -r b2c18c498f13 -r 3eedf7a653ea graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Wed May 28 12:15:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Wed May 28 12:16:44 2014 +0200 @@ -97,20 +97,14 @@ } @Override - public boolean canStoreConstant(Constant c, boolean isCompressed) { + public boolean canStoreConstant(Constant c) { // there is no immediate move of 64-bit constants on Intel switch (c.getKind()) { case Long: - if (isCompressed) { - return true; - } return Util.isInt(c.asLong()) && !getCodeCache().needsDataPatch(c); case Double: return false; case Object: - if (isCompressed) { - return true; - } return c.isNull(); default: return true; diff -r b2c18c498f13 -r 3eedf7a653ea graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java --- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Wed May 28 12:15:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Wed May 28 12:16:44 2014 +0200 @@ -62,7 +62,7 @@ } @Override - public boolean canStoreConstant(Constant c, boolean isCompressed) { + public boolean canStoreConstant(Constant c) { // Operand b must be in the .reg state space. return false; } diff -r b2c18c498f13 -r 3eedf7a653ea graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java --- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Wed May 28 12:15:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Wed May 28 12:16:44 2014 +0200 @@ -95,7 +95,7 @@ } @Override - public boolean canStoreConstant(Constant c, boolean isCompressed) { + public boolean canStoreConstant(Constant c) { // Operand b must be in the .reg state space. return false; } diff -r b2c18c498f13 -r 3eedf7a653ea graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java --- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Wed May 28 12:15:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Wed May 28 12:16:44 2014 +0200 @@ -63,7 +63,7 @@ } @Override - public boolean canStoreConstant(Constant c, boolean isCompressed) { + public boolean canStoreConstant(Constant c) { // SPARC can only store integer null constants (via g0) switch (c.getKind()) { case Float: diff -r b2c18c498f13 -r 3eedf7a653ea graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Wed May 28 12:15:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Wed May 28 12:16:44 2014 +0200 @@ -479,7 +479,7 @@ AMD64AddressValue storeAddress = asAddressValue(address); if (isConstant(inputVal)) { Constant c = asConstant(inputVal); - if (canStoreConstant(c, false)) { + if (canStoreConstant(c)) { append(new HotSpotStoreConstantOp(getMemoryKind(kind), storeAddress, c, state)); return; } diff -r b2c18c498f13 -r 3eedf7a653ea graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java Wed May 28 12:15:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java Wed May 28 12:16:44 2014 +0200 @@ -25,7 +25,6 @@ import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; -import com.oracle.graal.amd64.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; @@ -38,44 +37,11 @@ import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.MoveOp; import com.oracle.graal.lir.amd64.*; -import com.oracle.graal.lir.amd64.AMD64Move.LoadOp; import com.oracle.graal.lir.amd64.AMD64Move.StoreConstantOp; import com.oracle.graal.lir.asm.*; public class AMD64HotSpotMove { - public static class StoreCompressedConstantOp extends StoreConstantOp { - - public StoreCompressedConstantOp(Kind kind, AMD64AddressValue address, Constant input, LIRFrameState state) { - super(kind, address, input, state); - } - - @Override - public void emitMemAccess(CompilationResultBuilder crb, AMD64MacroAssembler masm) { - if (kind == Kind.Long) { - if (NumUtil.isInt(input.asLong())) { - if (input instanceof HotSpotMetaspaceConstant) { - crb.recordInlineDataInCode(new MetaspaceData(0, input.asLong(), HotSpotMetaspaceConstant.getMetaspaceObject(input), true)); - } - masm.movl(address.toAddress(), (int) input.asLong()); - } else { - throw GraalInternalError.shouldNotReachHere("Cannot store 64-bit constants to memory"); - } - } else if (kind == Kind.Object) { - if (input.isNull()) { - masm.movl(address.toAddress(), 0); - } else if (crb.target.inlineObjects) { - crb.recordInlineDataInCode(new OopData(0, HotSpotObjectConstant.asObject(input), true)); - masm.movl(address.toAddress(), 0xDEADDEAD); - } else { - throw GraalInternalError.shouldNotReachHere("Cannot store 64-bit constants to memory"); - } - } else { - throw GraalInternalError.shouldNotReachHere("Attempt to store compressed constant of wrong type."); - } - } - } - public static class HotSpotLoadConstantOp extends AMD64LIRInstruction implements MoveOp { @Def({REG, STACK}) private AllocatableValue result; @@ -276,175 +242,6 @@ } } - public static class LoadCompressedPointer extends LoadOp { - - private final CompressEncoding encoding; - @Temp({REG, ILLEGAL}) protected AllocatableValue scratch; - - public LoadCompressedPointer(Kind kind, AllocatableValue result, AllocatableValue scratch, AMD64AddressValue address, LIRFrameState state, CompressEncoding encoding) { - super(kind, result, address, state); - this.encoding = encoding; - this.scratch = scratch != null ? scratch : Value.ILLEGAL; - assert kind == Kind.Object || kind == Kind.Long; - } - - @Override - public void emitMemAccess(CompilationResultBuilder crb, AMD64MacroAssembler masm) { - Register resRegister = asRegister(result); - if (kind == Kind.Object) { - masm.movl(resRegister, address.toAddress()); - decodePointer(masm, resRegister, asRegister(scratch), encoding); - } else { - Register base = scratch.equals(Value.ILLEGAL) ? null : asRegister(scratch); - decodeKlassPointer(masm, resRegister, base, address.toAddress(), encoding); - } - } - } - - public static class StoreCompressedPointer extends AMD64LIRInstruction { - - protected final Kind kind; - private final Register heapBaseReg; - private final CompressEncoding encoding; - @Temp({REG}) private AllocatableValue scratch; - @Alive({REG}) protected Value input; - @Alive({COMPOSITE}) protected AMD64AddressValue address; - @State protected LIRFrameState state; - - public StoreCompressedPointer(Kind kind, AMD64AddressValue address, AllocatableValue input, AllocatableValue scratch, LIRFrameState state, CompressEncoding encoding, Register heapBaseReg) { - this.encoding = encoding; - this.heapBaseReg = heapBaseReg; - this.scratch = scratch; - this.kind = kind; - this.address = address; - this.state = state; - this.input = input; - assert kind == Kind.Object || kind == Kind.Long; - } - - @Override - public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { - masm.movq(asRegister(scratch), asRegister(input)); - if (kind == Kind.Long && (encoding.base & 0xffffffffL) == 0 && encoding.shift == 0) { - // Compressing the pointer won't change the low 32 bits, so just store it - masm.movl(address.toAddress(), asRegister(input)); - } else if (kind == Kind.Object) { - encodePointer(masm, asRegister(scratch), heapBaseReg, encoding); - } else { - masm.movq(asRegister(scratch), asRegister(input)); - if (kind == Kind.Object) { - encodePointer(masm, asRegister(scratch), heapBaseReg, encoding); - } else { - assert !asRegister(scratch).equals(heapBaseReg) : "need to restore value otherwise"; - encodeKlassPointer(masm, asRegister(scratch), heapBaseReg, encoding); - } - if (state != null) { - crb.recordImplicitException(masm.position(), state); - } - masm.movl(address.toAddress(), asRegister(scratch)); - } - if (state != null) { - crb.recordImplicitException(masm.position(), state); - } - masm.movl(address.toAddress(), asRegister(scratch)); - } - } - - @Opcode("CAS") - public static class CompareAndSwapCompressedOp extends AMD64LIRInstruction { - - @Def protected AllocatableValue result; - @Alive({COMPOSITE}) protected AMD64AddressValue address; - @Alive protected AllocatableValue cmpValue; - @Alive protected AllocatableValue newValue; - @Temp({REG}) protected AllocatableValue scratch; - - private CompressEncoding encoding; - private final Register heapBaseReg; - - public CompareAndSwapCompressedOp(AllocatableValue result, AMD64AddressValue address, AllocatableValue cmpValue, AllocatableValue newValue, AllocatableValue scratch, - CompressEncoding encoding, Register heapBaseReg) { - this.heapBaseReg = heapBaseReg; - this.scratch = scratch; - this.encoding = encoding; - this.result = result; - this.address = address; - this.cmpValue = cmpValue; - this.newValue = newValue; - assert cmpValue.getKind() == Kind.Object; - } - - @Override - public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { - compareAndSwapCompressed(crb, masm, result, address, cmpValue, newValue, scratch, encoding, heapBaseReg); - } - } - - protected static void compareAndSwapCompressed(CompilationResultBuilder crb, AMD64MacroAssembler masm, AllocatableValue result, AMD64AddressValue address, AllocatableValue cmpValue, - AllocatableValue newValue, AllocatableValue scratch, CompressEncoding encoding, Register heapBaseReg) { - assert AMD64.rax.equals(asRegister(cmpValue)) && AMD64.rax.equals(asRegister(result)); - final Register scratchRegister = asRegister(scratch); - final Register cmpRegister = asRegister(cmpValue); - final Register newRegister = asRegister(newValue); - Register heapBase = heapBaseReg; - encodePointer(masm, cmpRegister, heapBase, encoding); - masm.movq(scratchRegister, newRegister); - encodePointer(masm, scratchRegister, heapBase, encoding); - if (crb.target.isMP) { - masm.lock(); - } - masm.cmpxchgl(scratchRegister, address.toAddress()); - } - - private static void encodePointer(AMD64MacroAssembler masm, Register scratchRegister, Register heapBaseRegister, CompressEncoding encoding) { - // If the base is zero, the uncompressed address has to be shifted right - // in order to be compressed. - if (encoding.base == 0) { - if (encoding.shift != 0) { - assert encoding.alignment == encoding.shift : "Encode algorithm is wrong"; - masm.shrq(scratchRegister, encoding.alignment); - } - } else { - // Otherwise the heap base, which resides always in register 12, is subtracted - // followed by right shift. - masm.testq(scratchRegister, scratchRegister); - // If the stored reference is null, move the heap to scratch - // register and then calculate the compressed oop value. - masm.cmovq(ConditionFlag.Equal, scratchRegister, heapBaseRegister); - masm.subq(scratchRegister, heapBaseRegister); - masm.shrq(scratchRegister, encoding.alignment); - } - } - - public static void decodePointer(AMD64MacroAssembler masm, Register resRegister, Register heapBaseRegister, CompressEncoding encoding) { - // If the base is zero, the compressed address has to be shifted left - // in order to be uncompressed. - if (encoding.base == 0) { - if (encoding.shift != 0) { - assert encoding.alignment == encoding.shift : "Decode algorithm is wrong"; - masm.shlq(resRegister, encoding.alignment); - } - } else { - Label done = new Label(); - masm.shlq(resRegister, encoding.alignment); - masm.jccb(ConditionFlag.Equal, done); - // Otherwise the heap base is added to the shifted address. - masm.addq(resRegister, heapBaseRegister); - masm.bind(done); - } - } - - private static void encodeKlassPointer(AMD64MacroAssembler masm, Register scratchRegister, Register heapBaseRegister, CompressEncoding encoding) { - if (encoding.base != 0) { - masm.movq(heapBaseRegister, encoding.base); - masm.subq(scratchRegister, heapBaseRegister); - } - if (encoding.shift != 0) { - assert encoding.alignment == encoding.shift : "Encode algorithm is wrong"; - masm.shrq(scratchRegister, encoding.alignment); - } - } - public static void decodeKlassPointer(AMD64MacroAssembler masm, Register register, Register scratch, AMD64Address address, CompressEncoding encoding) { masm.movl(register, address); if (encoding.shift != 0) { diff -r b2c18c498f13 -r 3eedf7a653ea graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java Wed May 28 12:15:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java Wed May 28 12:16:44 2014 +0200 @@ -93,7 +93,7 @@ } @Override - public boolean canStoreConstant(Constant c, boolean isCompressed) { + public boolean canStoreConstant(Constant c) { return !(c instanceof HotSpotObjectConstant); } @@ -134,7 +134,7 @@ if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(c)) { c = Constant.INT_0; } - if (canStoreConstant(c, false)) { + if (canStoreConstant(c)) { append(new StoreConstantOp(getMemoryKind(kind), storeAddress, c, state)); return; } diff -r b2c18c498f13 -r 3eedf7a653ea graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Wed May 28 12:15:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Wed May 28 12:16:44 2014 +0200 @@ -179,8 +179,8 @@ SPARCAddressValue storeAddress = asAddressValue(address); if (isConstant(inputVal)) { Constant c = asConstant(inputVal); - if (canStoreConstant(c, false)) { - append(new StoreConstantOp((Kind) kind, storeAddress, c, state, false)); + if (canStoreConstant(c)) { + append(new StoreConstantOp((Kind) kind, storeAddress, c, state)); return; } } diff -r b2c18c498f13 -r 3eedf7a653ea graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java Wed May 28 12:15:50 2014 +0200 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java Wed May 28 12:16:44 2014 +0200 @@ -229,67 +229,6 @@ } } - public static class LoadCompressedPointer extends LoadOp { - - private final long base; - private final int shift; - private final int alignment; - @Temp({REG}) private AllocatableValue scratch; - - public LoadCompressedPointer(Kind kind, AllocatableValue result, AllocatableValue scratch, HSAILAddressValue address, LIRFrameState state, long base, int shift, int alignment) { - super(kind, result, address, state); - this.base = base; - this.shift = shift; - this.alignment = alignment; - this.scratch = scratch; - assert kind == Kind.Object || kind == Kind.Long; - } - - @Override - public void emitMemAccess(HSAILAssembler masm) { - // we will do a 32 bit load, zero extending into a 64 bit register - masm.emitLoad(result, address.toAddress(), "u32"); - boolean testForNull = (kind == Kind.Object); - decodePointer(masm, result, base, shift, alignment, testForNull); - } - } - - public static class StoreCompressedPointer extends HSAILLIRInstruction { - - protected final Kind kind; - private final long base; - private final int shift; - private final int alignment; - @Temp({REG}) private AllocatableValue scratch; - @Alive({REG}) protected AllocatableValue input; - @Alive({COMPOSITE}) protected HSAILAddressValue address; - @State protected LIRFrameState state; - - public StoreCompressedPointer(Kind kind, HSAILAddressValue address, AllocatableValue input, AllocatableValue scratch, LIRFrameState state, long base, int shift, int alignment) { - this.base = base; - this.shift = shift; - this.alignment = alignment; - this.scratch = scratch; - this.kind = kind; - this.address = address; - this.state = state; - this.input = input; - assert kind == Kind.Object || kind == Kind.Long; - } - - @Override - public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { - masm.emitMov(kind, scratch, input); - boolean testForNull = (kind == Kind.Object); - encodePointer(masm, scratch, base, shift, alignment, testForNull); - if (state != null) { - throw new InternalError("NYI"); - // crb.recordImplicitException(masm.position(), state); - } - masm.emitStore(scratch, address.toAddress(), "u32"); - } - } - public static class CompressPointer extends HSAILLIRInstruction { private final long base; diff -r b2c18c498f13 -r 3eedf7a653ea graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java Wed May 28 12:15:50 2014 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java Wed May 28 12:16:44 2014 +0200 @@ -329,12 +329,10 @@ public static class StoreConstantOp extends MemOp { protected final Constant input; - private final boolean compress; - public StoreConstantOp(Kind kind, SPARCAddressValue address, Constant input, LIRFrameState state, boolean compress) { + public StoreConstantOp(Kind kind, SPARCAddressValue address, Constant input, LIRFrameState state) { super(kind, address, state); this.input = input; - this.compress = compress; if (!input.isDefaultForKind()) { throw GraalInternalError.shouldNotReachHere("Can only store null constants to memory"); } @@ -356,11 +354,7 @@ break; case Long: case Object: - if (compress) { - new Stw(g0, address.toAddress()).emit(masm); - } else { - new Stx(g0, address.toAddress()).emit(masm); - } + new Stx(g0, address.toAddress()).emit(masm); break; case Float: case Double: diff -r b2c18c498f13 -r 3eedf7a653ea graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Wed May 28 12:15:50 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Wed May 28 12:16:44 2014 +0200 @@ -157,16 +157,6 @@ private LIRGenerationResult res; - /** - * Checks whether the supplied constant can be used without loading it into a register for store - * operations, i.e., on the right hand side of a memory access. - * - * @param c The constant to check. - * @return True if the constant can be used directly, false if the constant needs to be in a - * register. - */ - public abstract boolean canStoreConstant(Constant c, boolean isCompressed); - public LIRGenerator(CodeGenProviders providers, CallingConvention cc, LIRGenerationResult res) { this.res = res; this.providers = providers; diff -r b2c18c498f13 -r 3eedf7a653ea graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java Wed May 28 12:15:50 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java Wed May 28 12:16:44 2014 +0200 @@ -101,7 +101,15 @@ */ boolean canInlineConstant(Constant c); - boolean canStoreConstant(Constant c, boolean isCompressed); + /** + * Checks whether the supplied constant can be used without loading it into a register for store + * operations, i.e., on the right hand side of a memory access. + * + * @param c The constant to check. + * @return True if the constant can be used directly, false if the constant needs to be in a + * register. + */ + boolean canStoreConstant(Constant c); RegisterAttributes attributes(Register register); diff -r b2c18c498f13 -r 3eedf7a653ea graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java Wed May 28 12:15:50 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java Wed May 28 12:16:44 2014 +0200 @@ -48,7 +48,7 @@ // It's possible a constant was forced for other usages so inspect the value directly and // use a constant if it can be directly stored. Value v; - if (value().isConstant() && gen.getLIRGeneratorTool().canStoreConstant(value().asConstant(), false)) { + if (value().isConstant() && gen.getLIRGeneratorTool().canStoreConstant(value().asConstant())) { v = value().asConstant(); } else { v = gen.operand(value());