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();
}
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;
}
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();
}
}
}
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;
}
Aggregations