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

📄 pool.c

📁 Nucleus_2_kvm_Hello 是kvm移植到Nucleus系统的源代码。。。好东西啊
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (c) 1998-2001 Sun Microsystems, Inc. All Rights Reserved. *  * This software is the confidential and proprietary information of Sun * Microsystems, Inc. ("Confidential Information").  You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Sun. *  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING * THIS SOFTWARE OR ITS DERIVATIVES. *  * Use is subject to license terms. *//*========================================================================= * SYSTEM:    KVM * SUBSYSTEM: Constant pool * FILE:      pool.c * OVERVIEW:  Constant pool management operations (see pool.h). * AUTHOR:    Antero Taivalsaari, Sun Labs *            Frank Yellin, Sheng Liang (tightened the access  *            checks for JLS (Java Language Spec compliance) *=======================================================================*//*========================================================================= * Include files *=======================================================================*/#include "global.h"/*========================================================================= * Constant pool access methods (low level) *=======================================================================*//*========================================================================= * FUNCTION:      cachePoolEntry() * TYPE:          private instance-level operation * OVERVIEW:      Given an index to a pool entry, and a resolved value *                update that entry to have the given value. * INTERFACE: *   parameters:  constant pool pointer, constant pool index, resolved value  *   returns:     <nothing> * NOTE:          factoring out caching of resolved values like this means *                PalmOS specific code for writing to database memory is *                restricted. *=======================================================================*/static void cachePoolEntry(CONSTANTPOOL constantPool, unsigned int cpIndex, cell* value){    CONSTANTPOOL_ENTRY thisEntry = &constantPool->entries[cpIndex];    if (!USESTATIC || inCurrentHeap(constantPool)) {         /* For !USESTATIC, the constant pool is always in the heap.         * For USESTATIC, the constant pool can be in the heap when we're          *    setting the initial value of a final static String.         */        CONSTANTPOOL_TAG(constantPool, cpIndex) |= CP_CACHEBIT;        thisEntry->cache = value;    } else {         unsigned char *thisTagAddress = &CONSTANTPOOL_TAG(constantPool, cpIndex);        int entryOffset = (char *)thisEntry - (char *)constantPool;        int tagOffset =   (char *)thisTagAddress - (char *)constantPool;                unsigned char                 newTag = *thisTagAddress | CP_CACHEBIT;        union constantPoolEntryStruct newEntry;        newEntry.cache = value;        modifyStaticMemory(constantPool, entryOffset, &newEntry, sizeof(newEntry));        modifyStaticMemory(constantPool, tagOffset,   &newTag,   sizeof(newTag));    }}/*========================================================================= * FUNCTION:      verifyClassAccess *                classHasAccessToClass *                classHasAccessToMember * TYPE:          public instance-level operation * OVERVIEW:      Helper functions for checking access rights *                in field/method resolution. * INTERFACE: *   parameters: *   returns: *=======================================================================*/#define VERIFY_FIELD_ACCESS 1#define VERIFY_METHOD_ACCESS 2void verifyClassAccess(CLASS targetClass, INSTANCE_CLASS currentClass) {    if (!classHasAccessToClass(currentClass, targetClass)) {         START_TEMPORARY_ROOTS            DECLARE_TEMPORARY_ROOT(char *, targetName,                                    getClassName((CLASS)targetClass));            DECLARE_TEMPORARY_ROOT(char *, currentName,                                    getClassName((CLASS)currentClass));            sprintf(str_buffer,                     KVM_MSG_CANNOT_ACCESS_CLASS_FROM_CLASS_2STRPARAMS,                    targetName, currentName);        END_TEMPORARY_ROOTS        fatalError(str_buffer);    }}bool_tclassHasAccessToClass(INSTANCE_CLASS currentClass, CLASS targetClass) {     if (    currentClass == NULL         || ((CLASS)currentClass == targetClass)        /* Note that array classes have the same package and access as         * their base classes */        || (targetClass->accessFlags & ACC_PUBLIC)        || (targetClass->packageName == currentClass->clazz.packageName)        ) {         return TRUE;    } else {         return FALSE;    }}bool_tclassHasAccessToMember(INSTANCE_CLASS currentClass,                       int access, INSTANCE_CLASS fieldClass,                        INSTANCE_CLASS cpClass) {     if (   currentClass == NULL         || currentClass == fieldClass         || (ACC_PUBLIC & access)) {        return TRUE;    } else if (ACC_PRIVATE & access) {         return FALSE;    } else if (currentClass->clazz.packageName == fieldClass->clazz.packageName) {        return TRUE;    } else if (ACC_PROTECTED & access) {         /* See if currentClass is a subclass of fieldClass */        INSTANCE_CLASS cb;        for (cb = currentClass->superClass; ; cb = cb->superClass) {            if (cb == fieldClass) {                break;            } else if (cb == NULL) {                 return FALSE;            }        }        /* In addition, cpClass must either be a subclass, superclass, or the         *  same as currentClass         */        if (cpClass == currentClass) {            return TRUE;        }        for (cb = currentClass->superClass; cb; cb = cb->superClass) {             if (cb == cpClass) {                return TRUE;            }        }        for (cb = cpClass; cb; cb = cb->superClass) {             if (cb == currentClass) {                return TRUE;            }        }    }    return FALSE;}/*========================================================================= * Constant pool access methods (high level) *=======================================================================*//*========================================================================= * FUNCTION:      resolveClassReference() * TYPE:          public instance-level operation * OVERVIEW:      Given an index to a CONSTANT_Class, get the class *                that the index refers to. * INTERFACE: *   parameters:  constant pool pointer, constant pool index , current class *   returns:     class pointer *=======================================================================*/CLASS resolveClassReference(CONSTANTPOOL constantPool,                            unsigned int cpIndex,                            INSTANCE_CLASS currentClass) {    CONSTANTPOOL_ENTRY thisEntry = &constantPool->entries[cpIndex];    unsigned char thisTag = CONSTANTPOOL_TAG(constantPool, cpIndex);    CLASS thisClass;    if (thisTag & CP_CACHEBIT) {         /*  Check if this entry has already been resolved (cached) */        /*  If so, simply return the earlier resolved class */        return (CLASS)(thisEntry->cache);    }    if (VERIFYCONSTANTPOOLINTEGRITY &&         (thisTag & CP_CACHEMASK) != CONSTANT_Class) {         fatalError(KVM_MSG_ILLEGAL_CONSTANT_CLASS_REFERENCE);

⌨️ 快捷键说明

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