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

📄 verifierutil.h

📁 Nucleus_2_kvm_Hello 是kvm移植到Nucleus系统的源代码。。。好东西啊
💻 H
📖 第 1 页 / 共 3 页
字号:
    ((classKey > 255) ? classKey : (fatalError("Bad class key"), 0))/* * Convert a CLASSKEY to a VERIFIERTYPE * * In KVM the types are the same when the value is above 256 and the * verifier core never needs to convert values lower then this so it * is simply enough to check that this assumption is true. * * @param verifierType  A VERIFIERTYPE * @return              A CLASSKEY */#define Vfy_toClassKey(verifierType) \    ((verifierType > 255) ? verifierType : (fatalError("Bad verifier type"), 0))#else#define Vfy_toVerifierType(classKey) classKey#define Vfy_toClassKey(verifierType) verifierType#endif/* * Test to see if a type is a primitive type * * @param  type     A VERIFIERTYPE * @return bool_t   TRUE is type is a primitive */#define Vfy_isPrimitive(type)  ((type != ITEM_Null) && (type < 256))/* * Test to see if a type is an array * * @param  type     A VERIFIERTYPE * @return bool_t   TRUE is type is an array */#define Vfy_isArray(type)  ((type >> FIELD_KEY_ARRAY_SHIFT) != 0)/* * Test to see if a type is an array or null * * @param  type     A VERIFIERTYPE * @return bool_t   TRUE is type is an array or null */#define Vfy_isArrayOrNull(type)  (Vfy_isArray(type) || type == ITEM_Null)/* * Test to see if one type can be assigned to another type * * @param fromKey   A VERIFIERTYPE to assign from * @param toKey     A VERIFIERTYPE to assign to * @return bool_t   TRUE if the assignment is legal */#define Vfy_isAssignable(fromKey, toKey)    vIsAssignable(fromKey, toKey, NULL)/* * Test to see if a field of a class is "protected" * * @param clazz     A CLASS * @param index     The field index (offset in words) * @return          TRUE if field is protected */#define Vfy_isProtectedField(clazz, index) vIsProtectedAccess((INSTANCE_CLASS)clazz, index, FALSE)/* * Test to see if a method of a class is "protected" * * @param clazz     A CLASS * @param index     The method index (offset in words) * @return          TRUE if method is protected */#define Vfy_isProtectedMethod(clazz, index) vIsProtectedAccess((INSTANCE_CLASS)clazz, index, TRUE)/* * Check if the current state of the local variable and stack contents match * that of a stack map at a specific IP address * * @param targetIP  The IP address for the stack map * @param flags     One or more of SM_CHECK, SM_MERGE, and SM_EXIST * @param throwCode A verification error code * @throw           If the match is not correct */#define Vfy_matchStackMap(targetIP, flags, throwCode) {                                                 \    if (!matchStackMap(methodBeingVerified,  targetIP, flags)) {                                        \        Vfy_throw(throwCode);                                                                           \    }                                                                                                   \}/* * Check stack maps can be merged at the current location * * @param targetIP      The IP address for the stack map * @param noControlFlow TRUE if the location cannot be reached from the previous instruction * @throw               If the match is not correct */#define Vfy_checkCurrentTarget(current_ip, noControlFlow) {                                             \        Vfy_matchStackMap(                                                                              \                           current_ip,                                       /* target ip */            \                           SM_MERGE | (noControlFlow ? SM_EXIST : SM_CHECK), /* flags */                \                           VE_SEQ_BAD_TYPE                          /* Vfy_throw code if not matched */ \                         );                                                                             \}/* * Check stack maps match at an exception handler entry point * * @param target_ip     The IP address of the exception handler * @throw               If the match is not correct */#define Vfy_checkHandlerTarget(target_ip) {                                                             \    Vfy_trace1("Check exception handler at %ld:\n", (long)target_ip);                                   \    Vfy_matchStackMap(target_ip, SM_CHECK | SM_EXIST, VE_TARGET_BAD_TYPE);                              \}/* * Check stack maps match at a jump target * * @param current_ip    The current IP address * @param target_ip     The IP address of the jump target * @throw               If the match is not correct */#define Vfy_checkJumpTarget(this_ip, target_ip) {                                                       \    Vfy_trace1("Check jump target at %ld\n", target_ip);                                                \    Vfy_matchStackMap(target_ip, SM_CHECK | SM_EXIST, VE_TARGET_BAD_TYPE);                              \    if (!checkNewObject(this_ip, target_ip)) {                                                          \        Vfy_throw(VE_BACK_BRANCH_UNINIT);                                                               \    }                                                                                                   \}/* * Check stack maps match at a jump target * * @param current_ip    The current IP address * @param target_ip     The IP address of the jump target * @throw               If the match is not correct */#define Vfy_markNewInstruction(ip, length) {                                                            \    if (NEWInstructions == NULL) {                                                                      \        NEWInstructions = callocNewBitmap(length);                                                      \    }                                                                                                   \    SET_NTH_BIT(NEWInstructions, ip);                                                                   \}/* * Get the type of a local variable * * @param i             The slot index of the local variable * @param t             The VERIFIERTYPE that must match * @return              The actual VERIFIERTYPE found * @throw               If the match is not correct or index is bad */extern VERIFIERTYPE Vfy_getLocal(SLOTINDEX  i, VERIFIERTYPE t);/* * Set the type of a local variable * * @param i             The slot index of the local variable * @param t             The new VERIFIERTYPE of the slot * @throw               If index is bad */extern void Vfy_setLocal(SLOTINDEX  i, VERIFIERTYPE t);/* * Push a type * * @param t             The new VERIFIERTYPE to be pushed * @throw               If stack overflows */extern void Vfy_push(VERIFIERTYPE t);/* * Pop a type * * @param t             The VERIFIERTYPE that must match * @throw               If the match is not correct or stack underflow */extern VERIFIERTYPE Vfy_pop(VERIFIERTYPE t);/* * Pop category1 type (ITEM_Null, ITEM_Integer, ITEM_Float, <init> object, *                      reference type, or array type * * @throw               If the match is not correct or stack underflow */extern VERIFIERTYPE Vfy_popCategory1();/* * Pop the first word of a category2 type * * @throw               If the match is not correct or stack underflow */extern VERIFIERTYPE Vfy_popCategory2_firstWord();/* * Pop the second word of a category2 type * * @throw               If the match is not correct or stack underflow */extern VERIFIERTYPE Vfy_popCategory2_secondWord();/* * Pop the first word of a DoubleWord type * * @throw               If the match is not correct or stack underflow */#define Vfy_popDoubleWord_firstWord()  Vfy_popCategory2_firstWord()/* * Pop the second word of a DoubleWord type * * @throw               If the match is not correct or stack underflow */#define Vfy_popDoubleWord_secondWord() Vfy_popCategory2_secondWord()/* * Verify a void return * * @throw               If the method is not if type void, if the method *                      is <init> and super() was not called. */extern void Vfy_returnVoid();/* * Pop a type and verify a return * * @param returnType    The VERIFIERTYPE to be returned * @throw               If the return type is incorrect */extern void Vfy_popReturn(VERIFIERTYPE returnType);/* * Push a CLASSKEY * * @param returnType    The CLASSKEY to be pushed * @throw               If stack overflow, bad type. */extern void Vfy_pushClassKey(CLASSKEY fieldType);/* * Pop a CLASSKEY * * @param returnType    The CLASSKEY to be popped * @throw               If stack underflow, bad type. */extern void Vfy_popClassKey(CLASSKEY fieldType);/* * Setup the callee context (to process an invoke) * * @param methodTypeKey The METHODTYPEKEY the method type */extern void Vfy_setupCalleeContext(METHODTYPEKEY methodTypeKey);/* * Pop the callee arguments from the stack * * @throw               If argument are not correct */extern int Vfy_popInvokeArguments();/* * Push the callee result * * @throw               If result is not correct */extern void Vfy_pushInvokeResult();/* * Test to see if a method name start "<" * * @param methodNameKey The METHODNAMEKEY of the method * @return              TRUE if the method name starts with '<' */extern bool_t Vfy_MethodNameStartsWithLeftAngleBracket(METHODNAMEKEY methodNameKey);/* * Test to see if a method name is "<init>" * * @param methodNameKey The METHODNAMEKEY of the method * @return              TRUE if the method name is "<init>" */extern bool_t Vfy_MethodNameIsInit(METHODNAMEKEY methodNameKey);/* * Change all local and stack instances of one type to another * * @param fromType      The VERIFIERTYPE to convert from * @param fromType      The VERIFIERTYPE to convert to */extern void Vfy_ReplaceTypeWithType(VERIFIERTYPE fromType, VERIFIERTYPE toType);/* ------------------------------------------------------------------------ *\ *                             Stack state management                       *\* ------------------------------------------------------------------------ *//* * Save the state of the type stack */extern void Vfy_saveStackState();/* * Restore the state of the type stack */extern void Vfy_restoreStackState();/* ------------------------------------------------------------------------ *\ *                             Utility Functions                            *\* ------------------------------------------------------------------------ *//* * Initialize the local variable types */extern void Vfy_initializeLocals();/* * Abort the verification * * @param code          One of the VE_xxx codes */extern void Vfy_throw(int code);#if INCLUDEDEBUGCODE/* * Write a trace line with one parameter * * @param msg           printf format string * @param p1            32 bit parameter */extern void Vfy_trace1(char *msg, long p1);/* * Save the ip somewhere the error printing routine can find it * * @param ip            The IP address */extern void Vfy_setErrorIp(int ip);/* * Output a trace statement at the head of the dispatch loop * * @param vMethod       The METHOD being verified * @param ip            The IP address */extern void Vfy_printVerifyLoopMessage(METHOD vMethod, IPINDEX ip);#else#define Vfy_trace1(x, y)                    /**/#define Vfy_setErrorIp(x)                   /**/#define Vfy_printVerifyLoopMessage(x, y)    /**/

⌨️ 快捷键说明

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