当前位置: 首页>>代码示例>>Java>>正文


Java Assumption类代码示例

本文整理汇总了Java中jdk.vm.ci.meta.Assumptions.Assumption的典型用法代码示例。如果您正苦于以下问题:Java Assumption类的具体用法?Java Assumption怎么用?Java Assumption使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Assumption类属于jdk.vm.ci.meta.Assumptions包,在下文中一共展示了Assumption类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAssumption

import jdk.vm.ci.meta.Assumptions.Assumption; //导入依赖的package包/类
/**
 * Checks the behavior of class loading on {@link Assumption invalidation}. {@code methodName}
 * is compiled and the resulting graph is checked for {@code expectedAssumption}. The code is
 * installed and optionally {@code classToLoad} is loaded. The class is assumed to be an inner
 * class of the test class and the name of the class to load is constructed relative to that.
 *
 * @param methodName the method to compile
 * @param expectedAssumption expected {@link Assumption} instance to find in graph
 * @param classToLoad an optional class to load to trigger an invalidation check
 * @param willInvalidate true if loading {@code classToLoad} should invalidate the method
 */
protected void testAssumption(String methodName, Assumption expectedAssumption, String classToLoad, boolean willInvalidate) {
    ResolvedJavaMethod javaMethod = getResolvedJavaMethod(methodName);

    StructuredGraph graph = parseEager(javaMethod, AllowAssumptions.YES);
    assertTrue(!graph.getAssumptions().isEmpty());
    checkGraph(expectedAssumption, graph);

    CompilationResult compilationResult = compile(javaMethod, graph);
    final InstalledCode installedCode = getBackend().createDefaultInstalledCode(graph.getDebug(), javaMethod, compilationResult);
    assertTrue(installedCode.isValid());
    if (classToLoad != null) {
        String fullName = getClass().getName() + "$" + classToLoad;
        try {
            Class.forName(fullName);
        } catch (ClassNotFoundException e) {
            fail("Can't find class %s", fullName);
        }
        assertTrue(!willInvalidate == installedCode.isValid(), "method should be %s", willInvalidate ? "invalid" : "valid");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:GraalCompilerAssumptionsTest.java

示例2: checkForRegisterFinalizeNode

import jdk.vm.ci.meta.Assumptions.Assumption; //导入依赖的package包/类
private void checkForRegisterFinalizeNode(Class<?> cl, boolean shouldContainFinalizer, AllowAssumptions allowAssumptions) {
    StructuredGraph graph = parseAndProcess(cl, allowAssumptions);
    Assert.assertTrue(graph.getNodes().filter(RegisterFinalizerNode.class).count() == (shouldContainFinalizer ? 1 : 0));
    int noFinalizerAssumption = 0;
    Assumptions assumptions = graph.getAssumptions();
    if (assumptions != null) {
        for (Assumption a : assumptions) {
            if (a instanceof NoFinalizableSubclass) {
                noFinalizerAssumption++;
            } else if (a instanceof LeafType) {
                // Need to also allow leaf type assumption instead of no finalizable subclass
                // assumption.
                noFinalizerAssumption++;
            }
        }
    }
    Assert.assertTrue(noFinalizerAssumption == (shouldContainFinalizer ? 0 : 1));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:FinalizableSubclassTest.java

示例3: HotSpotCompiledCode

import jdk.vm.ci.meta.Assumptions.Assumption; //导入依赖的package包/类
@SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "caller transfers ownership of `sites`, `targetCode`, `comments`, `methods`, `dataSection`, `dataSectionPatches` and `assumptions`")
public HotSpotCompiledCode(String name, byte[] targetCode, int targetCodeSize, Site[] sites, Assumption[] assumptions, ResolvedJavaMethod[] methods, Comment[] comments, byte[] dataSection,
                int dataSectionAlignment, DataPatch[] dataSectionPatches, boolean isImmutablePIC, int totalFrameSize, StackSlot deoptRescueSlot) {
    this.name = name;
    this.targetCode = targetCode;
    this.targetCodeSize = targetCodeSize;
    this.sites = sites;
    this.assumptions = assumptions;
    this.methods = methods;

    this.comments = comments;
    this.dataSection = dataSection;
    this.dataSectionAlignment = dataSectionAlignment;
    this.dataSectionPatches = dataSectionPatches;
    this.isImmutablePIC = isImmutablePIC;
    this.totalFrameSize = totalFrameSize;
    this.deoptRescueSlot = deoptRescueSlot;

    assert validateFrames();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:HotSpotCompiledCode.java

示例4: HotSpotCompiledCode

import jdk.vm.ci.meta.Assumptions.Assumption; //导入依赖的package包/类
public HotSpotCompiledCode(String name, byte[] targetCode, int targetCodeSize, Site[] sites, Assumption[] assumptions, ResolvedJavaMethod[] methods, Comment[] comments, byte[] dataSection,
                int dataSectionAlignment, DataPatch[] dataSectionPatches, boolean isImmutablePIC, int totalFrameSize, StackSlot deoptRescueSlot) {
    this.name = name;
    this.targetCode = targetCode;
    this.targetCodeSize = targetCodeSize;
    this.sites = sites;
    this.assumptions = assumptions;
    this.methods = methods;

    this.comments = comments;
    this.dataSection = dataSection;
    this.dataSectionAlignment = dataSectionAlignment;
    this.dataSectionPatches = dataSectionPatches;
    this.isImmutablePIC = isImmutablePIC;
    this.totalFrameSize = totalFrameSize;
    this.deoptRescueSlot = deoptRescueSlot;

    assert validateFrames();
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:20,代码来源:HotSpotCompiledCode.java

示例5: testAssumption

import jdk.vm.ci.meta.Assumptions.Assumption; //导入依赖的package包/类
/**
 * Checks the behavior of class loading on {@link Assumption invalidation}. {@code methodName}
 * is compiled and the resulting graph is checked for {@code expectedAssumption}. The code is
 * installed and optionally {@code classToLoad} is loaded. The class is assumed to be an inner
 * class of the test class and the name of the class to load is constructed relative to that.
 *
 * @param methodName the method to compile
 * @param expectedAssumption expected {@link Assumption} instance to find in graph
 * @param classToLoad an optional class to load to trigger an invalidation check
 * @param willInvalidate true if loading {@code classToLoad} should invalidate the method
 */
protected void testAssumption(String methodName, Assumption expectedAssumption, String classToLoad, boolean willInvalidate) {
    ResolvedJavaMethod javaMethod = getResolvedJavaMethod(methodName);

    StructuredGraph graph = parseEager(javaMethod, AllowAssumptions.YES);
    assertTrue(!graph.getAssumptions().isEmpty());
    checkGraph(expectedAssumption, graph);

    CompilationResult compilationResult = compile(javaMethod, graph);
    final InstalledCode installedCode = getBackend().createDefaultInstalledCode(javaMethod, compilationResult);
    assertTrue(installedCode.isValid());
    if (classToLoad != null) {
        String fullName = getClass().getName() + "$" + classToLoad;
        try {
            Class.forName(fullName);
        } catch (ClassNotFoundException e) {
            fail("Can't find class %s", fullName);
        }
        assertTrue(!willInvalidate == installedCode.isValid(), "method should be %s", willInvalidate ? "invalid" : "valid");
    }
}
 
开发者ID:graalvm,项目名称:graal-core,代码行数:32,代码来源:GraalCompilerAssumptionsTest.java

示例6: checkGraph

import jdk.vm.ci.meta.Assumptions.Assumption; //导入依赖的package包/类
protected void checkGraph(Assumption expectedAssumption, StructuredGraph graph) {
    boolean found = false;
    for (Assumption a : graph.getAssumptions()) {
        if (expectedAssumption.equals(a)) {
            found = true;
        }
    }
    assertTrue(found, "Can't find assumption %s", expectedAssumption);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:GraalCompilerAssumptionsTest.java

示例7: HotSpotCompiledNmethod

import jdk.vm.ci.meta.Assumptions.Assumption; //导入依赖的package包/类
public HotSpotCompiledNmethod(String name, byte[] targetCode, int targetCodeSize, Site[] sites, Assumption[] assumptions, ResolvedJavaMethod[] methods, Comment[] comments, byte[] dataSection,
                int dataSectionAlignment, DataPatch[] dataSectionPatches, boolean isImmutablePIC, int totalFrameSize, StackSlot deoptRescueSlot, HotSpotResolvedJavaMethod method, int entryBCI,
                int id, long jvmciEnv, boolean hasUnsafeAccess) {
    super(name, targetCode, targetCodeSize, sites, assumptions, methods, comments, dataSection, dataSectionAlignment, dataSectionPatches, isImmutablePIC, totalFrameSize, deoptRescueSlot);
    this.method = method;
    this.entryBCI = entryBCI;
    this.id = id;
    this.jvmciEnv = jvmciEnv;
    this.hasUnsafeAccess = hasUnsafeAccess;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:HotSpotCompiledNmethod.java

示例8: finish

import jdk.vm.ci.meta.Assumptions.Assumption; //导入依赖的package包/类
public HotSpotCompiledCode finish(HotSpotResolvedJavaMethod method) {
    int id = method.allocateCompileId(0);
    byte[] finishedCode = code.finish();
    Site[] finishedSites = sites.toArray(new Site[0]);
    byte[] finishedData = data.finish();
    DataPatch[] finishedDataPatches = dataPatches.toArray(new DataPatch[0]);
    return new HotSpotCompiledNmethod(method.getName(), finishedCode, finishedCode.length, finishedSites, new Assumption[0], new ResolvedJavaMethod[]{method}, new Comment[0], finishedData, 16,
                    finishedDataPatches, false, frameSize, deoptRescue, method, 0, id, 0L, false);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:TestAssembler.java

示例9: processAssumption

import jdk.vm.ci.meta.Assumptions.Assumption; //导入依赖的package包/类
static void processAssumption(Set<Assumption> newAssumptions, Assumption assumption, List<AssumptionValidAssumption> manual) {
    if (assumption != null) {
        if (assumption instanceof AssumptionValidAssumption) {
            AssumptionValidAssumption assumptionValidAssumption = (AssumptionValidAssumption) assumption;
            manual.add(assumptionValidAssumption);
        } else {
            newAssumptions.add(assumption);
        }
    }
}
 
开发者ID:graalvm,项目名称:graal-core,代码行数:11,代码来源:TruffleCompilationResultBuilderFactory.java

示例10: setAssumptions

import jdk.vm.ci.meta.Assumptions.Assumption; //导入依赖的package包/类
/**
 * Sets the assumptions made during compilation.
 */
public void setAssumptions(Assumption[] assumptions) {
    this.assumptions = assumptions;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:CompilationResult.java

示例11: checkGraph

import jdk.vm.ci.meta.Assumptions.Assumption; //导入依赖的package包/类
@Override
protected void checkGraph(Assumption expectedAssumption, StructuredGraph graph) {
    super.checkGraph(expectedAssumption, graph);
    assertTrue(graph.isTrivial());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:ConcreteSubtypeTest.java

示例12: testAssumptionInvalidate

import jdk.vm.ci.meta.Assumptions.Assumption; //导入依赖的package包/类
protected void testAssumptionInvalidate(String methodName, Assumption expected, String classToLoad) {
    testAssumption(methodName, expected, classToLoad, true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:GraalCompilerAssumptionsTest.java

示例13: createCompiledCode

import jdk.vm.ci.meta.Assumptions.Assumption; //导入依赖的package包/类
public static HotSpotCompiledCode createCompiledCode(CodeCacheProvider codeCache, ResolvedJavaMethod method, HotSpotCompilationRequest compRequest, CompilationResult compResult) {
    String name = compResult.getName();

    byte[] targetCode = compResult.getTargetCode();
    int targetCodeSize = compResult.getTargetCodeSize();

    Site[] sites = getSortedSites(codeCache, compResult);

    Assumption[] assumptions = compResult.getAssumptions();

    ResolvedJavaMethod[] methods = compResult.getMethods();

    List<CodeAnnotation> annotations = compResult.getAnnotations();
    Comment[] comments = new Comment[annotations.size()];
    if (!annotations.isEmpty()) {
        for (int i = 0; i < comments.length; i++) {
            CodeAnnotation annotation = annotations.get(i);
            String text;
            if (annotation instanceof CodeComment) {
                CodeComment codeComment = (CodeComment) annotation;
                text = codeComment.value;
            } else if (annotation instanceof JumpTable) {
                JumpTable jumpTable = (JumpTable) annotation;
                text = "JumpTable [" + jumpTable.low + " .. " + jumpTable.high + "]";
            } else {
                text = annotation.toString();
            }
            comments[i] = new Comment(annotation.position, text);
        }
    }

    DataSection data = compResult.getDataSection();
    byte[] dataSection = new byte[data.getSectionSize()];

    ByteBuffer buffer = ByteBuffer.wrap(dataSection).order(ByteOrder.nativeOrder());
    Builder<DataPatch> patchBuilder = Stream.builder();
    data.buildDataSection(buffer, vmConstant -> {
        patchBuilder.accept(new DataPatch(buffer.position(), new ConstantReference(vmConstant)));
    });

    int dataSectionAlignment = data.getSectionAlignment();
    DataPatch[] dataSectionPatches = patchBuilder.build().toArray(len -> new DataPatch[len]);

    int totalFrameSize = compResult.getTotalFrameSize();
    StackSlot customStackArea = compResult.getCustomStackArea();
    boolean isImmutablePIC = compResult.isImmutablePIC();

    if (method instanceof HotSpotResolvedJavaMethod) {
        HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) method;
        int entryBCI = compResult.getEntryBCI();
        boolean hasUnsafeAccess = compResult.hasUnsafeAccess();

        int id;
        long jvmciEnv;
        if (compRequest != null) {
            id = compRequest.getId();
            jvmciEnv = compRequest.getJvmciEnv();
        } else {
            id = hsMethod.allocateCompileId(entryBCI);
            jvmciEnv = 0L;
        }
        return new HotSpotCompiledNmethod(name, targetCode, targetCodeSize, sites, assumptions, methods, comments, dataSection, dataSectionAlignment, dataSectionPatches, isImmutablePIC,
                        totalFrameSize, customStackArea, hsMethod, entryBCI, id, jvmciEnv, hasUnsafeAccess);
    } else {
        return new HotSpotCompiledCode(name, targetCode, targetCodeSize, sites, assumptions, methods, comments, dataSection, dataSectionAlignment, dataSectionPatches, isImmutablePIC,
                        totalFrameSize, customStackArea);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:69,代码来源:HotSpotCompiledCodeBuilder.java

示例14: testInvalidAssumption

import jdk.vm.ci.meta.Assumptions.Assumption; //导入依赖的package包/类
@Test(expected = JVMCIError.class)
public void testInvalidAssumption() {
    installEmptyCode(new Site[0], new Assumption[]{new InvalidAssumption()}, new Comment[0], 16, new DataPatch[0], null);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:TestInvalidCompilationResult.java

示例15: testInvalidAlignment

import jdk.vm.ci.meta.Assumptions.Assumption; //导入依赖的package包/类
@Test(expected = JVMCIError.class)
public void testInvalidAlignment() {
    installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 7, new DataPatch[0], null);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:TestInvalidCompilationResult.java


注:本文中的jdk.vm.ci.meta.Assumptions.Assumption类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。