8267614: Outline VarHandleGuards exact behavior checks

Reviewed-by: psandoz, mchung
This commit is contained in:
Claes Redestad 2021-05-24 23:02:40 +00:00
parent f6909596ca
commit c519ba2e43
3 changed files with 95 additions and 324 deletions

View file

@ -40,6 +40,7 @@ import java.util.function.BiFunction;
import java.util.function.Function;
import jdk.internal.util.Preconditions;
import jdk.internal.vm.annotation.DontInline;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.annotation.IntrinsicCandidate;
import jdk.internal.vm.annotation.Stable;
@ -2028,6 +2029,19 @@ public abstract class VarHandle implements Constable {
return accessModeType(accessMode.at.ordinal());
}
@ForceInline
final void checkExactAccessMode(VarHandle.AccessDescriptor ad) {
if (exact && accessModeType(ad.type) != ad.symbolicMethodTypeExact) {
throwWrongMethodTypeException(ad);
}
}
@DontInline
private final void throwWrongMethodTypeException(VarHandle.AccessDescriptor ad) {
throw new WrongMethodTypeException("expected " + accessModeType(ad.type) + " but found "
+ ad.symbolicMethodTypeExact);
}
@ForceInline
final MethodType accessModeType(int accessTypeOrdinal) {
TypesAndInvokers tis = getTypesAndInvokers();