# HG changeset patch # User Doug Simon # Date 1416999956 -3600 # Node ID be44c1ca8f00235e84ee79a7382c0da933753b54 # Parent c538c2c6b7e2dfb60d8d11d0279617af5b6ff501 removed static access to HotSpotGraalRuntime from some AMD64 HotSpot classes diff -r c538c2c6b7e2 -r be44c1ca8f00 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizationStub.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizationStub.java Wed Nov 26 11:48:34 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizationStub.java Wed Nov 26 12:05:56 2014 +0100 @@ -33,9 +33,9 @@ private RegisterConfig registerConfig; - public AMD64DeoptimizationStub(HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) { + public AMD64DeoptimizationStub(HotSpotProviders providers, TargetDescription target, HotSpotVMConfig config, HotSpotForeignCallLinkage linkage) { super(providers, target, linkage); - registerConfig = new AMD64HotSpotRegisterConfig(target.arch, HotSpotGraalRuntime.runtime().getConfig(), new Register[]{rbx, rcx, rdx, rsi, rdi, r8, r9, r10, r11, r13, r14}); + registerConfig = new AMD64HotSpotRegisterConfig(target.arch, config, new Register[]{rbx, rcx, rdx, rsi, rdi, r8, r9, r10, r11, r13, r14}); } @Override diff -r c538c2c6b7e2 -r be44c1ca8f00 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Wed Nov 26 11:48:34 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Wed Nov 26 12:05:56 2014 +0100 @@ -89,7 +89,7 @@ @Override public NodeLIRBuilderTool newNodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool lirGen) { - return new AMD64HotSpotNodeLIRBuilder(graph, lirGen); + return new AMD64HotSpotNodeLIRBuilder(getRuntime(), graph, lirGen); } @Override diff -r c538c2c6b7e2 -r be44c1ca8f00 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java Wed Nov 26 11:48:34 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java Wed Nov 26 12:05:56 2014 +0100 @@ -61,8 +61,8 @@ register(new HotSpotForeignCallLinkageImpl(EXCEPTION_HANDLER, 0L, PRESERVES_REGISTERS, LEAF_NOFP, null, exceptionCc, NOT_REEXECUTABLE, ANY_LOCATION)); register(new HotSpotForeignCallLinkageImpl(EXCEPTION_HANDLER_IN_CALLER, JUMP_ADDRESS, PRESERVES_REGISTERS, LEAF_NOFP, exceptionCc, null, NOT_REEXECUTABLE, ANY_LOCATION)); - link(new AMD64DeoptimizationStub(providers, target, registerStubCall(DEOPTIMIZATION_HANDLER, REEXECUTABLE, LEAF, NO_LOCATIONS))); - link(new AMD64UncommonTrapStub(providers, target, registerStubCall(UNCOMMON_TRAP_HANDLER, REEXECUTABLE, LEAF, NO_LOCATIONS))); + link(new AMD64DeoptimizationStub(providers, target, config, registerStubCall(DEOPTIMIZATION_HANDLER, REEXECUTABLE, LEAF, NO_LOCATIONS))); + link(new AMD64UncommonTrapStub(providers, target, config, registerStubCall(UNCOMMON_TRAP_HANDLER, REEXECUTABLE, LEAF, NO_LOCATIONS))); if (config.useCRC32Intrinsics) { // This stub does callee saving diff -r c538c2c6b7e2 -r be44c1ca8f00 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 Nov 26 11:48:34 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Wed Nov 26 12:05:56 2014 +0100 @@ -25,7 +25,7 @@ import static com.oracle.graal.amd64.AMD64.*; import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.hotspot.HotSpotBackend.*; -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; +//import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; import java.util.*; @@ -166,7 +166,7 @@ if (pollOnReturnScratchRegister == null) { pollOnReturnScratchRegister = findPollOnReturnScratchRegister(); } - append(new AMD64HotSpotReturnOp(operand, getStub() != null, pollOnReturnScratchRegister)); + append(new AMD64HotSpotReturnOp(operand, getStub() != null, pollOnReturnScratchRegister, config)); } @Override @@ -387,8 +387,8 @@ } private void moveDeoptValuesToThread(Value actionAndReason, Value speculation) { - moveValueToThread(actionAndReason, runtime().getConfig().pendingDeoptimizationOffset); - moveValueToThread(speculation, runtime().getConfig().pendingFailedSpeculationOffset); + moveValueToThread(actionAndReason, config.pendingDeoptimizationOffset); + moveValueToThread(speculation, config.pendingFailedSpeculationOffset); } private void moveValueToThread(Value v, int offset) { @@ -438,7 +438,7 @@ Variable framePcVariable = load(framePc); Variable senderSpVariable = load(senderSp); Variable initialInfoVariable = load(initialInfo); - append(new AMD64HotSpotPushInterpreterFrameOp(frameSizeVariable, framePcVariable, senderSpVariable, initialInfoVariable)); + append(new AMD64HotSpotPushInterpreterFrameOp(frameSizeVariable, framePcVariable, senderSpVariable, initialInfoVariable, config)); } @Override diff -r c538c2c6b7e2 -r be44c1ca8f00 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Wed Nov 26 11:48:34 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Wed Nov 26 12:05:56 2014 +0100 @@ -68,6 +68,8 @@ return result; } + private final HotSpotGraalRuntimeProvider runtime; + private void emitCompareCompressedMemory(Kind kind, IfNode ifNode, ValueNode valueNode, CompressionNode compress, ConstantLocationNode location, Access access, CompareNode compare) { Value value = gen.load(operand(valueNode)); AMD64AddressValue address = makeCompressedAddress(compress, location); @@ -84,8 +86,9 @@ getGen().emitCompareBranchMemory(kind, value, address, getState(access), cond, compare.unorderedIsTrue(), trueLabel, falseLabel, trueLabelProbability); } - public AMD64HotSpotNodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool gen) { + public AMD64HotSpotNodeLIRBuilder(HotSpotGraalRuntimeProvider runtime, StructuredGraph graph, LIRGeneratorTool gen) { super(graph, gen); + this.runtime = runtime; assert gen instanceof AMD64HotSpotLIRGenerator; assert getDebugInfoBuilder() instanceof HotSpotDebugInfoBuilder; ((AMD64HotSpotLIRGenerator) gen).setLockStack(((HotSpotDebugInfoBuilder) getDebugInfoBuilder()).lockStack()); @@ -148,7 +151,7 @@ protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) { InvokeKind invokeKind = ((HotSpotDirectCallTargetNode) callTarget).invokeKind(); if (invokeKind == InvokeKind.Interface || invokeKind == InvokeKind.Virtual) { - append(new AMD64HotspotDirectVirtualCallOp(callTarget.targetMethod(), result, parameters, temps, callState, invokeKind)); + append(new AMD64HotspotDirectVirtualCallOp(callTarget.targetMethod(), result, parameters, temps, callState, invokeKind, runtime.getConfig())); } else { assert invokeKind == InvokeKind.Static || invokeKind == InvokeKind.Special; HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) callTarget.targetMethod(); @@ -221,7 +224,7 @@ } boolean canFormCompressedMemory(CompressionNode compress, ConstantLocationNode location) { - HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig(); + HotSpotVMConfig config = runtime.getConfig(); if (config.useCompressedOops && compress.getEncoding().shift <= 3 && NumUtil.isInt(location.getDisplacement())) { Stamp compressedStamp = compress.getValue().stamp(); if (compressedStamp instanceof NarrowOopStamp) { diff -r c538c2c6b7e2 -r be44c1ca8f00 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotPushInterpreterFrameOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotPushInterpreterFrameOp.java Wed Nov 26 11:48:34 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotPushInterpreterFrameOp.java Wed Nov 26 12:05:56 2014 +0100 @@ -44,12 +44,14 @@ @Alive(REG) AllocatableValue framePc; @Alive(REG) AllocatableValue senderSp; @Alive(REG) AllocatableValue initialInfo; + private final HotSpotVMConfig config; - AMD64HotSpotPushInterpreterFrameOp(AllocatableValue frameSize, AllocatableValue framePc, AllocatableValue senderSp, AllocatableValue initialInfo) { + AMD64HotSpotPushInterpreterFrameOp(AllocatableValue frameSize, AllocatableValue framePc, AllocatableValue senderSp, AllocatableValue initialInfo, HotSpotVMConfig config) { this.frameSize = frameSize; this.framePc = framePc; this.senderSp = senderSp; this.initialInfo = initialInfo; + this.config = config; } @Override @@ -58,8 +60,7 @@ final Register framePcRegister = asRegister(framePc); final Register senderSpRegister = asRegister(senderSp); final Register initialInfoRegister = asRegister(initialInfo); - final HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig(); - final int wordSize = HotSpotGraalRuntime.runtime().getTarget().wordSize; + final int wordSize = 8; // We'll push PC and BP by hand. masm.subq(frameSizeRegister, 2 * wordSize); diff -r c538c2c6b7e2 -r be44c1ca8f00 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotReturnOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotReturnOp.java Wed Nov 26 11:48:34 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotReturnOp.java Wed Nov 26 12:05:56 2014 +0100 @@ -22,12 +22,12 @@ */ package com.oracle.graal.hotspot.amd64; -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; +import com.oracle.graal.hotspot.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.BlockEndOp; import com.oracle.graal.lir.asm.*; @@ -41,11 +41,13 @@ @Use({REG, ILLEGAL}) protected Value value; private final boolean isStub; private final Register scratchForSafepointOnReturn; + private final HotSpotVMConfig config; - AMD64HotSpotReturnOp(Value value, boolean isStub, Register scratchForSafepointOnReturn) { + AMD64HotSpotReturnOp(Value value, boolean isStub, Register scratchForSafepointOnReturn, HotSpotVMConfig config) { this.value = value; this.isStub = isStub; this.scratchForSafepointOnReturn = scratchForSafepointOnReturn; + this.config = config; } @Override @@ -53,7 +55,7 @@ leaveFrameAndRestoreRbp(crb, masm); if (!isStub) { // Every non-stub compile method must have a poll before the return. - AMD64HotSpotSafepointOp.emitCode(crb, masm, runtime().getConfig(), true, null, scratchForSafepointOnReturn); + AMD64HotSpotSafepointOp.emitCode(crb, masm, config, true, null, scratchForSafepointOnReturn); } masm.ret(0); } diff -r c538c2c6b7e2 -r be44c1ca8f00 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectVirtualCallOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectVirtualCallOp.java Wed Nov 26 11:48:34 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectVirtualCallOp.java Wed Nov 26 12:05:56 2014 +0100 @@ -40,10 +40,12 @@ final class AMD64HotspotDirectVirtualCallOp extends DirectCallOp { private final InvokeKind invokeKind; + private final HotSpotVMConfig config; - AMD64HotspotDirectVirtualCallOp(ResolvedJavaMethod target, Value result, Value[] parameters, Value[] temps, LIRFrameState state, InvokeKind invokeKind) { + AMD64HotspotDirectVirtualCallOp(ResolvedJavaMethod target, Value result, Value[] parameters, Value[] temps, LIRFrameState state, InvokeKind invokeKind, HotSpotVMConfig config) { super(target, result, parameters, temps, state); this.invokeKind = invokeKind; + this.config = config; assert invokeKind == InvokeKind.Interface || invokeKind == InvokeKind.Virtual; } @@ -53,7 +55,7 @@ // instruction that loads the Klass from the inline cache. MarkId.recordMark(crb, invokeKind == InvokeKind.Virtual ? MarkId.INVOKEVIRTUAL : MarkId.INVOKEINTERFACE); // This must be emitted exactly like this to ensure it's patchable - masm.movq(AMD64.rax, HotSpotGraalRuntime.runtime().getConfig().nonOopBits); + masm.movq(AMD64.rax, config.nonOopBits); super.emitCode(crb, masm); } } diff -r c538c2c6b7e2 -r be44c1ca8f00 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64UncommonTrapStub.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64UncommonTrapStub.java Wed Nov 26 11:48:34 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64UncommonTrapStub.java Wed Nov 26 12:05:56 2014 +0100 @@ -33,10 +33,10 @@ private RegisterConfig registerConfig; - public AMD64UncommonTrapStub(HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) { + public AMD64UncommonTrapStub(HotSpotProviders providers, TargetDescription target, HotSpotVMConfig config, HotSpotForeignCallLinkage linkage) { super(providers, target, linkage); Register[] allocatable = new Register[]{rbx, rcx, rdx, rsi, rdi, r8, r9, r10, r11, r13, r14}; - registerConfig = new AMD64HotSpotRegisterConfig(target.arch, HotSpotGraalRuntime.runtime().getConfig(), allocatable); + registerConfig = new AMD64HotSpotRegisterConfig(target.arch, config, allocatable); } @Override