/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Shared information for a group of method types, which differ
* only by reference types, and therefore share a common erasure
* and wrapping.
* <p>
* For an empirical discussion of the structure of method types,
* see <a href="http://groups.google.com/group/jvm-languages/browse_thread/thread/ac9308ae74da9b7e/">
* the thread "Avoiding Boxing" on jvm-languages</a>.
* There are approximately 2000 distinct erased method types in the JDK.
* There are a little over 10 times that number of unerased types.
* No more than half of these are likely to be loaded at once.
* @author John Rose
*/
final class MethodTypeForm {
// Cached adapter information:
// Cached lambda form information, for basic types only:
// Indexes into lambdaForms:
static final int
return erasedType;
}
return basicType;
}
return lambdaForms[which];
}
// Should we perform some sort of CAS, to avoid racy duplication?
}
assert(erasedType == basicType) : "erasedType: " + erasedType + " != basicType: " + basicType; // primitives must be flattened also
return invoker;
}
/**
* Build an MTF for a given type, which must have all references erased to Object.
* This MTF will stand for that type and all un-erased variations.
* Eagerly compute some basic properties of the type, common to all variations.
*/
this.erasedType = erasedType;
// Walk the argument types, looking for primitives.
++pac;
if (w.isDoubleWord()) ++lac;
if (w.isSubwordOrInt() && pt != int.class) {
bpts[i] = int.class;
}
}
}
++prc; // even void.class counts as a prim here
if (w.isDoubleWord()) ++lrc;
if (w.isSubwordOrInt() && rt != int.class)
bt = int.class;
// adjust #slots, #args
if (rt == void.class)
else
rslotCount += lrc;
}
this.basicType = erasedType;
} else {
}
if (lac != 0) {
if (w.isDoubleWord()) --slot;
--slot;
}
}
if (slotToArgTab == null) {
for (int i = 0; i < ptypeCount; i++) {
--slot;
}
}
this.argToSlotTable = argToSlotTab;
this.slotToArgTable = slotToArgTab;
// send a few bits down to the JVM:
this.vmslots = parameterSlotCount();
if (basicType == erasedType) {
} else {
}
}
private static long pack(int a, int b, int c, int d) {
assert(((a|b|c|d) & ~0xFFFF) == 0);
}
assert(word <= 3);
}
}
}
}
}
public int primitiveParameterCount() {
}
public int longPrimitiveParameterCount() {
}
}
}
public boolean hasPrimitives() {
return primCounts != 0;
}
public boolean hasNonVoidPrimitives() {
if (primCounts == 0) return false;
if (primitiveParameterCount() != 0) return true;
}
public boolean hasLongPrimitives() {
}
public int parameterToArgSlot(int i) {
return argToSlotTable[1+i];
}
// Note: Empty slots are represented by zero in this table.
// Valid arguments slots contain incremented entries, so as to be non-zero.
// We return -1 the caller to mean an empty slot.
}
// It is already erased. Make a new MethodTypeForm.
return new MethodTypeForm(mt);
} else {
// Share the MethodTypeForm with the erased version.
}
}
/** Codes for {@link #canonicalize(java.lang.Class, int)}.
* ERASE means change every reference to {@code Object}.
* WRAP means convert primitives (including {@code void} to their
* corresponding wrapper types. UNWRAP means the reverse of WRAP.
* INTS means convert all non-void primitive types to int or long,
* according to size. LONGS means convert all non-void primitives
* to long, regardless of size. RAW_RETURN means convert a type
* (assumed to be a return type) to int if it is smaller than an int,
* or if it is void.
*/
public static final int NO_CHANGE = 0, ERASE = 1, WRAP = 2, UNWRAP = 3, INTS = 4, LONGS = 5, RAW_RETURN = 6;
/** Canonicalize the types in the given method type.
* If any types change, intern the new type, and return it.
* Otherwise return null.
*/
// It is already canonical.
return null;
}
// Find the erased version of the method type:
}
/** Canonicalize the given return or param type.
* Return null if the type is already canonicalized.
*/
if (t == Object.class) {
// no change, ever
} else if (!t.isPrimitive()) {
switch (how) {
case UNWRAP:
break;
case RAW_RETURN:
case ERASE:
return Object.class;
}
} else if (t == void.class) {
// no change, usually
switch (how) {
case RAW_RETURN:
return int.class;
case WRAP:
return Void.class;
}
} else {
// non-void primitive
switch (how) {
case WRAP:
return Wrapper.asWrapperType(t);
case INTS:
if (t == int.class || t == long.class)
return null; // no change
if (t == double.class)
return long.class;
return int.class;
case LONGS:
if (t == long.class)
return null; // no change
return long.class;
case RAW_RETURN:
if (t == int.class || t == long.class ||
t == float.class || t == double.class)
return null; // no change
// everything else returns as an int
return int.class;
}
}
// no change; return null to signify
return null;
}
/** Canonicalize each param type in the given array.
* Return null if all types are already canonicalized.
*/
if (c == void.class)
c = null; // a Void parameter was unwrapped to void; ignore
if (c != null) {
cs[i] = c;
}
}
return cs;
}
return "Form"+erasedType;
}
}