< prev index next >

src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java

Print this page




 641     private static final LambdaForm[] ACCESSOR_FORMS
 642             = new LambdaForm[afIndex(AF_LIMIT, false, false, 0)];
 643     static int ftypeKind(Class<?> ftype, boolean canBeNull) {
 644         if (ftype.isPrimitive())
 645             return Wrapper.forPrimitiveType(ftype).ordinal();
 646         else if (VerifyType.isNullReferenceConversion(Object.class, ftype)) {
 647             return FT_UNCHECKED_REF;
 648         } else
 649             // null check for value type in addition to check cast
 650             return canBeNull ? FT_CHECKED_REF : FT_CHECKED_VALUE;
 651     }
 652 
 653     /**
 654      * Create a LF which can access the given field.
 655      * Cache and share this structure among all fields with
 656      * the same basicType and refKind.
 657      */
 658     private static LambdaForm preparedFieldLambdaForm(MemberName m) {
 659         Class<?> ftype = m.getFieldType();
 660         boolean isVolatile = m.isVolatile();
 661         boolean isFlatValue = m.isFlatValue();
 662         boolean canBeNull = m.canBeNull();
 663         byte formOp;
 664         switch (m.getReferenceKind()) {
 665         case REF_getField:      formOp = AF_GETFIELD;    break;
 666         case REF_putField:      formOp = AF_PUTFIELD;    break;
 667         case REF_getStatic:     formOp = AF_GETSTATIC;   break;
 668         case REF_putStatic:     formOp = AF_PUTSTATIC;   break;
 669         default:  throw new InternalError(m.toString());
 670         }
 671         if (shouldBeInitialized(m)) {
 672             // precompute the barrier-free version:
 673             preparedFieldLambdaForm(formOp, isVolatile, isFlatValue , canBeNull, ftype);
 674             assert((AF_GETSTATIC_INIT - AF_GETSTATIC) ==
 675                    (AF_PUTSTATIC_INIT - AF_PUTSTATIC));
 676             formOp += (AF_GETSTATIC_INIT - AF_GETSTATIC);
 677         }
 678         LambdaForm lform = preparedFieldLambdaForm(formOp, isVolatile, isFlatValue , canBeNull, ftype);
 679         maybeCompile(lform, m);
 680         assert(lform.methodType().dropParameterTypes(0, 1)
 681                 .equals(m.getInvocationType().basicType()))




 641     private static final LambdaForm[] ACCESSOR_FORMS
 642             = new LambdaForm[afIndex(AF_LIMIT, false, false, 0)];
 643     static int ftypeKind(Class<?> ftype, boolean canBeNull) {
 644         if (ftype.isPrimitive())
 645             return Wrapper.forPrimitiveType(ftype).ordinal();
 646         else if (VerifyType.isNullReferenceConversion(Object.class, ftype)) {
 647             return FT_UNCHECKED_REF;
 648         } else
 649             // null check for value type in addition to check cast
 650             return canBeNull ? FT_CHECKED_REF : FT_CHECKED_VALUE;
 651     }
 652 
 653     /**
 654      * Create a LF which can access the given field.
 655      * Cache and share this structure among all fields with
 656      * the same basicType and refKind.
 657      */
 658     private static LambdaForm preparedFieldLambdaForm(MemberName m) {
 659         Class<?> ftype = m.getFieldType();
 660         boolean isVolatile = m.isVolatile();
 661         boolean isFlatValue = m.isFlattened();
 662         boolean canBeNull = m.canBeNull();
 663         byte formOp;
 664         switch (m.getReferenceKind()) {
 665         case REF_getField:      formOp = AF_GETFIELD;    break;
 666         case REF_putField:      formOp = AF_PUTFIELD;    break;
 667         case REF_getStatic:     formOp = AF_GETSTATIC;   break;
 668         case REF_putStatic:     formOp = AF_PUTSTATIC;   break;
 669         default:  throw new InternalError(m.toString());
 670         }
 671         if (shouldBeInitialized(m)) {
 672             // precompute the barrier-free version:
 673             preparedFieldLambdaForm(formOp, isVolatile, isFlatValue , canBeNull, ftype);
 674             assert((AF_GETSTATIC_INIT - AF_GETSTATIC) ==
 675                    (AF_PUTSTATIC_INIT - AF_PUTSTATIC));
 676             formOp += (AF_GETSTATIC_INIT - AF_GETSTATIC);
 677         }
 678         LambdaForm lform = preparedFieldLambdaForm(formOp, isVolatile, isFlatValue , canBeNull, ftype);
 679         maybeCompile(lform, m);
 680         assert(lform.methodType().dropParameterTypes(0, 1)
 681                 .equals(m.getInvocationType().basicType()))


< prev index next >