Skip to content
Permalink
Browse files
8263821: Remove unused MethodTypeForm canonicalization codes
Reviewed-by: mchung
  • Loading branch information
cl4es committed Mar 19, 2021
1 parent 4d51a82 commit 57497ab0ca784cfa9538ccb3718baca92590861e
Showing 2 changed files with 10 additions and 45 deletions.
@@ -742,7 +742,7 @@ private static MethodType wrapWithPrims(MethodType pt) {
MethodType wt = (MethodType)pt.wrapAlt;
if (wt == null) {
// fill in lazily
wt = MethodTypeForm.canonicalize(pt, MethodTypeForm.WRAP, MethodTypeForm.WRAP);
wt = MethodTypeForm.canonicalize(pt, MethodTypeForm.WRAP);
assert(wt != null);
pt.wrapAlt = wt;
}
@@ -754,7 +754,7 @@ private static MethodType unwrapWithNoPrims(MethodType wt) {
MethodType uwt = (MethodType)wt.wrapAlt;
if (uwt == null) {
// fill in lazily
uwt = MethodTypeForm.canonicalize(wt, MethodTypeForm.UNWRAP, MethodTypeForm.UNWRAP);
uwt = MethodTypeForm.canonicalize(wt, MethodTypeForm.UNWRAP);
if (uwt == null)
uwt = wt; // type has no wrappers or prims at all
wt.wrapAlt = uwt;
@@ -216,7 +216,7 @@ public boolean hasPrimitives() {
}

static MethodTypeForm findForm(MethodType mt) {
MethodType erased = canonicalize(mt, ERASE, ERASE);
MethodType erased = canonicalize(mt, ERASE);
if (erased == null) {
// It is already erased. Make a new MethodTypeForm.
return new MethodTypeForm(mt);
@@ -230,23 +230,18 @@ static MethodTypeForm findForm(MethodType mt) {
* 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 ERASE = 1, WRAP = 2, UNWRAP = 3, INTS = 4, LONGS = 5, RAW_RETURN = 6;
public static final int ERASE = 1, WRAP = 2, UNWRAP = 3;

/** Canonicalize the types in the given method type.
* If any types change, intern the new type, and return it.
* Otherwise return null.
*/
public static MethodType canonicalize(MethodType mt, int howRet, int howArgs) {
public static MethodType canonicalize(MethodType mt, int how) {
Class<?>[] ptypes = mt.ptypes();
Class<?>[] ptypesCanonical = canonicalizeAll(ptypes, howArgs);
Class<?>[] ptypesCanonical = canonicalizeAll(ptypes, how);
Class<?> rtype = mt.returnType();
Class<?> rtypeCanonical = canonicalize(rtype, howRet);
Class<?> rtypeCanonical = canonicalize(rtype, how);
if (ptypesCanonical == null && rtypeCanonical == null) {
// It is already canonical.
return null;
@@ -261,49 +256,19 @@ public static MethodType canonicalize(MethodType mt, int howRet, int howArgs) {
* Return null if the type is already canonicalized.
*/
static Class<?> canonicalize(Class<?> t, int how) {
Class<?> ct;
if (t == Object.class) {
// no change, ever
} else if (!t.isPrimitive()) {
switch (how) {
case UNWRAP:
ct = Wrapper.asPrimitiveType(t);
Class<?> ct = Wrapper.asPrimitiveType(t);
if (ct != t) return ct;
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;
}
} else if (how == WRAP) {
return Wrapper.asWrapperType(t);
}
// no change; return null to signify
return null;

1 comment on commit 57497ab

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 57497ab Mar 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.