Skip to content

Commit

Permalink
[GR-31247] Substitute insensitive wording in compiler.
Browse files Browse the repository at this point in the history
PullRequest: graal/8939
  • Loading branch information
dougxc committed May 19, 2021
2 parents 8d7867d + 6ce08a3 commit bd6a03c
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 92 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/quarkus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ env:
DB_USER: hibernate_orm_test
DB_PASSWORD: hibernate_orm_test
DB_NAME: hibernate_orm_test
NATIVE_TEST_MAVEN_OPTS: "-B --settings ${QUARKUS_PATH}/.github/mvn-settings.xml --fail-at-end -Dtest-containers -Dstart-containers -Dnative-image.xmx=5g -Dnative -Dnative.surefire.skip -Dformat.skip -Dno-descriptor-tests install -DskipDocs"
COMMON_MAVEN_ARGS: "-e -B --settings .github/mvn-settings.xml --fail-at-end"
NATIVE_TEST_MAVEN_ARGS: "-Dtest-containers -Dstart-containers -Dquarkus.native.native-image-xmx=5g -Dnative -Dnative.surefire.skip -Dformat.skip -Dno-descriptor-tests install -DskipDocs"
MX_GIT_CACHE: refcache
MX_PATH: ${{ github.workspace }}/mx
JAVA_HOME: ${{ github.workspace }}/jdk
Expand Down Expand Up @@ -107,48 +108,45 @@ jobs:
matrix: ${{ fromJson(needs.build-quarkus-and-graalvm.outputs.matrix) }}
steps:
- name: Download GraalVM build
if: startsWith(matrix.os-name, 'ubuntu')
uses: actions/download-artifact@v1
with:
name: graalvm
path: .
- name: Extract GraalVM build
if: startsWith(matrix.os-name, 'ubuntu')
shell: bash
run: tar -xzvf graalvm.tgz -C $(dirname ${GRAALVM_HOME})
- name: Get latest quarkus release
if: startsWith(matrix.os-name, 'ubuntu')
run: |
export QUARKUS_VERSION=main #$(curl https://repo1.maven.org/maven2/io/quarkus/quarkus-bom/maven-metadata.xml | awk -F"[<>]" '/latest/ {print $3}')
echo Getting Quarkus $QUARKUS_VERSION
curl --output quarkus.tgz -sL https://api.github.com/repos/quarkusio/quarkus/tarball/$QUARKUS_VERSION
mkdir ${QUARKUS_PATH}
tar xf quarkus.tgz -C ${QUARKUS_PATH} --strip-components=1
- name: Reclaim Disk Space
if: startsWith(matrix.os-name, 'ubuntu')
run: ${QUARKUS_PATH}/.github/ci-prerequisites.sh
- name: Download Maven Repo
if: startsWith(matrix.os-name, 'ubuntu')
uses: actions/download-artifact@v1
with:
name: maven-repo
path: .
- name: Extract Maven Repo
if: startsWith(matrix.os-name, 'ubuntu')
shell: bash
run: tar -xzf maven-repo.tgz -C ~
- name: Build with Maven
if: startsWith(matrix.os-name, 'ubuntu')
env:
TEST_MODULES: ${{matrix.test-modules}}
CATEGORY: ${{matrix.category}}
run: |
cd ${QUARKUS_PATH}
export JAVA_HOME=${GRAALVM_HOME}
${GRAALVM_HOME}/bin/native-image --version
for i in $TEST_MODULES
do modules+=("integration-tests/$i"); done
IFS=,
eval mvn -pl "${modules[*]}" $NATIVE_TEST_MAVEN_OPTS
# add the 'simple with spaces' project to the run of 'Misc1' by executing it explicitly
# done because there is no good way to pass strings with empty values to the previous command
# so this hack is as good as any
if [ "$CATEGORY" == "Misc1" ]; then
mvn -Dnative -B --settings ${GITHUB_WORKSPACE}/quarkus/.github/mvn-settings.xml -f 'integration-tests/simple with space/' verify
fi
./mvnw $COMMON_MAVEN_ARGS -f integration-tests -pl "$TEST_MODULES" $NATIVE_TEST_MAVEN_ARGS
- name: Prepare failure archive (if maven failed)
if: failure()
shell: bash
Expand Down
6 changes: 3 additions & 3 deletions compiler/mx.compiler/mx_updategraalinopenjdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def updategraalinopenjdk(args):
}

# Strings that must not exist in OpenJDK source files. This is applied after replacements are made.
blacklist = ['"Classpath" exception']
denylist = ['"Classpath" exception']

jdkrepo = args.jdkrepo
git_repo = _is_git_repo(jdkrepo)
Expand Down Expand Up @@ -284,9 +284,9 @@ def run_output(args, cwd=None):
new_line_count = len(contents.split('\n'))
if new_line_count != old_line_count:
mx.abort('Unable to correct line count for {}'.format(src_file))
for forbidden in blacklist:
for forbidden in denylist:
if forbidden in contents:
mx.abort('Found blacklisted pattern \'{}\' in {}'.format(forbidden, src_file))
mx.abort('Found deny-listed pattern \'{}\' in {}'.format(forbidden, src_file))
dst_dir = os.path.dirname(dst_file)
if not exists(dst_dir):
os.makedirs(dst_dir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
*/
public class OptionsVerifierTest {

private static Set<String> WHITELIST = new TreeSet<>(Arrays.asList(//
private static Set<String> ALLOWLIST = new TreeSet<>(Arrays.asList(//
// Generated options delegating default values to PolyglotCompilerOptions
"org.graalvm.compiler.truffle.compiler.SharedTruffleCompilerOptions",
// Deprecated options delegating default values to PolyglotCompilerOptions
Expand All @@ -67,7 +67,7 @@ public void verifyOptions() throws IOException {
for (OptionDescriptors opts : OptionsParser.getOptionsLoader()) {
for (OptionDescriptor desc : opts) {
Class<?> descDeclaringClass = desc.getDeclaringClass();
if (!WHITELIST.contains(descDeclaringClass.getName())) {
if (!ALLOWLIST.contains(descDeclaringClass.getName())) {
OptionsVerifier.checkClass(descDeclaringClass, desc, checked);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ protected void verify(StructuredGraph graph, CoreProviders context) {
* parameter bound to {@link DebugContext#BASIC_LEVEL} and the {@code object} parameter bound to
* a {@link StructuredGraph} value.
*
* This whitelist exists to ensure any increase in graph dumps is in line with the policy
* This allow list exists to ensure any increase in graph dumps is in line with the policy
* outlined by {@link DebugContext#BASIC_LEVEL}. If you add a *justified* graph dump at this
* level, then update the whitelist.
* level, then update the allow list.
*/
private static final Set<String> BasicLevelStructuredGraphDumpWhitelist = new HashSet<>(Arrays.asList(
private static final Set<String> BasicLevelStructuredGraphDumpAllowList = new HashSet<>(Arrays.asList(
"org.graalvm.compiler.phases.BasePhase.dumpAfter",
"org.graalvm.compiler.phases.BasePhase.dumpBefore",
"org.graalvm.compiler.core.GraalCompiler.emitFrontEnd",
Expand All @@ -128,11 +128,11 @@ protected void verify(StructuredGraph graph, CoreProviders context) {
* parameter bound to {@link DebugContext#INFO_LEVEL} and the {@code object} parameter bound to
* a {@link StructuredGraph} value.
*
* This whitelist exists to ensure any increase in graph dumps is in line with the policy
* This allow list exists to ensure any increase in graph dumps is in line with the policy
* outlined by {@link DebugContext#INFO_LEVEL}. If you add a *justified* graph dump at this
* level, then update the whitelist.
* level, then update the allow list.
*/
private static final Set<String> InfoLevelStructuredGraphDumpWhitelist = new HashSet<>(Arrays.asList(
private static final Set<String> InfoLevelStructuredGraphDumpAllowList = new HashSet<>(Arrays.asList(
"org.graalvm.compiler.core.GraalCompiler.emitFrontEnd",
"org.graalvm.compiler.phases.BasePhase.dumpAfter",
"org.graalvm.compiler.replacements.ReplacementsImpl$GraphMaker.makeGraph",
Expand Down Expand Up @@ -193,17 +193,17 @@ protected void verifyStructuredGraphDumping(StructuredGraph callerGraph, MethodC
if (dumpLevel == DebugContext.BASIC_LEVEL) {
StackTraceElement e = callerGraph.method().asStackTraceElement(debugCallTarget.invoke().bci());
String qualifiedMethod = e.getClassName() + "." + e.getMethodName();
if (!BasicLevelStructuredGraphDumpWhitelist.contains(qualifiedMethod)) {
if (!BasicLevelStructuredGraphDumpAllowList.contains(qualifiedMethod)) {
throw new VerificationError(
"In %s: call to %s with level == DebugContext.BASIC_LEVEL not in %s.BasicLevelDumpWhitelist.%n", e, verifiedCallee.format("%H.%n(%p)"),
"In %s: call to %s with level == DebugContext.BASIC_LEVEL not in %s.BasicLevelDumpAllowList.%n", e, verifiedCallee.format("%H.%n(%p)"),
getClass().getName());
}
} else if (dumpLevel == DebugContext.INFO_LEVEL) {
StackTraceElement e = callerGraph.method().asStackTraceElement(debugCallTarget.invoke().bci());
String qualifiedMethod = e.getClassName() + "." + e.getMethodName();
if (!InfoLevelStructuredGraphDumpWhitelist.contains(qualifiedMethod)) {
if (!InfoLevelStructuredGraphDumpAllowList.contains(qualifiedMethod)) {
throw new VerificationError(
"In %s: call to %s with level == Debug.INFO_LEVEL not in %s.InfoLevelDumpWhitelist.%n", e, verifiedCallee.format("%H.%n(%p)"),
"In %s: call to %s with level == Debug.INFO_LEVEL not in %s.InfoLevelDumpAllowList.%n", e, verifiedCallee.format("%H.%n(%p)"),
getClass().getName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@
<property name="message" value="Single year shouldn't be duplicated"/>
<property name="illegalPattern" value="true"/>
</module>
<module name="Regexp">
<property name="format" value="[^/](?i)master|(?i)slave|(?i)whitelist|(?i)blacklist|(?i)whitehat|(?i)blackhat|(?i)grandfather"/>
<message key="illegal.regexp" value="Avoid insensitive term matched by {0}." />
<property name="illegalPattern" value="true"/>
</module>
</module>
<module name="LineLength">
<property name="max" value="250"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static void testOption(MBeanInfo mbeanInfo,
Object defaultValue;
if (optionKey instanceof NestedBooleanOptionKey) {
NestedBooleanOptionKey nbok = (NestedBooleanOptionKey) optionKey;
defaultValue = nbok.getMasterOption().getValue(runtime.getOptions());
defaultValue = nbok.getParentOption().getValue(runtime.getOptions());
} else {
defaultValue = optionKey.getDefaultValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@

package org.graalvm.compiler.options.test;

import static org.graalvm.compiler.options.test.NestedBooleanOptionKeyTest.Options.Master0;
import static org.graalvm.compiler.options.test.NestedBooleanOptionKeyTest.Options.Master1;
import static org.graalvm.compiler.options.test.NestedBooleanOptionKeyTest.Options.Master2;
import static org.graalvm.compiler.options.test.NestedBooleanOptionKeyTest.Options.Parent0;
import static org.graalvm.compiler.options.test.NestedBooleanOptionKeyTest.Options.Parent1;
import static org.graalvm.compiler.options.test.NestedBooleanOptionKeyTest.Options.Parent2;
import static org.graalvm.compiler.options.test.NestedBooleanOptionKeyTest.Options.NestedOption0;
import static org.graalvm.compiler.options.test.NestedBooleanOptionKeyTest.Options.NestedOption1;
import static org.graalvm.compiler.options.test.NestedBooleanOptionKeyTest.Options.NestedOption2;
Expand All @@ -49,78 +49,78 @@
public class NestedBooleanOptionKeyTest {

public static class Options {
public static final OptionKey<Boolean> Master0 = new OptionKey<>(true);
public static final OptionKey<Boolean> NestedOption0 = new NestedBooleanOptionKey(Master0, true);
public static final OptionKey<Boolean> Master1 = new OptionKey<>(true);
public static final OptionKey<Boolean> NestedOption1 = new NestedBooleanOptionKey(Master1, true);
public static final OptionKey<Boolean> Master2 = new OptionKey<>(true);
public static final OptionKey<Boolean> NestedOption2 = new NestedBooleanOptionKey(Master2, false);
public static final OptionKey<Boolean> Parent0 = new OptionKey<>(true);
public static final OptionKey<Boolean> NestedOption0 = new NestedBooleanOptionKey(Parent0, true);
public static final OptionKey<Boolean> Parent1 = new OptionKey<>(true);
public static final OptionKey<Boolean> NestedOption1 = new NestedBooleanOptionKey(Parent1, true);
public static final OptionKey<Boolean> Parent2 = new OptionKey<>(true);
public static final OptionKey<Boolean> NestedOption2 = new NestedBooleanOptionKey(Parent2, false);
}

static final OptionDescriptor master0 = OptionDescriptor.create("Master0", OptionType.Debug, Boolean.class, "", Options.class, "Master0", Master0);
static final OptionDescriptor parent0 = OptionDescriptor.create("Parent0", OptionType.Debug, Boolean.class, "", Options.class, "Parent0", Parent0);
static final OptionDescriptor nestedOption0 = OptionDescriptor.create("NestedOption0", OptionType.Debug, Boolean.class, "", Options.class, "NestedOption0", NestedOption0);
static final OptionDescriptor master1 = OptionDescriptor.create("Master1", OptionType.Debug, Boolean.class, "", Options.class, "Master1", Master1);
static final OptionDescriptor parent1 = OptionDescriptor.create("Parent1", OptionType.Debug, Boolean.class, "", Options.class, "Parent1", Parent1);
static final OptionDescriptor nestedOption1 = OptionDescriptor.create("NestedOption1", OptionType.Debug, Boolean.class, "", Options.class, "NestedOption1", NestedOption1);
static final OptionDescriptor master2 = OptionDescriptor.create("Master2", OptionType.Debug, Boolean.class, "", Options.class, "Master2", Master2);
static final OptionDescriptor parent2 = OptionDescriptor.create("Parent2", OptionType.Debug, Boolean.class, "", Options.class, "Parent2", Parent2);
static final OptionDescriptor nestedOption2 = OptionDescriptor.create("NestedOption2", OptionType.Debug, Boolean.class, "", Options.class, "NestedOption2", NestedOption2);

@Test
public void runDefaultTrue() {
OptionValues options = new OptionValues(null, Master1, true);
assertTrue(Master1.getValue(options));
OptionValues options = new OptionValues(null, Parent1, true);
assertTrue(Parent1.getValue(options));
assertTrue(NestedOption1.getValue(options));

// nested value unset
options = new OptionValues(null, Master1, false);
assertFalse(Master1.getValue(options));
options = new OptionValues(null, Parent1, false);
assertFalse(Parent1.getValue(options));
assertFalse(NestedOption1.getValue(options));

// set false
options = new OptionValues(null, Master1, false, NestedOption1, false);
assertFalse(Master1.getValue(options));
options = new OptionValues(null, Parent1, false, NestedOption1, false);
assertFalse(Parent1.getValue(options));
assertFalse(NestedOption1.getValue(options));

options = new OptionValues(null, Master1, true, NestedOption1, false);
assertTrue(Master1.getValue(options));
options = new OptionValues(null, Parent1, true, NestedOption1, false);
assertTrue(Parent1.getValue(options));
assertFalse(NestedOption1.getValue(options));

// set true
options = new OptionValues(null, Master1, false, NestedOption1, true);
assertFalse(Master1.getValue(options));
options = new OptionValues(null, Parent1, false, NestedOption1, true);
assertFalse(Parent1.getValue(options));
assertTrue(NestedOption1.getValue(options));

options = new OptionValues(null, Master1, true, NestedOption1, true);
assertTrue(Master1.getValue(options));
options = new OptionValues(null, Parent1, true, NestedOption1, true);
assertTrue(Parent1.getValue(options));
assertTrue(NestedOption1.getValue(options));
}

@Test
public void runDefaultFalse() {
OptionValues options = new OptionValues(null, Master2, true);
assertTrue(Master2.getValue(options));
OptionValues options = new OptionValues(null, Parent2, true);
assertTrue(Parent2.getValue(options));
assertFalse(NestedOption2.getValue(options));

// nested value unset
options = new OptionValues(null, Master2, false);
assertFalse(Master2.getValue(options));
options = new OptionValues(null, Parent2, false);
assertFalse(Parent2.getValue(options));
assertFalse(NestedOption2.getValue(options));

// set false
options = new OptionValues(null, Master2, false, NestedOption2, false);
assertFalse(Master2.getValue(options));
options = new OptionValues(null, Parent2, false, NestedOption2, false);
assertFalse(Parent2.getValue(options));
assertFalse(NestedOption2.getValue(options));

options = new OptionValues(null, Master2, true, NestedOption2, false);
assertTrue(Master2.getValue(options));
options = new OptionValues(null, Parent2, true, NestedOption2, false);
assertTrue(Parent2.getValue(options));
assertFalse(NestedOption2.getValue(options));

// set true
options = new OptionValues(null, Master2, false, NestedOption2, true);
assertFalse(Master2.getValue(options));
options = new OptionValues(null, Parent2, false, NestedOption2, true);
assertFalse(Parent2.getValue(options));
assertTrue(NestedOption2.getValue(options));

options = new OptionValues(null, Master2, true, NestedOption2, true);
assertTrue(Master2.getValue(options));
options = new OptionValues(null, Parent2, true, NestedOption2, true);
assertTrue(Parent2.getValue(options));
assertTrue(NestedOption2.getValue(options));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,34 @@
package org.graalvm.compiler.options;

/**
* A nested Boolean {@link OptionKey} that can be overridden by a {@link #masterOption master
* A nested Boolean {@link OptionKey} that can be overridden by a {@link #parentOption parent
* option}.
* <p>
* <li>If the option is present on the command line the specified value is used.
* <li>Otherwise {@link #getValue} depends on the {@link #masterOption} and evaluates as follows:
* <li>Otherwise {@link #getValue} depends on the {@link #parentOption} and evaluates as follows:
* <ul>
* <li>If {@link #masterOption} is set, this value equals to {@link #initialValue}.
* <li>Otherwise, if {@link #masterOption} is {@code false}, this option is {@code false}.
* <li>If {@link #parentOption} is set, this value equals to {@link #initialValue}.
* <li>Otherwise, if {@link #parentOption} is {@code false}, this option is {@code false}.
*/
public class NestedBooleanOptionKey extends OptionKey<Boolean> {
private final OptionKey<Boolean> masterOption;
private final OptionKey<Boolean> parentOption;
private final Boolean initialValue;

public NestedBooleanOptionKey(OptionKey<Boolean> masterOption, Boolean initialValue) {
public NestedBooleanOptionKey(OptionKey<Boolean> parentOption, Boolean initialValue) {
super(null);
this.masterOption = masterOption;
this.parentOption = parentOption;
this.initialValue = initialValue;
}

public OptionKey<Boolean> getMasterOption() {
return masterOption;
public OptionKey<Boolean> getParentOption() {
return parentOption;
}

@Override
public Boolean getValue(OptionValues options) {
Boolean v = super.getValue(options);
if (v == null) {
return initialValue && masterOption.getValue(options);
return initialValue && parentOption.getValue(options);
}
return v;
}
Expand Down
Loading

0 comments on commit bd6a03c

Please sign in to comment.