< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases/src/org/graalvm/compiler/phases/verify/VerifyBailoutUsage.java

Print this page
rev 52509 : [mq]: graal2


  31 import org.graalvm.compiler.nodes.java.MethodCallTargetNode;
  32 import org.graalvm.compiler.phases.VerifyPhase;
  33 import org.graalvm.compiler.phases.tiers.PhaseContext;
  34 
  35 import jdk.vm.ci.code.BailoutException;
  36 import jdk.vm.ci.meta.ResolvedJavaMethod;
  37 import jdk.vm.ci.meta.ResolvedJavaType;
  38 
  39 public class VerifyBailoutUsage extends VerifyPhase<PhaseContext> {
  40 
  41     private static final String[] AllowedPackagePrefixes;
  42 
  43     private static String getPackageName(Class<?> c) {
  44         String classNameWithPackage = c.getName();
  45         String simpleName = c.getSimpleName();
  46         return classNameWithPackage.substring(0, classNameWithPackage.length() - simpleName.length() - 1);
  47     }
  48 
  49     static {
  50         try {
  51             AllowedPackagePrefixes = new String[]{getPackageName(PermanentBailoutException.class), "jdk.vm.ci"};









  52         } catch (Throwable t) {
  53             throw new GraalError(t);
  54         }
  55     }
  56 
  57     private static boolean matchesPrefix(String packageName) {
  58         for (String allowedPackagePrefix : AllowedPackagePrefixes) {
  59             if (packageName.startsWith(allowedPackagePrefix)) {
  60                 return true;
  61             }
  62         }
  63         return false;
  64     }
  65 
  66     @Override
  67     protected boolean verify(StructuredGraph graph, PhaseContext context) {
  68         final ResolvedJavaType bailoutType = context.getMetaAccess().lookupJavaType(BailoutException.class);
  69         ResolvedJavaMethod caller = graph.method();
  70         String holderQualified = caller.format("%H");
  71         String holderUnqualified = caller.format("%h");


  31 import org.graalvm.compiler.nodes.java.MethodCallTargetNode;
  32 import org.graalvm.compiler.phases.VerifyPhase;
  33 import org.graalvm.compiler.phases.tiers.PhaseContext;
  34 
  35 import jdk.vm.ci.code.BailoutException;
  36 import jdk.vm.ci.meta.ResolvedJavaMethod;
  37 import jdk.vm.ci.meta.ResolvedJavaType;
  38 
  39 public class VerifyBailoutUsage extends VerifyPhase<PhaseContext> {
  40 
  41     private static final String[] AllowedPackagePrefixes;
  42 
  43     private static String getPackageName(Class<?> c) {
  44         String classNameWithPackage = c.getName();
  45         String simpleName = c.getSimpleName();
  46         return classNameWithPackage.substring(0, classNameWithPackage.length() - simpleName.length() - 1);
  47     }
  48 
  49     static {
  50         try {
  51             AllowedPackagePrefixes = new String[]{
  52                             getPackageName(PermanentBailoutException.class),
  53                             "jdk.vm.ci",
  54 
  55                             // Allows GraalTruffleRuntime.handleAnnotationFailure to throw
  56                             // a BailoutException since the org.graalvm.compiler.truffle.runtime
  57                             // project can not see the PermanentBailoutException or
  58                             // RetryableBailoutException types.
  59                             "org.graalvm.compiler.truffle.runtime"
  60             };
  61         } catch (Throwable t) {
  62             throw new GraalError(t);
  63         }
  64     }
  65 
  66     private static boolean matchesPrefix(String packageName) {
  67         for (String allowedPackagePrefix : AllowedPackagePrefixes) {
  68             if (packageName.startsWith(allowedPackagePrefix)) {
  69                 return true;
  70             }
  71         }
  72         return false;
  73     }
  74 
  75     @Override
  76     protected boolean verify(StructuredGraph graph, PhaseContext context) {
  77         final ResolvedJavaType bailoutType = context.getMetaAccess().lookupJavaType(BailoutException.class);
  78         ResolvedJavaMethod caller = graph.method();
  79         String holderQualified = caller.format("%H");
  80         String holderUnqualified = caller.format("%h");
< prev index next >