Search in sources :

Example 1 with StackSlot

use of jdk.vm.ci.code.StackSlot in project graal by oracle.

the class AArch64HotSpotNodeLIRBuilder method emitPrologue.

@Override
protected void emitPrologue(StructuredGraph graph) {
    CallingConvention incomingArguments = gen.getResult().getCallingConvention();
    Value[] params = new Value[incomingArguments.getArgumentCount() + 2];
    for (int i = 0; i < incomingArguments.getArgumentCount(); i++) {
        params[i] = incomingArguments.getArgument(i);
        if (isStackSlot(params[i])) {
            StackSlot slot = ValueUtil.asStackSlot(params[i]);
            if (slot.isInCallerFrame() && !gen.getResult().getLIR().hasArgInCallerFrame()) {
                gen.getResult().getLIR().setHasArgInCallerFrame();
            }
        }
    }
    params[params.length - 2] = fp.asValue(LIRKind.value(AArch64Kind.QWORD));
    params[params.length - 1] = lr.asValue(LIRKind.value(AArch64Kind.QWORD));
    gen.emitIncomingValues(params);
    for (ParameterNode param : graph.getNodes(ParameterNode.TYPE)) {
        Value paramValue = params[param.index()];
        assert paramValue.getValueKind().equals(getLIRGeneratorTool().getLIRKind(param.stamp(NodeView.DEFAULT))) : paramValue.getValueKind() + " != " + param.stamp(NodeView.DEFAULT);
        setResult(param, gen.emitMove(paramValue));
    }
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) RegisterValue(jdk.vm.ci.code.RegisterValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) ValueUtil.isStackSlot(jdk.vm.ci.code.ValueUtil.isStackSlot) StackSlot(jdk.vm.ci.code.StackSlot)

Example 2 with StackSlot

use of jdk.vm.ci.code.StackSlot in project graal by oracle.

the class AMD64HotSpotNodeLIRBuilder method emitPrologue.

@Override
protected void emitPrologue(StructuredGraph graph) {
    CallingConvention incomingArguments = gen.getResult().getCallingConvention();
    Value[] params = new Value[incomingArguments.getArgumentCount() + 1];
    for (int i = 0; i < params.length - 1; i++) {
        params[i] = incomingArguments.getArgument(i);
        if (isStackSlot(params[i])) {
            StackSlot slot = ValueUtil.asStackSlot(params[i]);
            if (slot.isInCallerFrame() && !gen.getResult().getLIR().hasArgInCallerFrame()) {
                gen.getResult().getLIR().setHasArgInCallerFrame();
            }
        }
    }
    params[params.length - 1] = rbp.asValue(LIRKind.value(AMD64Kind.QWORD));
    gen.emitIncomingValues(params);
    getGen().emitSaveRbp();
    getGen().append(((HotSpotDebugInfoBuilder) getDebugInfoBuilder()).lockStack());
    for (ParameterNode param : graph.getNodes(ParameterNode.TYPE)) {
        Value paramValue = params[param.index()];
        assert paramValue.getValueKind().equals(getLIRGeneratorTool().getLIRKind(param.stamp(NodeView.DEFAULT))) : paramValue.getValueKind() + " != " + param.stamp(NodeView.DEFAULT);
        setResult(param, gen.emitMove(paramValue));
    }
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) RegisterValue(jdk.vm.ci.code.RegisterValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) ValueUtil.isStackSlot(jdk.vm.ci.code.ValueUtil.isStackSlot) StackSlot(jdk.vm.ci.code.StackSlot)

Example 3 with StackSlot

use of jdk.vm.ci.code.StackSlot in project graal by oracle.

the class HotSpotCompiledCodeBuilder method createCompiledCode.

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, (position, vmConstant) -> {
        patchBuilder.accept(new DataPatch(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);
    }
}
Also used : Site(jdk.vm.ci.code.site.Site) CodeAnnotation(org.graalvm.compiler.code.CompilationResult.CodeAnnotation) HotSpotCompiledCode(jdk.vm.ci.hotspot.HotSpotCompiledCode) ConstantReference(jdk.vm.ci.code.site.ConstantReference) JumpTable(org.graalvm.compiler.code.CompilationResult.JumpTable) Assumption(jdk.vm.ci.meta.Assumptions.Assumption) CodeComment(org.graalvm.compiler.code.CompilationResult.CodeComment) Comment(jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment) HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) StackSlot(jdk.vm.ci.code.StackSlot) ByteBuffer(java.nio.ByteBuffer) Infopoint(jdk.vm.ci.code.site.Infopoint) CodeComment(org.graalvm.compiler.code.CompilationResult.CodeComment) DataPatch(jdk.vm.ci.code.site.DataPatch) DataSection(org.graalvm.compiler.code.DataSection) HotSpotCompiledNmethod(jdk.vm.ci.hotspot.HotSpotCompiledNmethod) HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 4 with StackSlot

use of jdk.vm.ci.code.StackSlot in project graal by oracle.

the class HotSpotReferenceMapBuilder method toLocation.

private Location toLocation(Value v, int offset) {
    if (isRegister(v)) {
        return Location.subregister(asRegister(v), offset);
    } else {
        StackSlot s = asStackSlot(v);
        int totalOffset = s.getOffset(totalFrameSize) + offset;
        if (totalOffset > maxOopMapStackOffset) {
            throw new PermanentBailoutException("stack offset %d for oopmap is greater than encoding limit %d", totalOffset, maxOopMapStackOffset);
        }
        return Location.stack(totalOffset);
    }
}
Also used : ValueUtil.asStackSlot(jdk.vm.ci.code.ValueUtil.asStackSlot) StackSlot(jdk.vm.ci.code.StackSlot) PermanentBailoutException(org.graalvm.compiler.core.common.PermanentBailoutException)

Example 5 with StackSlot

use of jdk.vm.ci.code.StackSlot in project graal by oracle.

the class SPARCSaveRegistersOp method emitCode.

@Override
public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
    // Can be used with VIS3
    // new Movxtod(SPARC.i0, RETURN_REGISTER_STORAGE).emit(masm);
    // We abuse the first stackslot for transferring i0 to return_register_storage
    // assert slots.length >= 1;
    SPARCAddress slot0Address = (SPARCAddress) crb.asAddress(slots[0]);
    masm.stx(SPARC.i0, slot0Address);
    masm.lddf(slot0Address, RETURN_REGISTER_STORAGE);
    // Now save the registers
    for (int i = 0; i < savedRegisters.length; i++) {
        if (savedRegisters[i] != null) {
            assert isStackSlot(slots[i]) : "not a StackSlot: " + slots[i];
            Register savedRegister = savedRegisters[i];
            StackSlot slot = asStackSlot(slots[i]);
            SPARCAddress slotAddress = (SPARCAddress) crb.asAddress(slot);
            RegisterValue input = savedRegister.asValue(slot.getValueKind());
            SPARCMove.emitStore(input, slotAddress, slot.getPlatformKind(), DUMMY, null, crb, masm);
        }
    }
}
Also used : RegisterValue(jdk.vm.ci.code.RegisterValue) Register(jdk.vm.ci.code.Register) ValueUtil.isStackSlot(jdk.vm.ci.code.ValueUtil.isStackSlot) ValueUtil.asStackSlot(jdk.vm.ci.code.ValueUtil.asStackSlot) StackSlot(jdk.vm.ci.code.StackSlot) SPARCAddress(org.graalvm.compiler.asm.sparc.SPARCAddress)

Aggregations

StackSlot (jdk.vm.ci.code.StackSlot)21 ValueUtil.isStackSlot (jdk.vm.ci.code.ValueUtil.isStackSlot)8 Register (jdk.vm.ci.code.Register)6 ValueUtil.asStackSlot (jdk.vm.ci.code.ValueUtil.asStackSlot)6 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)5 Value (jdk.vm.ci.meta.Value)4 DebugContext (org.graalvm.compiler.debug.DebugContext)4 CallingConvention (jdk.vm.ci.code.CallingConvention)3 RegisterValue (jdk.vm.ci.code.RegisterValue)3 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)3 JavaConstant (jdk.vm.ci.meta.JavaConstant)3 Assembler (org.graalvm.compiler.asm.Assembler)3 LIRValueUtil.isVirtualStackSlot (org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot)3 VirtualStackSlot (org.graalvm.compiler.lir.VirtualStackSlot)3 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)3 RegisterSaveLayout (jdk.vm.ci.code.RegisterSaveLayout)2 ValueUtil.asAllocatableValue (jdk.vm.ci.code.ValueUtil.asAllocatableValue)2 Infopoint (jdk.vm.ci.code.site.Infopoint)2 ScratchRegister (org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister)2 HotSpotDataBuilder (org.graalvm.compiler.hotspot.HotSpotDataBuilder)2