OpenJDK / jdk / jdk
changeset 50823:accde81a0046
8202698: Update Graal for JEP 181 - Nest-based access control
Reviewed-by: kvn
author | iveresov |
---|---|
date | Wed, 27 Jun 2018 09:56:06 -0700 |
parents | 87aef9853b52 |
children | f8c8bfd59e05 |
files | src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/BytecodeParser.java test/jdk/ProblemList-graal.txt |
diffstat | 2 files changed, 21 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/BytecodeParser.java Wed Jun 27 18:46:30 2018 +0200 +++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/BytecodeParser.java Wed Jun 27 09:56:06 2018 -0700 @@ -1661,6 +1661,8 @@ if (initialInvokeKind == InvokeKind.Special && !targetMethod.isConstructor()) { emitCheckForInvokeSuperSpecial(args); + } else if (initialInvokeKind == InvokeKind.Interface && targetMethod.isPrivate()) { + emitCheckForDeclaringClassChange(targetMethod.getDeclaringClass(), args); } InlineInfo inlineInfo = null; @@ -1748,6 +1750,25 @@ } /** + * Checks that the class of the receiver of an {@link Bytecodes#INVOKEINTERFACE} invocation of a + * private method is assignable to the interface that declared the method. If not, then + * deoptimize so that the interpreter can throw an {@link IllegalAccessError}. + * + * This is a check not performed by the verifier and so must be performed at runtime. + * + * @param declaringClass interface declaring the callee + * @param args arguments to an {@link Bytecodes#INVOKEINTERFACE} call to a private method + * declared in a interface + */ + private void emitCheckForDeclaringClassChange(ResolvedJavaType declaringClass, ValueNode[] args) { + ValueNode receiver = args[0]; + TypeReference checkedType = TypeReference.createTrusted(graph.getAssumptions(), declaringClass); + LogicNode condition = genUnique(createInstanceOf(checkedType, receiver, null)); + FixedGuardNode fixedGuard = append(new FixedGuardNode(condition, ClassCastException, None, false)); + args[0] = append(PiNode.create(receiver, StampFactory.object(checkedType, true), fixedGuard)); + } + + /** * Checks that the class of the receiver of an {@link Bytecodes#INVOKESPECIAL} in a method * declared in an interface (i.e., a default method) is assignable to the interface. If not, * then deoptimize so that the interpreter can throw an {@link IllegalAccessError}.
--- a/test/jdk/ProblemList-graal.txt Wed Jun 27 18:46:30 2018 +0200 +++ b/test/jdk/ProblemList-graal.txt Wed Jun 27 09:56:06 2018 -0700 @@ -69,8 +69,6 @@ java/lang/Runtime/exec/LotsOfOutput.java 8196611 generic-all java/util/concurrent/ScheduledThreadPoolExecutor/BasicCancelTest.java 8196611 generic-all -java/lang/invoke/PrivateInterfaceCall.java 8202698 generic-all - # Next JFR tests fail with Graal. Assuming 8193210. jdk/jfr/event/compiler/TestCodeSweeper.java 8193210 generic-all jdk/jfr/event/compiler/TestCompilerInlining.java 8193210 generic-all