8213234: Move LambdaForm.Hidden to jdk.internal.vm.annotation

Reviewed-by: mchung, dlong
This commit is contained in:
Vladimir Ivanov 2019-01-22 18:13:49 -08:00
parent 5063110306
commit 6a61345684
8 changed files with 72 additions and 47 deletions

View file

@ -77,6 +77,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
private static final String DESCR_CTOR_NOT_SERIALIZABLE_EXCEPTION = "(Ljava/lang/String;)V";
private static final String[] SER_HOSTILE_EXCEPTIONS = new String[] {NAME_NOT_SERIALIZABLE_EXCEPTION};
private static final String DESCR_HIDDEN = "Ljdk/internal/vm/annotation/Hidden;";
private static final String[] EMPTY_STRING_ARRAY = new String[0];
@ -279,7 +280,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
// Forward the SAM method
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, samMethodName,
samMethodType.toMethodDescriptorString(), null, null);
mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
mv.visitAnnotation(DESCR_HIDDEN, true);
new ForwardingMethodGenerator(mv).generate(samMethodType);
// Forward the bridges
@ -287,7 +288,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
for (MethodType mt : additionalBridges) {
mv = cw.visitMethod(ACC_PUBLIC|ACC_BRIDGE, samMethodName,
mt.toMethodDescriptorString(), null, null);
mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
mv.visitAnnotation(DESCR_HIDDEN, true);
new ForwardingMethodGenerator(mv).generate(mt);
}
}

View file

@ -721,11 +721,11 @@ class InvokerBytecodeGenerator {
}
}
static final String LF_HIDDEN_SIG = className("Ljava/lang/invoke/LambdaForm$Hidden;");
static final String LF_COMPILED_SIG = className("Ljava/lang/invoke/LambdaForm$Compiled;");
static final String FORCEINLINE_SIG = className("Ljdk/internal/vm/annotation/ForceInline;");
static final String DONTINLINE_SIG = className("Ljdk/internal/vm/annotation/DontInline;");
static final String INJECTEDPROFILE_SIG = className("Ljava/lang/invoke/InjectedProfile;");
static final String DONTINLINE_SIG = className("Ljdk/internal/vm/annotation/DontInline;");
static final String FORCEINLINE_SIG = className("Ljdk/internal/vm/annotation/ForceInline;");
static final String HIDDEN_SIG = className("Ljdk/internal/vm/annotation/Hidden;");
static final String INJECTEDPROFILE_SIG = className("Ljava/lang/invoke/InjectedProfile;");
static final String LF_COMPILED_SIG = className("Ljava/lang/invoke/LambdaForm$Compiled;");
/**
* Generate an invoker method for the passed {@link LambdaForm}.
@ -748,7 +748,7 @@ class InvokerBytecodeGenerator {
methodPrologue();
// Suppress this method in backtraces displayed to the user.
mv.visitAnnotation(LF_HIDDEN_SIG, true);
mv.visitAnnotation(HIDDEN_SIG, true);
// Mark this method as a compiled LambdaForm
mv.visitAnnotation(LF_COMPILED_SIG, true);
@ -1752,7 +1752,7 @@ class InvokerBytecodeGenerator {
methodPrologue();
// Suppress this method in backtraces displayed to the user.
mv.visitAnnotation(LF_HIDDEN_SIG, true);
mv.visitAnnotation(HIDDEN_SIG, true);
// Don't inline the interpreter entry.
mv.visitAnnotation(DONTINLINE_SIG, true);
@ -1812,7 +1812,7 @@ class InvokerBytecodeGenerator {
methodPrologue();
// Suppress this method in backtraces displayed to the user.
mv.visitAnnotation(LF_HIDDEN_SIG, true);
mv.visitAnnotation(HIDDEN_SIG, true);
// Force inlining of this invoker method.
mv.visitAnnotation(FORCEINLINE_SIG, true);

View file

@ -27,6 +27,7 @@ package java.lang.invoke;
import jdk.internal.perf.PerfCounter;
import jdk.internal.vm.annotation.DontInline;
import jdk.internal.vm.annotation.Hidden;
import jdk.internal.vm.annotation.Stable;
import sun.invoke.util.Wrapper;
@ -1828,15 +1829,6 @@ class LambdaForm {
@interface Compiled {
}
/**
* Internal marker for LambdaForm interpreter frames.
*/
/*non-public*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@interface Hidden {
}
private static final HashMap<String,Integer> DEBUG_NAME_COUNTERS;
private static final HashMap<LambdaForm,String> DEBUG_NAMES;
static {

View file

@ -33,6 +33,7 @@ import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.annotation.Hidden;
import jdk.internal.vm.annotation.Stable;
import sun.invoke.empty.Empty;
import sun.invoke.util.ValueConversions;
@ -681,7 +682,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
return SimpleMethodHandle.make(srcType, form);
}
@LambdaForm.Hidden
@Hidden
static
MethodHandle selectAlternative(boolean testResult, MethodHandle target, MethodHandle fallback) {
if (testResult) {
@ -692,7 +693,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
}
// Intrinsified by C2. Counters are used during parsing to calculate branch frequencies.
@LambdaForm.Hidden
@Hidden
@jdk.internal.HotSpotIntrinsicCandidate
static
boolean profileBoolean(boolean result, int[] counters) {
@ -708,7 +709,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
}
// Intrinsified by C2. Returns true if obj is a compile-time constant.
@LambdaForm.Hidden
@Hidden
@jdk.internal.HotSpotIntrinsicCandidate
static
boolean isCompileConstant(Object obj) {
@ -1054,7 +1055,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
* Intrinsified during LambdaForm compilation
* (see {@link InvokerBytecodeGenerator#emitGuardWithCatch emitGuardWithCatch}).
*/
@LambdaForm.Hidden
@Hidden
static Object guardWithCatch(MethodHandle target, Class<? extends Throwable> exType, MethodHandle catcher,
Object... av) throws Throwable {
// Use asFixedArity() to avoid unnecessary boxing of last argument for VarargsCollector case.
@ -1067,7 +1068,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
}
/** Prepend elements to an array. */
@LambdaForm.Hidden
@Hidden
private static Object[] prepend(Object[] array, Object... elems) {
int nArray = array.length;
int nElems = elems.length;
@ -1265,7 +1266,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
null, null);
// Suppress invoker method in stack traces.
AnnotationVisitor av0 = mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
AnnotationVisitor av0 = mv.visitAnnotation(InvokerBytecodeGenerator.HIDDEN_SIG, true);
av0.visitEnd();
mv.visitCode();
@ -1969,7 +1970,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
* Intrinsified during LambdaForm compilation
* (see {@link InvokerBytecodeGenerator#emitLoop(int)}).
*/
@LambdaForm.Hidden
@Hidden
static Object loop(BasicType[] localTypes, LoopClauses clauseData, Object... av) throws Throwable {
final MethodHandle[] init = clauseData.clauses[0];
final MethodHandle[] step = clauseData.clauses[1];
@ -2174,7 +2175,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
* Intrinsified during LambdaForm compilation
* (see {@link InvokerBytecodeGenerator#emitTryFinally emitTryFinally}).
*/
@LambdaForm.Hidden
@Hidden
static Object tryFinally(MethodHandle target, MethodHandle cleanup, Object... av) throws Throwable {
Throwable t = null;
Object r = null;

View file

@ -30,6 +30,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.ref.Reference;
import jdk.internal.vm.annotation.Hidden;
import sun.security.util.Debug;
import sun.security.util.SecurityConstants;
import jdk.internal.reflect.CallerSensitive;
@ -789,16 +791,6 @@ public final class AccessController {
}
/**
* Internal marker for hidden implementation frames.
*/
/*non-public*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@interface Hidden {
}
/**
* Wrap an exception. The annotations are used in a best effort to
* avoid StackOverflowError in the caller. Inlining the callees as

View file

@ -0,0 +1,45 @@
/*
* 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 jdk.internal.vm.annotation;
import java.lang.annotation.*;
/**
* A method or constructor may be annotated as "hidden" to hint it is desirable
* to omit it from stack traces.
*
* @implNote
* This annotation only takes effect for methods or constructors of classes
* loaded by the boot loader. Annotations on methods or constructors of classes
* loaded outside of the boot loader are ignored.
*
* <p>HotSpot JVM provides diagnostic option {@code -XX:+ShowHiddenFrames} to
* always show "hidden" frames.
*/
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
@Retention(RetentionPolicy.RUNTIME)
public @interface Hidden {
}