# HG changeset patch # User Doug Simon # Date 1395668488 -3600 # Node ID 4c5ed5a670ed3c247855a8510442125c4d2edffd # Parent 8dfd3f53ba4a089723ef89ce6bed267788b7688a HSAIL: implemented storing compressed constants and made HSAILHotSpotLIRGenerator implement HotSpotLIRGenerator Contributed-by: Eric Caspole diff -r 8dfd3f53ba4a -r 4c5ed5a670ed 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 Mon Mar 24 11:24:22 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java Mon Mar 24 14:41:28 2014 +0100 @@ -31,6 +31,9 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.hsail.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.hsail.*; import com.oracle.graal.lir.hsail.HSAILControlFlow.*; @@ -45,7 +48,7 @@ /** * The HotSpot specific portion of the HSAIL LIR generator. */ -public class HSAILHotSpotLIRGenerator extends HSAILLIRGenerator { +public class HSAILHotSpotLIRGenerator extends HSAILLIRGenerator implements HotSpotLIRGenerator { private final HotSpotVMConfig config; @@ -54,6 +57,11 @@ this.config = config; } + @Override + public HotSpotProviders getProviders() { + return (HotSpotProviders) super.getProviders(); + } + private int getLogMinObjectAlignment() { return config.logMinObjAlignment(); } @@ -87,6 +95,41 @@ return true; } + @Override + public StackSlot getLockSlot(int lockDepth) { + throw GraalInternalError.shouldNotReachHere("NYI"); + } + + @Override + public void visitDirectCompareAndSwap(DirectCompareAndSwapNode x) { + throw GraalInternalError.shouldNotReachHere("NYI"); + } + + @Override + public void emitPrefetchAllocate(ValueNode address, ValueNode distance) { + throw GraalInternalError.shouldNotReachHere("NYI"); + } + + @Override + public void emitJumpToExceptionHandlerInCaller(ValueNode handlerInCallerPc, ValueNode exception, ValueNode exceptionPc) { + throw GraalInternalError.shouldNotReachHere("NYI"); + } + + @Override + public void emitPatchReturnAddress(ValueNode address) { + throw GraalInternalError.shouldNotReachHere("NYI"); + } + + @Override + public void emitDeoptimizeCaller(DeoptimizationAction action, DeoptimizationReason reason) { + throw GraalInternalError.shouldNotReachHere("NYI"); + } + + @Override + public void emitTailcall(Value[] args, Value address) { + throw GraalInternalError.shouldNotReachHere("NYI"); + } + /** * Appends either a {@link CompareAndSwapOp} or a {@link CompareAndSwapCompressedOp} depending * on whether the memory location of a given {@link LoweredCompareAndSwapNode} contains a @@ -163,6 +206,9 @@ if (isCompressed) { if ((c.getKind() == Kind.Object) && c.isNull()) { append(new StoreConstantOp(Kind.Int, storeAddress, Constant.forInt(0), state)); + } else if (c.getKind() == Kind.Long) { + Constant value = compress(c, config.getKlassEncoding()); + append(new StoreConstantOp(Kind.Int, storeAddress, value, state)); } else { throw GraalInternalError.shouldNotReachHere("can't handle: " + access); } @@ -226,4 +272,14 @@ // this version of emitForeignCall not used for now } + /** + * @return a compressed version of the incoming constant lifted from AMD64HotSpotLIRGenerator + */ + protected static Constant compress(Constant c, CompressEncoding encoding) { + if (c.getKind() == Kind.Long) { + return Constant.forIntegerKind(Kind.Int, (int) (((c.asLong() - encoding.base) >> encoding.shift) & 0xffffffffL), c.getPrimitiveAnnotation()); + } else { + throw GraalInternalError.shouldNotReachHere(); + } + } }