Skip to content

Commit

Permalink
JDK15 fixes, java.lang.invoke.MemberName is reachable and others
Browse files Browse the repository at this point in the history
  • Loading branch information
bobvandette committed Jul 22, 2020
1 parent 2d9beb0 commit 1a53a64
Show file tree
Hide file tree
Showing 828 changed files with 21,353 additions and 6,532 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jdk:

env:
global:
- JVMCI_VERSION="jvmci-20.2-b02"
- JDK8_UPDATE_VERSION="252"
- JDK8_UPDATE_VERSION_SUFFIX="+09"
- JDK11_VERSION="11.0.7+10"
- JVMCI_VERSION="jvmci-20.2-b03"
- JDK8_UPDATE_VERSION="262"
- JDK8_UPDATE_VERSION_SUFFIX="+10"
- JDK11_VERSION="11.0.8+10"

matrix:
include:
Expand Down
3 changes: 2 additions & 1 deletion common.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ openjdk8 : { downloads : { JAVA_HOME : ${jdks.openjdk8} }}
oraclejdk11 : { downloads : { JAVA_HOME : ${jdks.oraclejdk11} }}
oraclejdk15 : { downloads : { JAVA_HOME : ${jdks.oraclejdk15} }}
openjdk11 : { downloads : { JAVA_HOME : ${jdks.openjdk11} }}
openjdk15 : { downloads : { JAVA_HOME : ${jdks.openjdk15} }}

labsjdk-ce-11 : { downloads : { JAVA_HOME : ${jdks.labsjdk-ce-11} }}
labsjdk-ee-11 : { downloads : { JAVA_HOME : ${jdks.labsjdk-ee-11} }}
Expand Down Expand Up @@ -213,7 +214,7 @@ svm-common-windows: ${svm-common} ${windows-amd64} {

windows-devkit-jdk11: {
packages : {
"devkit:VS2017-15.5.5+1" : "==0"
"devkit:VS2017-15.9.16+1" : "==0"
}
}

Expand Down
13 changes: 7 additions & 6 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
"README": "This file contains definitions that are useful for the hocon and jsonnet CI files of multiple repositories.",

"jdks": {
"oraclejdk8": {"name": "oraclejdk", "version": "8u251+08-jvmci-20.2-b02", "platformspecific": true },
"openjdk8": {"name": "openjdk", "version": "8u252+09-jvmci-20.2-b02", "platformspecific": true },
"oraclejdk8Debug": {"name": "oraclejdk", "version": "8u251+08-jvmci-20.2-b02-fastdebug", "platformspecific": true },
"oraclejdk8": {"name": "oraclejdk", "version": "8u261+33-jvmci-20.2-b03", "platformspecific": true },
"openjdk8": {"name": "openjdk", "version": "8u262+10-jvmci-20.2-b03", "platformspecific": true },
"oraclejdk8Debug": {"name": "oraclejdk", "version": "8u261+33-jvmci-20.2-b03-fastdebug", "platformspecific": true },
"oraclejdk11": {"name": "oraclejdk", "version": "11.0.6+8", "platformspecific": true },
"oraclejdk15": {"name": "oraclejdk", "version": "15+27", "platformspecific": true },
"oraclejdk15": {"name": "oraclejdk", "version": "15+30", "platformspecific": true },
"openjdk11": {"name": "openjdk", "version": "11.0.3+7", "platformspecific": true },
"labsjdk-ce-11": {"name": "labsjdk", "version": "ce-11.0.7+10-jvmci-20.2-b02", "platformspecific": true },
"labsjdk-ee-11": {"name": "labsjdk", "version": "ee-11.0.7+8-jvmci-20.2-b02", "platformspecific": true }
"openjdk15": {"name": "openjdk", "version": "15+30", "platformspecific": true },
"labsjdk-ce-11": {"name": "labsjdk", "version": "ce-11.0.8+10-jvmci-20.2-b03", "platformspecific": true },
"labsjdk-ee-11": {"name": "labsjdk", "version": "ee-11.0.8.0.2+1-jvmci-20.2-b03", "platformspecific": true }
},

"sulong": {
Expand Down
2 changes: 1 addition & 1 deletion compiler/ci_common/gate.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ gateTestAVX1 : ${gateTest} {

gateTestCompileImmediately : ${gateTest} {
environment : {
EXTRA_VM_ARGS : "-Dgraal.TruffleBackgroundCompilation=false -Dgraal.TruffleCompileImmediately=true -Dtck.inlineVerifierInstrument=false"
EXTRA_VM_ARGS : "-Dpolyglot.engine.AllowExperimentalOptions=true -Dpolyglot.engine.CompileImmediately=true -Dpolyglot.engine.BackgroundCompilation=false -Dtck.inlineVerifierInstrument=false"
}
}

Expand Down
1 change: 1 addition & 0 deletions compiler/mx.compiler/mx_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ def compiler_gate_benchmark_runner(tasks, extraVMarguments=None, prefix=''):
'scalariform':1,
'scalatest': 1,
'scalaxb': 1,
'specs': 1,
'tmt': 1,
'actors': 1,
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/mx.compiler/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"sourceinprojectwhitelist" : [],

"groupId" : "org.graalvm.compiler",
"version" : "20.2.0",
"version" : "20.3.0",
"release" : False,
"url" : "http://www.graalvm.org/",
"developer" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public static void sideEffect() {
* A call to this method will force the compiler to assume this instruction has a visible memory
* effect killing all memory locations.
*/
public static int sideEffect(@SuppressWarnings("unused") int a) {
return 0;
public static int sideEffect(int a) {
return a;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1765,22 +1765,6 @@ public void fcmov(int size, Register result, Register trueValue, Register falseV
super.fcsel(size, result, trueValue, falseValue, condition);
}

/**
* dst = src1 % src2.
*
* @param size register size. Has to be 32 or 64.
* @param dst floating-point register. May not be null.
* @param n numerator. Floating-point register. May not be null.
* @param d denominator. Floating-point register. May not be null.
*/
public void frem(int size, Register dst, Register n, Register d) {
// There is no frem instruction, instead we compute the remainder using the relation:
// rem = n - Truncating(n / d) * d
super.fdiv(size, dst, n, d);
super.frintz(size, dst, dst);
super.fmsub(size, dst, dst, d, n);
}

/**
* dst = src1 * src2 + src3.
*
Expand Down Expand Up @@ -2361,7 +2345,7 @@ public void patch(int codePos, int relative, byte[] code) {
int[] adrLoOffsets = {5};
PatcherUtil.writeBitSequence(code, pos + 3, curValue, adrLoBits, adrLoOffsets);
// ldr bits
curValue = (targetAddress >> shiftSize) & 0x1FF;
curValue = (targetAddress & 0xFFF) >> shiftSize;
int[] ldrBits = {6, 6};
int[] ldrOffsets = {2, 0};
PatcherUtil.writeBitSequence(code, pos + 5, curValue, ldrBits, ldrOffsets);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,34 @@ public void emit(AMD64Assembler asm, AVXSize size, Register dst, AMD64Address sr
}
}

/**
* VEX-encoded vector gather instructions with an operand order of RMV.
*/
public static final class VexGatherOp extends VexOp {
// @formatter:off
public static final VexGatherOp VPGATHERDD = new VexGatherOp("VPGATHERDD", P_66, M_0F38, W0, 0x90, VEXOpAssertion.AVX2);
public static final VexGatherOp VPGATHERQD = new VexGatherOp("VPGATHERQD", P_66, M_0F38, W0, 0x91, VEXOpAssertion.AVX2);
public static final VexGatherOp VPGATHERDQ = new VexGatherOp("VPGATHERDQ", P_66, M_0F38, W1, 0x90, VEXOpAssertion.AVX2);
public static final VexGatherOp VPGATHERQQ = new VexGatherOp("VPGATHERQQ", P_66, M_0F38, W1, 0x91, VEXOpAssertion.AVX2);
public static final VexGatherOp VGATHERDPD = new VexGatherOp("VGATHERDPD", P_66, M_0F38, W1, 0x92, VEXOpAssertion.AVX2);
public static final VexGatherOp VGATHERQPD = new VexGatherOp("VGATHERQPD", P_66, M_0F38, W1, 0x93, VEXOpAssertion.AVX2);
public static final VexGatherOp VGATHERDPS = new VexGatherOp("VGATHERDPS", P_66, M_0F38, W0, 0x92, VEXOpAssertion.AVX2);
public static final VexGatherOp VGATHERQPS = new VexGatherOp("VGATHERQPS", P_66, M_0F38, W0, 0x93, VEXOpAssertion.AVX2);
// @formatter:on

protected VexGatherOp(String opcode, int pp, int mmmmm, int w, int op, VEXOpAssertion assertion) {
super(opcode, pp, mmmmm, w, op, assertion, EVEXTuple.INVALID, WIG);
}

public void emit(AMD64Assembler asm, AVXSize size, Register dst, AMD64Address address, Register mask) {
assert assertion.check((AMD64) asm.target.arch, size, dst, mask, null, null);
assert size == AVXSize.XMM || size == AVXSize.YMM;
asm.vexPrefix(dst, mask, address, size, pp, mmmmm, w, wEvex, true);
asm.emitByte(op);
asm.emitOperandHelper(dst, address, 0);
}
}

public static final class VexGeneralPurposeRMOp extends VexRMOp {
// @formatter:off
public static final VexGeneralPurposeRMOp BLSI = new VexGeneralPurposeRMOp("BLSI", P_, M_0F38, WIG, 0xF3, 3, VEXOpAssertion.BMI1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

import static jdk.vm.ci.aarch64.AArch64Kind.DWORD;
import static jdk.vm.ci.aarch64.AArch64Kind.QWORD;
import static org.graalvm.compiler.core.target.Backend.ARITHMETIC_DREM;
import static org.graalvm.compiler.core.target.Backend.ARITHMETIC_FREM;
import static org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant;
import static org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant;
import static org.graalvm.compiler.lir.aarch64.AArch64BitManipulationOp.BitManipulationOpCode.BSR;
Expand All @@ -38,6 +40,7 @@
import org.graalvm.compiler.core.common.LIRKind;
import org.graalvm.compiler.core.common.NumUtil;
import org.graalvm.compiler.core.common.calc.FloatConvert;
import org.graalvm.compiler.core.common.spi.ForeignCallLinkage;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.lir.ConstantValue;
import org.graalvm.compiler.lir.LIRFrameState;
Expand Down Expand Up @@ -161,7 +164,21 @@ public Value emitDiv(Value a, Value b, LIRFrameState state) {

@Override
public Value emitRem(Value a, Value b, LIRFrameState state) {
return emitBinary(LIRKind.combine(a, b), getOpCode(a, AArch64ArithmeticOp.REM, AArch64ArithmeticOp.FREM), false, asAllocatable(a), asAllocatable(b));
if (isNumericInteger(a.getPlatformKind())) {
return emitBinary(LIRKind.combine(a, b), AArch64ArithmeticOp.REM, false, asAllocatable(a), asAllocatable(b));
} else {
switch ((AArch64Kind) a.getPlatformKind()) {
case SINGLE:
ForeignCallLinkage fremCall = getLIRGen().getForeignCalls().lookupForeignCall(ARITHMETIC_FREM);
return getLIRGen().emitForeignCall(fremCall, state, a, b);
case DOUBLE:
ForeignCallLinkage dremCall = getLIRGen().getForeignCalls().lookupForeignCall(ARITHMETIC_DREM);
return getLIRGen().emitForeignCall(dremCall, state, a, b);
default:
GraalError.shouldNotReachHere("emitRem on unexpected kind " + a.getPlatformKind());
return null;
}
}
}

@Override
Expand Down Expand Up @@ -360,7 +377,6 @@ private void emitBinaryVar(Variable result, AArch64ArithmeticOp op, AllocatableV
AllocatableValue x = moveSp(a);
AllocatableValue y = moveSp(b);
switch (op) {
case FREM:
case REM:
case UREM:
getLIRGen().append(new AArch64ArithmeticOp.BinaryCompositeOp(op, result, x, y));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void testDump() throws IOException {
overrides.put(DebugOptions.PrintGraph, PrintGraphTarget.File);
overrides.put(DebugOptions.PrintCanonicalGraphStrings, true);
overrides.put(DebugOptions.Dump, "*");
overrides.put(DebugOptions.MethodFilter, null);

// Generate dump files.
test(new OptionValues(getInitialOptions(), overrides), "snippet");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/*
* Copyright (c) 2019, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.core.test;

import jdk.vm.ci.meta.ResolvedJavaType;
import org.graalvm.compiler.nodes.CallTargetNode;
import org.graalvm.compiler.nodes.InvokeNode;
import org.graalvm.compiler.nodes.StructuredGraph;
import org.graalvm.compiler.nodes.java.InstanceOfNode;
import org.graalvm.compiler.phases.OptimisticOptimizations;
import org.graalvm.compiler.phases.tiers.HighTierContext;
import org.graalvm.compiler.serviceprovider.GraalServices;
import org.junit.Test;

public class SingleImplementorInterfaceTest extends GraalCompilerTest {

public interface Interface0 {
void interfaceMethod();
}

public interface Interface1 extends Interface0 {

}

public interface Interface2 extends Interface1 {
}

@SuppressWarnings("all")
public static class SingleImplementor1 implements Interface1 {
public void interfaceMethod() {
}
}

// Requires that the CHA analysis starts from the referenced type. Since {@code
// SingleImplementor1}
// is not a single implementor of {@code Interface2} devirtualization shouldn't happen.
@SuppressWarnings("all")
private static void singleImplementorInterfaceSnippet1(Interface2 i) {
i.interfaceMethod();
}

// Devirtualization should happen in this case.
@SuppressWarnings("all")
private static void singleImplementorInterfaceSnippet2(Interface1 i) {
i.interfaceMethod();
}

@Test
public void testSingleImplementorInterfaceDevirtualization1() {
ResolvedJavaType singleImplementorType = getMetaAccess().lookupJavaType(SingleImplementor1.class);
ResolvedJavaType expectedReferencedType = getMetaAccess().lookupJavaType(Interface2.class);
singleImplementorType.initialize();
StructuredGraph graph = parseEager("singleImplementorInterfaceSnippet1", StructuredGraph.AllowAssumptions.YES);
createCanonicalizerPhase().apply(graph, getProviders());
// Devirtualization shouldn't work in this case. The invoke should remain intact.
InvokeNode invoke = graph.getNodes().filter(InvokeNode.class).first();
assertTrue(invoke != null, "Should have an invoke");
assertTrue(invoke.callTarget().invokeKind() == CallTargetNode.InvokeKind.Interface, "Should still be an interface call");
if (GraalServices.hasLookupReferencedType()) {
assertTrue(invoke.callTarget().referencedType() != null, "Invoke should have a reference class set");
assertTrue(invoke.callTarget().referencedType().equals(expectedReferencedType));
}
}

@Test
public void testSingleImplementorInterfaceDevirtualization2() {
ResolvedJavaType singleImplementorType = getMetaAccess().lookupJavaType(SingleImplementor1.class);
singleImplementorType.initialize();
StructuredGraph graph = parseEager("singleImplementorInterfaceSnippet2", StructuredGraph.AllowAssumptions.YES);
createCanonicalizerPhase().apply(graph, getProviders());
InvokeNode invoke = graph.getNodes().filter(InvokeNode.class).first();
assertTrue(invoke != null, "Should have an invoke");
if (GraalServices.hasLookupReferencedType()) {
assertTrue(invoke.callTarget().invokeKind() == CallTargetNode.InvokeKind.Special, "Should be devirtualized");
InstanceOfNode instanceOfNode = graph.getNodes().filter(InstanceOfNode.class).first();
assertTrue(instanceOfNode != null, "Missing the subtype check");
assertTrue(instanceOfNode.getCheckedStamp().type().equals(singleImplementorType), "Checking against a wrong type");
} else {
assertTrue(invoke.callTarget().invokeKind() == CallTargetNode.InvokeKind.Interface, "Should not be devirtualized");
}
}

@Test
public void testSingleImplementorInterfaceInlining1() {
ResolvedJavaType singleImplementorType = getMetaAccess().lookupJavaType(SingleImplementor1.class);
ResolvedJavaType expectedReferencedType = getMetaAccess().lookupJavaType(Interface2.class);
singleImplementorType.initialize();
StructuredGraph graph = parseEager("singleImplementorInterfaceSnippet1", StructuredGraph.AllowAssumptions.YES);
HighTierContext context = new HighTierContext(getProviders(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
createInliningPhase().apply(graph, context);
// Inlining shouldn't do anything
InvokeNode invoke = graph.getNodes().filter(InvokeNode.class).first();
assertTrue(invoke != null, "Should have an invoke");
if (GraalServices.hasLookupReferencedType()) {
assertTrue(invoke.callTarget().referencedType() != null, "Invoke should have a reference class set");
assertTrue(invoke.callTarget().invokeKind() == CallTargetNode.InvokeKind.Interface, "Should still be an interface call");
assertTrue(invoke.callTarget().referencedType().equals(expectedReferencedType));
} else {
assertTrue(invoke.callTarget().invokeKind() == CallTargetNode.InvokeKind.Interface, "Should not be devirtualized");
}
}

@Test
public void testSingleImplementorInterfaceInlining2() {
ResolvedJavaType singleImplementorType = getMetaAccess().lookupJavaType(SingleImplementor1.class);
ResolvedJavaType expectedReferencedType = getMetaAccess().lookupJavaType(Interface1.class);
singleImplementorType.initialize();
StructuredGraph graph = parseEager("singleImplementorInterfaceSnippet2", StructuredGraph.AllowAssumptions.YES);
HighTierContext context = new HighTierContext(getProviders(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
createInliningPhase().apply(graph, context);

// Right now inlining will not do anything, but if it starts doing devirtualization of
// interface calls
// in the future there should be a subtype check.
InvokeNode invoke = graph.getNodes().filter(InvokeNode.class).first();
if (invoke != null) {
assertTrue(invoke.callTarget().invokeKind() == CallTargetNode.InvokeKind.Interface, "Should still be an interface call");
if (GraalServices.hasLookupReferencedType()) {
assertTrue(invoke.callTarget().referencedType() != null, "Invoke should have a reference class set");
assertTrue(invoke.callTarget().referencedType().equals(expectedReferencedType));
}
} else {
InstanceOfNode instanceOfNode = graph.getNodes().filter(InstanceOfNode.class).first();
assertTrue(instanceOfNode != null, "Missing the subtype check");
assertTrue(instanceOfNode.getCheckedStamp().type().equals(singleImplementorType), "Checking against a wrong type");
}
}
}
Loading

0 comments on commit 1a53a64

Please sign in to comment.