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


Java HotSpotCompilationRequest类代码示例

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


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

示例1: doCompilation

import jdk.vm.ci.hotspot.HotSpotCompilationRequest; //导入依赖的package包/类
@SuppressWarnings("try")
private void doCompilation(String methodName, String label) {
    HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) getResolvedJavaMethod(methodName);

    // invalidate any existing compiled code
    method.reprofile();

    long jvmciEnv = 0L;

    try (MemoryUsageCloseable c = label == null ? null : new MemoryUsageCloseable(label)) {
        HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
        int entryBCI = JVMCICompiler.INVOCATION_ENTRY_BCI;
        HotSpotCompilationRequest request = new HotSpotCompilationRequest(method, entryBCI, jvmciEnv);
        CompilationTask task = new CompilationTask(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), request, true, false, getInitialOptions());
        task.runCompilation();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:MemoryUsageBenchmark.java

示例2: allocSpyCompilation

import jdk.vm.ci.hotspot.HotSpotCompilationRequest; //导入依赖的package包/类
@SuppressWarnings("try")
private void allocSpyCompilation(String methodName) {
    if (AllocSpy.isEnabled()) {
        HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) getResolvedJavaMethod(methodName);

        // invalidate any existing compiled code
        method.reprofile();

        long jvmciEnv = 0L;
        try (AllocSpy as = AllocSpy.open(methodName)) {
            HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
            HotSpotCompilationRequest request = new HotSpotCompilationRequest(method, JVMCICompiler.INVOCATION_ENTRY_BCI, jvmciEnv);
            HotSpotGraalCompiler compiler = (HotSpotGraalCompiler) runtime.getCompiler();
            OptionValues options = getInitialOptions();
            CompilationTask task = new CompilationTask(runtime, compiler, request, true, false, options);
            task.runCompilation();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:MemoryUsageBenchmark.java

示例3: allocSpyCompilation

import jdk.vm.ci.hotspot.HotSpotCompilationRequest; //导入依赖的package包/类
@SuppressWarnings("try")
private void allocSpyCompilation(String methodName) {
    if (AllocSpy.isEnabled()) {
        HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) getResolvedJavaMethod(methodName);

        // invalidate any existing compiled code
        method.reprofile();

        long jvmciEnv = 0L;
        try (AllocSpy as = AllocSpy.open(methodName)) {
            HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
            HotSpotCompilationRequest request = new HotSpotCompilationRequest(method, JVMCICompiler.INVOCATION_ENTRY_BCI, jvmciEnv);
            CompilationTask task = new CompilationTask(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), request, true, false, getInitialOptions());
            task.runCompilation();
        }
    }
}
 
开发者ID:graalvm,项目名称:graal-core,代码行数:18,代码来源:MemoryUsageBenchmark.java

示例4: compile

import jdk.vm.ci.hotspot.HotSpotCompilationRequest; //导入依赖的package包/类
protected static void compile(DebugContext debug, ResolvedJavaMethod method, int bci) {
    HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
    long jvmciEnv = 0L;
    HotSpotCompilationRequest request = new HotSpotCompilationRequest((HotSpotResolvedJavaMethod) method, bci, jvmciEnv);
    HotSpotGraalCompiler compiler = (HotSpotGraalCompiler) runtime.getCompiler();
    CompilationTask task = new CompilationTask(runtime, compiler, request, true, true, debug.getOptions());
    HotSpotCompilationRequestResult result = task.runCompilation(debug);
    if (result.getFailure() != null) {
        throw new GraalError(result.getFailureMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:GraalOSRTestBase.java

示例5: compileMethod

import jdk.vm.ci.hotspot.HotSpotCompilationRequest; //导入依赖的package包/类
/**
 * Compiles a method and gathers some statistics.
 */
private void compileMethod(HotSpotResolvedJavaMethod method, int counter) {
    try {
        long start = System.currentTimeMillis();
        long allocatedAtStart = getCurrentThreadAllocatedBytes();
        int entryBCI = JVMCICompiler.INVOCATION_ENTRY_BCI;
        HotSpotCompilationRequest request = new HotSpotCompilationRequest(method, entryBCI, 0L);
        // For more stable CTW execution, disable use of profiling information
        boolean useProfilingInfo = false;
        boolean installAsDefault = false;
        CompilationTask task = new CompilationTask(jvmciRuntime, compiler, request, useProfilingInfo, installAsDefault, currentOptions);
        task.runCompilation();

        // Invalidate the generated code so the code cache doesn't fill up
        HotSpotInstalledCode installedCode = task.getInstalledCode();
        if (installedCode != null) {
            installedCode.invalidate();
        }

        memoryUsed.getAndAdd(getCurrentThreadAllocatedBytes() - allocatedAtStart);
        compileTime.getAndAdd(System.currentTimeMillis() - start);
        compiledMethodsCounter.incrementAndGet();
    } catch (Throwable t) {
        // Catch everything and print a message
        println("CompileTheWorld (%d) : Error compiling method: %s", counter, method.format("%H.%n(%p):%r"));
        printStackTrace(t);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:CompileTheWorld.java

示例6: CompilationTask

import jdk.vm.ci.hotspot.HotSpotCompilationRequest; //导入依赖的package包/类
public CompilationTask(HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotGraalCompiler compiler, HotSpotCompilationRequest request, boolean useProfilingInfo, boolean installAsDefault,
                OptionValues options) {
    this.jvmciRuntime = jvmciRuntime;
    this.compiler = compiler;
    this.compilationId = new HotSpotCompilationIdentifier(request);
    this.useProfilingInfo = useProfilingInfo;
    this.installAsDefault = installAsDefault;

    /*
     * Disable inlining if HotSpot has it disabled unless it's been explicitly set in Graal.
     */
    HotSpotGraalRuntimeProvider graalRuntime = compiler.getGraalRuntime();
    GraalHotSpotVMConfig config = graalRuntime.getVMConfig();
    OptionValues newOptions = options;
    if (!config.inline) {
        EconomicMap<OptionKey<?>, Object> m = OptionValues.newOptionMap();
        if (Inline.getValue(options) && !Inline.hasBeenSet(options)) {
            m.put(Inline, false);
        }
        if (InlineDuringParsing.getValue(options) && !InlineDuringParsing.hasBeenSet(options)) {
            m.put(InlineDuringParsing, false);
        }
        if (!m.isEmpty()) {
            newOptions = new OptionValues(options, m);
        }
    }
    this.options = newOptions;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:CompilationTask.java

示例7: dumpMethod

import jdk.vm.ci.hotspot.HotSpotCompilationRequest; //导入依赖的package包/类
public void dumpMethod(String className, String methodName, String filter, String host, int port) throws javax.management.MBeanException {
    String jvmName = MetaUtil.toInternalName(className);
    methodDumps.add(new Dump(host, port, jvmName, methodName, filter));

    ClassNotFoundException last = null;
    EconomicSet<Class<?>> found = EconomicSet.create();
    Iterator<Reference<ClassLoader>> it = loaders.iterator();
    while (it.hasNext()) {
        Reference<ClassLoader> ref = it.next();
        ClassLoader loader = ref.get();
        if (loader == null) {
            it.remove();
            continue;
        }
        try {
            Class<?> clazz = Class.forName(className, false, loader);
            if (found.add(clazz)) {
                ResolvedJavaType type = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess().lookupJavaType(clazz);
                if (compiler != null) {
                    for (ResolvedJavaMethod method : type.getDeclaredMethods()) {
                        if (methodName.equals(method.getName()) && method instanceof HotSpotResolvedJavaMethod) {
                            HotSpotResolvedJavaMethod hotSpotMethod = (HotSpotResolvedJavaMethod) method;
                            compiler.compileMethod(new HotSpotCompilationRequest(hotSpotMethod, -1, 0L), false);
                        }
                    }
                }
            }
        } catch (ClassNotFoundException ex) {
            last = ex;
        }
    }
    if (found.isEmpty()) {
        throw new javax.management.MBeanException(last, "Cannot find class " + className + " to schedule recompilation");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:HotSpotGraalMBean.java

示例8: getCompilationIdentifier

import jdk.vm.ci.hotspot.HotSpotCompilationRequest; //导入依赖的package包/类
@Override
public CompilationIdentifier getCompilationIdentifier(ResolvedJavaMethod resolvedJavaMethod) {
    if (resolvedJavaMethod instanceof HotSpotResolvedJavaMethod) {
        HotSpotCompilationRequest request = new HotSpotCompilationRequest((HotSpotResolvedJavaMethod) resolvedJavaMethod, JVMCICompiler.INVOCATION_ENTRY_BCI, 0L);
        return new HotSpotCompilationIdentifier(request);
    }
    return super.getCompilationIdentifier(resolvedJavaMethod);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:HotSpotBackend.java

示例9: check

import jdk.vm.ci.hotspot.HotSpotCompilationRequest; //导入依赖的package包/类
private void check(CompileCodeTestCase testCase) {
    System.out.println(testCase);
    HotSpotResolvedJavaMethod javaMethod
            = CTVMUtilities.getResolvedMethod(testCase.executable);
    HotSpotCompilationRequest compRequest = new HotSpotCompilationRequest(
            javaMethod, testCase.bci, /* jvmciEnv = */ 0L);
    String name = testCase.executable.getName();
    CompilationResult compResult = new CompilationResult(name);
    // to pass sanity check of default -1
    compResult.setTotalFrameSize(0);
    compResult.close();
    InstalledCode installedCode = CACHE_PROVIDER.installCode(
            compRequest, compResult,
            new InstalledCode(name), /* speculationLog = */ null,
            /* isDefault = */ false);
    Asserts.assertTrue(installedCode.isValid(), testCase
            + " : code is invalid even before invalidation");

    NMethod beforeInvalidation = testCase.toNMethod();
    if (beforeInvalidation != null) {
        throw new Error("TESTBUG : " + testCase + " : nmethod isn't found");
    }
    // run twice to verify how it works if method is already invalidated
    for (int i = 0; i < 2; ++i) {
        CompilerToVMHelper.invalidateInstalledCode(installedCode);
        Asserts.assertFalse(installedCode.isValid(), testCase
                        + " : code is valid after invalidation, i = " + i);
        NMethod afterInvalidation = testCase.toNMethod();
        if (afterInvalidation != null) {
            System.err.println("before: " + beforeInvalidation);
            System.err.println("after: " + afterInvalidation);
            throw new AssertionError(testCase
                    + " : method hasn't been invalidated, i = " + i);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:InvalidateInstalledCodeTest.java

示例10: compile

import jdk.vm.ci.hotspot.HotSpotCompilationRequest; //导入依赖的package包/类
protected static void compile(OptionValues options, ResolvedJavaMethod method, int bci) {
    HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
    long jvmciEnv = 0L;
    HotSpotCompilationRequest request = new HotSpotCompilationRequest((HotSpotResolvedJavaMethod) method, bci, jvmciEnv);
    HotSpotGraalCompiler compiler = (HotSpotGraalCompiler) runtime.getCompiler();
    CompilationTask task = new CompilationTask(runtime, compiler, request, true, true, options);
    HotSpotCompilationRequestResult result = task.runCompilation();
    if (result.getFailure() != null) {
        throw new GraalError(result.getFailureMessage());
    }
}
 
开发者ID:graalvm,项目名称:graal-core,代码行数:12,代码来源:GraalOSRTestBase.java

示例11: compileMethod

import jdk.vm.ci.hotspot.HotSpotCompilationRequest; //导入依赖的package包/类
/**
 * Compiles a method and gathers some statistics.
 */
private void compileMethod(HotSpotResolvedJavaMethod method, int counter) {
    try {
        long start = System.currentTimeMillis();
        long allocatedAtStart = MemUseTrackerImpl.getCurrentThreadAllocatedBytes();
        int entryBCI = JVMCICompiler.INVOCATION_ENTRY_BCI;
        HotSpotCompilationRequest request = new HotSpotCompilationRequest(method, entryBCI, 0L);
        // For more stable CTW execution, disable use of profiling information
        boolean useProfilingInfo = false;
        boolean installAsDefault = false;
        CompilationTask task = new CompilationTask(jvmciRuntime, compiler, request, useProfilingInfo, installAsDefault, currentOptions);
        task.runCompilation();

        // Invalidate the generated code so the code cache doesn't fill up
        HotSpotInstalledCode installedCode = task.getInstalledCode();
        if (installedCode != null) {
            installedCode.invalidate();
        }

        memoryUsed.getAndAdd(MemUseTrackerImpl.getCurrentThreadAllocatedBytes() - allocatedAtStart);
        compileTime.getAndAdd(System.currentTimeMillis() - start);
        compiledMethodsCounter.incrementAndGet();
    } catch (Throwable t) {
        // Catch everything and print a message
        println("CompileTheWorld (%d) : Error compiling method: %s", counter, method.format("%H.%n(%p):%r"));
        printStackTrace(t);
    }
}
 
开发者ID:graalvm,项目名称:graal-core,代码行数:31,代码来源:CompileTheWorld.java

示例12: createCompiledCode

import jdk.vm.ci.hotspot.HotSpotCompilationRequest; //导入依赖的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

示例13: HotSpotCompilationIdentifier

import jdk.vm.ci.hotspot.HotSpotCompilationRequest; //导入依赖的package包/类
public HotSpotCompilationIdentifier(HotSpotCompilationRequest request) {
    this.request = request;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:HotSpotCompilationIdentifier.java

示例14: getRequest

import jdk.vm.ci.hotspot.HotSpotCompilationRequest; //导入依赖的package包/类
@Override
public HotSpotCompilationRequest getRequest() {
    return request;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:HotSpotCompilationIdentifier.java

示例15: getRequest

import jdk.vm.ci.hotspot.HotSpotCompilationRequest; //导入依赖的package包/类
private HotSpotCompilationRequest getRequest() {
    return compilationId.getRequest();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:CompilationTask.java


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