Package org.jnode.vm.classmgr

Examples of org.jnode.vm.classmgr.VmMethod


    public final void visit_invokeinterface(VmConstIMethodRef methodRef, int count) {
        vstack.push(eContext);

        // Resolve the method
        methodRef.resolve(loader);
        final VmMethod method = methodRef.getResolvedVmMethod();
        final int argSlotCount = count - 1;

        // remove parameters from vstack
        dropParameters(method, true);
        // Get objectref -> EAX
        os.writeMOV(helper.ADDRSIZE, helper.AAX, helper.SP, argSlotCount
            * helper.SLOTSIZE);
        // Write the actual invokeinterface
        if (os.isCode32()) {
            X86IMTCompiler32.emitInvokeInterface(os, method);
        } else {
            X86IMTCompiler64.emitInvokeInterface(os, method);
        }
        // Test the stack alignment
        stackFrame.writeStackAlignmentTest(getCurInstrLabel());
        // Write the push result
        helper.pushReturnValue(method.getSignature());
    }
View Full Code Here


        // Flush the stack before an invoke
        vstack.push(eContext);

        methodRef.resolve(loader);
        try {
            final VmMethod sm = methodRef.getResolvedVmMethod();

            dropParameters(sm, true);

            // Call the methods code from the statics table
            helper.invokeJavaMethod(sm);
View Full Code Here

     * @param methodRef
     * @see org.jnode.vm.bytecode.BytecodeVisitor#visit_invokevirtual(org.jnode.vm.classmgr.VmConstMethodRef)
     */
    public final void visit_invokevirtual(VmConstMethodRef methodRef) {
        methodRef.resolve(loader);
        final VmMethod mts = methodRef.getResolvedVmMethod();

        if (mts.isStatic()) {
            throw new IncompatibleClassChangeError(
                "Static method in invokevirtual");
        }

        final VmInstanceMethod method = (VmInstanceMethod) mts;
View Full Code Here

        vstack.push(eContext);

        // Resolve the method
        methodRef.resolve(loader);
        final VmMethod method = methodRef.getResolvedVmMethod();
        final int argSlotCount = count - 1;

        // remove parameters from vstack
        dropParameters(method, true);
        // Get objectref -> EAX
        os.writeMOV(helper.ADDRSIZE, helper.AAX, helper.SP, argSlotCount
            * helper.SLOTSIZE);
        // Write the actual invokeinterface
        if (os.isCode32()) {
            X86IMTCompiler32.emitInvokeInterface(os, method);
        } else {
            X86IMTCompiler64.emitInvokeInterface(os, method);
        }
        // Test the stack alignment
        stackFrame.writeStackAlignmentTest(getCurInstrLabel());
        // Write the push result
        helper.pushReturnValue(method.getSignature());
    }
View Full Code Here

        // Flush the stack before an invoke
        vstack.push(eContext);

        methodRef.resolve(loader);
        try {
            final VmMethod sm = methodRef.getResolvedVmMethod();

            dropParameters(sm, true);

            // Call the methods code from the statics table
            helper.invokeJavaMethod(sm);
View Full Code Here

        if (countBytecode) {
            counters.getCounter("invokevirtual").inc();
        }

        methodRef.resolve(loader);
        final VmMethod mts = methodRef.getResolvedVmMethod();

        if (mts.isStatic()) {
            throw new IncompatibleClassChangeError(
                "Static method in invokevirtual");
        }

        final VmInstanceMethod method = (VmInstanceMethod) mts;
View Full Code Here

                LittleEndian.setInt32(code, ofs, (extraIndex - ofs) - 4);
                ofs += 4;

                // Create extra field
                for (int k = 0; k < arrLength; k++) {
                    final VmMethod method = (VmMethod) arr[k];

                    if (k + 1 == arrLength) {
                        // Last entry, jump directly
                        // JMP [statics+method_statics_index]
                        extraIndex = genJmpStaticsCodeOfs(code, extraIndex,
                            method.getSharedStaticsIndex());
                    } else {
                        // Non-last entry, compare and jump of select match

                        // CMP selectorReg, imm32_selector
                        code[extraIndex++] = (byte) 0x81;
                        code[extraIndex++] = (byte) 0xFA;
                        LittleEndian.setInt32(code, extraIndex, method
                            .getSelector());
                        extraIndex += 4;

                        // JNE labelAfterJump
                        code[extraIndex++] = (byte) 0x75;
                        code[extraIndex++] = (byte) 0x06;

                        // JMP [statics+method_statics_index]
                        extraIndex = genJmpStaticsCodeOfs(code, extraIndex,
                            method.getSharedStaticsIndex());
                    }
                }
            } else if (imt[i] != null) {
                // Simple route

                // JMP [STATICS+staticsOfs]
                final VmMethod method = (VmMethod) imt[i];
                ofs = genJmpStaticsCodeOfs(code, ofs, method.getSharedStaticsIndex());
            } else {
                // Empty IMT slot
                // INT ABSTRACT_METHOD
                code[ofs++] = (byte) 0xCD;
                code[ofs++] = (byte) X86CompilerConstants.ABSTRACT_METHOD_INTNO;
View Full Code Here

                LittleEndian.setInt32(code, ofs, (extraIndex - ofs) - 4);
                ofs += 4;

                // Create extra field
                for (int k = 0; k < arrLength; k++) {
                    final VmMethod method = (VmMethod) arr[k];

                    if (k + 1 == arrLength) {
                        // Last entry, jump directly
                        // JMP [statics+method_statics_index]
                        extraIndex = genJmpStaticsCodeOfs(code, extraIndex,
                            method.getSharedStaticsIndex());
                    } else {
                        // Non-last entry, compare and jump of select match

                        // CMP selectorReg, imm32_selector
                        code[extraIndex++] = (byte) 0x81;
                        code[extraIndex++] = (byte) 0xFA;
                        LittleEndian.setInt32(code, extraIndex, method
                            .getSelector());
                        extraIndex += 4;

                        // JNE labelAfterJump
                        code[extraIndex++] = (byte) 0x75;
                        code[extraIndex++] = (byte) 0x06;

                        // JMP [statics+method_statics_index]
                        extraIndex = genJmpStaticsCodeOfs(code, extraIndex,
                            method.getSharedStaticsIndex());
                    }
                }
            } else if (imt[i] != null) {
                // Simple route

                // JMP [STATICS+staticsOfs]
                final VmMethod method = (VmMethod) imt[i];
                ofs = genJmpStaticsCodeOfs(code, ofs, method.getSharedStaticsIndex());
            } else {
                // Empty IMT slot
                // INT ABSTRACT_METHOD
                code[ofs++] = (byte) 0xCD;
                code[ofs++] = (byte) X86CompilerConstants.ABSTRACT_METHOD_INTNO;
View Full Code Here

     * Gets the method at the current stack position.
     *
     * @return
     */
    public final VmMethod getMethod() {
        VmMethod m = null;
        if (cc != null) {
            m = cc.getAddressMap().getMethodAtIndex(codeIndex);
        }
        if (m == null) {
            m = cc.getMethod();
View Full Code Here

            final VmStackReader reader = VmProcessor.current()
                .getArchitecture().getStackReader();
            final VmStackFrameEnumerator sfEnum = new VmStackFrameEnumerator(reader);
            int recursionCount = 0;
            while (sfEnum.isValid()) {
                final VmMethod method = sfEnum.getMethod();
                if (method.hasDoPrivilegedPragma()) {
                    // Stop here with the current thread's stacktrace.
                    break;
                } else if (method.hasCheckPermissionPragma()) {
                    // Be paranoia for now, let's check for recursive
                    // checkPermission calls.
                    recursionCount++;
                    if (recursionCount > 2) {
                        reader.debugStackTrace();
                        Unsafe.die("Recursive checkPermission");
                    }
                } else {
                    final VmType<?> declClass = method.getDeclaringClass();
                    final ProtectionDomain pd = declClass.getProtectionDomain();
                    if (pd != null) {
                        // Unsafe.debug(":pd");
                        if (!pd.implies(perm)) {
                            // Unsafe.debug("Permission denied");
                            throw new AccessControlException("Permission \""
                                + perm + "\" not granted due to "
                                + declClass.getName());
                        }
                    }
                }
                if (method.hasPrivilegedActionPragma()) {
                    // Break here, do not include inherited thread context
                    return;
                }
                sfEnum.next();
            }
View Full Code Here

TOP

Related Classes of org.jnode.vm.classmgr.VmMethod

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.