1 /*
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
38 import org.graalvm.compiler.hotspot.HotSpotLIRGenerator;
39 import org.graalvm.compiler.nodeinfo.NodeInfo;
40 import org.graalvm.compiler.nodes.ConstantNode;
41 import org.graalvm.compiler.nodes.calc.FloatingNode;
42 import org.graalvm.compiler.nodes.spi.LIRLowerable;
43 import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
44
45 import jdk.vm.ci.meta.JavaKind;
46 import jdk.vm.ci.meta.Value;
47
48 /**
49 * Represents {@link GraalHotSpotVMConfig} values that may change after compilation.
50 */
51 @NodeInfo(cycles = CYCLES_1, size = SIZE_1)
52 public class GraalHotSpotVMConfigNode extends FloatingNode implements LIRLowerable, Canonicalizable {
53 public static final NodeClass<GraalHotSpotVMConfigNode> TYPE = NodeClass.create(GraalHotSpotVMConfigNode.class);
54
55 private final GraalHotSpotVMConfig config;
56 protected final int markId;
57
58 public GraalHotSpotVMConfigNode(@InjectedNodeParameter GraalHotSpotVMConfig config, int markId, JavaKind kind) {
59 super(TYPE, StampFactory.forKind(kind));
60 this.config = config;
61 this.markId = markId;
62 }
63
64 /**
65 * Constructor selected by {@link #loadConfigValue(int, JavaKind)}.
66 *
67 * @param config
68 * @param markId
69 */
70 public GraalHotSpotVMConfigNode(@InjectedNodeParameter GraalHotSpotVMConfig config, int markId) {
71 super(TYPE, StampFactory.forKind(JavaKind.Boolean));
72 this.config = config;
73 this.markId = 0;
74 }
75
76 @Override
77 public void generate(NodeLIRBuilderTool generator) {
78 Value res = ((HotSpotLIRGenerator) generator.getLIRGeneratorTool()).emitLoadConfigValue(markId);
79 generator.setResult(this, res);
80 }
81
82 @NodeIntrinsic
83 private static native boolean isConfigValueConstant(@ConstantNodeParameter int markId);
84
85 @NodeIntrinsic
86 private static native long loadConfigValue(@ConstantNodeParameter int markId, @ConstantNodeParameter JavaKind kind);
87
88 public static long cardTableAddress() {
89 return loadConfigValue(cardTableAddressMark(INJECTED_VMCONFIG), JavaKind.Long);
90 }
91
92 public static boolean isCardTableAddressConstant() {
93 return isConfigValueConstant(cardTableAddressMark(INJECTED_VMCONFIG));
94 }
95
96 public static long heapTopAddress() {
97 return loadConfigValue(heapTopAddressMark(INJECTED_VMCONFIG), JavaKind.Long);
98 }
99
100 public static long heapEndAddress() {
101 return loadConfigValue(heapEndAddressMark(INJECTED_VMCONFIG), JavaKind.Long);
102 }
103
104 public static long crcTableAddress() {
105 return loadConfigValue(crcTableAddressMark(INJECTED_VMCONFIG), JavaKind.Long);
106 }
107
108 public static int logOfHeapRegionGrainBytes() {
109 return (int) loadConfigValue(logOfHeapRegionGrainBytesMark(INJECTED_VMCONFIG), JavaKind.Byte);
110 }
111
112 public static boolean inlineContiguousAllocationSupported() {
113 return loadConfigValue(inlineContiguousAllocationSupportedMark(INJECTED_VMCONFIG), JavaKind.Byte) > 0;
114 }
115
116 @Fold
117 public static int cardTableAddressMark(@InjectedParameter GraalHotSpotVMConfig config) {
118 return config.MARKID_CARD_TABLE_ADDRESS;
119 }
120
121 @Fold
122 public static int heapTopAddressMark(@InjectedParameter GraalHotSpotVMConfig config) {
123 return config.MARKID_HEAP_TOP_ADDRESS;
124 }
125
126 @Fold
127 public static int heapEndAddressMark(@InjectedParameter GraalHotSpotVMConfig config) {
128 return config.MARKID_HEAP_END_ADDRESS;
129 }
130
131 @Fold
132 public static int crcTableAddressMark(@InjectedParameter GraalHotSpotVMConfig config) {
133 return config.MARKID_CRC_TABLE_ADDRESS;
|
1 /*
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
38 import org.graalvm.compiler.hotspot.HotSpotLIRGenerator;
39 import org.graalvm.compiler.nodeinfo.NodeInfo;
40 import org.graalvm.compiler.nodes.ConstantNode;
41 import org.graalvm.compiler.nodes.calc.FloatingNode;
42 import org.graalvm.compiler.nodes.spi.LIRLowerable;
43 import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
44
45 import jdk.vm.ci.meta.JavaKind;
46 import jdk.vm.ci.meta.Value;
47
48 /**
49 * Represents {@link GraalHotSpotVMConfig} values that may change after compilation.
50 */
51 @NodeInfo(cycles = CYCLES_1, size = SIZE_1)
52 public class GraalHotSpotVMConfigNode extends FloatingNode implements LIRLowerable, Canonicalizable {
53 public static final NodeClass<GraalHotSpotVMConfigNode> TYPE = NodeClass.create(GraalHotSpotVMConfigNode.class);
54
55 private final GraalHotSpotVMConfig config;
56 protected final int markId;
57
58 /**
59 * Constructor for {@link #areConfigValuesConstant()}.
60 *
61 * @param config
62 */
63 public GraalHotSpotVMConfigNode(@InjectedNodeParameter GraalHotSpotVMConfig config) {
64 super(TYPE, StampFactory.forKind(JavaKind.Boolean));
65 this.config = config;
66 this.markId = 0;
67 }
68
69 /**
70 * Constructor for node intrinsics below.
71 *
72 * @param config
73 * @param markId id of the config value
74 */
75 public GraalHotSpotVMConfigNode(@InjectedNodeParameter GraalHotSpotVMConfig config, int markId) {
76 super(TYPE, StampFactory.forNodeIntrinsic());
77 this.config = config;
78 this.markId = markId;
79 }
80
81 /**
82 * Constructor with explicit type specification.
83 *
84 * @param config
85 * @param markId id of the config value
86 * @param kind explicit type of the node
87 */
88 public GraalHotSpotVMConfigNode(@InjectedNodeParameter GraalHotSpotVMConfig config, int markId, JavaKind kind) {
89 super(TYPE, StampFactory.forKind(kind));
90 this.config = config;
91 this.markId = markId;
92 }
93
94 @Override
95 public void generate(NodeLIRBuilderTool generator) {
96 Value res = ((HotSpotLIRGenerator) generator.getLIRGeneratorTool()).emitLoadConfigValue(markId, generator.getLIRGeneratorTool().getLIRKind(stamp));
97 generator.setResult(this, res);
98 }
99
100 @NodeIntrinsic
101 private static native boolean areConfigValuesConstant();
102
103 @NodeIntrinsic(setStampFromReturnType = true)
104 private static native long loadLongConfigValue(@ConstantNodeParameter int markId);
105
106 @NodeIntrinsic(setStampFromReturnType = true)
107 private static native int loadIntConfigValue(@ConstantNodeParameter int markId);
108
109 @NodeIntrinsic(setStampFromReturnType = true)
110 private static native byte loadByteConfigValue(@ConstantNodeParameter int markId);
111
112 public static long cardTableAddress() {
113 return loadLongConfigValue(cardTableAddressMark(INJECTED_VMCONFIG));
114 }
115
116 public static boolean isCardTableAddressConstant() {
117 return areConfigValuesConstant();
118 }
119
120 public static long heapTopAddress() {
121 return loadLongConfigValue(heapTopAddressMark(INJECTED_VMCONFIG));
122 }
123
124 public static long heapEndAddress() {
125 return loadLongConfigValue(heapEndAddressMark(INJECTED_VMCONFIG));
126 }
127
128 public static long crcTableAddress() {
129 return loadLongConfigValue(crcTableAddressMark(INJECTED_VMCONFIG));
130 }
131
132 public static int logOfHeapRegionGrainBytes() {
133 return loadIntConfigValue(logOfHeapRegionGrainBytesMark(INJECTED_VMCONFIG));
134 }
135
136 public static boolean inlineContiguousAllocationSupported() {
137 return loadByteConfigValue(inlineContiguousAllocationSupportedMark(INJECTED_VMCONFIG)) != 0;
138 }
139
140 @Fold
141 public static int cardTableAddressMark(@InjectedParameter GraalHotSpotVMConfig config) {
142 return config.MARKID_CARD_TABLE_ADDRESS;
143 }
144
145 @Fold
146 public static int heapTopAddressMark(@InjectedParameter GraalHotSpotVMConfig config) {
147 return config.MARKID_HEAP_TOP_ADDRESS;
148 }
149
150 @Fold
151 public static int heapEndAddressMark(@InjectedParameter GraalHotSpotVMConfig config) {
152 return config.MARKID_HEAP_END_ADDRESS;
153 }
154
155 @Fold
156 public static int crcTableAddressMark(@InjectedParameter GraalHotSpotVMConfig config) {
157 return config.MARKID_CRC_TABLE_ADDRESS;
|