Search in sources :

Example 1 with LocationOperand

use of org.jikesrvm.compilers.opt.ir.operand.LocationOperand in project JikesRVM by JikesRVM.

the class InstrumentationSamplingFramework method appendLoad.

/**
 * Append a load of the global counter to the given basic block.
 *
 * WARNING: Tested for LIR only!
 *
 * @param bb The block to append the load to
 * @param ir The IR
 */
private void appendLoad(BasicBlock bb, IR ir) {
    if (DEBUG)
        VM.sysWriteln("Adding load to " + bb);
    Instruction load = null;
    if (ir.options.ADAPTIVE_PROCESSOR_SPECIFIC_COUNTER) {
        if (ir.isHIR()) {
            VM.sysFail("Not implemented yet.");
        } else {
            // Phase is being used in LIR
            if (VM.VerifyAssertions)
                VM._assert(ir.isLIR());
            // Insert the load instruction.
            load = Load.create(INT_LOAD, cbsReg.copyRO(), ir.regpool.makeTROp(), IRTools.AC(AosEntrypoints.threadCBSField.getOffset()), new LocationOperand(AosEntrypoints.threadCBSField));
            bb.appendInstruction(load);
        }
    } else {
        // Use global counter
        if (ir.isHIR()) {
            Operand offsetOp = new AddressConstantOperand(AosEntrypoints.globalCBSField.getOffset());
            load = GetStatic.create(GETSTATIC, cbsReg.copyRO(), offsetOp, new LocationOperand(AosEntrypoints.globalCBSField));
            bb.appendInstruction(load);
        } else {
            // LIR
            Instruction dummy = Load.create(INT_LOAD, null, null, null, null);
            bb.appendInstruction(dummy);
            load = Load.create(INT_LOAD, cbsReg.copyRO(), ir.regpool.makeJTOCOp(), IRTools.AC(AosEntrypoints.globalCBSField.getOffset()), new LocationOperand(AosEntrypoints.globalCBSField));
            dummy.insertBefore(load);
            dummy.remove();
        }
    }
}
Also used : LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand) BranchOperand(org.jikesrvm.compilers.opt.ir.operand.BranchOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ConditionOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Example 2 with LocationOperand

use of org.jikesrvm.compilers.opt.ir.operand.LocationOperand in project JikesRVM by JikesRVM.

the class InstrumentationSamplingFramework method prependCounterReset.

/**
 * Prepend the code to reset the global counter to the given basic
 * block.
 *
 * Warning:  Tested in LIR only!
 *
 * @param bb The block to append the load to
 * @param ir The IR
 */
private void prependCounterReset(BasicBlock bb, IR ir) {
    Instruction load = null;
    Instruction store = null;
    if (ir.isHIR()) {
        // Not tested
        Operand offsetOp = new AddressConstantOperand(AosEntrypoints.cbsResetValueField.getOffset());
        load = GetStatic.create(GETSTATIC, cbsReg.copyRO(), offsetOp, new LocationOperand(AosEntrypoints.cbsResetValueField));
        store = PutStatic.create(PUTSTATIC, cbsReg.copyRO(), new AddressConstantOperand(AosEntrypoints.globalCBSField.getOffset()), new LocationOperand(AosEntrypoints.globalCBSField));
        bb.prependInstruction(store);
        bb.prependInstruction(load);
    } else {
        // LIR
        if (VM.VerifyAssertions)
            VM._assert(ir.isLIR());
        Instruction dummy = Load.create(INT_LOAD, null, null, null, null);
        bb.prependInstruction(dummy);
        // Load the reset value
        load = Load.create(INT_LOAD, cbsReg.copyRO(), ir.regpool.makeJTOCOp(), IRTools.AC(AosEntrypoints.cbsResetValueField.getOffset()), new LocationOperand(AosEntrypoints.cbsResetValueField));
        dummy.insertBefore(load);
        // Store it in the counter register
        if (ir.options.ADAPTIVE_PROCESSOR_SPECIFIC_COUNTER) {
            store = Store.create(INT_STORE, cbsReg.copyRO(), ir.regpool.makeTROp(), IRTools.AC(AosEntrypoints.threadCBSField.getOffset()), new LocationOperand(AosEntrypoints.threadCBSField));
        } else {
            // Use global counter
            store = Store.create(INT_STORE, cbsReg.copyRO(), ir.regpool.makeJTOCOp(), IRTools.AC(AosEntrypoints.globalCBSField.getOffset()), new LocationOperand(AosEntrypoints.globalCBSField));
        }
        dummy.insertBefore(store);
        dummy.remove();
    }
}
Also used : LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand) BranchOperand(org.jikesrvm.compilers.opt.ir.operand.BranchOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ConditionOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Example 3 with LocationOperand

use of org.jikesrvm.compilers.opt.ir.operand.LocationOperand in project JikesRVM by JikesRVM.

the class InstrumentationSamplingFramework method prependStore.

/**
 * Append a store of the global counter to the given basic block.
 *
 * WARNING: Tested in LIR only!
 *
 * @param bb The block to append the load to
 * @param ir The IR
 */
private void prependStore(BasicBlock bb, IR ir) {
    if (DEBUG)
        VM.sysWriteln("Adding store to " + bb);
    Instruction store = null;
    if (ir.options.ADAPTIVE_PROCESSOR_SPECIFIC_COUNTER) {
        store = Store.create(INT_STORE, cbsReg.copyRO(), ir.regpool.makeTROp(), IRTools.AC(AosEntrypoints.threadCBSField.getOffset()), new LocationOperand(AosEntrypoints.threadCBSField));
        bb.prependInstruction(store);
    } else {
        if (ir.isHIR()) {
            store = PutStatic.create(PUTSTATIC, cbsReg.copyRO(), new AddressConstantOperand(AosEntrypoints.globalCBSField.getOffset()), new LocationOperand(AosEntrypoints.globalCBSField));
            bb.prependInstruction(store);
        } else {
            Instruction dummy = Load.create(INT_LOAD, null, null, null, null);
            bb.prependInstruction(dummy);
            store = Store.create(INT_STORE, cbsReg.copyRO(), ir.regpool.makeJTOCOp(), IRTools.AC(AosEntrypoints.globalCBSField.getOffset()), new LocationOperand(AosEntrypoints.globalCBSField));
            dummy.insertBefore(store);
            dummy.remove();
        }
    }
}
Also used : LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Example 4 with LocationOperand

use of org.jikesrvm.compilers.opt.ir.operand.LocationOperand in project JikesRVM by JikesRVM.

the class FinalMIRExpansion method expandUnconditionalYieldpoint.

/* generate yieldpoint without checking threadSwith request
   */
private static void expandUnconditionalYieldpoint(Instruction s, IR ir, RVMMethod meth) {
    // split the basic block after the yieldpoint, create a new
    // block at the end of the IR to hold the yieldpoint,
    // remove the yieldpoint (to prepare to out it in the new block at the end)
    BasicBlock thisBlock = s.getBasicBlock();
    BasicBlock nextBlock = thisBlock.splitNodeWithLinksAt(s, ir);
    BasicBlock yieldpoint = thisBlock.createSubBlock(s.getBytecodeIndex(), ir);
    thisBlock.insertOut(yieldpoint);
    yieldpoint.insertOut(nextBlock);
    ir.cfg.addLastInCodeOrder(yieldpoint);
    s.remove();
    // change thread switch instruction into call to thread switch routine
    // NOTE: must make s the call instruction: it is the GC point!
    // must also inform the GCMap that s has been moved!!!
    Offset offset = meth.getOffset();
    LocationOperand loc = new LocationOperand(offset);
    Operand guard = TG();
    Operand target;
    if (JTOC_REGISTER == null) {
        target = MemoryOperand.D(Magic.getTocPointer().plus(offset), (byte) BYTES_IN_ADDRESS, loc, guard);
    } else {
        target = MemoryOperand.BD(ir.regpool.makeTocOp().asRegister(), offset, (byte) BYTES_IN_ADDRESS, loc, guard);
    }
    MIR_Call.mutate0(s, CALL_SAVE_VOLATILE, null, null, target, MethodOperand.STATIC(meth));
    yieldpoint.appendInstruction(s);
    ir.MIRInfo.gcIRMap.moveToEnd(s);
    yieldpoint.appendInstruction(MIR_Branch.create(IA32_JMP, nextBlock.makeJumpTarget()));
    // make a jump to yield block
    thisBlock.appendInstruction(MIR_Branch.create(IA32_JMP, yieldpoint.makeJumpTarget()));
}
Also used : LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IA32ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand) TrapCodeOperand(org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand) LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) MemoryOperand(org.jikesrvm.compilers.opt.ir.operand.MemoryOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) Offset(org.vmmagic.unboxed.Offset)

Example 5 with LocationOperand

use of org.jikesrvm.compilers.opt.ir.operand.LocationOperand in project JikesRVM by JikesRVM.

the class FinalMIRExpansion method expandYieldpoint.

private static void expandYieldpoint(Instruction s, IR ir, RVMMethod meth, IA32ConditionOperand ypCond) {
    // split the basic block after the yieldpoint, create a new
    // block at the end of the IR to hold the yieldpoint,
    // remove the yieldpoint (to prepare to out it in the new block at the end)
    BasicBlock thisBlock = s.getBasicBlock();
    BasicBlock nextBlock = thisBlock.splitNodeWithLinksAt(s, ir);
    BasicBlock yieldpoint = thisBlock.createSubBlock(s.getBytecodeIndex(), ir, 0);
    thisBlock.insertOut(yieldpoint);
    yieldpoint.insertOut(nextBlock);
    ir.cfg.addLastInCodeOrder(yieldpoint);
    s.remove();
    // change thread switch instruction into call to thread switch routine
    // NOTE: must make s the call instruction: it is the GC point!
    // must also inform the GCMap that s has been moved!!!
    Offset offset = meth.getOffset();
    LocationOperand loc = new LocationOperand(offset);
    Operand guard = TG();
    Operand target;
    if (JTOC_REGISTER == null) {
        target = MemoryOperand.D(Magic.getTocPointer().plus(offset), (byte) BYTES_IN_ADDRESS, loc, guard);
    } else {
        target = MemoryOperand.BD(ir.regpool.makeTocOp().asRegister(), offset, (byte) BYTES_IN_ADDRESS, loc, guard);
    }
    MIR_Call.mutate0(s, CALL_SAVE_VOLATILE, null, null, target, MethodOperand.STATIC(meth));
    yieldpoint.appendInstruction(s);
    ir.MIRInfo.gcIRMap.moveToEnd(s);
    yieldpoint.appendInstruction(MIR_Branch.create(IA32_JMP, nextBlock.makeJumpTarget()));
    // Check to see if threadSwitch requested
    Offset tsr = Entrypoints.takeYieldpointField.getOffset();
    MemoryOperand M = MemoryOperand.BD(ir.regpool.makeTROp(), tsr, (byte) 4, null, null);
    thisBlock.appendInstruction(MIR_Compare.create(IA32_CMP, M, IC(0)));
    thisBlock.appendInstruction(MIR_CondBranch.create(IA32_JCC, ypCond, yieldpoint.makeJumpTarget(), BranchProfileOperand.never()));
}
Also used : LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IA32ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand) TrapCodeOperand(org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand) LocationOperand(org.jikesrvm.compilers.opt.ir.operand.LocationOperand) MemoryOperand(org.jikesrvm.compilers.opt.ir.operand.MemoryOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) MemoryOperand(org.jikesrvm.compilers.opt.ir.operand.MemoryOperand) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) Offset(org.vmmagic.unboxed.Offset)

Aggregations

LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)38 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)28 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)23 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)22 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)20 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)16 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)14 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)14 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)13 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)11 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)10 BranchOperand (org.jikesrvm.compilers.opt.ir.operand.BranchOperand)8 MemoryOperand (org.jikesrvm.compilers.opt.ir.operand.MemoryOperand)8 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)8 NullConstantOperand (org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand)7 FieldReference (org.jikesrvm.classloader.FieldReference)6 RVMClass (org.jikesrvm.classloader.RVMClass)6 TypeReference (org.jikesrvm.classloader.TypeReference)6 TIBConstantOperand (org.jikesrvm.compilers.opt.ir.operand.TIBConstantOperand)6 TypeOperand (org.jikesrvm.compilers.opt.ir.operand.TypeOperand)6