Search in sources :

Example 21 with Assembler

use of org.jikesrvm.compilers.common.assembler.ppc.Assembler in project JikesRVM by JikesRVM.

the class Barriers method putfieldStoreBarrierHelper.

// on entry java stack contains ...|target_ref|value_to_store|
// T2 already contains the offset of the field on entry
private static void putfieldStoreBarrierHelper(BaselineCompilerImpl comp, int locationMetadata, NormalMethod barrier) {
    // value_to_store is an Int or smaller and takes up 1 stack slot
    Assembler asm = comp.asm;
    asm.emitLAddrToc(S0, barrier.getOffset());
    asm.emitMTCTR(S0);
    // store target_ref in T0
    comp.peekAddr(T0, 1);
    asm.emitNullCheck(T0);
    // store value_to_store in T1
    comp.peekInt(T1, 0);
    // store locationMetaData in T3
    asm.emitLVAL(T3, locationMetadata);
    // call barrier with parameters in (T0,T1,T2,T3)
    asm.emitBCCTRL();
    // clean up stack
    comp.discardSlots(2);
}
Also used : Assembler(org.jikesrvm.compilers.common.assembler.ppc.Assembler)

Example 22 with Assembler

use of org.jikesrvm.compilers.common.assembler.ppc.Assembler in project JikesRVM by JikesRVM.

the class Barriers method putfieldUnboxedStoreBarrierHelper.

// on entry java stack contains ...|target_ref|value_to_store|
// T2 already contains the offset of the field on entry
private static void putfieldUnboxedStoreBarrierHelper(BaselineCompilerImpl comp, int locationMetadata, NormalMethod barrier) {
    Assembler asm = comp.asm;
    asm.emitLAddrToc(S0, barrier.getOffset());
    asm.emitMTCTR(S0);
    // store target_ref in T0
    comp.peekAddr(T0, 1);
    asm.emitNullCheck(T0);
    // value to store
    comp.peekUnboxed(T1, 0);
    asm.emitLVAL(T3, locationMetadata);
    // call barrier with parameters in (T0,T1,T2,T3)
    asm.emitBCCTRL();
    comp.discardSlots(2);
}
Also used : Assembler(org.jikesrvm.compilers.common.assembler.ppc.Assembler)

Example 23 with Assembler

use of org.jikesrvm.compilers.common.assembler.ppc.Assembler in project JikesRVM by JikesRVM.

the class Barriers method compileGetfieldBarrier.

// on entry java stack contains ...|source_ref|
// T1 already contains the offset of the field on entry
static void compileGetfieldBarrier(BaselineCompilerImpl comp, int locationMetadata) {
    Assembler asm = comp.asm;
    asm.emitLAddrToc(S0, Entrypoints.objectFieldReadBarrierMethod.getOffset());
    asm.emitMTCTR(S0);
    // object base
    comp.peekAddr(T0, 0);
    asm.emitNullCheck(T0);
    asm.emitLVAL(T2, locationMetadata);
    // MemoryManager.getfieldReadBarrier(T0,T1,T2)
    asm.emitBCCTRL();
}
Also used : Assembler(org.jikesrvm.compilers.common.assembler.ppc.Assembler)

Example 24 with Assembler

use of org.jikesrvm.compilers.common.assembler.ppc.Assembler in project JikesRVM by JikesRVM.

the class CodeInstaller method install.

/* install the newly compiled instructions. */
public static boolean install(ExecutionState state, CompiledMethod cm) {
    RVMThread thread = state.getThread();
    byte[] stack = thread.getStack();
    Offset fooFPOffset = state.getFPOffset();
    // we are going to dynamically generate some code recover
    // register values from the stack frame.
    int foomid = Magic.getIntAtOffset(stack, fooFPOffset.plus(STACKFRAME_METHOD_ID_OFFSET));
    CompiledMethod foo = CompiledMethods.getCompiledMethod(foomid);
    int cType = foo.getCompilerType();
    Assembler asm = new Assembler(0, VM.TraceOnStackReplacement);
    // ///////////////////////////////////
    if (cType == CompiledMethod.BASELINE) {
        ArchBaselineCompiledMethod bcm = (ArchBaselineCompiledMethod) foo;
        int offset = bcm.getFrameSize();
        for (int i = bcm.getLastFloatStackRegister(); i >= FIRST_FLOAT_LOCAL_REGISTER.value(); --i) {
            offset -= BYTES_IN_DOUBLE;
            asm.emitLFD(FPR.lookup(i), offset, FP);
        }
        for (int i = bcm.getLastFixedStackRegister(); i >= FIRST_FIXED_LOCAL_REGISTER.value(); --i) {
            offset -= BYTES_IN_ADDRESS;
            asm.emitLAddr(GPR.lookup(i), offset, FP);
        }
    } else if (cType == CompiledMethod.OPT) {
        OptCompiledMethod fooOpt = (OptCompiledMethod) foo;
        // foo definitely not save volatile.
        boolean saveVolatile = fooOpt.isSaveVolatile();
        if (VM.VerifyAssertions) {
            VM._assert(!saveVolatile);
        }
        int offset = fooOpt.getUnsignedNonVolatileOffset();
        // recover nonvolatile GPRs
        int firstGPR = fooOpt.getFirstNonVolatileGPR();
        if (firstGPR != -1) {
            for (int i = firstGPR; i <= LAST_NONVOLATILE_GPR.value(); i++) {
                asm.emitLAddr(GPR.lookup(i), offset, FP);
                offset += BYTES_IN_STACKSLOT;
            }
        }
        // recover nonvolatile FPRs
        int firstFPR = fooOpt.getFirstNonVolatileFPR();
        if (firstFPR != -1) {
            for (int i = firstFPR; i <= LAST_NONVOLATILE_FPR.value(); i++) {
                asm.emitLFD(FPR.lookup(i), offset, FP);
                offset += BYTES_IN_DOUBLE;
            }
        }
    }
    if (VM.VerifyAssertions) {
        Object jtocContent = Statics.getSlotContentsAsObject(cm.getOsrJTOCoffset());
        VM._assert(jtocContent == cm.getEntryCodeArray());
    }
    // load address of newInstructions from JTOC
    asm.emitLAddrToc(S0, cm.getOsrJTOCoffset());
    // mov CTR addr
    asm.emitMTCTR(S0);
    // lwz FP, 0(FP)
    asm.emitLAddr(FP, 0, FP);
    // lwz T0, NEXT_INSTR(FP)
    asm.emitLAddr(S0, STACKFRAME_RETURN_ADDRESS_OFFSET.toInt(), FP);
    // mov LR, addr
    asm.emitMTLR(S0);
    // bctr
    asm.emitBCCTR();
    // mark the thread as waiting for on stack replacement.
    thread.isWaitingForOsr = true;
    thread.bridgeInstructions = asm.getMachineCodes();
    thread.fooFPOffset = fooFPOffset;
    Address bridgeaddr = Magic.objectAsAddress(thread.bridgeInstructions);
    Memory.sync(bridgeaddr, thread.bridgeInstructions.length() << LG_INSTRUCTION_WIDTH);
    AOSLogging.logger.logOsrEvent("OSR code installation succeeded");
    return true;
}
Also used : ArchBaselineCompiledMethod(org.jikesrvm.compilers.baseline.ppc.ArchBaselineCompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) Address(org.vmmagic.unboxed.Address) RVMThread(org.jikesrvm.scheduler.RVMThread) Assembler(org.jikesrvm.compilers.common.assembler.ppc.Assembler) ArchBaselineCompiledMethod(org.jikesrvm.compilers.baseline.ppc.ArchBaselineCompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Offset(org.vmmagic.unboxed.Offset)

Example 25 with Assembler

use of org.jikesrvm.compilers.common.assembler.ppc.Assembler in project JikesRVM by JikesRVM.

the class InterfaceMethodConflictResolver method createStub.

/**
 * Creates a conflict resolution stub for the set of interface method signatures {@code l}.
 * @param sigIds ids of elements in {@code l}
 * @param targets target methods of elements in {@code l}
 * @return code that implements the stub
 */
public static CodeArray createStub(int[] sigIds, RVMMethod[] targets) {
    // (1) Create an assembler.
    int numEntries = sigIds.length;
    // pretend each entry is a bytecode
    Assembler asm = new Assembler(numEntries);
    // (2) signatures must be in ascending order (to build binary search tree).
    if (VM.VerifyAssertions) {
        for (int i = 1; i < sigIds.length; i++) {
            VM._assert(sigIds[i - 1] < sigIds[i]);
        }
    }
    // (3) Assign synthetic bytecode numbers to each switch such that we'll generate them
    // in ascending order.  This lets us use the general forward branching mechanisms
    // of the Assembler.
    int[] bcIndices = new int[numEntries];
    assignBytecodeIndices(0, bcIndices, 0, numEntries - 1);
    // (4) Generate the stub.
    insertStubPrologue(asm);
    insertStubCase(asm, sigIds, targets, bcIndices, 0, numEntries - 1);
    CodeArray stub = asm.getMachineCodes();
    // (5) synchronize icache with generated machine code that was written through dcache
    if (VM.runningVM)
        Memory.sync(Magic.objectAsAddress(stub), stub.length() << LG_INSTRUCTION_WIDTH);
    return stub;
}
Also used : CodeArray(org.jikesrvm.compilers.common.CodeArray) Assembler(org.jikesrvm.compilers.common.assembler.ppc.Assembler)

Aggregations

Assembler (org.jikesrvm.compilers.common.assembler.ppc.Assembler)30 Entrypoint (org.vmmagic.pragma.Entrypoint)6 ForwardReference (org.jikesrvm.compilers.common.assembler.ForwardReference)4 Address (org.vmmagic.unboxed.Address)2 Offset (org.vmmagic.unboxed.Offset)2 RVMClass (org.jikesrvm.classloader.RVMClass)1 TypeReference (org.jikesrvm.classloader.TypeReference)1 ArchBaselineCompiledMethod (org.jikesrvm.compilers.baseline.ppc.ArchBaselineCompiledMethod)1 CodeArray (org.jikesrvm.compilers.common.CodeArray)1 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)1 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)1 JNICompiledMethod (org.jikesrvm.jni.JNICompiledMethod)1 FIRST_NONVOLATILE_GPR (org.jikesrvm.ppc.RegisterConstants.FIRST_NONVOLATILE_GPR)1 FIRST_OS_PARAMETER_FPR (org.jikesrvm.ppc.RegisterConstants.FIRST_OS_PARAMETER_FPR)1 FIRST_OS_PARAMETER_GPR (org.jikesrvm.ppc.RegisterConstants.FIRST_OS_PARAMETER_GPR)1 FIRST_RVM_RESERVED_NV_GPR (org.jikesrvm.ppc.RegisterConstants.FIRST_RVM_RESERVED_NV_GPR)1 FIRST_SCRATCH_FPR (org.jikesrvm.ppc.RegisterConstants.FIRST_SCRATCH_FPR)1 FIRST_VOLATILE_FPR (org.jikesrvm.ppc.RegisterConstants.FIRST_VOLATILE_FPR)1 FIRST_VOLATILE_GPR (org.jikesrvm.ppc.RegisterConstants.FIRST_VOLATILE_GPR)1 FPR (org.jikesrvm.ppc.RegisterConstants.FPR)1