Search in sources :

Example 1 with MethodPointer

use of com.oracle.svm.core.meta.MethodPointer in project graal by oracle.

the class LIRNativeImageCodeCache method layoutMethods.

@SuppressWarnings("try")
@Override
public void layoutMethods(DebugContext debug, String imageName, BigBang bb, ForkJoinPool threadPool) {
    try (Indent indent = debug.logAndIndent("layout methods")) {
        // Assign a location to all methods.
        assert codeCacheSize == 0;
        HostedMethod firstMethod = null;
        for (Entry<HostedMethod, CompilationResult> entry : compilations.entrySet()) {
            HostedMethod method = entry.getKey();
            if (firstMethod == null) {
                firstMethod = method;
            }
            CompilationResult compilation = entry.getValue();
            compilationsByStart.put(codeCacheSize, compilation);
            method.setCodeAddressOffset(codeCacheSize);
            codeCacheSize = NumUtil.roundUp(codeCacheSize + compilation.getTargetCodeSize(), SubstrateOptions.codeAlignment());
        }
        buildRuntimeMetadata(new MethodPointer(firstMethod), WordFactory.unsigned(codeCacheSize));
    }
}
Also used : Indent(org.graalvm.compiler.debug.Indent) MethodPointer(com.oracle.svm.core.meta.MethodPointer) HostedMethod(com.oracle.svm.hosted.meta.HostedMethod) CompilationResult(org.graalvm.compiler.code.CompilationResult)

Example 2 with MethodPointer

use of com.oracle.svm.core.meta.MethodPointer in project graal by oracle.

the class ReflectionFeature method register.

private CFunctionPointer register(ResolvedJavaMethod method) {
    AnalysisMethod aMethod = method instanceof AnalysisMethod ? (AnalysisMethod) method : analysisAccess.getUniverse().lookup(method);
    analysisAccess.registerAsCompiled(aMethod);
    return new MethodPointer(aMethod);
}
Also used : AnalysisMethod(com.oracle.graal.pointsto.meta.AnalysisMethod) MethodPointer(com.oracle.svm.core.meta.MethodPointer)

Example 3 with MethodPointer

use of com.oracle.svm.core.meta.MethodPointer in project graal by oracle.

the class DynamicHubInitializer method buildRuntimeInitializationInfo.

private ClassInitializationInfo buildRuntimeInitializationInfo(AnalysisType type) {
    assert !type.isInitialized();
    try {
        /*
             * Check if there are any linking errors. This method throws an error even if linking
             * already failed in a previous attempt.
             */
        type.link();
    } catch (VerifyError e) {
        /* Synthesize a VerifyError to be thrown at run time. */
        AnalysisMethod throwVerifyError = metaAccess.lookupJavaMethod(ExceptionSynthesizer.throwExceptionMethod(VerifyError.class));
        registerAsCompiled(throwVerifyError);
        return new ClassInitializationInfo(new MethodPointer(throwVerifyError));
    } catch (Throwable t) {
        /*
             * All other linking errors will be reported as NoClassDefFoundError when initialization
             * is attempted at run time.
             */
        return ClassInitializationInfo.FAILED_INFO_SINGLETON;
    }
    /*
         * Now we now that there are no linking errors, we can register the class initialization
         * information.
         */
    assert type.isLinked();
    CFunctionPointer classInitializerFunction = null;
    AnalysisMethod classInitializer = type.getClassInitializer();
    if (classInitializer != null) {
        assert classInitializer.getCode() != null;
        registerAsCompiled(classInitializer);
        classInitializerFunction = new MethodPointer(classInitializer);
    }
    return new ClassInitializationInfo(classInitializerFunction);
}
Also used : AnalysisMethod(com.oracle.graal.pointsto.meta.AnalysisMethod) MethodPointer(com.oracle.svm.core.meta.MethodPointer) ClassInitializationInfo(com.oracle.svm.core.classinitialization.ClassInitializationInfo) CFunctionPointer(org.graalvm.nativeimage.c.function.CFunctionPointer)

Example 4 with MethodPointer

use of com.oracle.svm.core.meta.MethodPointer in project graal by oracle.

the class CEntryPointCallStubFeature method registerJavaStubForMethod.

public AnalysisMethod registerJavaStubForMethod(AnalysisMethod method) {
    return methodToJavaStub.compute(method, (key, existingValue) -> {
        AnalysisMethod value = existingValue;
        if (value == null) {
            assert !bb.getUniverse().sealed();
            AnalysisMethod nativeStub = registerStubForMethod(method, () -> CEntryPointData.create(method));
            CFunctionPointer nativeStubAddress = new MethodPointer(nativeStub);
            String stubName = SubstrateUtil.uniqueShortName(method);
            ResolvedJavaType holderClass = bb.getMetaAccess().lookupJavaType(IsolateLeaveStub.class).getWrapped();
            CEntryPointJavaCallStubMethod stub = new CEntryPointJavaCallStubMethod(method.getWrapped(), stubName, holderClass, nativeStubAddress);
            value = bb.getUniverse().lookup(stub);
        }
        return value;
    });
}
Also used : IsolateLeaveStub(com.oracle.svm.core.code.IsolateLeaveStub) AnalysisMethod(com.oracle.graal.pointsto.meta.AnalysisMethod) MethodPointer(com.oracle.svm.core.meta.MethodPointer) CFunctionPointer(org.graalvm.nativeimage.c.function.CFunctionPointer) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 5 with MethodPointer

use of com.oracle.svm.core.meta.MethodPointer in project graal by oracle.

the class DeoptimizationFeature method beforeCompilation.

@Override
public void beforeCompilation(BeforeCompilationAccess a) {
    CompilationAccessImpl config = (CompilationAccessImpl) a;
    config.registerAsImmutable(ImageSingletons.lookup(DeoptimizationSupport.class));
    HostedMetaAccess metaAccess = config.getMetaAccess();
    DeoptimizationSupport.setDeoptStubPointer(new MethodPointer(metaAccess.lookupJavaMethod(deoptStubMethod)));
}
Also used : MethodPointer(com.oracle.svm.core.meta.MethodPointer) CompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl) DeoptimizationSupport(com.oracle.svm.core.deopt.DeoptimizationSupport) HostedMetaAccess(com.oracle.svm.hosted.meta.HostedMetaAccess)

Aggregations

MethodPointer (com.oracle.svm.core.meta.MethodPointer)13 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)6 HostedMethod (com.oracle.svm.hosted.meta.HostedMethod)6 CFunctionPointer (org.graalvm.nativeimage.c.function.CFunctionPointer)5 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)4 AnalysisUniverse (com.oracle.graal.pointsto.meta.AnalysisUniverse)2 DeoptEntryInfopoint (com.oracle.svm.core.deopt.DeoptEntryInfopoint)2 SubstrateMethodPointerConstant (com.oracle.svm.core.meta.SubstrateMethodPointerConstant)2 Infopoint (jdk.vm.ci.code.site.Infopoint)2 JavaKind (jdk.vm.ci.meta.JavaKind)2 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)2 CompilationResult (org.graalvm.compiler.code.CompilationResult)2 AnalysisField (com.oracle.graal.pointsto.meta.AnalysisField)1 AnalysisType (com.oracle.graal.pointsto.meta.AnalysisType)1 ClassInitializationInfo (com.oracle.svm.core.classinitialization.ClassInitializationInfo)1 IsolateLeaveStub (com.oracle.svm.core.code.IsolateLeaveStub)1 ObjectLayout (com.oracle.svm.core.config.ObjectLayout)1 DeoptimizationSupport (com.oracle.svm.core.deopt.DeoptimizationSupport)1 LLVMTextSectionInfo (com.oracle.svm.core.graal.llvm.util.LLVMObjectFileReader.LLVMTextSectionInfo)1 DeoptEntryNode (com.oracle.svm.core.graal.nodes.DeoptEntryNode)1