Search in sources :

Example 1 with CGlobalDataReference

use of com.oracle.svm.core.graal.code.CGlobalDataReference in project graal by oracle.

the class AMD64CGlobalDataLoadAddressOp method emitCode.

@Override
public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
    if (SubstrateUtil.HOSTED) {
        // AOT compilation: record patch that is fixed up later
        int before = masm.position();
        AMD64Address address = masm.getPlaceholder(before);
        if (dataInfo.isSymbolReference()) {
            // Pure symbol reference: the data contains the symbol's address, load it
            masm.movq(asRegister(result), address);
        } else {
            // Data: load its address
            masm.leaq(asRegister(result), address);
        }
        crb.compilationResult.recordDataPatch(before, new CGlobalDataReference(dataInfo));
    } else {
        // Runtime compilation: compute the actual address
        Pointer globalsBase = CGlobalDataInfo.CGLOBALDATA_RUNTIME_BASE_ADDRESS.get();
        Pointer address = globalsBase.add(dataInfo.getOffset());
        masm.movq(asRegister(result), address.rawValue());
        if (dataInfo.isSymbolReference()) {
            // load data, which contains symbol's address
            masm.movq(asRegister(result), new AMD64Address(asRegister(result)));
        }
    }
}
Also used : CGlobalDataReference(com.oracle.svm.core.graal.code.CGlobalDataReference) Pointer(org.graalvm.word.Pointer) AMD64Address(org.graalvm.compiler.asm.amd64.AMD64Address)

Aggregations

CGlobalDataReference (com.oracle.svm.core.graal.code.CGlobalDataReference)1 AMD64Address (org.graalvm.compiler.asm.amd64.AMD64Address)1 Pointer (org.graalvm.word.Pointer)1