< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyBailoutUsage.java

Print this page




  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");
  81         String packageName = holderQualified.substring(0, holderQualified.length() - holderUnqualified.length() - 1);
  82         if (!matchesPrefix(packageName)) {
  83             for (MethodCallTargetNode t : graph.getNodes(MethodCallTargetNode.TYPE)) {
  84                 ResolvedJavaMethod callee = t.targetMethod();
  85                 if (callee.getDeclaringClass().equals(bailoutType)) {
  86                     // we only allow the getter
  87                     if (!callee.getName().equals("isPermanent")) {
  88                         throw new VerificationError("Call to %s at callsite %s is prohibited. Consider using %s for permanent bailouts or %s for retryables.", callee.format("%H.%n(%p)"),
  89                                         caller.format("%H.%n(%p)"), PermanentBailoutException.class.getName(),
  90                                         RetryableBailoutException.class.getName());
  91                     }
  92                 }
  93             }
  94         }
  95         return true;
  96     }
  97 
  98 }


  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 void 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");
  81         String packageName = holderQualified.substring(0, holderQualified.length() - holderUnqualified.length() - 1);
  82         if (!matchesPrefix(packageName)) {
  83             for (MethodCallTargetNode t : graph.getNodes(MethodCallTargetNode.TYPE)) {
  84                 ResolvedJavaMethod callee = t.targetMethod();
  85                 if (callee.getDeclaringClass().equals(bailoutType)) {
  86                     // we only allow the getter
  87                     if (!callee.getName().equals("isPermanent")) {
  88                         throw new VerificationError("Call to %s at callsite %s is prohibited. Consider using %s for permanent bailouts or %s for retryables.", callee.format("%H.%n(%p)"),
  89                                         caller.format("%H.%n(%p)"), PermanentBailoutException.class.getName(),
  90                                         RetryableBailoutException.class.getName());
  91                     }
  92                 }
  93             }
  94         }

  95     }
  96 
  97 }
< prev index next >