src/share/classes/java/lang/invoke/DirectMethodHandle.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File jdk Sdiff src/share/classes/java/lang/invoke

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

Print this page
rev 9490 : 8037210: Get rid of char-based descriptions 'J' of basic types
Reviewed-by: ?
Contributed-by: john.r.rose@oracle.com
rev 9491 : 8037209: Improvements and cleanups to bytecode assembly for lambda forms
Reviewed-by: ?
Contributed-by: john.r.rose@oracle.com


 247             throw newInternalError(ex);
 248         }
 249         final int DMH_THIS    = 0;
 250         final int ARG_BASE    = 1;
 251         final int ARG_LIMIT   = ARG_BASE + mtype.parameterCount();
 252         int nameCursor = ARG_LIMIT;
 253         final int NEW_OBJ     = (doesAlloc ? nameCursor++ : -1);
 254         final int GET_MEMBER  = nameCursor++;
 255         final int LINKER_CALL = nameCursor++;
 256         Name[] names = arguments(nameCursor - ARG_LIMIT, mtype.invokerType());
 257         assert(names.length == nameCursor);
 258         if (doesAlloc) {
 259             // names = { argx,y,z,... new C, init method }
 260             names[NEW_OBJ] = new Name(Lazy.NF_allocateInstance, names[DMH_THIS]);
 261             names[GET_MEMBER] = new Name(Lazy.NF_constructorMethod, names[DMH_THIS]);
 262         } else if (needsInit) {
 263             names[GET_MEMBER] = new Name(Lazy.NF_internalMemberNameEnsureInit, names[DMH_THIS]);
 264         } else {
 265             names[GET_MEMBER] = new Name(Lazy.NF_internalMemberName, names[DMH_THIS]);
 266         }

 267         Object[] outArgs = Arrays.copyOfRange(names, ARG_BASE, GET_MEMBER+1, Object[].class);
 268         assert(outArgs[outArgs.length-1] == names[GET_MEMBER]);  // look, shifted args!
 269         int result = LambdaForm.LAST_RESULT;
 270         if (doesAlloc) {
 271             assert(outArgs[outArgs.length-2] == names[NEW_OBJ]);  // got to move this one
 272             System.arraycopy(outArgs, 0, outArgs, 1, outArgs.length-2);
 273             outArgs[0] = names[NEW_OBJ];
 274             result = NEW_OBJ;
 275         }
 276         names[LINKER_CALL] = new Name(linker, outArgs);
 277         lambdaName += "_" + shortenSignature(basicTypeSignature(mtype));
 278         LambdaForm lform = new LambdaForm(lambdaName, ARG_LIMIT, names, result);
 279         // This is a tricky bit of code.  Don't send it through the LF interpreter.
 280         lform.compileToBytecode();
 281         return lform;
 282     }
 283 










 284     private static void maybeCompile(LambdaForm lform, MemberName m) {
 285         if (VerifyAccess.isSamePackage(m.getDeclaringClass(), MethodHandle.class))
 286             // Help along bootstrapping...
 287             lform.compileToBytecode();
 288     }
 289 
 290     /** Static wrapper for DirectMethodHandle.internalMemberName. */
 291     @ForceInline
 292     /*non-public*/ static Object internalMemberName(Object mh) {
 293         return ((DirectMethodHandle)mh).member;
 294     }
 295 
 296     /** Static wrapper for DirectMethodHandle.internalMemberName.
 297      * This one also forces initialization.
 298      */
 299     /*non-public*/ static Object internalMemberNameEnsureInit(Object mh) {
 300         DirectMethodHandle dmh = (DirectMethodHandle)mh;
 301         dmh.ensureInitialized();
 302         return dmh.member;
 303     }




 247             throw newInternalError(ex);
 248         }
 249         final int DMH_THIS    = 0;
 250         final int ARG_BASE    = 1;
 251         final int ARG_LIMIT   = ARG_BASE + mtype.parameterCount();
 252         int nameCursor = ARG_LIMIT;
 253         final int NEW_OBJ     = (doesAlloc ? nameCursor++ : -1);
 254         final int GET_MEMBER  = nameCursor++;
 255         final int LINKER_CALL = nameCursor++;
 256         Name[] names = arguments(nameCursor - ARG_LIMIT, mtype.invokerType());
 257         assert(names.length == nameCursor);
 258         if (doesAlloc) {
 259             // names = { argx,y,z,... new C, init method }
 260             names[NEW_OBJ] = new Name(Lazy.NF_allocateInstance, names[DMH_THIS]);
 261             names[GET_MEMBER] = new Name(Lazy.NF_constructorMethod, names[DMH_THIS]);
 262         } else if (needsInit) {
 263             names[GET_MEMBER] = new Name(Lazy.NF_internalMemberNameEnsureInit, names[DMH_THIS]);
 264         } else {
 265             names[GET_MEMBER] = new Name(Lazy.NF_internalMemberName, names[DMH_THIS]);
 266         }
 267         assert(findDirectMethodHandle(names[GET_MEMBER]) == names[DMH_THIS]);
 268         Object[] outArgs = Arrays.copyOfRange(names, ARG_BASE, GET_MEMBER+1, Object[].class);
 269         assert(outArgs[outArgs.length-1] == names[GET_MEMBER]);  // look, shifted args!
 270         int result = LAST_RESULT;
 271         if (doesAlloc) {
 272             assert(outArgs[outArgs.length-2] == names[NEW_OBJ]);  // got to move this one
 273             System.arraycopy(outArgs, 0, outArgs, 1, outArgs.length-2);
 274             outArgs[0] = names[NEW_OBJ];
 275             result = NEW_OBJ;
 276         }
 277         names[LINKER_CALL] = new Name(linker, outArgs);
 278         lambdaName += "_" + shortenSignature(basicTypeSignature(mtype));
 279         LambdaForm lform = new LambdaForm(lambdaName, ARG_LIMIT, names, result);
 280         // This is a tricky bit of code.  Don't send it through the LF interpreter.
 281         lform.compileToBytecode();
 282         return lform;
 283     }
 284 
 285     static Object findDirectMethodHandle(Name name) {
 286         if (name.function == Lazy.NF_internalMemberName ||
 287             name.function == Lazy.NF_internalMemberNameEnsureInit ||
 288             name.function == Lazy.NF_constructorMethod) {
 289             assert(name.arguments.length == 1);
 290             return name.arguments[0];
 291         }
 292         return null;
 293     }
 294 
 295     private static void maybeCompile(LambdaForm lform, MemberName m) {
 296         if (VerifyAccess.isSamePackage(m.getDeclaringClass(), MethodHandle.class))
 297             // Help along bootstrapping...
 298             lform.compileToBytecode();
 299     }
 300 
 301     /** Static wrapper for DirectMethodHandle.internalMemberName. */
 302     @ForceInline
 303     /*non-public*/ static Object internalMemberName(Object mh) {
 304         return ((DirectMethodHandle)mh).member;
 305     }
 306 
 307     /** Static wrapper for DirectMethodHandle.internalMemberName.
 308      * This one also forces initialization.
 309      */
 310     /*non-public*/ static Object internalMemberNameEnsureInit(Object mh) {
 311         DirectMethodHandle dmh = (DirectMethodHandle)mh;
 312         dmh.ensureInitialized();
 313         return dmh.member;
 314     }


src/share/classes/java/lang/invoke/DirectMethodHandle.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File