⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 verifierutil.c

📁 Nucleus_2_kvm_Hello 是kvm移植到Nucleus系统的源代码。。。好东西啊
💻 C
📖 第 1 页 / 共 4 页
字号:
                opcode = getVerifierBreakpointOpcode(methodBeingVerified, ip);        }#endif    return opcode;}/* ------------------------------------------------------------------------ *\ *                          Stack state management                          *\* ------------------------------------------------------------------------ */static unsigned short vSP_bak;static VERIFIERTYPE   vStack0_bak;/*========================================================================= * FUNCTION:      Vfy_saveStackState * TYPE:          private operation * OVERVIEW:      Save and initialize the type stack * * INTERFACE: *   parameters:  None *   returns:     Nothing *=======================================================================*/void Vfy_saveStackState() {    vSP_bak = vSP;    vStack0_bak = vStack[0];    vSP = 0;}/*========================================================================= * FUNCTION:      Vfy_restoreStackState * TYPE:          private operation * OVERVIEW:      Restore the saved type stack * * INTERFACE: *   parameters:  None *   returns:     Nothing *=======================================================================*/void Vfy_restoreStackState() {    vStack[0] = vStack0_bak;    vSP = vSP_bak;}/* ------------------------------------------------------------------------ *\ *                              Type checking                               *\* ------------------------------------------------------------------------ *//*========================================================================= * FUNCTION:      Vfy_getLocal * TYPE:          private operation on the virtual local frame * OVERVIEW:      Get a type key from the virtual local frame maintained by *                the verifier. Performs index check and type check. * * INTERFACE: *   parameters:  index: the local index *                typeKey: the type expected. *   returns:     The actual type from the slot *=======================================================================*/VERIFIERTYPE Vfy_getLocal(SLOTINDEX index, VERIFIERTYPE typeKey) {    VERIFIERTYPE k;    if (index >= vFrameSize) {        Vfy_throw(VE_LOCALS_OVERFLOW);    }    k = vLocals[index];    if (!vIsAssignable(k, typeKey, NULL)) {        Vfy_throw(VE_LOCALS_BAD_TYPE);    }    return k;}/*========================================================================= * FUNCTION:      Vfy_setLocal * TYPE:          private operation on the virtual local frame * OVERVIEW:      Set a type key in the virtual local frame maintained by *                the verifier. Performs index check and type check. * * INTERFACE: *   parameters:  index: local index. *                typeKey: the supplied type. *   returns:     Nothing *=======================================================================*/void Vfy_setLocal(SLOTINDEX index, VERIFIERTYPE typeKey) {    if (index >= vFrameSize) {        Vfy_throw(VE_LOCALS_OVERFLOW);    }    if (vLocals[index] == ITEM_Long_2#if IMPLEMENTS_FLOAT        || vLocals[index] == ITEM_Double_2#endif        ) {        if (index < 1) {            Vfy_throw(VE_LOCALS_UNDERFLOW);        }        vLocals[index - 1] = ITEM_Bogus;    }    if (vLocals[index] == ITEM_Long#if IMPLEMENTS_FLOAT        || vLocals[index] == ITEM_Double#endif        ) {        if (index >= vFrameSize - 1) {            Vfy_throw(VE_LOCALS_OVERFLOW);        }        vLocals[index + 1] = ITEM_Bogus;    }    vLocals[index] = typeKey;}/*========================================================================= * FUNCTION:      vPushStack * TYPE:          private operation on the virtual stack * OVERVIEW:      Push a type key onto the virtual stack maintained by *                the verifier. Performs stack overflow check. * * INTERFACE: *   parameters:  typeKey: the type to be pushed. *   returns:     Nothing *=======================================================================*/void Vfy_push(VERIFIERTYPE typeKey) {    if (vSP >= vMaxStack) {        Vfy_throw(VE_STACK_OVERFLOW);    }    vStack[vSP++] = typeKey;}/*========================================================================= * FUNCTION:      Vfy_pop * TYPE:          private operation on the virtual stack * OVERVIEW:      Pop an item from the virtual stack maintained by *                the verifier. Performs stack underflow check and type check. * * INTERFACE: *   parameters:  typeKey: The expected type *   returns:     The actual type popped *=======================================================================*/VERIFIERTYPE Vfy_pop(VERIFIERTYPE typeKey) {    VERIFIERTYPE resultKey;    if (typeKey == ITEM_DoubleWord || typeKey == ITEM_Category2 || typeKey == ITEM_Category1) {        fatalError(KVM_MSG_V_BAD_POPSTACK_TYPE);    }    if (vSP == 0) { /* vSP is unsigned, See bug 4323211 */        Vfy_throw(VE_STACK_UNDERFLOW);    }    resultKey = vStack[vSP - 1];    vSP--;    if (!vIsAssignable(resultKey, typeKey, NULL)) {        Vfy_throw(VE_STACK_BAD_TYPE);    }    return resultKey;}/*========================================================================= * FUNCTION:      Vfy_popCategory2_secondWord * TYPE:          private operation on the virtual stack * OVERVIEW:      Pop an the second word of an ITEM_DoubleWord or ITEM_Category2 *                from the virtual stack maintained by the verifier. *                Performs stack underflow check and type check. *                (This is always called before vPopStackCategory2_firstWord) * * INTERFACE: *   parameters:  None. *   returns:     The actual type popped *=======================================================================*/VERIFIERTYPE Vfy_popCategory2_secondWord() {    VERIFIERTYPE resultKey;    if (vSP <= 1) {        Vfy_throw(VE_STACK_UNDERFLOW);    }    resultKey = vStack[vSP - 1];    vSP--;    return resultKey;}/*========================================================================= * FUNCTION:      Vfy_popCategory2_firstWord * TYPE:          private operation on the virtual stack * OVERVIEW:      Pop an the first word of an ITEM_DoubleWord or ITEM_Category2 *                from the virtual stack maintained by the verifier. *                Performs stack underflow check and type check. * * INTERFACE: *   parameters:  None. *   returns:     The actual type popped *=======================================================================*/VERIFIERTYPE Vfy_popCategory2_firstWord() {    VERIFIERTYPE resultKey;    if (vSP <= 0) {        Vfy_throw(VE_STACK_UNDERFLOW);    }    resultKey = vStack[vSP - 1];    vSP--;   /*    * The only think known about this operation is that it    * cannot result in an ITEM_Long_2 or ITEM_Double_2 being    * popped.    */    if ((resultKey == ITEM_Long_2) || (resultKey == ITEM_Double_2)) {        Vfy_throw(VE_STACK_BAD_TYPE);    }    return resultKey;}/*========================================================================= * FUNCTION:      Vfy_popCategory1 * TYPE:          private operation on the virtual stack * OVERVIEW:      Pop a ITEM_Category1 from the virtual stack maintained by *                the verifier. Performs stack underflow check and type check. * * INTERFACE: *   parameters:  None. *   returns:     The actual type popped *=======================================================================*/VERIFIERTYPE Vfy_popCategory1() {    VERIFIERTYPE resultKey;    if (vSP == 0) { /* vSP is unsigned, See bug 4323211 */        Vfy_throw(VE_STACK_UNDERFLOW);    }    resultKey = vStack[vSP - 1];    vSP--;    if (resultKey == ITEM_Integer ||#if IMPLEMENTS_FLOAT        resultKey == ITEM_Float ||#endif        resultKey == ITEM_Null ||        resultKey > 255 ||        resultKey == ITEM_InitObject ||       (resultKey & ITEM_NewObject_Flag)) {       /* its okay */    } else {        Vfy_throw(VE_STACK_EXPECT_CAT1);    }    return resultKey;}/*========================================================================= * FUNCTION:      Vfy_returnVoid * TYPE:          private operation * OVERVIEW:      Check that a return is valid for this method. If the *                method is <init> make sure that 'this' was initialized * * INTERFACE: *   parameters:  None. *   returns:     Nothing. *=======================================================================*/void Vfy_returnVoid() {    if (returnSig[0] != 'V') {        Vfy_throw(VE_EXPECT_RETVAL);    }    if (methodBeingVerified->nameTypeKey.nt.nameKey                        == initNameAndType.nt.nameKey) {        if (vNeedInitialization) {            Vfy_throw(VE_RETURN_UNINIT_THIS);        }    }}/*========================================================================= * FUNCTION:      Vfy_popReturn * TYPE:          private operation * OVERVIEW:      Check that a return is valid for this method. * * INTERFACE: *   parameters:  returnType: the type to be returned. *   returns:     Nothing. *=======================================================================*/void Vfy_popReturn(VERIFIERTYPE returnType) {    VERIFIERTYPE ty[2];    unsigned char *sig = returnSig;    returnType = Vfy_pop(returnType);    if (sig[0] == 'V') {        Vfy_throw(VE_EXPECT_NO_RETVAL);    }    change_Arg_to_StackType(&sig, ty);    if (!Vfy_isAssignable(returnType, ty[0])) {        Vfy_throw(VE_RETVAL_BAD_TYPE);    }   /*    * Is this needed here as well as in Vfy_popReturnVoid()?    */    if (methodBeingVerified->nameTypeKey.nt.nameKey == initNameAndType.nt.nameKey) {        fatalError(KVM_MSG_VFY_UNEXPECTED_RETURN_TYPE);     /*     //   if (vLocals[0] == ITEM_InitObject) {     //       Vfy_throw(VE_RETURN_UNINIT_THIS);     //   }     */    }}/*========================================================================= * FUNCTION:      Vfy_pushClassKey * TYPE:          private operation on type keys * OVERVIEW:      Push the equivalent VERIFIERTYPES for CLASSKEY * * INTERFACE: *   parameters:  fieldType: CLASSKEY *   returns:     Nothing *=======================================================================*/void Vfy_pushClassKey(CLASSKEY fieldType) {    switch (fieldType) {        case 'I':        case 'B':        case 'Z':        case 'C':        case 'S': {            Vfy_push(ITEM_Integer);            break;        }#if IMPLEMENTS_FLOAT        case 'F': {            Vfy_push(ITEM_Float);            break;        }        case 'D': {            Vfy_push(ITEM_Double);            Vfy_push(ITEM_Double_2);            break;        }#endif        case 'J': {            Vfy_push(ITEM_Long);            Vfy_push(ITEM_Long_2);            break;        }        default: {            Vfy_push(Vfy_toVerifierType(fieldType));            break;        }    }}/*========================================================================= * FUNCTION:      Vfy_popClassKey * TYPE:          private operation on type keys * OVERVIEW:      Pop the equivalent VERIFIERTYPES for CLASSKEY * * INTERFACE: *   parameters:  fieldType: CLASSKEY *   returns:     Nothing *=======================================================================*/void Vfy_popClassKey(CLASSKEY fieldType) {    switch (fieldType) {        case 'I':        case 'B':        case 'Z':        case 'C':        case 'S': {            Vfy_pop(ITEM_Integer);            break;        }#if IMPLEMENTS_FLOAT        case 'F': {            Vfy_pop(ITEM_Float);            break;        }        case 'D': {            Vfy_pop(ITEM_Double_2);            Vfy_pop(ITEM_Double);            break;        }#endif        case 'J': {            Vfy_pop(ITEM_Long_2);            Vfy_pop(ITEM_Long);            break;        }        default: {            Vfy_pop(Vfy_toVerifierType(fieldType));            break;        }    }}/*========================================================================= * FUNCTION:      Vfy_setupCalleeContext * TYPE:          private operation * OVERVIEW:      Pop the arguments of the callee context * * INTERFACE: *   parameters:  Class key for the methodTypeKey *   returns:     Nothing. *=======================================================================*/METHODTYPEKEY calleeContext;unsigned char *sigResult;void Vfy_setupCalleeContext(METHODTYPEKEY methodTypeKey) {    calleeContext = methodTypeKey;}/*========================================================================= * FUNCTION:      Vfy_popInvokeArguments * TYPE:          private operation on stack * OVERVIEW:      Pop the arguments of the callee context * * INTERFACE: *   parameters:  None *   returns:     The number of words popped

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -