src/share/classes/java/lang/invoke/MethodTypeForm.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
*** old/src/share/classes/java/lang/invoke/MethodTypeForm.java Fri Jul 11 20:23:05 2014
--- new/src/share/classes/java/lang/invoke/MethodTypeForm.java Fri Jul 11 20:23:05 2014
*** 49,59 ****
--- 49,65 ----
final long primCounts; // packed prim & double counts
final MethodType erasedType; // the canonical erasure
final MethodType basicType; // the canonical erasure, with primitives simplified
// Cached adapter information:
! @Stable MethodHandle namedFunctionInvoker; // cached helper for LF.NamedFunction
! @Stable final MethodHandle[] methodHandles;
+ // Indexes into methodHandles:
+ static final int
+ MH_BASIC_INV = 0, // cached instance of MH.invokeBasic
+ MH_NF_INV = 1, // cached helper for LF.NamedFunction
+ MH_UNINIT_CS = 2, // uninitialized call site
+ MH_LIMIT = 3;
// Cached lambda form information, for basic types only:
final @Stable LambdaForm[] lambdaForms;
// Indexes into lambdaForms:
static final int
*** 96,105 ****
--- 102,123 ----
assert(erasedType == basicType)
: "erasedType: " + erasedType + " != basicType: " + basicType;
return true;
}
+ public MethodHandle cachedMethodHandle(int which) {
+ assert(assertIsBasicType());
+ return methodHandles[which];
+ }
+
+ synchronized public MethodHandle setCachedMethodHandle(int which, MethodHandle mh) {
+ // Simulate a CAS, to avoid racy duplication of results.
+ MethodHandle prev = methodHandles[which];
+ if (prev != null) return prev;
+ return methodHandles[which] = mh;
+ }
+
public LambdaForm cachedLambdaForm(int which) {
assert(assertIsBasicType());
return lambdaForms[which];
}
*** 167,176 ****
--- 185,195 ----
assert(this != that);
this.primCounts = that.primCounts;
this.argCounts = that.argCounts;
this.argToSlotTable = that.argToSlotTable;
this.slotToArgTable = that.slotToArgTable;
+ this.methodHandles = null;
this.lambdaForms = null;
return;
}
if (lac != 0) {
int slot = ptypeCount + lac;
*** 212,221 ****
--- 231,241 ----
if (pslotCount >= 256) throw newIllegalArgumentException("too many arguments");
// Initialize caches, but only for basic types
assert(basicType == erasedType);
this.lambdaForms = new LambdaForm[LF_LIMIT];
+ this.methodHandles = new MethodHandle[MH_LIMIT];
}
private static long pack(int a, int b, int c, int d) {
assert(((a|b|c|d) & ~0xFFFF) == 0);
long hw = ((a << 16) | b), lw = ((c << 16) | d);
src/share/classes/java/lang/invoke/MethodTypeForm.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File