Skip to content

Commit

Permalink
remove unnecessary JDK9Method class
Browse files Browse the repository at this point in the history
  • Loading branch information
dougxc committed Mar 19, 2018
1 parent 657491d commit a0a2d08
Show file tree
Hide file tree
Showing 26 changed files with 480 additions and 648 deletions.

This file was deleted.

@@ -0,0 +1,61 @@
/*
* Copyright (c) 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.graalvm.compiler.hotspot;

import jdk.vm.ci.hotspot.HotSpotJVMCICompilerFactory;

/**
* Determines if a given class is a JVMCI or Graal class for the purpose of
* {@link HotSpotGraalCompilerFactory.Options#CompileGraalWithC1Only}.
*/
public class IsGraalPredicate {
/**
* Module containing {@link HotSpotJVMCICompilerFactory}.
*/
private final Module jvmciModule;

/**
* Module containing {@link HotSpotGraalCompilerFactory}.
*/
private final Module graalModule;

/**
* Module containing the {@linkplain CompilerConfigurationFactory#selectFactory selected}
* configuration.
*/
private Module compilerConfigurationModule;

public IsGraalPredicate() {
jvmciModule = HotSpotJVMCICompilerFactory.class.getModule();
graalModule = HotSpotGraalCompilerFactory.class.getModule();
}

void onCompilerConfigurationFactorySelection(CompilerConfigurationFactory factory) {
compilerConfigurationModule = factory.getClass().getModule();
}

boolean apply(Class<?> declaringClass) {
Module module = declaringClass.getModule();
return jvmciModule == module || graalModule == module || compilerConfigurationModule == module;
}
}
Expand Up @@ -28,28 +28,39 @@
import org.graalvm.compiler.phases.tiers.CompilerConfiguration;

/**
* Builds the result for {@link HotSpotInvocationPlugins#initTrustedModules(CompilerConfiguration)}.
* Determines if methods in a given class can be intrinsified.
*
* This version of the class must be used on JDK 9 or later.
* Only classes loaded from the module defining the compiler configuration or any of its transitive
* dependencies can be intrinsified.
*
* @see "https://docs.oracle.com/javase/9/docs/specs/jar/jar.html#Multi-release"
* This version of the class must be used on JDK 9 or later.
*/
public final class HotSpotTrustedModules {
static EconomicSet<Object> build(CompilerConfiguration compilerConfiguration) {
EconomicSet<Object> res = EconomicSet.create();
public final class IntrinsificationPredicate {
/**
* Set of modules composed of the module defining the compiler configuration and its transitive
* dependencies.
*/
private final EconomicSet<Module> trustedModules;

IntrinsificationPredicate(CompilerConfiguration compilerConfiguration) {
trustedModules = EconomicSet.create();
Module compilerConfigurationModule = compilerConfiguration.getClass().getModule();
if (compilerConfigurationModule.getDescriptor().isAutomatic()) {
throw new IllegalArgumentException(String.format("The module '%s' defining the Graal compiler configuration class '%s' must not be an automatic module",
compilerConfigurationModule.getName(), compilerConfiguration.getClass().getName()));
}
res.add(compilerConfigurationModule);
trustedModules.add(compilerConfigurationModule);
for (Requires require : compilerConfigurationModule.getDescriptor().requires()) {
for (Module module : compilerConfigurationModule.getLayer().modules()) {
if (module.getName().equals(require.name())) {
res.add(module);
trustedModules.add(module);
}
}
}
return res;
}

public boolean apply(Class<?> declaringClass) {
Module module = declaringClass.getModule();
return trustedModules.contains(module);
}
}
Expand Up @@ -43,7 +43,7 @@
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Binding;
import org.graalvm.compiler.runtime.RuntimeProvider;
import org.graalvm.compiler.serviceprovider.JDK9Method;
import org.graalvm.compiler.serviceprovider.GraalServices;
import org.graalvm.compiler.test.GraalTest;
import org.junit.Test;

Expand Down Expand Up @@ -542,11 +542,11 @@ private static Collection<String> add(Collection<String> c, String... elements)
}

private static boolean isJDK9OrHigher() {
return JDK9Method.JAVA_SPECIFICATION_VERSION >= 9;
return GraalServices.JAVA_SPECIFICATION_VERSION >= 9;
}

private static boolean isJDK10OrHigher() {
return JDK9Method.JAVA_SPECIFICATION_VERSION >= 10;
return GraalServices.JAVA_SPECIFICATION_VERSION >= 10;
}

private static String getHostArchitectureName() {
Expand Down
Expand Up @@ -29,7 +29,7 @@
import static org.graalvm.compiler.core.test.ReflectionOptionDescriptors.extractEntries;
import static org.graalvm.compiler.debug.MemUseTrackerKey.getCurrentThreadAllocatedBytes;
import static org.graalvm.compiler.hotspot.test.CompileTheWorld.Options.DESCRIPTORS;
import static org.graalvm.compiler.serviceprovider.JDK9Method.Java8OrEarlier;
import static org.graalvm.compiler.serviceprovider.GraalServices.Java8OrEarlier;

import java.io.Closeable;
import java.io.File;
Expand Down Expand Up @@ -88,7 +88,7 @@
import org.graalvm.compiler.options.OptionKey;
import org.graalvm.compiler.options.OptionValues;
import org.graalvm.compiler.options.OptionsParser;
import org.graalvm.compiler.serviceprovider.JDK9Method;
import org.graalvm.compiler.serviceprovider.GraalServices;

import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider;
import jdk.vm.ci.hotspot.HotSpotCompilationRequest;
Expand All @@ -109,8 +109,8 @@ public final class CompileTheWorld {

/**
* Magic token to denote that JDK classes are to be compiled. If
* {@link JDK9Method#Java8OrEarlier}, then the classes in {@code rt.jar} are compiled. Otherwise
* the classes in the Java runtime image are compiled.
* {@link GraalServices#Java8OrEarlier}, then the classes in {@code rt.jar} are compiled.
* Otherwise the classes in the Java runtime image are compiled.
*/
public static final String SUN_BOOT_CLASS_PATH = "sun.boot.class.path";

Expand Down

0 comments on commit a0a2d08

Please sign in to comment.