Skip to content

Commit 56ce091

Browse files
Automatic merge of master into galahad
2 parents f282333 + 643e28d commit 56ce091

File tree

3 files changed

+81
-9
lines changed

3 files changed

+81
-9
lines changed

substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/lowering/LLVMLoadExceptionObjectLowering.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@
2424
*/
2525
package com.oracle.svm.core.graal.llvm.lowering;
2626

27-
import jdk.graal.compiler.core.common.type.StampFactory;
27+
import com.oracle.svm.core.graal.nodes.ReadExceptionObjectNode;
28+
import com.oracle.svm.core.graal.snippets.NodeLoweringProvider;
29+
import com.oracle.svm.core.nodes.CFunctionEpilogueNode;
30+
import com.oracle.svm.core.thread.VMThreads;
31+
2832
import jdk.graal.compiler.debug.GraalError;
2933
import jdk.graal.compiler.nodes.FixedWithNextNode;
3034
import jdk.graal.compiler.nodes.FrameState;
35+
import jdk.graal.compiler.nodes.NodeView;
3136
import jdk.graal.compiler.nodes.StructuredGraph;
3237
import jdk.graal.compiler.nodes.java.LoadExceptionObjectNode;
3338
import jdk.graal.compiler.nodes.spi.LoweringTool;
3439

35-
import com.oracle.svm.core.graal.nodes.ReadExceptionObjectNode;
36-
import com.oracle.svm.core.graal.snippets.NodeLoweringProvider;
37-
import com.oracle.svm.core.nodes.CFunctionEpilogueNode;
38-
import com.oracle.svm.core.thread.VMThreads;
39-
4040
public class LLVMLoadExceptionObjectLowering implements NodeLoweringProvider<LoadExceptionObjectNode> {
4141

4242
@Override
@@ -46,7 +46,7 @@ public void lower(LoadExceptionObjectNode node, LoweringTool tool) {
4646

4747
StructuredGraph graph = node.graph();
4848
GraalError.guarantee(graph.getGuardsStage().areFrameStatesAtDeopts(), "Should be after FSA %s", node);
49-
FixedWithNextNode readRegNode = graph.add(new ReadExceptionObjectNode(StampFactory.objectNonNull()));
49+
FixedWithNextNode readRegNode = graph.add(new ReadExceptionObjectNode(node.stamp(NodeView.DEFAULT)));
5050
graph.replaceFixedWithFixed(node, readRegNode);
5151

5252
/*

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/ExceptionSnippets.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444

4545
import jdk.graal.compiler.api.replacements.Snippet;
4646
import jdk.graal.compiler.api.replacements.Snippet.ConstantParameter;
47-
import jdk.graal.compiler.core.common.type.StampFactory;
4847
import jdk.graal.compiler.graph.Node;
4948
import jdk.graal.compiler.nodes.FixedWithNextNode;
49+
import jdk.graal.compiler.nodes.NodeView;
5050
import jdk.graal.compiler.nodes.StructuredGraph;
5151
import jdk.graal.compiler.nodes.UnwindNode;
5252
import jdk.graal.compiler.nodes.java.LoadExceptionObjectNode;
@@ -111,7 +111,7 @@ public static class LoadExceptionObjectLowering implements NodeLoweringProvider<
111111
@Override
112112
public void lower(LoadExceptionObjectNode node, LoweringTool tool) {
113113
StructuredGraph graph = node.graph();
114-
FixedWithNextNode readRegNode = graph.add(new ReadExceptionObjectNode(StampFactory.objectNonNull()));
114+
FixedWithNextNode readRegNode = graph.add(new ReadExceptionObjectNode(node.stamp(NodeView.DEFAULT)));
115115
graph.replaceFixedWithFixed(node, readRegNode);
116116
}
117117
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaUtilSubstitutions.java

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import com.oracle.svm.core.SubstrateUtil;
3838
import com.oracle.svm.core.annotate.Alias;
3939
import com.oracle.svm.core.annotate.Inject;
40+
import com.oracle.svm.core.annotate.InjectAccessors;
4041
import com.oracle.svm.core.annotate.RecomputeFieldValue;
4142
import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind;
4243
import com.oracle.svm.core.annotate.Substitute;
@@ -150,6 +151,46 @@ final class Target_java_util_concurrent_ConcurrentHashMap {
150151
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)//
151152
Target_java_util_concurrent_ConcurrentHashMap_EntrySetView entrySet;
152153

154+
@Alias @InjectAccessors(NCPUAccessor.class) //
155+
private static int NCPU;
156+
}
157+
158+
final class NCPUAccessor {
159+
private static int cachedNCPU = -1;
160+
161+
static int get() {
162+
if (cachedNCPU != -1) {
163+
return cachedNCPU;
164+
}
165+
return initializeNCPU();
166+
}
167+
168+
private static synchronized int initializeNCPU() {
169+
if (cachedNCPU != -1) {
170+
return cachedNCPU;
171+
}
172+
173+
cachedNCPU = Runtime.getRuntime().availableProcessors();
174+
return cachedNCPU;
175+
}
176+
177+
static synchronized void set(int value) {
178+
cachedNCPU = value;
179+
}
180+
}
181+
182+
@TargetClass(java.util.concurrent.Phaser.class)
183+
final class Target_java_util_concurrent_Phaser {
184+
185+
@Alias @InjectAccessors(NCPUAccessor.class) //
186+
private static int NCPU;
187+
}
188+
189+
@TargetClass(className = "java.util.concurrent.atomic.Striped64")
190+
final class Target_java_util_concurrent_atomic_Striped64 {
191+
192+
@Alias @InjectAccessors(NCPUAccessor.class) //
193+
private static int NCPU;
153194
}
154195

155196
@TargetClass(value = java.util.concurrent.ConcurrentHashMap.class, innerClass = "KeySetView")
@@ -289,6 +330,37 @@ public boolean getAsBoolean() {
289330
}
290331
}
291332

333+
@TargetClass(className = "java.util.concurrent.LinkedTransferQueue", innerClass = "DualNode")
334+
final class Target_java_util_concurrent_LinkedTransferQueue_DualNode {
335+
336+
@Alias @InjectAccessors(LinkedTransferQueueDualNodeIsUniprocessorAccessor.class) //
337+
private static boolean isUniprocessor;
338+
}
339+
340+
final class LinkedTransferQueueDualNodeIsUniprocessorAccessor {
341+
private static Boolean cachedIsUniprocessor = null;
342+
343+
static boolean get() {
344+
if (cachedIsUniprocessor != null) {
345+
return cachedIsUniprocessor;
346+
}
347+
return initializeIsUniprocessor();
348+
}
349+
350+
static void set(boolean value) {
351+
cachedIsUniprocessor = value;
352+
}
353+
354+
private static synchronized boolean initializeIsUniprocessor() {
355+
if (cachedIsUniprocessor != null) {
356+
return cachedIsUniprocessor;
357+
}
358+
359+
cachedIsUniprocessor = Runtime.getRuntime().availableProcessors() == 1;
360+
return cachedIsUniprocessor;
361+
}
362+
}
363+
292364
/** Dummy class to have a class with the file's name. */
293365
public final class JavaUtilSubstitutions {
294366
}

0 commit comments

Comments
 (0)