8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package

Reviewed-by: jrose, vlivanov, mchung, roland
This commit is contained in:
Paul Sandoz 2015-12-03 11:17:31 +01:00
parent 8d7fe09e10
commit c464a9de39
11 changed files with 113 additions and 53 deletions

View File

@ -25,25 +25,25 @@
package java.lang.invoke;
import static jdk.internal.org.objectweb.asm.Opcodes.*;
import static java.lang.invoke.LambdaForm.*;
import static java.lang.invoke.LambdaForm.BasicType.*;
import static java.lang.invoke.MethodHandleStatics.*;
import jdk.internal.vm.annotation.Stable;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.FieldVisitor;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import sun.invoke.util.ValueConversions;
import sun.invoke.util.Wrapper;
import java.lang.invoke.LambdaForm.NamedFunction;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.function.Function;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Function;
import jdk.internal.org.objectweb.asm.FieldVisitor;
import sun.invoke.util.ValueConversions;
import sun.invoke.util.Wrapper;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import static java.lang.invoke.LambdaForm.BasicType;
import static java.lang.invoke.LambdaForm.BasicType.*;
import static java.lang.invoke.MethodHandleStatics.*;
import static jdk.internal.org.objectweb.asm.Opcodes.*;
/**
* The flavor of method handle which emulates an invoke instruction
@ -459,7 +459,7 @@ import jdk.internal.org.objectweb.asm.MethodVisitor;
static final String BMH_SIG = "L"+BMH+";";
static final String SPECIES_DATA = "java/lang/invoke/BoundMethodHandle$SpeciesData";
static final String SPECIES_DATA_SIG = "L"+SPECIES_DATA+";";
static final String STABLE_SIG = "Ljava/lang/invoke/Stable;";
static final String STABLE_SIG = "Ljdk/internal/vm/annotation/Stable;";
static final String SPECIES_PREFIX_NAME = "Species_";
static final String SPECIES_PREFIX_PATH = BMH + "$" + SPECIES_PREFIX_NAME;

View File

@ -26,20 +26,24 @@
package java.lang.invoke;
import jdk.internal.misc.Unsafe;
import java.lang.reflect.Method;
import java.util.Arrays;
import sun.invoke.util.VerifyAccess;
import static java.lang.invoke.MethodHandleNatives.Constants.*;
import static java.lang.invoke.LambdaForm.*;
import static java.lang.invoke.MethodTypeForm.*;
import static java.lang.invoke.MethodHandleStatics.*;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.Objects;
import jdk.internal.vm.annotation.ForceInline;
import sun.invoke.util.ValueConversions;
import sun.invoke.util.VerifyAccess;
import sun.invoke.util.VerifyType;
import sun.invoke.util.Wrapper;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Objects;
import static java.lang.invoke.LambdaForm.*;
import static java.lang.invoke.MethodHandleNatives.Constants.*;
import static java.lang.invoke.MethodHandleStatics.UNSAFE;
import static java.lang.invoke.MethodHandleStatics.newInternalError;
import static java.lang.invoke.MethodTypeForm.*;
/**
* The flavor of method handle which implements a constant reference
* to a class member.

View File

@ -608,9 +608,9 @@ class InvokerBytecodeGenerator {
if (lambdaForm.forceInline) {
// Force inlining of this invoker method.
mv.visitAnnotation("Ljava/lang/invoke/ForceInline;", true);
mv.visitAnnotation("Ljdk/internal/vm/annotation/ForceInline;", true);
} else {
mv.visitAnnotation("Ljava/lang/invoke/DontInline;", true);
mv.visitAnnotation("Ljdk/internal/vm/annotation/DontInline;", true);
}
if (lambdaForm.customized != null) {
@ -1292,7 +1292,7 @@ class InvokerBytecodeGenerator {
mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
// Don't inline the interpreter entry.
mv.visitAnnotation("Ljava/lang/invoke/DontInline;", true);
mv.visitAnnotation("Ljdk/internal/vm/annotation/DontInline;", true);
// create parameter array
emitIconstInsn(invokerType.parameterCount());
@ -1351,7 +1351,7 @@ class InvokerBytecodeGenerator {
mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
// Force inlining of this invoker method.
mv.visitAnnotation("Ljava/lang/invoke/ForceInline;", true);
mv.visitAnnotation("Ljdk/internal/vm/annotation/ForceInline;", true);
// Load receiver
emitAloadInsn(0);

View File

@ -25,6 +25,10 @@
package java.lang.invoke;
import jdk.internal.vm.annotation.DontInline;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.annotation.Stable;
import java.lang.reflect.Array;
import java.util.Arrays;

View File

@ -25,18 +25,24 @@
package java.lang.invoke;
import java.lang.annotation.*;
import jdk.internal.vm.annotation.DontInline;
import jdk.internal.vm.annotation.Stable;
import sun.invoke.util.Wrapper;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Arrays;
import java.util.HashMap;
import sun.invoke.util.Wrapper;
import java.lang.reflect.Field;
import java.util.List;
import static java.lang.invoke.LambdaForm.BasicType.*;
import static java.lang.invoke.MethodHandleStatics.*;
import static java.lang.invoke.MethodHandleNatives.Constants.*;
import static java.lang.invoke.MethodHandleNatives.Constants.REF_invokeStatic;
import static java.lang.invoke.MethodHandleStatics.debugEnabled;
import static java.lang.invoke.MethodHandleStatics.newInternalError;
/**
* The symbolic, non-executable form of a method handle's invocation semantics.

View File

@ -32,8 +32,8 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import jdk.internal.vm.annotation.Stable;
import sun.invoke.empty.Empty;
import sun.invoke.util.ValueConversions;
import sun.invoke.util.VerifyType;
@ -1483,7 +1483,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
}
private static final int LEFT_ARGS = FILL_ARRAYS_COUNT - 1;
private static final @Stable MethodHandle[] FILL_ARRAY_TO_RIGHT = new MethodHandle[MAX_ARITY+1];
private static final @Stable MethodHandle[] FILL_ARRAY_TO_RIGHT = new MethodHandle[MAX_ARITY + 1];
/** fill_array_to_right(N).invoke(a, argL..arg[N-1])
* fills a[L]..a[N-1] with corresponding arguments,
* and then returns a. The value L is a global constant (LEFT_ARGS).

View File

@ -25,6 +25,7 @@
package java.lang.invoke;
import jdk.internal.vm.annotation.Stable;
import sun.invoke.util.Wrapper;
import java.lang.ref.WeakReference;
import java.lang.ref.Reference;

View File

@ -25,6 +25,7 @@
package java.lang.invoke;
import jdk.internal.vm.annotation.Stable;
import sun.invoke.util.Wrapper;
import java.lang.ref.SoftReference;
import static java.lang.invoke.MethodHandleStatics.*;

View File

@ -23,15 +23,28 @@
* questions.
*/
package java.lang.invoke;
package jdk.internal.vm.annotation;
import java.lang.annotation.*;
/**
* Internal marker for some methods in the JSR 292 implementation.
* A method or constructor may be annotated as "don't inline" if the inlining of
* this method should not be performed by the HotSpot VM.
* <p>
* This annotation must be used sparingly. It is useful when the only
* reasonable alternative is to bind the name of a specific method or
* constructor into the HotSpot VM for special handling by the inlining policy.
* This annotation must not be relied on as an alternative to avoid tuning the
* VM's inlining policy. In a few cases, it may act as a temporary workaround
* until the profiling and inlining performed by the HotSpot VM is sufficiently
* improved.
*
* @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.
*/
/*non-public*/
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
@Retention(RetentionPolicy.RUNTIME)
@interface DontInline {
public @interface DontInline {
}

View File

@ -23,15 +23,29 @@
* questions.
*/
package java.lang.invoke;
package jdk.internal.vm.annotation;
import java.lang.annotation.*;
/**
* Internal marker for some methods in the JSR 292 implementation.
* A method or constructor may be annotated as "force inline" if the standard
* inlining metrics are to be ignored when the HotSpot VM inlines the method
* or constructor.
* <p>
* This annotation must be used sparingly. It is useful when the only
* reasonable alternative is to bind the name of a specific method or
* constructor into the HotSpot VM for special handling by the inlining policy.
* This annotation must not be relied on as an alternative to avoid tuning the
* VM's inlining policy. In a few cases, it may act as a temporary workaround
* until the profiling and inlining performed by the HotSpot VM is sufficiently
* improved.
*
* @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.
*/
/*non-public*/
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
@Retention(RetentionPolicy.RUNTIME)
@interface ForceInline {
public @interface ForceInline {
}

View File

@ -23,7 +23,7 @@
* questions.
*/
package java.lang.invoke;
package jdk.internal.vm.annotation;
import java.lang.annotation.*;
@ -57,17 +57,34 @@ import java.lang.annotation.*;
* <p>
* Fields which are declared {@code final} may also be annotated as stable.
* Since final fields already behave as stable values, such an annotation
* indicates no additional information, unless the type of the field is
* an array type.
* conveys no additional information regarding change of the field's value, but
* still conveys information regarding change of additional components values if
* the type of the field is an array type (as described above).
* <p>
* The HotSpot VM relies on this annotation to promote a non-null (resp.,
* non-zero) component value to a constant, thereby enabling superior
* optimizations of code depending on such a value (such as constant folding).
* More specifically, the HotSpot VM will process non-null stable fields (final
* or otherwise) in a similar manner to static final fields with respect to
* promoting the field's value to a constant. Thus, placing aside the
* differences for null/non-null values and arrays, a final stable field is
* treated as if it is really final from both the Java language and the HotSpot
* VM.
* <p>
* It is (currently) undefined what happens if a field annotated as stable
* is given a third value. In practice, if the JVM relies on this annotation
* to promote a field reference to a constant, it may be that the Java memory
* model would appear to be broken, if such a constant (the second value of the field)
* is used as the value of the field even after the field value has changed.
* is given a third value (by explicitly updating a stable field, a component of
* a stable array, or a final stable field via reflection or other means).
* Since the HotSpot VM promotes a non-null component value to constant, it may
* be that the Java memory model would appear to be broken, if such a constant
* (the second value of the field) is used as the value of the field even after
* the field value has changed (to a third value).
*
* @implNote
* This annotation only takes effect for fields of classes loaded by the boot
* loader. Annoations on fields of classes loaded outside of the boot loader
* are ignored.
*/
/* package-private */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@interface Stable {
public @interface Stable {
}