Skip to content

Commit

Permalink
replaced uses of java.specification.version with GraalServices API
Browse files Browse the repository at this point in the history
  • Loading branch information
dougxc committed Apr 18, 2018
1 parent b60b8c0 commit c0947aa
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.graalvm.compiler.lir.LIRInstructionClass;
import org.graalvm.compiler.lir.Opcode;
import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
import org.graalvm.compiler.serviceprovider.GraalServices;

import jdk.vm.ci.code.Register;
import jdk.vm.ci.meta.AllocatableValue;
Expand Down Expand Up @@ -68,11 +69,12 @@ public AArch64HotSpotJumpToExceptionHandlerInCallerOp(AllocatableValue handlerIn
public void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
leaveFrame(crb, masm, /* emitSafepoint */false);

if (System.getProperty("java.specification.version").compareTo("1.8") < 0) {
if (GraalServices.JAVA_SPECIFICATION_VERSION < 8) {
// Restore sp from fp if the exception PC is a method handle call site.
try (ScratchRegister sc = masm.getScratchRegister()) {
Register scratch = sc.getRegister();
AArch64Address address = masm.makeAddress(thread, isMethodHandleReturnOffset, scratch, 4, /* allowOverwrite */false);
final boolean allowOverwrite = false;
AArch64Address address = masm.makeAddress(thread, isMethodHandleReturnOffset, scratch, 4, allowOverwrite);
masm.ldr(32, scratch, address);
Label noRestore = new Label();
masm.cbz(32, scratch, noRestore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.graalvm.compiler.lir.LIRInstructionClass;
import org.graalvm.compiler.lir.Opcode;
import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
import org.graalvm.compiler.serviceprovider.GraalServices;

import jdk.vm.ci.code.Register;
import jdk.vm.ci.meta.AllocatableValue;
Expand Down Expand Up @@ -68,7 +69,7 @@ public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
// Discard the return address, thus completing restoration of caller frame
masm.incrementq(rsp, 8);

if (System.getProperty("java.specification.version").compareTo("1.8") < 0) {
if (GraalServices.JAVA_SPECIFICATION_VERSION < 8) {
// Restore rsp from rbp if the exception PC is a method handle call site.
AMD64Address dst = new AMD64Address(thread, isMethodHandleReturnOffset);
masm.cmpl(dst, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.graalvm.compiler.debug.DebugHandlersFactory;
import org.graalvm.compiler.debug.GlobalMetrics;
import org.graalvm.compiler.options.OptionValues;
import org.graalvm.compiler.serviceprovider.GraalServices;
import org.junit.After;
import org.junit.Assert;
import org.junit.internal.ComparisonCriteria;
Expand All @@ -64,7 +65,7 @@ public class GraalTest {
}
}

public static final boolean Java8OrEarlier = System.getProperty("java.specification.version").compareTo("1.9") < 0;
public static final boolean Java8OrEarlier = GraalServices.Java8OrEarlier;

protected Method getMethod(String methodName) {
return getMethod(getClass(), methodName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.graalvm.compiler.serviceprovider.GraalServices;
import org.graalvm.util.CollectionsUtil;

/**
Expand Down Expand Up @@ -236,7 +237,7 @@ private static Subprocess javaHelper(List<String> vmArgs, Map<String, String> en
return new Subprocess(command, process.waitFor(), output);
}

private static final boolean isJava8OrEarlier = System.getProperty("java.specification.version").compareTo("1.9") < 0;
private static final boolean isJava8OrEarlier = GraalServices.Java8OrEarlier;

private static boolean hasArg(String optionName) {
if (optionName.equals("-cp") || optionName.equals("-classpath")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/
package org.graalvm.compiler.truffle.test;

import static org.graalvm.compiler.serviceprovider.GraalServices.Java8OrEarlier;
import static org.graalvm.compiler.test.SubprocessUtil.getVMCommandLine;
import static org.graalvm.compiler.test.SubprocessUtil.withoutDebuggerArguments;

Expand Down Expand Up @@ -61,8 +62,6 @@ public class LazyInitializationTest {
private final Class<?> hotSpotGraalJVMCIServiceLocatorShared;
private final Class<?> jvmciVersionCheck;

private static boolean Java8OrEarlier = System.getProperty("java.specification.version").compareTo("1.9") < 0;

public LazyInitializationTest() {
hotSpotVMEventListener = forNameOrNull("jdk.vm.ci.hotspot.services.HotSpotVMEventListener");
hotSpotGraalCompilerFactoryOptions = forNameOrNull("org.graalvm.compiler.hotspot.HotSpotGraalCompilerFactory$Options");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import org.graalvm.compiler.api.test.Graal;
import org.graalvm.compiler.runtime.RuntimeProvider;
import org.graalvm.compiler.serviceprovider.GraalServices;
import org.junit.Test;

import com.oracle.truffle.api.Truffle;
Expand Down Expand Up @@ -80,7 +81,7 @@ public void testGetLayoutFactory() {
LayoutFactory layoutFactory = runtime.getCapability(LayoutFactory.class);
assertNotNull("LayoutFactory not found", layoutFactory);

boolean java8OrEarlier = System.getProperty("java.specification.version").compareTo("1.9") < 0;
boolean java8OrEarlier = GraalServices.Java8OrEarlier;
ClassLoader layoutFactoryCL = layoutFactory.getClass().getClassLoader();
if (java8OrEarlier) {
// Bootstrap class loader or JVMCI class loader
Expand Down

0 comments on commit c0947aa

Please sign in to comment.