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

@ -2120,12 +2120,7 @@ AnnotationCollector::annotation_index(const ClassLoaderData* loader_data,
if (!privileged) break; // only allow in privileged code if (!privileged) break; // only allow in privileged code
return _method_LambdaForm_Compiled; return _method_LambdaForm_Compiled;
} }
case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_LambdaForm_Hidden_signature): { case vmSymbols::VM_SYMBOL_ENUM_NAME(jdk_internal_vm_annotation_Hidden_signature): {
if (_location != _in_method) break; // only allow for methods
if (!privileged) break; // only allow in privileged code
return _method_Hidden;
}
case vmSymbols::VM_SYMBOL_ENUM_NAME(java_security_AccessController_Hidden_signature): {
if (_location != _in_method) break; // only allow for methods if (_location != _in_method) break; // only allow for methods
if (!privileged) break; // only allow in privileged code if (!privileged) break; // only allow in privileged code
return _method_Hidden; return _method_Hidden;

View file

@ -278,9 +278,10 @@
\ \
/* Intrinsic Annotation (JDK 9 and above) */ \ /* Intrinsic Annotation (JDK 9 and above) */ \
template(jdk_internal_HotSpotIntrinsicCandidate_signature, "Ljdk/internal/HotSpotIntrinsicCandidate;") \ template(jdk_internal_HotSpotIntrinsicCandidate_signature, "Ljdk/internal/HotSpotIntrinsicCandidate;") \
template(jdk_internal_vm_annotation_ForceInline_signature, "Ljdk/internal/vm/annotation/ForceInline;") \
template(jdk_internal_vm_annotation_DontInline_signature, "Ljdk/internal/vm/annotation/DontInline;") \ template(jdk_internal_vm_annotation_DontInline_signature, "Ljdk/internal/vm/annotation/DontInline;") \
template(jdk_internal_vm_annotation_Stable_signature, "Ljdk/internal/vm/annotation/Stable;") \ template(jdk_internal_vm_annotation_ForceInline_signature, "Ljdk/internal/vm/annotation/ForceInline;") \
template(jdk_internal_vm_annotation_Hidden_signature, "Ljdk/internal/vm/annotation/Hidden;") \
template(jdk_internal_vm_annotation_Stable_signature, "Ljdk/internal/vm/annotation/Stable;") \
\ \
/* Support for JSR 292 & invokedynamic (JDK 1.7 and above) */ \ /* Support for JSR 292 & invokedynamic (JDK 1.7 and above) */ \
template(java_lang_invoke_CallSite, "java/lang/invoke/CallSite") \ template(java_lang_invoke_CallSite, "java/lang/invoke/CallSite") \
@ -304,9 +305,7 @@
template(java_lang_invoke_LambdaForm, "java/lang/invoke/LambdaForm") \ template(java_lang_invoke_LambdaForm, "java/lang/invoke/LambdaForm") \
template(java_lang_invoke_InjectedProfile_signature, "Ljava/lang/invoke/InjectedProfile;") \ template(java_lang_invoke_InjectedProfile_signature, "Ljava/lang/invoke/InjectedProfile;") \
template(java_lang_invoke_LambdaForm_Compiled_signature, "Ljava/lang/invoke/LambdaForm$Compiled;") \ template(java_lang_invoke_LambdaForm_Compiled_signature, "Ljava/lang/invoke/LambdaForm$Compiled;") \
template(java_lang_invoke_LambdaForm_Hidden_signature, "Ljava/lang/invoke/LambdaForm$Hidden;") \
template(java_lang_invoke_MethodHandleNatives_CallSiteContext_signature, "Ljava/lang/invoke/MethodHandleNatives$CallSiteContext;") \ template(java_lang_invoke_MethodHandleNatives_CallSiteContext_signature, "Ljava/lang/invoke/MethodHandleNatives$CallSiteContext;") \
template(java_security_AccessController_Hidden_signature, "Ljava/security/AccessController$Hidden;") \
/* internal up-calls made only by the JVM, via class sun.invoke.MethodHandleNatives: */ \ /* internal up-calls made only by the JVM, via class sun.invoke.MethodHandleNatives: */ \
template(findMethodHandleType_name, "findMethodHandleType") \ template(findMethodHandleType_name, "findMethodHandleType") \
template(findMethodHandleType_signature, "(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/invoke/MethodType;") \ template(findMethodHandleType_signature, "(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/invoke/MethodType;") \

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 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[] 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]; 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 // Forward the SAM method
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, samMethodName, MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, samMethodName,
samMethodType.toMethodDescriptorString(), null, null); samMethodType.toMethodDescriptorString(), null, null);
mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true); mv.visitAnnotation(DESCR_HIDDEN, true);
new ForwardingMethodGenerator(mv).generate(samMethodType); new ForwardingMethodGenerator(mv).generate(samMethodType);
// Forward the bridges // Forward the bridges
@ -287,7 +288,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
for (MethodType mt : additionalBridges) { for (MethodType mt : additionalBridges) {
mv = cw.visitMethod(ACC_PUBLIC|ACC_BRIDGE, samMethodName, mv = cw.visitMethod(ACC_PUBLIC|ACC_BRIDGE, samMethodName,
mt.toMethodDescriptorString(), null, null); mt.toMethodDescriptorString(), null, null);
mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true); mv.visitAnnotation(DESCR_HIDDEN, true);
new ForwardingMethodGenerator(mv).generate(mt); 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 DONTINLINE_SIG = className("Ljdk/internal/vm/annotation/DontInline;");
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 FORCEINLINE_SIG = className("Ljdk/internal/vm/annotation/ForceInline;"); static final String HIDDEN_SIG = className("Ljdk/internal/vm/annotation/Hidden;");
static final String DONTINLINE_SIG = className("Ljdk/internal/vm/annotation/DontInline;"); static final String INJECTEDPROFILE_SIG = className("Ljava/lang/invoke/InjectedProfile;");
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}. * Generate an invoker method for the passed {@link LambdaForm}.
@ -748,7 +748,7 @@ class InvokerBytecodeGenerator {
methodPrologue(); methodPrologue();
// Suppress this method in backtraces displayed to the user. // 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 // Mark this method as a compiled LambdaForm
mv.visitAnnotation(LF_COMPILED_SIG, true); mv.visitAnnotation(LF_COMPILED_SIG, true);
@ -1752,7 +1752,7 @@ class InvokerBytecodeGenerator {
methodPrologue(); methodPrologue();
// Suppress this method in backtraces displayed to the user. // 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. // Don't inline the interpreter entry.
mv.visitAnnotation(DONTINLINE_SIG, true); mv.visitAnnotation(DONTINLINE_SIG, true);
@ -1812,7 +1812,7 @@ class InvokerBytecodeGenerator {
methodPrologue(); methodPrologue();
// Suppress this method in backtraces displayed to the user. // 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. // Force inlining of this invoker method.
mv.visitAnnotation(FORCEINLINE_SIG, true); mv.visitAnnotation(FORCEINLINE_SIG, true);

View file

@ -27,6 +27,7 @@ package java.lang.invoke;
import jdk.internal.perf.PerfCounter; import jdk.internal.perf.PerfCounter;
import jdk.internal.vm.annotation.DontInline; import jdk.internal.vm.annotation.DontInline;
import jdk.internal.vm.annotation.Hidden;
import jdk.internal.vm.annotation.Stable; import jdk.internal.vm.annotation.Stable;
import sun.invoke.util.Wrapper; import sun.invoke.util.Wrapper;
@ -1828,15 +1829,6 @@ class LambdaForm {
@interface Compiled { @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<String,Integer> DEBUG_NAME_COUNTERS;
private static final HashMap<LambdaForm,String> DEBUG_NAMES; private static final HashMap<LambdaForm,String> DEBUG_NAMES;
static { static {

View file

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

View file

@ -30,6 +30,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import java.lang.ref.Reference; import java.lang.ref.Reference;
import jdk.internal.vm.annotation.Hidden;
import sun.security.util.Debug; import sun.security.util.Debug;
import sun.security.util.SecurityConstants; import sun.security.util.SecurityConstants;
import jdk.internal.reflect.CallerSensitive; 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 * Wrap an exception. The annotations are used in a best effort to
* avoid StackOverflowError in the caller. Inlining the callees as * 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 {
}