Search in sources :

Example 46 with Offset

use of org.vmmagic.unboxed.Offset in project JikesRVM by JikesRVM.

the class BaselineCompilerImpl method emit_resolved_getstatic.

@Override
protected void emit_resolved_getstatic(FieldReference fieldRef) {
    RVMField field = fieldRef.peekResolvedField();
    Offset fieldOffset = field.getOffset();
    if (NEEDS_OBJECT_GETSTATIC_BARRIER && !fieldRef.getFieldContentsType().isPrimitiveType() && !field.isUntraced()) {
        Barriers.compileGetstaticBarrierImm(asm, fieldOffset, fieldRef.getId());
        return;
    }
    if (fieldRef.getSize() <= BYTES_IN_INT) {
        // field is one word
        if (VM.BuildFor32Addr) {
            asm.emitPUSH_Abs(Magic.getTocPointer().plus(fieldOffset));
        } else {
            asm.generateJTOCloadInt(T0, fieldOffset);
            asm.emitPUSH_Reg(T0);
        }
    } else {
        // field is two words (double or long)
        if (VM.VerifyAssertions)
            VM._assert(fieldRef.getSize() == BYTES_IN_LONG);
        if (VM.BuildFor32Addr) {
            // JMM: we need to guarantee atomic access for volatile fields
            if (field.isVolatile()) {
                if (SSE2_BASE) {
                    asm.emitMOVQ_Reg_Abs(XMM0, Magic.getTocPointer().plus(fieldOffset));
                    adjustStack(-2 * WORDSIZE, true);
                    asm.emitMOVQ_RegInd_Reg(SP, XMM0);
                } else {
                    asm.emitFLD_Reg_Abs_Quad(FP0, Magic.getTocPointer().plus(fieldOffset));
                    adjustStack(-2 * WORDSIZE, true);
                    asm.emitFSTP_RegInd_Reg_Quad(SP, FP0);
                }
            } else {
                // get high part
                asm.emitPUSH_Abs(Magic.getTocPointer().plus(fieldOffset).plus(WORDSIZE));
                // get low part
                asm.emitPUSH_Abs(Magic.getTocPointer().plus(fieldOffset));
            }
        } else {
            if (fieldRef.getNumberOfStackSlots() != 1) {
                adjustStack(-WORDSIZE, true);
            }
            asm.generateJTOCpush(fieldOffset);
        }
    }
}
Also used : RVMField(org.jikesrvm.classloader.RVMField) Offset(org.vmmagic.unboxed.Offset)

Example 47 with Offset

use of org.vmmagic.unboxed.Offset in project JikesRVM by JikesRVM.

the class BaselineCompilerImpl method emit_f2i.

@Override
protected void emit_f2i() {
    if (SSE2_BASE) {
        // Set up value in XMM0
        asm.emitMOVSS_Reg_RegInd(XMM0, SP);
        // adjust = 0
        asm.emitXOR_Reg_Reg(T1, T1);
        // result = 0
        asm.emitXOR_Reg_Reg(T0, T0);
        // value cmp maxint
        asm.generateJTOCcmpFloat(XMM0, Entrypoints.maxintFloatField.getOffset());
        // if NaN goto fr1
        ForwardReference fr1 = asm.forwardJcc(PE);
        // T1 = (value >= maxint) ? 1 : 0;
        asm.emitSET_Cond_Reg_Byte(LGE, T1);
        // T0 = (int)value, or 0x80000000 if value > maxint
        asm.emitCVTTSS2SI_Reg_Reg(T0, XMM0);
        // T0 = T0 - T1, ie fix max int case
        asm.emitSUB_Reg_Reg(T0, T1);
        fr1.resolve(asm);
        // push result
        asm.emitMOV_RegInd_Reg(SP, T0);
    } else {
        // TODO: use x87 operations to do this conversion inline taking care of
        // the boundary cases that differ between x87 and Java
        // (1) save RVM nonvolatiles
        int numNonVols = NONVOLATILE_GPRS.length;
        Offset off = Offset.fromIntSignExtend(numNonVols * WORDSIZE);
        for (int i = 0; i < numNonVols; i++) {
            asm.emitPUSH_Reg(NONVOLATILE_GPRS[i]);
        }
        // (2) Push arg to C function
        asm.emitPUSH_RegDisp(SP, off);
        // (3) invoke C function through bootrecord
        asm.emitMOV_Reg_Abs(S0, Magic.getTocPointer().plus(Entrypoints.the_boot_recordField.getOffset()));
        asm.emitCALL_RegDisp(S0, Entrypoints.sysFloatToIntIPField.getOffset());
        // (4) pop argument;
        asm.emitPOP_Reg(S0);
        // (5) restore RVM nonvolatiles
        for (int i = numNonVols - 1; i >= 0; i--) {
            asm.emitPOP_Reg(NONVOLATILE_GPRS[i]);
        }
        // (6) put result on expression stack
        asm.emitMOV_RegInd_Reg(SP, T0);
    }
}
Also used : ForwardReference(org.jikesrvm.compilers.common.assembler.ForwardReference) Offset(org.vmmagic.unboxed.Offset)

Example 48 with Offset

use of org.vmmagic.unboxed.Offset in project JikesRVM by JikesRVM.

the class BaselineCompilerImpl method emit_resolved_invokestatic.

@Override
protected void emit_resolved_invokestatic(MethodReference methodRef) {
    Offset methodOffset = methodRef.peekResolvedMethod().getOffset();
    genParameterRegisterLoad(methodRef, false);
    asm.generateJTOCcall(methodOffset);
    genResultRegisterUnload(methodRef);
}
Also used : Offset(org.vmmagic.unboxed.Offset)

Example 49 with Offset

use of org.vmmagic.unboxed.Offset in project JikesRVM by JikesRVM.

the class BaselineExceptionDeliverer method unwindStackFrame.

/**
 * Unwind a stackframe.
 */
@Override
@Unpreemptible("Unwind stack possibly from unpreemptible code")
public void unwindStackFrame(CompiledMethod compiledMethod, AbstractRegisters registers) {
    NormalMethod method = (NormalMethod) compiledMethod.getMethod();
    Address fp = registers.getInnermostFramePointer();
    if (method.isSynchronized()) {
        // release the lock, if it is being held
        Address ip = registers.getInnermostInstructionAddress();
        Offset instr = compiledMethod.getInstructionOffset(ip);
        Offset lockOffset = ((ArchBaselineCompiledMethod) compiledMethod).getLockAcquisitionOffset();
        if (instr.sGT(lockOffset)) {
            // we actually have the lock, so must unlock it.
            Object lock;
            if (method.isStatic()) {
                lock = method.getDeclaringClass().getResolvedClassForType();
            } else {
                lock = Magic.addressAsObject(fp.plus(BaselineCompilerImpl.locationToOffset(((ArchBaselineCompiledMethod) compiledMethod).getGeneralLocalLocation(0)) - BYTES_IN_ADDRESS).loadAddress());
            }
            if (ObjectModel.holdsLock(lock, RVMThread.getCurrentThread())) {
                ObjectModel.genericUnlock(lock);
            }
        }
    }
    // Restore nonvolatile registers used by the baseline compiler.
    if (VM.VerifyAssertions)
        VM._assert(SAVED_GPRS == 2);
    registers.getGPRs().set(EDI.value(), fp.plus(EDI_SAVE_OFFSET).loadWord());
    registers.getGPRs().set(EBX.value(), fp.plus(EBX_SAVE_OFFSET).loadWord());
    if (method.hasBaselineSaveLSRegistersAnnotation()) {
        registers.getGPRs().set(EBP.value(), fp.plus(EBP_SAVE_OFFSET).toWord());
    }
    registers.unwindStackFrame();
}
Also used : Address(org.vmmagic.unboxed.Address) NormalMethod(org.jikesrvm.classloader.NormalMethod) Offset(org.vmmagic.unboxed.Offset) Unpreemptible(org.vmmagic.pragma.Unpreemptible)

Example 50 with Offset

use of org.vmmagic.unboxed.Offset in project JikesRVM by JikesRVM.

the class BaselineGCMapIterator method setupIterator.

/*
   * Interface
   */
/**
 * Set the iterator to scan the map at the machine instruction offset
 * provided. The iterator is positioned to the beginning of the map. NOTE: An
 * iterator may be reused to scan a different method and map.
 *
 * @param compiledMethod
 *          identifies the method and class
 * @param instructionOffset
 *          identifies the map to be scanned.
 * @param fp
 *          identifies a specific occurrence of this method and allows for
 *          processing instance specific information i.e JSR return address
 *          values
 */
@Override
public void setupIterator(CompiledMethod compiledMethod, Offset instructionOffset, Address fp) {
    currentCompiledMethod = (ArchBaselineCompiledMethod) compiledMethod;
    currentMethod = (NormalMethod) currentCompiledMethod.getMethod();
    currentNumLocals = currentMethod.getLocalWords();
    // setup superclass
    // 
    framePtr = fp;
    // setup stackframe mapping
    // 
    mapReader.setMethod(currentMethod, compiledMethod);
    mapReader.locateGCPoint(instructionOffset);
    if (mapReader.currentMapIsForJSR()) {
        mapReader.acquireLockForJSRProcessing();
        int JSRindex = mapReader.setupJSRSubroutineMap();
        while (JSRindex != 0) {
            Address nextCallerAddress = framePtr.plus(convertIndexToOffset(JSRindex)).loadAddress();
            Offset nextMachineCodeOffset = compiledMethod.getInstructionOffset(nextCallerAddress);
            if (VM.TraceStkMaps) {
                traceSetupJSRsubroutineMap(JSRindex, nextCallerAddress, nextMachineCodeOffset);
            }
            JSRindex = mapReader.getNextJSRAddressIndex(nextMachineCodeOffset);
        }
    }
    if (VM.TraceStkMaps || TRACE_ALL) {
        VM.sysWrite("BaselineGCMapIterator setupIterator mapId = ");
        VM.sysWrite(mapReader.getMapId());
        VM.sysWrite(" for ");
        VM.sysWrite(compiledMethod.getMethod());
        VM.sysWriteln(".");
    }
    bridgeData.setupDynamicBridgeMapping(currentMethod, fp);
    reset();
}
Also used : Address(org.vmmagic.unboxed.Address) Offset(org.vmmagic.unboxed.Offset)

Aggregations

Offset (org.vmmagic.unboxed.Offset)215 Address (org.vmmagic.unboxed.Address)48 Inline (org.vmmagic.pragma.Inline)38 Entrypoint (org.vmmagic.pragma.Entrypoint)32 ObjectReference (org.vmmagic.unboxed.ObjectReference)21 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)20 TypeReference (org.jikesrvm.classloader.TypeReference)17 RVMField (org.jikesrvm.classloader.RVMField)14 ForwardReference (org.jikesrvm.compilers.common.assembler.ForwardReference)13 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)13 NoInline (org.vmmagic.pragma.NoInline)13 RVMMethod (org.jikesrvm.classloader.RVMMethod)11 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)10 Word (org.vmmagic.unboxed.Word)10 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)9 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)9 RVMType (org.jikesrvm.classloader.RVMType)8 Register (org.jikesrvm.compilers.opt.ir.Register)8 RVMClass (org.jikesrvm.classloader.RVMClass)7 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)7