Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperIRL committed Dec 20, 2019
2 parents 1691abc + 261f4bf commit 4f22b49
Show file tree
Hide file tree
Showing 42 changed files with 1,188 additions and 174 deletions.
1 change: 1 addition & 0 deletions .hgtags
Expand Up @@ -602,4 +602,5 @@ c16ac7a2eba4e73cb4f7ee9294dd647860eebff0 jdk-14+21
2c724dba4c3cf9516b2152e151c9aea66b21b30b jdk-15+0
91a3f092682fc715d991a87eb6ec6f28886d2035 jdk-14+27
63e17cf29bed191ea21020b4648c9cdf893f80f5 jdk-15+1
2069b4bfd23b56b6fc659fba8b75aaaa23debbe0 jdk-14+28
f33197adda9ad82fdef46ac0f7dc0126204f35b2 jdk-15+2
19 changes: 18 additions & 1 deletion make/autoconf/hotspot.m4
Expand Up @@ -345,10 +345,27 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES],
fi
# Only enable ZGC on supported platforms
if (test "x$OPENJDK_TARGET_OS" = "xwindows" && test "x$OPENJDK_TARGET_CPU" = "xx86_64"); then
AC_MSG_CHECKING([if zgc can be built on windows])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <windows.h>]],
[[struct MEM_EXTENDED_PARAMETER x;]])
],
[
AC_MSG_RESULT([yes])
CAN_BUILD_ZGC_ON_WINDOWS="yes"
],
[
AC_MSG_RESULT([no, missing required APIs])
CAN_BUILD_ZGC_ON_WINDOWS="no"
]
)
fi
AC_MSG_CHECKING([if zgc can be built])
if (test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = "xx86_64") || \
(test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = "xaarch64") || \
(test "x$OPENJDK_TARGET_OS" = "xwindows" && test "x$OPENJDK_TARGET_CPU" = "xx86_64") || \
(test "x$CAN_BUILD_ZGC_ON_WINDOWS" = "xyes") || \
(test "x$OPENJDK_TARGET_OS" = "xmacosx" && test "x$OPENJDK_TARGET_CPU" = "xx86_64"); then
AC_MSG_RESULT([yes])
else
Expand Down
Expand Up @@ -31,6 +31,7 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -43,6 +44,7 @@
import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig;
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
import org.graalvm.compiler.options.OptionValues;
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;

/**
* A format-agnostic container class that holds various components of a binary.
Expand All @@ -67,6 +69,8 @@ public final class BinaryContainer implements SymbolTable {

private final int codeEntryAlignment;

private final boolean threadLocalHandshakes;

/**
* Container holding code bits and any other related information.
*/
Expand Down Expand Up @@ -292,6 +296,8 @@ public BinaryContainer(OptionValues graalOptions, GraalHotSpotVMConfig graalHotS

this.codeEntryAlignment = graalHotSpotVMConfig.codeEntryAlignment;

this.threadLocalHandshakes = graalHotSpotVMConfig.threadLocalHandshakes;

// Section unique name is limited to 8 characters due to limitation on Windows.
// Name could be longer but only first 8 characters are stored on Windows.

Expand Down Expand Up @@ -350,6 +356,12 @@ private void recordConfiguration(GraalHotSpotVMConfig graalHotSpotVMConfig, Grap
// @formatter:on
// @Checkstyle: resume

if (JavaVersionUtil.JAVA_SPEC < 14) {
// See JDK-8220049. Thread local handshakes are on by default since JDK14, the command line option has been removed.
booleanFlags = Arrays.copyOf(booleanFlags, booleanFlags.length + 1);
booleanFlags[booleanFlags.length - 1] = graalHotSpotVMConfig.threadLocalHandshakes;
}

byte[] booleanFlagsAsBytes = flagsToByteArray(booleanFlags);
int size0 = configContainer.getByteStreamSize();

Expand Down Expand Up @@ -449,6 +461,10 @@ public int getCodeEntryAlignment() {
return codeEntryAlignment;
}

public boolean getThreadLocalHandshakes() {
return threadLocalHandshakes;
}

/**
* Gets the global AOT symbol associated with the function name.
*
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2018, 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
Expand Down Expand Up @@ -56,8 +56,11 @@ void process(CompiledMethodInfo methodInfo, Mark mark) {
break;
case POLL_FAR:
case POLL_RETURN_FAR:
// skip relocation
break;
if (binaryContainer.getThreadLocalHandshakes()) {
// skip relocation
break;
}
// fallthrough
case CARD_TABLE_ADDRESS:
case HEAP_TOP_ADDRESS:
case HEAP_END_ADDRESS:
Expand Down
Expand Up @@ -290,7 +290,7 @@ private File buildDMG(
protoDMG.getAbsolutePath(),
hdiUtilVerbosityFlag,
"-mountroot", imagesRoot.getAbsolutePath());
IOUtils.exec(pb);
IOUtils.exec(pb, false, null, true);

File mountedRoot = new File(imagesRoot.getAbsolutePath(),
APP_NAME.fetchFrom(params));
Expand Down
Expand Up @@ -48,6 +48,11 @@ Executor saveOutput(boolean v) {
return this;
}

Executor setWaitBeforeOutput(boolean v) {
waitBeforeOutput = v;
return this;
}

Executor setProcessBuilder(ProcessBuilder v) {
pb = v;
return this;
Expand Down Expand Up @@ -88,6 +93,16 @@ int execute() throws IOException {
Log.verbose(String.format("Running %s", createLogMessage(pb)));
Process p = pb.start();

int code = 0;
if (waitBeforeOutput) {
try {
code = p.waitFor();
} catch (InterruptedException ex) {
Log.verbose(ex);
throw new RuntimeException(ex);
}
}

if (needProcessOutput) {
try (var br = new BufferedReader(new InputStreamReader(
p.getInputStream()))) {
Expand Down Expand Up @@ -131,7 +146,10 @@ int execute() throws IOException {
}

try {
return p.waitFor();
if (!waitBeforeOutput) {
code = p.waitFor();
}
return code;
} catch (InterruptedException ex) {
Log.verbose(ex);
throw new RuntimeException(ex);
Expand All @@ -157,6 +175,7 @@ private static String createLogMessage(ProcessBuilder pb) {

private ProcessBuilder pb;
private boolean saveOutput;
private boolean waitBeforeOutput;
private List<String> output;
private Consumer<Stream<String>> outputConsumer;
}
Expand Up @@ -133,20 +133,33 @@ public static void run(String launcher, File paramFile)

public static void exec(ProcessBuilder pb)
throws IOException {
exec(pb, false, null);
exec(pb, false, null, false);
}

static void exec(ProcessBuilder pb, boolean testForPresenseOnly,
// Reading output from some processes (currently known "hdiutil attach" might hang even if process already
// exited. Only possible workaround found in "hdiutil attach" case is to wait for process to exit before
// reading output.
public static void exec(ProcessBuilder pb, boolean waitBeforeOutput)
throws IOException {
exec(pb, false, null, waitBeforeOutput);
}

static void exec(ProcessBuilder pb, boolean testForPresenceOnly,
PrintStream consumer) throws IOException {
exec(pb, testForPresenceOnly, consumer, false);
}

static void exec(ProcessBuilder pb, boolean testForPresenceOnly,
PrintStream consumer, boolean waitBeforeOutput) throws IOException {
List<String> output = new ArrayList<>();
Executor exec = Executor.of(pb).setOutputConsumer(lines -> {
Executor exec = Executor.of(pb).setWaitBeforeOutput(waitBeforeOutput).setOutputConsumer(lines -> {
lines.forEach(output::add);
if (consumer != null) {
output.forEach(consumer::println);
}
});

if (testForPresenseOnly) {
if (testForPresenceOnly) {
exec.execute();
} else {
exec.executeExpectSuccess();
Expand Down
Expand Up @@ -29,16 +29,13 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.junit.Assert;
import org.junit.Test;

import org.graalvm.compiler.api.directives.GraalDirectives;
import org.graalvm.compiler.core.test.GraalCompilerTest;
import org.graalvm.compiler.nodes.ParameterNode;
import org.graalvm.compiler.nodes.StructuredGraph;
import org.graalvm.compiler.phases.OptimisticOptimizations;
import org.graalvm.compiler.phases.OptimisticOptimizations.Optimization;
import org.graalvm.compiler.phases.tiers.HighTierContext;
import org.junit.Assert;
import org.junit.Test;

/**
* Tests for {@link GraalDirectives#blackhole}.
Expand Down Expand Up @@ -134,8 +131,8 @@ public void testObject() {
}

@Override
protected HighTierContext getDefaultHighTierContext() {
return new HighTierContext(getProviders(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL.remove(Optimization.RemoveNeverExecutedCode));
protected OptimisticOptimizations getOptimisticOptimizations() {
return OptimisticOptimizations.ALL.remove(OptimisticOptimizations.Optimization.RemoveNeverExecutedCode);
}

@Override
Expand Down
Expand Up @@ -33,9 +33,6 @@
import java.util.Collections;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;

import org.graalvm.compiler.api.directives.GraalDirectives;
import org.graalvm.compiler.core.test.GraalCompilerTest;
import org.graalvm.compiler.graph.Node;
Expand All @@ -46,11 +43,11 @@
import org.graalvm.compiler.nodes.StructuredGraph;
import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
import org.graalvm.compiler.nodes.debug.ControlFlowAnchorNode;
import org.graalvm.compiler.phases.OptimisticOptimizations;
import org.junit.Assert;
import org.junit.Test;

import jdk.vm.ci.meta.ResolvedJavaMethod;
import org.graalvm.compiler.phases.OptimisticOptimizations;
import org.graalvm.compiler.phases.OptimisticOptimizations.Optimization;
import org.graalvm.compiler.phases.tiers.HighTierContext;

public class ControlFlowAnchorDirectiveTest extends GraalCompilerTest {

Expand Down Expand Up @@ -244,8 +241,8 @@ private static List<NodeCount> getNodeCountAnnotations(StructuredGraph graph) {
}

@Override
protected HighTierContext getDefaultHighTierContext() {
return new HighTierContext(getProviders(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL.remove(Optimization.RemoveNeverExecutedCode));
protected OptimisticOptimizations getOptimisticOptimizations() {
return OptimisticOptimizations.ALL.remove(OptimisticOptimizations.Optimization.RemoveNeverExecutedCode);
}

@Override
Expand Down
Expand Up @@ -29,9 +29,6 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.junit.Assert;
import org.junit.Test;

import org.graalvm.compiler.api.directives.GraalDirectives;
import org.graalvm.compiler.core.test.GraalCompilerTest;
import org.graalvm.compiler.nodes.ConstantNode;
Expand All @@ -40,8 +37,8 @@
import org.graalvm.compiler.nodes.calc.AddNode;
import org.graalvm.compiler.nodes.calc.ConditionalNode;
import org.graalvm.compiler.phases.OptimisticOptimizations;
import org.graalvm.compiler.phases.OptimisticOptimizations.Optimization;
import org.graalvm.compiler.phases.tiers.HighTierContext;
import org.junit.Assert;
import org.junit.Test;

/**
* Tests for {@link GraalDirectives#opaque}.
Expand Down Expand Up @@ -133,8 +130,8 @@ public void testObject() {
}

@Override
protected HighTierContext getDefaultHighTierContext() {
return new HighTierContext(getProviders(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL.remove(Optimization.RemoveNeverExecutedCode));
protected OptimisticOptimizations getOptimisticOptimizations() {
return OptimisticOptimizations.ALL.remove(OptimisticOptimizations.Optimization.RemoveNeverExecutedCode);
}

@Override
Expand Down

0 comments on commit 4f22b49

Please sign in to comment.