Skip to content

Commit a0a2d08

Browse files
committed
remove unnecessary JDK9Method class
1 parent 657491d commit a0a2d08

File tree

26 files changed

+480
-648
lines changed

26 files changed

+480
-648
lines changed

compiler/src/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/ModuleAPI.java

Lines changed: 0 additions & 126 deletions
This file was deleted.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2018, 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+
*/
23+
package org.graalvm.compiler.hotspot;
24+
25+
import jdk.vm.ci.hotspot.HotSpotJVMCICompilerFactory;
26+
27+
/**
28+
* Determines if a given class is a JVMCI or Graal class for the purpose of
29+
* {@link HotSpotGraalCompilerFactory.Options#CompileGraalWithC1Only}.
30+
*/
31+
public class IsGraalPredicate {
32+
/**
33+
* Module containing {@link HotSpotJVMCICompilerFactory}.
34+
*/
35+
private final Module jvmciModule;
36+
37+
/**
38+
* Module containing {@link HotSpotGraalCompilerFactory}.
39+
*/
40+
private final Module graalModule;
41+
42+
/**
43+
* Module containing the {@linkplain CompilerConfigurationFactory#selectFactory selected}
44+
* configuration.
45+
*/
46+
private Module compilerConfigurationModule;
47+
48+
public IsGraalPredicate() {
49+
jvmciModule = HotSpotJVMCICompilerFactory.class.getModule();
50+
graalModule = HotSpotGraalCompilerFactory.class.getModule();
51+
}
52+
53+
void onCompilerConfigurationFactorySelection(CompilerConfigurationFactory factory) {
54+
compilerConfigurationModule = factory.getClass().getModule();
55+
}
56+
57+
boolean apply(Class<?> declaringClass) {
58+
Module module = declaringClass.getModule();
59+
return jvmciModule == module || graalModule == module || compilerConfigurationModule == module;
60+
}
61+
}
Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,39 @@
2828
import org.graalvm.compiler.phases.tiers.CompilerConfiguration;
2929

3030
/**
31-
* Builds the result for {@link HotSpotInvocationPlugins#initTrustedModules(CompilerConfiguration)}.
31+
* Determines if methods in a given class can be intrinsified.
3232
*
33-
* This version of the class must be used on JDK 9 or later.
33+
* Only classes loaded from the module defining the compiler configuration or any of its transitive
34+
* dependencies can be intrinsified.
3435
*
35-
* @see "https://docs.oracle.com/javase/9/docs/specs/jar/jar.html#Multi-release"
36+
* This version of the class must be used on JDK 9 or later.
3637
*/
37-
public final class HotSpotTrustedModules {
38-
static EconomicSet<Object> build(CompilerConfiguration compilerConfiguration) {
39-
EconomicSet<Object> res = EconomicSet.create();
38+
public final class IntrinsificationPredicate {
39+
/**
40+
* Set of modules composed of the module defining the compiler configuration and its transitive
41+
* dependencies.
42+
*/
43+
private final EconomicSet<Module> trustedModules;
44+
45+
IntrinsificationPredicate(CompilerConfiguration compilerConfiguration) {
46+
trustedModules = EconomicSet.create();
4047
Module compilerConfigurationModule = compilerConfiguration.getClass().getModule();
4148
if (compilerConfigurationModule.getDescriptor().isAutomatic()) {
4249
throw new IllegalArgumentException(String.format("The module '%s' defining the Graal compiler configuration class '%s' must not be an automatic module",
4350
compilerConfigurationModule.getName(), compilerConfiguration.getClass().getName()));
4451
}
45-
res.add(compilerConfigurationModule);
52+
trustedModules.add(compilerConfigurationModule);
4653
for (Requires require : compilerConfigurationModule.getDescriptor().requires()) {
4754
for (Module module : compilerConfigurationModule.getLayer().modules()) {
4855
if (module.getName().equals(require.name())) {
49-
res.add(module);
56+
trustedModules.add(module);
5057
}
5158
}
5259
}
53-
return res;
60+
}
61+
62+
public boolean apply(Class<?> declaringClass) {
63+
Module module = declaringClass.getModule();
64+
return trustedModules.contains(module);
5465
}
5566
}

compiler/src/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
4444
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Binding;
4545
import org.graalvm.compiler.runtime.RuntimeProvider;
46-
import org.graalvm.compiler.serviceprovider.JDK9Method;
46+
import org.graalvm.compiler.serviceprovider.GraalServices;
4747
import org.graalvm.compiler.test.GraalTest;
4848
import org.junit.Test;
4949

@@ -542,11 +542,11 @@ private static Collection<String> add(Collection<String> c, String... elements)
542542
}
543543

544544
private static boolean isJDK9OrHigher() {
545-
return JDK9Method.JAVA_SPECIFICATION_VERSION >= 9;
545+
return GraalServices.JAVA_SPECIFICATION_VERSION >= 9;
546546
}
547547

548548
private static boolean isJDK10OrHigher() {
549-
return JDK9Method.JAVA_SPECIFICATION_VERSION >= 10;
549+
return GraalServices.JAVA_SPECIFICATION_VERSION >= 10;
550550
}
551551

552552
private static String getHostArchitectureName() {

compiler/src/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CompileTheWorld.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import static org.graalvm.compiler.core.test.ReflectionOptionDescriptors.extractEntries;
3030
import static org.graalvm.compiler.debug.MemUseTrackerKey.getCurrentThreadAllocatedBytes;
3131
import static org.graalvm.compiler.hotspot.test.CompileTheWorld.Options.DESCRIPTORS;
32-
import static org.graalvm.compiler.serviceprovider.JDK9Method.Java8OrEarlier;
32+
import static org.graalvm.compiler.serviceprovider.GraalServices.Java8OrEarlier;
3333

3434
import java.io.Closeable;
3535
import java.io.File;
@@ -88,7 +88,7 @@
8888
import org.graalvm.compiler.options.OptionKey;
8989
import org.graalvm.compiler.options.OptionValues;
9090
import org.graalvm.compiler.options.OptionsParser;
91-
import org.graalvm.compiler.serviceprovider.JDK9Method;
91+
import org.graalvm.compiler.serviceprovider.GraalServices;
9292

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

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

0 commit comments

Comments
 (0)