Skip to content

Commit

Permalink
implicit type profiling of LLVMIVarBit via the type system
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasstadler committed Sep 24, 2019
1 parent 32e0341 commit ff4ebdc
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,36 @@ public static LLVMManagedPointer asManagedPointer(Object object) {
// Automatic type profiling for LLVMIVarBitSmall vs. LLVMIVarBitLarge:
// The type never changes (it depends on the bit width), so this is always a perfect profile.

@TypeCheck(LLVMIVarBitSmall.class)
public static boolean isLLVMIVarBitSmall(Object object) {
return object instanceof LLVMIVarBitSmall;
}

@TypeCast(LLVMIVarBitSmall.class)
public static LLVMIVarBitSmall asLLVMIVarBitSmall(Object object) {
return (LLVMIVarBitSmall) object;
}

@TypeCheck(LLVMIVarBitLarge.class)
public static boolean isLLVMIVarBitLarge(Object object) {
return object instanceof LLVMIVarBitLarge;
}

@TypeCast(LLVMIVarBitLarge.class)
public static LLVMIVarBitLarge asLLVMIVarBitLarge(Object object) {
return (LLVMIVarBitLarge) object;
}

@TypeCheck(LLVMIVarBit.class)
public static boolean isLLVMIVarBit(@SuppressWarnings("unused") Object object) {
return false;
}

@TypeCast(LLVMIVarBit.class)
public static LLVMIVarBit asLLVMIVarBit(@SuppressWarnings("unused") Object object) {
throw new IllegalStateException("LLVMIVarBit should always be cast via small/large");
}

@ImplicitCast
public static LLVMIVarBit asIVarBit(LLVMIVarBitSmall small) {
return small;
Expand Down

0 comments on commit ff4ebdc

Please sign in to comment.