--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotLIRGenerator.java 2017-03-20 17:38:11.000000000 -0700 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotLIRGenerator.java 2017-03-20 17:38:11.000000000 -0700 @@ -22,29 +22,26 @@ */ package org.graalvm.compiler.hotspot.amd64; +import static jdk.vm.ci.amd64.AMD64.rbp; import static org.graalvm.compiler.core.common.GraalOptions.GeneratePIC; import static org.graalvm.compiler.hotspot.HotSpotBackend.INITIALIZE_KLASS_BY_SYMBOL; import static org.graalvm.compiler.hotspot.HotSpotBackend.RESOLVE_KLASS_BY_SYMBOL; import static org.graalvm.compiler.hotspot.HotSpotBackend.RESOLVE_METHOD_BY_SYMBOL_AND_LOAD_COUNTERS; import static org.graalvm.compiler.hotspot.HotSpotBackend.RESOLVE_STRING_BY_SYMBOL; -import static org.graalvm.compiler.hotspot.HotSpotBackend.FETCH_UNROLL_INFO; -import static org.graalvm.compiler.hotspot.HotSpotBackend.UNCOMMON_TRAP; -import static jdk.vm.ci.amd64.AMD64.rbp; import java.util.ArrayList; import java.util.List; -import java.util.Map; import org.graalvm.compiler.asm.amd64.AMD64Address.Scale; import org.graalvm.compiler.core.amd64.AMD64ArithmeticLIRGenerator; import org.graalvm.compiler.core.amd64.AMD64LIRGenerator; import org.graalvm.compiler.core.amd64.AMD64MoveFactoryBase.BackupSlotProvider; +import org.graalvm.compiler.core.common.CompressEncoding; import org.graalvm.compiler.core.common.LIRKind; import org.graalvm.compiler.core.common.spi.ForeignCallLinkage; import org.graalvm.compiler.core.common.spi.LIRKindTool; import org.graalvm.compiler.debug.Debug; import org.graalvm.compiler.debug.GraalError; -import org.graalvm.compiler.hotspot.CompressEncoding; import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig; import org.graalvm.compiler.hotspot.HotSpotBackend; import org.graalvm.compiler.hotspot.HotSpotDebugInfoBuilder; @@ -63,7 +60,6 @@ import org.graalvm.compiler.lir.LIRInstructionClass; import org.graalvm.compiler.lir.LabelRef; import org.graalvm.compiler.lir.StandardOp.NoOp; -import org.graalvm.compiler.lir.StandardOp.SaveRegistersOp; import org.graalvm.compiler.lir.SwitchStrategy; import org.graalvm.compiler.lir.Variable; import org.graalvm.compiler.lir.VirtualStackSlot; @@ -81,6 +77,7 @@ import org.graalvm.compiler.lir.asm.CompilationResultBuilder; import org.graalvm.compiler.lir.framemap.FrameMapBuilder; import org.graalvm.compiler.lir.gen.LIRGenerationResult; +import org.graalvm.compiler.options.OptionValues; import jdk.vm.ci.amd64.AMD64; import jdk.vm.ci.amd64.AMD64Kind; @@ -294,34 +291,6 @@ super.emitForeignCallOp(linkage, result, arguments, temps, info); } - @Override - public void emitLeaveCurrentStackFrame(SaveRegistersOp saveRegisterOp) { - append(new AMD64HotSpotLeaveCurrentStackFrameOp(saveRegisterOp)); - } - - @Override - public void emitLeaveDeoptimizedStackFrame(Value frameSize, Value initialInfo) { - Variable frameSizeVariable = load(frameSize); - Variable initialInfoVariable = load(initialInfo); - append(new AMD64HotSpotLeaveDeoptimizedStackFrameOp(frameSizeVariable, initialInfoVariable)); - } - - @Override - public void emitEnterUnpackFramesStackFrame(Value framePc, Value senderSp, Value senderFp, SaveRegistersOp saveRegisterOp) { - Register threadRegister = getProviders().getRegisters().getThreadRegister(); - Variable framePcVariable = load(framePc); - Variable senderSpVariable = load(senderSp); - Variable senderFpVariable = load(senderFp); - append(new AMD64HotSpotEnterUnpackFramesStackFrameOp(threadRegister, config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadLastJavaFpOffset(), framePcVariable, - senderSpVariable, senderFpVariable, saveRegisterOp)); - } - - @Override - public void emitLeaveUnpackFramesStackFrame(SaveRegistersOp saveRegisterOp) { - Register threadRegister = getProviders().getRegisters().getThreadRegister(); - append(new AMD64HotSpotLeaveUnpackFramesStackFrameOp(threadRegister, config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadLastJavaFpOffset(), saveRegisterOp)); - } - /** * @param savedRegisters the registers saved by this operation which may be subject to pruning * @param savedRegisterLocations the slots to which the registers are saved @@ -359,13 +328,6 @@ return emitSaveRegisters(savedRegisters, savedRegisterLocations, supportsRemove); } - @Override - public SaveRegistersOp emitSaveAllRegisters() { - // We are saving all registers. - // TODO Save upper half of YMM registers. - return emitSaveAllRegisters(target().arch.getAvailableValueRegisters().toArray(), false); - } - protected void emitRestoreRegisters(AMD64SaveRegistersOp save) { append(new AMD64RestoreRegistersOp(save.getSlots().clone(), save)); } @@ -421,8 +383,12 @@ if (stub != null) { if (stub.preservesRegisters()) { HotSpotLIRGenerationResult generationResult = getResult(); - assert !generationResult.getCalleeSaveInfo().containsKey(currentRuntimeCallInfo); - generationResult.getCalleeSaveInfo().put(currentRuntimeCallInfo, save); + LIRFrameState key = currentRuntimeCallInfo; + if (key == null) { + key = LIRFrameState.NO_STATE; + } + assert !generationResult.getCalleeSaveInfo().containsKey(key); + generationResult.getCalleeSaveInfo().put(key, save); emitRestoreRegisters(save); } } @@ -511,38 +477,6 @@ } @Override - public Value emitUncommonTrapCall(Value trapRequest, Value mode, SaveRegistersOp saveRegisterOp) { - ForeignCallLinkage linkage = getForeignCalls().lookupForeignCall(UNCOMMON_TRAP); - - Register thread = getProviders().getRegisters().getThreadRegister(); - append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread)); - Variable result = super.emitForeignCall(linkage, null, thread.asValue(LIRKind.value(AMD64Kind.QWORD)), trapRequest, mode); - append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), config.threadLastJavaPcOffset(), thread)); - - Map calleeSaveInfo = getResult().getCalleeSaveInfo(); - assert !calleeSaveInfo.containsKey(currentRuntimeCallInfo); - calleeSaveInfo.put(currentRuntimeCallInfo, saveRegisterOp); - - return result; - } - - @Override - public Value emitDeoptimizationFetchUnrollInfoCall(Value mode, SaveRegistersOp saveRegisterOp) { - ForeignCallLinkage linkage = getForeignCalls().lookupForeignCall(FETCH_UNROLL_INFO); - - Register thread = getProviders().getRegisters().getThreadRegister(); - append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread)); - Variable result = super.emitForeignCall(linkage, null, thread.asValue(LIRKind.value(AMD64Kind.QWORD)), mode); - append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), config.threadLastJavaPcOffset(), thread)); - - Map calleeSaveInfo = getResult().getCalleeSaveInfo(); - assert !calleeSaveInfo.containsKey(currentRuntimeCallInfo); - calleeSaveInfo.put(currentRuntimeCallInfo, saveRegisterOp); - - return result; - } - - @Override public void emitTailcall(Value[] args, Value address) { append(new AMD64TailcallOp(args, address)); } @@ -621,22 +555,13 @@ LIRInstruction op = getOrInitRescueSlotOp(); // insert dummy instruction into the start block LIR lir = getResult().getLIR(); - List instructions = lir.getLIRforBlock(lir.getControlFlowGraph().getStartBlock()); + ArrayList instructions = lir.getLIRforBlock(lir.getControlFlowGraph().getStartBlock()); instructions.add(1, op); Debug.dump(Debug.INFO_LOG_LEVEL, lir, "created rescue dummy op"); } } @Override - public void emitPushInterpreterFrame(Value frameSize, Value framePc, Value senderSp, Value initialInfo) { - Variable frameSizeVariable = load(frameSize); - Variable framePcVariable = load(framePc); - Variable senderSpVariable = load(senderSp); - Variable initialInfoVariable = load(initialInfo); - append(new AMD64HotSpotPushInterpreterFrameOp(frameSizeVariable, framePcVariable, senderSpVariable, initialInfoVariable, config)); - } - - @Override public Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull) { LIRKind inputKind = pointer.getValueKind(LIRKind.class); assert inputKind.getPlatformKind() == AMD64Kind.QWORD; @@ -649,14 +574,15 @@ // metaspace pointer Variable result = newVariable(LIRKind.value(AMD64Kind.DWORD)); AllocatableValue base = Value.ILLEGAL; - if (encoding.base != 0 || GeneratePIC.getValue()) { - if (GeneratePIC.getValue()) { + OptionValues options = getResult().getLIR().getOptions(); + if (encoding.hasBase() || GeneratePIC.getValue(options)) { + if (GeneratePIC.getValue(options)) { Variable baseAddress = newVariable(LIRKind.value(AMD64Kind.QWORD)); AMD64HotSpotMove.BaseMove move = new AMD64HotSpotMove.BaseMove(baseAddress, config); append(move); base = baseAddress; } else { - base = emitLoadConstant(LIRKind.value(AMD64Kind.QWORD), JavaConstant.forLong(encoding.base)); + base = emitLoadConstant(LIRKind.value(AMD64Kind.QWORD), JavaConstant.forLong(encoding.getBase())); } } append(new AMD64HotSpotMove.CompressPointer(result, asAllocatable(pointer), base, encoding, nonNull)); @@ -677,14 +603,15 @@ // metaspace pointer Variable result = newVariable(LIRKind.value(AMD64Kind.QWORD)); AllocatableValue base = Value.ILLEGAL; - if (encoding.base != 0 || GeneratePIC.getValue()) { - if (GeneratePIC.getValue()) { + OptionValues options = getResult().getLIR().getOptions(); + if (encoding.hasBase() || GeneratePIC.getValue(options)) { + if (GeneratePIC.getValue(options)) { Variable baseAddress = newVariable(LIRKind.value(AMD64Kind.QWORD)); AMD64HotSpotMove.BaseMove move = new AMD64HotSpotMove.BaseMove(baseAddress, config); append(move); base = baseAddress; } else { - base = emitLoadConstant(LIRKind.value(AMD64Kind.QWORD), JavaConstant.forLong(encoding.base)); + base = emitLoadConstant(LIRKind.value(AMD64Kind.QWORD), JavaConstant.forLong(encoding.getBase())); } } append(new AMD64HotSpotMove.UncompressPointer(result, asAllocatable(pointer), base, encoding, nonNull)); @@ -697,9 +624,10 @@ if (address.getValueKind().getPlatformKind() == AMD64Kind.DWORD) { CompressEncoding encoding = config.getOopEncoding(); Value uncompressed; - if (encoding.shift <= 3) { + if (encoding.getShift() <= 3) { LIRKind wordKind = LIRKind.unknownReference(target().arch.getWordKind()); - uncompressed = new AMD64AddressValue(wordKind, getProviders().getRegisters().getHeapBaseRegister().asValue(wordKind), asAllocatable(address), Scale.fromInt(1 << encoding.shift), 0); + uncompressed = new AMD64AddressValue(wordKind, getProviders().getRegisters().getHeapBaseRegister().asValue(wordKind), asAllocatable(address), Scale.fromInt(1 << encoding.getShift()), + 0); } else { uncompressed = emitUncompress(address, encoding, false); }