Package org.jnode.assembler.x86

Examples of org.jnode.assembler.x86.InvalidOpcodeException


            }
            final X86RegisterPool pool = eContext.getGPRPool();
            final IntItem result;
            v.load(eContext);
            if (os.isCode32()) {
                final X86Register lsb = v.getLsbRegister(eContext);
                v.release(eContext);
                pool.request(lsb);
                result = (IntItem) ifac.createReg(eContext, JvmType.INT, lsb);
                pool.transferOwnerTo(lsb, result);
            } else {
                final X86Register reg = v.getRegister(eContext);
                final X86Register intReg = pool.getRegisterInSameGroup(reg,
                    JvmType.INT);
                v.release(eContext);
                pool.request(intReg);
                result = (IntItem) ifac.createReg(eContext, JvmType.INT, intReg);
                pool.transferOwnerTo(intReg, result);
View Full Code Here


     * @param index
     * @param scale
     */
    private void loadArrayEntryOffset(GPR dst, RefItem ref, IntItem index, int scale) {
        assertCondition(ref.isGPR(), "ref must be in a register");
        final GPR refr = ref.getRegister();
        if (index.isConstant()) {
            final int offset = index.getValue() * scale;
            os.writeLEA(dst, refr, arrayDataOffset + offset);
        } else {
            final GPR32 idxr = (GPR32) index.getRegister();
View Full Code Here

            v2 = v1;
            v1 = tmp;
        }

        if (os.isCode32()) {
            final GPR r1_lsb = v1.getLsbRegister(eContext);
            final GPR r1_msb = v1.getMsbRegister(eContext);
            switch (v2.getKind()) {
                case Item.Kind.GPR:
                    os.writeArithOp(operationLsb, r1_lsb, v2
                        .getLsbRegister(eContext));
                    os.writeArithOp(operationMsb, r1_msb, v2
View Full Code Here

        vstack.push(eContext);

        // Claim EAX/RAX, we're going to use it later
        L1AHelper.requestRegister(eContext, helper.AAX);
        // Request tmp register
        final GPR classr = (GPR) L1AHelper.requestRegister(eContext,
            JvmType.REFERENCE, false);

        // Pop
        final IntItem cnt = vstack.popInt();

        // Load the count value
        cnt.load(eContext);
        final GPR cntr = cnt.getRegister();

        // Resolve the class
        writeResolveAndLoadClassToReg(classRef, classr);

        // Release EAX so it can be used by invokeJavaMethod
View Full Code Here

        final IntItem result = (IntItem) L1AHelper.requestWordRegister(
            eContext, JvmType.INT, false);

        // Load
        ref.load(eContext);
        final GPR refr = ref.getRegister();
        final GPR resultr = result.getRegister();

        // Get length
        os.writeMOV(INTSIZE, resultr, refr, arrayLengthOffset);

        // Release
View Full Code Here

            // check that top item is a reference
            final RefItem ref = vstack.popRef();

            // Load the ref
            ref.load(eContext);
            final GPR refr = ref.getRegister();
            final GPR classr = helper.AAX;
            final GPR cntr = (GPR) L1AHelper.requestRegister(eContext,
                JvmType.INT, false);
            final GPR tmpr = (GPR) L1AHelper.requestRegister(eContext,
                JvmType.REFERENCE, false);

            // Resolve the class
            writeResolveAndLoadClassToReg(classRef, classr);
            helper.writeClassInitialize(curInstrLabel, classr, tmpr, resolvedType);

            final Label okLabel = new Label(curInstrLabel + "cc-ok");

            /* Is objectref null? */
            os.writeTEST(refr, refr);
            os.writeJCC(okLabel, X86Constants.JZ);
            /* Is instanceof? */
            instanceOf(refr, classr, tmpr, cntr, okLabel, true);
            /* Not instanceof */

            // Call classCastFailed
            os.writePUSH(refr);
            os.writePUSH(classr);
            // Release temp registers here, so invokeJavaMethod can use it
            L1AHelper.releaseRegister(eContext, cntr);
            L1AHelper.releaseRegister(eContext, tmpr);
            L1AHelper.releaseRegister(eContext, classr);
            invokeJavaMethod(context.getClassCastFailedMethod());

            /* Normal exit */
            os.setObjectRef(okLabel);

            // Leave ref on stack
            vstack.push(ref);
        } else {
            // classRef is a class, do the fast test

            // Pre-claim EAX/RAX
            L1AHelper.requestRegister(eContext, helper.AAX);

            // check that top item is a reference
            final RefItem ref = vstack.popRef();

            // Load the ref
            ref.load(eContext);
            final GPR refr = ref.getRegister();
            final GPR tmpr = (GPR) L1AHelper.requestRegister(eContext,
                JvmType.REFERENCE, false);

            final Label okLabel = new Label(curInstrLabel + "cc-ok");

            // Is objectref null?
View Full Code Here

        final boolean isfloat = JvmType.isFloat(type);

        // Pop & load
        final RefItem ref = vstack.popRef();
        ref.load(eContext);
        final GPR refr = ref.getRegister();

        // get field
        final Item result;
        if (!fieldRef.isWide()) {
            if (isfloat) {
                result = ifac.createFPUStack(JvmType.FLOAT);
                os.writeFLD32(refr, fieldOffset);
                pushFloat(result);
            } else {
                final char fieldType = field.getSignature().charAt(0);
                final WordItem iw = L1AHelper.requestWordRegister(eContext,
                    type, (fieldType != 'I') && (type != JvmType.REFERENCE));
                final GPR iwr = iw.getRegister();
                switch (fieldType) {
                    case 'Z': // boolean
                        os.writeMOVZX(iwr, refr, fieldOffset, BITS8);
                        break;
                    case 'B': // byte
                        os.writeMOVSX(iwr, refr, fieldOffset, BITS8);
                        break;
                    case 'C': // char
                        os.writeMOVZX(iwr, refr, fieldOffset, BITS16);
                        break;
                    case 'S': // short
                        os.writeMOVSX(iwr, refr, fieldOffset, BITS16);
                        break;
                    case 'I': // int
                    case 'L': // Object
                    case '[': // array
                        os.writeMOV(iwr.getSize(), iwr, refr, fieldOffset);
                        break;
                    default:
                        throw new IllegalArgumentException("Unknown fieldType " + fieldType);
                }
                result = iw;
            }
        } else {
            if (isfloat) {
                result = ifac.createFPUStack(JvmType.DOUBLE);
                os.writeFLD64(refr, fieldOffset);
                pushFloat(result);
            } else {
                final DoubleWordItem idw = L1AHelper
                    .requestDoubleWordRegisters(eContext, type);
                if (os.isCode32()) {
                    final GPR lsb = idw.getLsbRegister(eContext);
                    final GPR msb = idw.getMsbRegister(eContext);
                    os.writeMOV(BITS32, lsb, refr, fieldOffset + LSB);
                    os.writeMOV(BITS32, msb, refr, fieldOffset + MSB);
                } else {
                    final GPR64 reg = idw.getRegister(eContext);
                    os.writeMOV(BITS64, reg, refr, fieldOffset);
View Full Code Here

        if (JvmType.isFloat(type)) {
            final boolean is32bit = !fieldRef.isWide();
            if (sf.isShared()) {
                helper.writeGetStaticsEntryToFPU(curInstrLabel, (VmSharedStaticsEntry) sf, is32bit);
            } else {
                final GPR tmp = (GPR) L1AHelper.requestRegister(eContext,
                    JvmType.REFERENCE, false);
                helper.writeGetStaticsEntryToFPU(curInstrLabel,
                    (VmIsolatedStaticsEntry) sf, is32bit, tmp);
                L1AHelper.releaseRegister(eContext, tmp);
            }
            final Item result = ifac.createFPUStack(type);
            pushFloat(result);
            vstack.push(result);
        } else if (!fieldRef.isWide()) {
            final WordItem result = L1AHelper.requestWordRegister(eContext,
                type, false);
            final GPR resultr = result.getRegister();
            if (os.isCode32() || (type != JvmType.REFERENCE)) {
                if (sf.isShared()) {
                    helper.writeGetStaticsEntry(curInstrLabel, resultr, (VmSharedStaticsEntry) sf);
                } else {
                    final GPR tmp = (GPR) L1AHelper.requestRegister(eContext,
                        JvmType.REFERENCE, false);
                    helper.writeGetStaticsEntry(curInstrLabel, resultr,
                        (VmIsolatedStaticsEntry) sf, tmp);
                    L1AHelper.releaseRegister(eContext, tmp);
                }
            } else {
                if (sf.isShared()) {
                    helper.writeGetStaticsEntry64(curInstrLabel, (GPR64) resultr, (VmSharedStaticsEntry) sf);
                } else {
                    helper.writeGetStaticsEntry64(curInstrLabel, (GPR64) resultr, (VmIsolatedStaticsEntry) sf);
                }
            }
            vstack.push(result);
        } else {
            final DoubleWordItem result = L1AHelper.requestDoubleWordRegisters(
                eContext, type);
            if (os.isCode32()) {
                final GPR lsb = result.getLsbRegister(eContext);
                final GPR msb = result.getMsbRegister(eContext);
                if (sf.isShared()) {
                    helper.writeGetStaticsEntry64(curInstrLabel, lsb, msb, (VmSharedStaticsEntry) sf);
                } else {
                    helper.writeGetStaticsEntry64(curInstrLabel, lsb, msb, (VmIsolatedStaticsEntry) sf);
                }
View Full Code Here

        if (v.isConstant()) {
            vstack.push(ifac.createIConst(eContext, (byte) v.getValue()));
            v.release(eContext);
        } else {
            v.loadToBITS8GPR(eContext);
            final GPR r = v.getRegister();
            os.writeMOVSX(r, r, BYTESIZE);
            vstack.push(v);
        }
    }
View Full Code Here

        if (v.isConstant()) {
            vstack.push(ifac.createIConst(eContext, (char) v.getValue()));
            v.release(eContext);
        } else {
            v.load(eContext);
            final GPR r = v.getRegister();
            os.writeMOVZX(r, r, WORDSIZE);
            vstack.push(v);
        }
    }
View Full Code Here

TOP

Related Classes of org.jnode.assembler.x86.InvalidOpcodeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.