Пример #1
0
MTable::MethodInfo::MethodInfo(Method_Handle _mh, size_t _num) {
    num = _num;
    mh = _mh;
    Class_Handle ch = method_get_class(mh);
    className = class_get_name(ch);
    methodName = method_get_name(mh);
    signature = method_get_descriptor(mh);
    assert(!className.empty() && !methodName.empty() && !signature.empty());
}
Пример #2
0
static void logReadyProfile(const std::string& catName, const std::string& profilerName, EBMethodProfile* mp) {
    const char* methodName = method_get_name(mp->mh);
    Class_Handle ch = method_get_class(mp->mh);
    const char* className = class_get_name(ch);
    const char* signature = method_get_descriptor(mp->mh);

    std::ostringstream msg;
    msg <<"EM: profiler["<<profilerName.c_str()<<"] profile is ready [e:"
        << mp->entryCounter <<" b:"<<mp->backedgeCounter<<"] "
        <<className<<"::"<<methodName<<signature;
    INFO2(catName.c_str(), msg.str().c_str());
}
Пример #3
0
static void addProfilesForClassloader(Class_Loader_Handle h, EBProfiles& from, EBProfiles& to, bool erase) {
    for (EBProfiles::iterator it = from.begin(), end = from.end(); it!=end; ++it) {
        EBMethodProfile* profile = *it;
        Class_Handle ch =  method_get_class(profile->mh);;
        Class_Loader_Handle clh = class_get_class_loader(ch);
        if (clh == h) {
            to.push_back(profile);
            if (erase) {
                *it=NULL;
            }
        }
    }
    if (erase) {
        from.erase(std::remove(from.begin(), from.end(), (EBMethodProfile*)NULL), from.end());
    }
}
Пример #4
0
static jint skip_old_frames(VM_thread *thread)
{
    if (NULL == getLastStackFrame(thread))
        return 0;

    StackFrame* first_frame = (StackFrame*)(thread->firstFrame);

    if (first_frame)
    {
        Class *clss = method_get_class(first_frame->method);
        assert(clss);

        if (strcmp(method_get_name(first_frame->method), "runImpl") == 0 &&
            strcmp(class_get_name(clss), "java/lang/Thread") == 0)
        {
            return 1;
        }
    }

    return 0;
}
Пример #5
0
void Compiler::handle_ik_meth(const JInst& jinst) {
    if (jinst.opcode == OPCODE_INVOKESTATIC || 
        jinst.opcode == OPCODE_INVOKESPECIAL ||
        jinst.opcode == OPCODE_INVOKEVIRTUAL || 
        jinst.opcode == OPCODE_INVOKEINTERFACE) {
        
       
        JavaByteCodes opkod = jinst.opcode;
        ::std::vector<jtype> args;
        jtype retType;
        bool is_static = opkod == OPCODE_INVOKESTATIC;
        get_args_info(is_static, jinst.op0, args, &retType);
        
        Method_Handle meth = NULL;
        unsigned short cpIndex = (unsigned short)jinst.op0;
        bool lazy = m_lazy_resolution;
        bool resolve = !lazy || class_cp_is_entry_resolved(m_klass, cpIndex);
        if (!resolve) {
            assert(lazy);
            gen_invoke(opkod, NULL, cpIndex, args, retType);
            return;
        }
        if (opkod == OPCODE_INVOKESTATIC) {
            meth = resolve_static_method(m_compileHandle, m_klass,
                                            jinst.op0);
            if (meth != NULL) {
                Class_Handle klass = method_get_class(meth);
                if (!class_is_initialized(klass)) {
                    gen_call_vm(ci_helper_o, rt_helper_init_class, 0, klass);
                }
            }
        }
        else if (opkod == OPCODE_INVOKEVIRTUAL) {
            meth = resolve_virtual_method(m_compileHandle, m_klass,
                                            jinst.op0);
        }
        else if (opkod == OPCODE_INVOKEINTERFACE) {
            // BUG and HACK - all in one:
            // An 'org/eclipse/ui/keys/KeyStroke::hashCode' (e3.0) does
            // invokeinterface on java/util/SortedSet::hashCode(), but the
            // entry get resolved into the 'java/lang/Object::hashCode' !
            // later: for eclipse 3.1.1 the same problem happens with 
            // org/eclipse/jdt/internal/core/JavaProject::equals
            // which tries to resolve 
            //  'org/eclipse/core/resources/IProject::equals (Ljava/lang/Object;)Z'
            meth = resolve_interface_method(m_compileHandle, m_klass, jinst.op0);
            //
            //*** workaround here:
            if (meth != NULL && 
                !class_is_interface(method_get_class(meth))) {
                opkod = OPCODE_INVOKEVIRTUAL;
            }
        }
        else {
            assert(opkod == OPCODE_INVOKESPECIAL);
            meth = resolve_special_method(m_compileHandle, m_klass, jinst.op0);
        }
        // if class to call to is available, but method is not found in the class
        // meth here will be equal to NULL and lazy resolution call will be
        // generated in gen_invoke
        gen_invoke(opkod, meth, cpIndex, args, retType);
        return;
    }
    switch(jinst.opcode) {
    case OPCODE_IRETURN: {
        SYNC_FIRST(static const CallSig cs(CCONV_MANAGED, i32));
        gen_return(cs);
        break;
    }
    case OPCODE_LRETURN: {
        SYNC_FIRST(static const CallSig cs(CCONV_MANAGED, i64));
        gen_return(cs);
        break;
    }
    case OPCODE_FRETURN: {
        SYNC_FIRST(static const CallSig cs(CCONV_MANAGED, flt32));
        gen_return(cs);
        break;
    }
    case OPCODE_DRETURN: {
        SYNC_FIRST(static const CallSig cs(CCONV_MANAGED, dbl64));
        gen_return(cs);
        break;
    }
    case OPCODE_ARETURN: {
        SYNC_FIRST(static const CallSig cs(CCONV_MANAGED, jobj));
        gen_return(cs);
        break;
    }
    case OPCODE_RETURN: {
        SYNC_FIRST(static const CallSig cs(CCONV_MANAGED, jvoid));
        gen_return(cs);   
        break;
    }
    default: assert(false);   break;
    };
}