--- old/src/jdk.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotLIRGenerator.java 2017-02-06 12:01:21.000000000 -0800 +++ new/src/jdk.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotLIRGenerator.java 2017-02-06 12:01:20.000000000 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -497,9 +497,8 @@ } @Override - public Value emitLoadConfigValue(int markId) { - // Globals are always full-pointer width. - Variable result = newVariable(LIRKind.value(target().arch.getWordKind())); + public Value emitLoadConfigValue(int markId, LIRKind kind) { + Variable result = newVariable(kind); append(new AMD64HotSpotLoadConfigValueOp(markId, result)); return result; } --- old/src/jdk.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotLoadConfigValueOp.java 2017-02-06 12:01:21.000000000 -0800 +++ new/src/jdk.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotLoadConfigValueOp.java 2017-02-06 12:01:21.000000000 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,8 +24,12 @@ import static org.graalvm.compiler.core.common.GraalOptions.GeneratePIC; import static jdk.vm.ci.code.ValueUtil.asRegister; + +import jdk.vm.ci.amd64.AMD64Kind; +import jdk.vm.ci.code.Register; import jdk.vm.ci.meta.AllocatableValue; +import org.graalvm.compiler.asm.amd64.AMD64Address; import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler; import org.graalvm.compiler.debug.GraalError; import org.graalvm.compiler.lir.LIRInstructionClass; @@ -48,7 +52,25 @@ @Override public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { if (GeneratePIC.getValue()) { - masm.movq(asRegister(result), masm.getPlaceholder(-1)); + AMD64Kind kind = (AMD64Kind) result.getPlatformKind(); + Register reg = asRegister(result); + AMD64Address placeholder = masm.getPlaceholder(-1); + switch (kind) { + case BYTE: + masm.movsbl(reg, placeholder); + break; + case WORD: + masm.movswl(reg, placeholder); + break; + case DWORD: + masm.movl(reg, placeholder); + break; + case QWORD: + masm.movq(reg, placeholder); + break; + default: + throw GraalError.unimplemented(); + } } else { throw GraalError.unimplemented(); } --- old/src/jdk.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotLIRGenerator.java 2017-02-06 12:01:22.000000000 -0800 +++ new/src/jdk.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotLIRGenerator.java 2017-02-06 12:01:21.000000000 -0800 @@ -22,6 +22,7 @@ */ package org.graalvm.compiler.hotspot; +import org.graalvm.compiler.core.common.LIRKind; import org.graalvm.compiler.debug.GraalError; import org.graalvm.compiler.hotspot.meta.HotSpotConstantLoadAction; import org.graalvm.compiler.hotspot.meta.HotSpotProviders; @@ -141,10 +142,10 @@ /** * Emits code for a {@link LoadConstantIndirectlyNode}. * - * @param constant + * @param constant original constant + * @param action action to perform on the metaspace object * @return Value of loaded address in register */ - @SuppressWarnings("unused") default Value emitLoadMetaspaceAddress(Constant constant, HotSpotConstantLoadAction action) { throw GraalError.unimplemented(); } @@ -152,21 +153,23 @@ /** * Emits code for a {@link GraalHotSpotVMConfigNode}. * - * @param markId type of address to load + * @param markId id of the value to load + * @param kind type of the value to load * @return value of loaded global in register */ - default Value emitLoadConfigValue(int markId) { + default Value emitLoadConfigValue(int markId, LIRKind kind) { throw GraalError.unimplemented(); } /** * Emits code for a {@link ResolveConstantNode} to resolve a {@link HotSpotObjectConstant}. * + * @param constant original constant * @param constantDescription a description of the string that need to be materialized (and * interned) as java.lang.String, generated with {@link EncodedSymbolConstant} + * @param frameState frame state for the runtime call * @return Returns the address of the requested constant. */ - @SuppressWarnings("unused") default Value emitObjectConstantRetrieval(Constant constant, Value constantDescription, LIRFrameState frameState) { throw GraalError.unimplemented(); } @@ -174,11 +177,12 @@ /** * Emits code for a {@link ResolveConstantNode} to resolve a {@link HotSpotMetaspaceConstant}. * + * @param constant original constant * @param constantDescription a symbolic description of the {@link HotSpotMetaspaceConstant} * generated by {@link EncodedSymbolConstant} + * @param frameState frame state for the runtime call * @return Returns the address of the requested constant. */ - @SuppressWarnings("unused") default Value emitMetaspaceConstantRetrieval(Constant constant, Value constantDescription, LIRFrameState frameState) { throw GraalError.unimplemented(); } @@ -188,12 +192,13 @@ * {@link HotSpotMetaspaceConstant} that represents a {@link ResolvedJavaMethod} and return the * corresponding MethodCounters object. * + * @param method original constant * @param klassHint a klass in which the method is declared * @param methodDescription is symbolic description of the constant generated by * {@link EncodedSymbolConstant} + * @param frameState frame state for the runtime call * @return Returns the address of the requested constant. */ - @SuppressWarnings("unused") default Value emitResolveMethodAndLoadCounters(Constant method, Value klassHint, Value methodDescription, LIRFrameState frameState) { throw GraalError.unimplemented(); } @@ -202,11 +207,13 @@ * Emits code for a {@link ResolveConstantNode} to resolve a klass * {@link HotSpotMetaspaceConstant} and run static initializer. * + * + * @param constant original constant * @param constantDescription a symbolic description of the {@link HotSpotMetaspaceConstant} * generated by {@link EncodedSymbolConstant} + * @param frameState frame state for the runtime call * @return Returns the address of the requested constant. */ - @SuppressWarnings("unused") default Value emitKlassInitializationAndRetrieval(Constant constant, Value constantDescription, LIRFrameState frameState) { throw GraalError.unimplemented(); } --- old/src/jdk.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/nodes/GraalHotSpotVMConfigNode.java 2017-02-06 12:01:22.000000000 -0800 +++ new/src/jdk.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/nodes/GraalHotSpotVMConfigNode.java 2017-02-06 12:01:22.000000000 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,62 +55,86 @@ private final GraalHotSpotVMConfig config; protected final int markId; - public GraalHotSpotVMConfigNode(@InjectedNodeParameter GraalHotSpotVMConfig config, int markId, JavaKind kind) { - super(TYPE, StampFactory.forKind(kind)); + /** + * Constructor for {@link #areConfigValuesConstant()}. + * + * @param config + */ + public GraalHotSpotVMConfigNode(@InjectedNodeParameter GraalHotSpotVMConfig config) { + super(TYPE, StampFactory.forKind(JavaKind.Boolean)); this.config = config; - this.markId = markId; + this.markId = 0; } /** - * Constructor selected by {@link #loadConfigValue(int, JavaKind)}. + * Constructor for node intrinsics below. * * @param config - * @param markId + * @param markId id of the config value */ public GraalHotSpotVMConfigNode(@InjectedNodeParameter GraalHotSpotVMConfig config, int markId) { - super(TYPE, StampFactory.forKind(JavaKind.Boolean)); + super(TYPE, StampFactory.forNodeIntrinsic()); this.config = config; - this.markId = 0; + this.markId = markId; + } + + /** + * Constructor with explicit type specification. + * + * @param config + * @param markId id of the config value + * @param kind explicit type of the node + */ + public GraalHotSpotVMConfigNode(@InjectedNodeParameter GraalHotSpotVMConfig config, int markId, JavaKind kind) { + super(TYPE, StampFactory.forKind(kind)); + this.config = config; + this.markId = markId; } @Override public void generate(NodeLIRBuilderTool generator) { - Value res = ((HotSpotLIRGenerator) generator.getLIRGeneratorTool()).emitLoadConfigValue(markId); + Value res = ((HotSpotLIRGenerator) generator.getLIRGeneratorTool()).emitLoadConfigValue(markId, generator.getLIRGeneratorTool().getLIRKind(stamp)); generator.setResult(this, res); } @NodeIntrinsic - private static native boolean isConfigValueConstant(@ConstantNodeParameter int markId); + private static native boolean areConfigValuesConstant(); - @NodeIntrinsic - private static native long loadConfigValue(@ConstantNodeParameter int markId, @ConstantNodeParameter JavaKind kind); + @NodeIntrinsic(setStampFromReturnType = true) + private static native long loadLongConfigValue(@ConstantNodeParameter int markId); + + @NodeIntrinsic(setStampFromReturnType = true) + private static native int loadIntConfigValue(@ConstantNodeParameter int markId); + + @NodeIntrinsic(setStampFromReturnType = true) + private static native byte loadByteConfigValue(@ConstantNodeParameter int markId); public static long cardTableAddress() { - return loadConfigValue(cardTableAddressMark(INJECTED_VMCONFIG), JavaKind.Long); + return loadLongConfigValue(cardTableAddressMark(INJECTED_VMCONFIG)); } public static boolean isCardTableAddressConstant() { - return isConfigValueConstant(cardTableAddressMark(INJECTED_VMCONFIG)); + return areConfigValuesConstant(); } public static long heapTopAddress() { - return loadConfigValue(heapTopAddressMark(INJECTED_VMCONFIG), JavaKind.Long); + return loadLongConfigValue(heapTopAddressMark(INJECTED_VMCONFIG)); } public static long heapEndAddress() { - return loadConfigValue(heapEndAddressMark(INJECTED_VMCONFIG), JavaKind.Long); + return loadLongConfigValue(heapEndAddressMark(INJECTED_VMCONFIG)); } public static long crcTableAddress() { - return loadConfigValue(crcTableAddressMark(INJECTED_VMCONFIG), JavaKind.Long); + return loadLongConfigValue(crcTableAddressMark(INJECTED_VMCONFIG)); } public static int logOfHeapRegionGrainBytes() { - return (int) loadConfigValue(logOfHeapRegionGrainBytesMark(INJECTED_VMCONFIG), JavaKind.Byte); + return loadIntConfigValue(logOfHeapRegionGrainBytesMark(INJECTED_VMCONFIG)); } public static boolean inlineContiguousAllocationSupported() { - return loadConfigValue(inlineContiguousAllocationSupportedMark(INJECTED_VMCONFIG), JavaKind.Byte) > 0; + return loadByteConfigValue(inlineContiguousAllocationSupportedMark(INJECTED_VMCONFIG)) != 0; } @Fold