Search in sources :

Example 6 with Data

use of org.graalvm.compiler.code.DataSection.Data in project graal by oracle.

the class DataSection method addAll.

/**
 * Transfers all {@link Data} from the provided other {@link DataSection} to this
 * {@link DataSection}, and empties the other section.
 */
public void addAll(DataSection other) {
    checkOpen();
    other.checkOpen();
    for (Data data : other.dataItems) {
        assert data.ref != null;
        dataItems.add(data);
    }
    other.dataItems.clear();
}
Also used : Data(org.graalvm.compiler.code.DataSection.Data)

Example 7 with Data

use of org.graalvm.compiler.code.DataSection.Data in project graal by oracle.

the class DataSection method close.

/**
 * Computes the layout of the data section and closes this object to further updates.
 *
 * This must be called exactly once.
 */
public void close() {
    checkOpen();
    closed = true;
    // simple heuristic: put items with larger alignment requirement first
    dataItems.sort((a, b) -> a.alignment - b.alignment);
    int position = 0;
    int alignment = 1;
    for (Data d : dataItems) {
        alignment = lcm(alignment, d.alignment);
        position = align(position, d.alignment);
        d.ref.setOffset(position);
        position += d.size;
    }
    sectionAlignment = alignment;
    sectionSize = position;
}
Also used : Data(org.graalvm.compiler.code.DataSection.Data)

Example 8 with Data

use of org.graalvm.compiler.code.DataSection.Data in project graal by oracle.

the class SPARCMove method loadFromConstantTable.

/**
 * This method creates a load from the constant section. It automatically respects the different
 * patterns used for small constant sections (<8k) and large constant sections (>=8k). The
 * generated patterns by this method must be understood by
 * CodeInstaller::pd_patch_DataSectionReference (jvmciCodeInstaller_sparc.cpp).
 *
 * @return the number of bytes loaded from the constant table
 */
public static int loadFromConstantTable(CompilationResultBuilder crb, SPARCMacroAssembler masm, Register constantTableBase, Constant input, Register dest, SPARCDelayedControlTransfer delaySlotInstruction) {
    SPARCAddress address;
    ScratchRegister scratch = null;
    try {
        Data data = crb.createDataItem(input);
        int size = data.getSize();
        if (masm.isImmediateConstantLoad()) {
            address = new SPARCAddress(constantTableBase, 0);
            // Make delayed only, when using immediate constant load.
            delaySlotInstruction.emitControlTransfer(crb, masm);
            crb.recordDataReferenceInCode(data, size);
        } else {
            scratch = masm.getScratchRegister();
            Register sr = scratch.getRegister();
            crb.recordDataReferenceInCode(data, size);
            masm.sethix(0, sr, true);
            address = new SPARCAddress(sr, 0);
        }
        masm.ld(address, dest, size, false);
        return size;
    } finally {
        if (scratch != null) {
            scratch.close();
        }
    }
}
Also used : ScratchRegister(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister) SPARCAssembler.isSingleFloatRegister(org.graalvm.compiler.asm.sparc.SPARCAssembler.isSingleFloatRegister) SPARCAssembler.isCPURegister(org.graalvm.compiler.asm.sparc.SPARCAssembler.isCPURegister) SPARCAssembler.isDoubleFloatRegister(org.graalvm.compiler.asm.sparc.SPARCAssembler.isDoubleFloatRegister) Register(jdk.vm.ci.code.Register) ValueUtil.isRegister(jdk.vm.ci.code.ValueUtil.isRegister) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) ScratchRegister(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister) Data(org.graalvm.compiler.code.DataSection.Data) SPARCAddress(org.graalvm.compiler.asm.sparc.SPARCAddress)

Example 9 with Data

use of org.graalvm.compiler.code.DataSection.Data in project graal by oracle.

the class CompilationResultBuilder method createDataItem.

public Data createDataItem(Constant constant) {
    Data data = dataCache.get(constant);
    if (data == null) {
        data = dataBuilder.createDataItem(constant);
        dataCache.put(constant, data);
    }
    return data;
}
Also used : RawData(org.graalvm.compiler.code.DataSection.RawData) Data(org.graalvm.compiler.code.DataSection.Data)

Aggregations

Data (org.graalvm.compiler.code.DataSection.Data)9 RawData (org.graalvm.compiler.code.DataSection.RawData)4 Register (jdk.vm.ci.code.Register)3 SerializableData (org.graalvm.compiler.code.DataSection.SerializableData)3 CallingConvention (jdk.vm.ci.code.CallingConvention)2 RegisterConfig (jdk.vm.ci.code.RegisterConfig)2 TargetDescription (jdk.vm.ci.code.TargetDescription)2 DataSectionReference (jdk.vm.ci.code.site.DataSectionReference)2 AMD64MacroAssembler (org.graalvm.compiler.asm.amd64.AMD64MacroAssembler)2 AssemblerTest (org.graalvm.compiler.asm.test.AssemblerTest)2 CompilationResult (org.graalvm.compiler.code.CompilationResult)2 Test (org.junit.Test)2 ByteBuffer (java.nio.ByteBuffer)1 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)1 ValueUtil.isRegister (jdk.vm.ci.code.ValueUtil.isRegister)1 HotSpotConstant (jdk.vm.ci.hotspot.HotSpotConstant)1 SerializableConstant (jdk.vm.ci.meta.SerializableConstant)1 VMConstant (jdk.vm.ci.meta.VMConstant)1 SPARCAddress (org.graalvm.compiler.asm.sparc.SPARCAddress)1 SPARCAssembler.isCPURegister (org.graalvm.compiler.asm.sparc.SPARCAssembler.isCPURegister)1