コード例 #1
0
 /**
  * Create a LF which can access the given field. Cache and share this structure among all fields
  * with the same basicType and refKind.
  */
 private static LambdaForm preparedFieldLambdaForm(MemberName m) {
   Class<?> ftype = m.getFieldType();
   boolean isVolatile = m.isVolatile();
   byte formOp;
   switch (m.getReferenceKind()) {
     case REF_getField:
       formOp = AF_GETFIELD;
       break;
     case REF_putField:
       formOp = AF_PUTFIELD;
       break;
     case REF_getStatic:
       formOp = AF_GETSTATIC;
       break;
     case REF_putStatic:
       formOp = AF_PUTSTATIC;
       break;
     default:
       throw new InternalError(m.toString());
   }
   if (shouldBeInitialized(m)) {
     // precompute the barrier-free version:
     preparedFieldLambdaForm(formOp, isVolatile, ftype);
     assert ((AF_GETSTATIC_INIT - AF_GETSTATIC) == (AF_PUTSTATIC_INIT - AF_PUTSTATIC));
     formOp += (AF_GETSTATIC_INIT - AF_GETSTATIC);
   }
   LambdaForm lform = preparedFieldLambdaForm(formOp, isVolatile, ftype);
   maybeCompile(lform, m);
   assert (lform.methodType().dropParameterTypes(0, 1).equals(m.getInvocationType().basicType()))
       : Arrays.asList(m, m.getInvocationType().basicType(), lform, lform.methodType());
   return lform;
 }
コード例 #2
0
 /**
  * Create a LF which can invoke the given method. Cache and share this structure among all methods
  * with the same basicType and refKind.
  */
 private static LambdaForm preparedLambdaForm(MemberName m) {
   assert (m.isInvocable()) : m; // call preparedFieldLambdaForm instead
   MethodType mtype = m.getInvocationType().basicType();
   assert (!m.isMethodHandleInvoke()) : m;
   int which;
   switch (m.getReferenceKind()) {
     case REF_invokeVirtual:
       which = LF_INVVIRTUAL;
       break;
     case REF_invokeStatic:
       which = LF_INVSTATIC;
       break;
     case REF_invokeSpecial:
       which = LF_INVSPECIAL;
       break;
     case REF_invokeInterface:
       which = LF_INVINTERFACE;
       break;
     case REF_newInvokeSpecial:
       which = LF_NEWINVSPECIAL;
       break;
     default:
       throw new InternalError(m.toString());
   }
   if (which == LF_INVSTATIC && shouldBeInitialized(m)) {
     // precompute the barrier-free version:
     preparedLambdaForm(mtype, which);
     which = LF_INVSTATIC_INIT;
   }
   LambdaForm lform = preparedLambdaForm(mtype, which);
   maybeCompile(lform, m);
   assert (lform.methodType().dropParameterTypes(0, 1).equals(m.getInvocationType().basicType()))
       : Arrays.asList(m, m.getInvocationType().basicType(), lform, lform.methodType());
   return lform;
 }