📄 fields.h
字号:
/*0001*//*
/*0002./ * Copyright (c) 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
/*0003./ *
/*0004./ * This software is the confidential and proprietary information of Sun
/*0005./ * Microsystems, Inc. ("Confidential Information"). You shall not
/*0006./ * disclose such Confidential Information and shall use it only in
/*0007./ * accordance with the terms of the license agreement you entered into
/*0008./ * with Sun.
/*0009./ *
/*0010./ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
/*0011./ * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
/*0012./ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
/*0013./ * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
/*0014./ * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
/*0015./ * THIS SOFTWARE OR ITS DERIVATIVES.
/*0016./ *
/*0017./ */
/*0018*/
/*0019*//*=========================================================================
/*0020./ * SYSTEM: KVM
/*0021./ * SUBSYSTEM: Internal runtime structures
/*0022./ * FILE: fields.h
/*0023./ * OVERVIEW: Internal runtime structures for storing different kinds
/*0024./ * of fields (constants, variables, methods, interfaces).
/*0025./ * Tables of these fields are created every time a new class
/*0026./ * is loaded into the virtual machine.
/*0027./ * AUTHOR: Antero Taivalsaari, Sun Labs
/*0028./ * Edited by Doug Simon 11/1998
/*0029./ * Sheng Liang, Frank Yellin
/*0030./ *=======================================================================*/
/*0031*/
/*0032*//*=========================================================================
/*0033./ * COMMENTS:
/*0034./ * This file defines the VM-specific internal runtime structures
/*0035./ * needed for representing fields, methods and interfaces.
/*0036./ *=======================================================================*/
/*0037*/
/*0038*//*=========================================================================
/*0039./ * Include files
/*0040./ *=======================================================================*/
/*0041*/
/*0042*//*=========================================================================
/*0043./ * COMMENTS:
/*0044./ * FIELD is the basic structure that is used for representing
/*0045./ * information about instance variables, static variables, constants
/*0046./ * and static methods. It is used as a component in constant pool
/*0047./ * and instance variable tables stored in CLASS structures.
/*0048./ *
/*0049./ * Method tables use a slightly larger structure (METHOD)
/*0050./ * which is a logical subtype of FIELD.
/*0051./ *
/*0052./ * Note: to speed up stack frame generation at runtime, we calculate
/*0053./ * the number of parameters (argCount) and local variables (localCount)
/*0054./ * for each method in advance upon class loading.
/*0055./ *=======================================================================*/
/*0056*/
/*0057*//*=========================================================================
/*0058./ * IMPORTANT: If you change the order of any of the data elements
/*0059./ * in these data structures, make sure that the order matches
/*0060./ * with the corresponding data structures in 'rom.h'.
/*0061./ *=======================================================================*/
/*0062*/
/*0063*//* FIELD */
/*0064*/struct fieldStruct {
/*0065*/ NameTypeKey nameTypeKey;
/*0066*/ long accessFlags; /* Access indicators (public/private etc.) */
/*0067*/ INSTANCE_CLASS ofClass; /* Backpointer to the class owning the field */
/*0068*/ union {
/*0069*/ long offset; /* for dynamic objects */
/*0070*/ void *staticAddress; /* pointer to static. */
/*0071*/ } u;
/*0072*/};
/*0073*/
/*0074*/struct fieldTableStruct {
/*0075*/ long length;
/*0076*/ struct fieldStruct fields[1];
/*0077*/};
/*0078*/
/*0079*//* METHOD */
/*0080*/struct methodStruct {
/*0081*/ NameTypeKey nameTypeKey;
/*0082*/ union {
/*0083*/ struct {
/*0084*/ BYTE* code;
/*0085*/ HANDLERTABLE handlers;
/*0086*/ union {
/*0087*/ STACKMAP pointerMap;
/*0088*/ POINTERLIST verifierMap;
/*0089*/ } stackMaps;
/*0090*/ unsigned short codeLength;
/*0091*/ unsigned short maxStack;
/*0092*/ /* frameSize should be here, rather than in the generic part, */
/*0093*/ /* but this gives us better packing of the bytes */
/*0094*/ } java;
/*0095*/ struct {
/*0096*/ void (*code)(void);
/*0097*/ void *info;
/*0098*/ } native;
/*0099*/ } u;
/*0100*/ long accessFlags; /* Access indicators (public/private etc.) */
/*0101*/ INSTANCE_CLASS ofClass; /* Backpointer to the class owning the field */
/*0102*/ unsigned short frameSize; /* Method frame size (arguments+local vars) */
/*0103*/ unsigned short argCount; /* Method argument (parameter) count */
/*0104*/};
/*0105*/
/*0106*/struct methodTableStruct {
/*0107*/ long length;
/*0108*/ struct methodStruct methods[1];
/*0109*/};
/*0110*/
/*0111*//*=========================================================================
/*0112./ * COMMENTS:
/*0113./ * STACKMAPs are used internally by the KVM to store
/*0114./ * information that the runtime part of the classfile
/*0115./ * verifier can utilize to speed up verification.
/*0116./ * This information is also utilized by the exact
/*0117./ * garbage collector.
/*0118./ *=======================================================================*/
/*0119*/
/*0120*/#define STACK_MAP_SHORT_ENTRY_FLAG 0x8000
/*0121*/#define STACK_MAP_ENTRY_COUNT_MASK 0x7FFF
/*0122*/#define STACK_MAP_SHORT_ENTRY_OFFSET_MASK 0xFFF
/*0123*/#define STACK_MAP_SHORT_ENTRY_MAX_OFFSET 0xFFF
/*0124*/#define STACK_MAP_SHORT_ENTRY_MAX_STACK_SIZE 0xF
/*0125*/
/*0126*/struct stackMapStruct {
/*0127*/
/*0128*/ /* The high bit of nEntries is a flag indicating whether the structs are
/*0129./ * short entries or not.
/*0130./ * If this is a short entry
/*0131./ * The low 12 bits of offset are the actual offset
/*0132./ * The high 4 bits of offset are the operand stack size
/*0133./ * stackMapKey is a bitmap giving the live locals and operand
/*0134./ * stacks. ((char *)stackMapKey)[0] contains the low 8 bits and
/*0135./ * ((char *)stackMapKey)[1] contains the high 8 bits.
/*0136./ * If this isn't a short entry, then offset is the actual 16-bit offset.
/*0137./ * Stackmap key is an entry in the name table. The first byte of the
/*0138./ * entry is the stack size. The remaining bytes are a variable length
/*0139./ * bitmap.
/*0140./ */
/*0141*/ unsigned short nEntries;
/*0142*/ struct stackMapEntryStruct {
/*0143*/ unsigned short offset;
/*0144*/ unsigned short stackMapKey;
/*0145*/ } entries[1];
/*0146*/};
/*0147*/
/*0148*//*=========================================================================
/*0149./ * COMMENTS:
/*0150./ * The Java-level debugging interfaces need access to line number
/*0151./ * information. The following structures are used for storing
/*0152./ * that information.
/*0153./ *=======================================================================*/
/*0154*/
/*0155*/#if ENABLE_JAVA_DEBUGGER
/*0156*/
/*0157*/struct lineNumberStruct {
/*0158*/ unsigned short start_pc;
/*0159*/ unsigned short line_number;
/*0160*/};
/*0161*/
/*0162*/struct lineNumberTableStruct {
/*0163*/ unsigned short length;
/*0164*/ struct lineNumberStruct lineNumber[1];
/*0165*/};
/*0166*/
/*0167*/#endif /* ENABLE_JAVA_DEBUGGER */
/*0168*/
/*0169*//*=========================================================================
/*0170./ * Sizes of the data structures above
/*0171./ *=======================================================================*/
/*0172*/
/*0173*/#define SIZEOF_FIELD StructSizeInCells(fieldStruct)
/*0174*/#define SIZEOF_METHOD StructSizeInCells(methodStruct)
/*0175*/
/*0176*/#define SIZEOF_METHODTABLE(n) \
/*0177*/ (StructSizeInCells(methodTableStruct) + (n - 1) * SIZEOF_METHOD)
/*0178*/
/*0179*/#define SIZEOF_FIELDTABLE(n) \
/*0180*/ (StructSizeInCells(fieldTableStruct) + (n - 1) * SIZEOF_FIELD)
/*0181*/
/*0182*//*=========================================================================
/*0183./ * Operations on field and method tables
/*0184./ *=======================================================================*/
/*0185*/
/*0186*/FIELD lookupField(INSTANCE_CLASS thisClass, NameTypeKey key);
/*0187*/METHOD lookupMethod(CLASS thisClass, NameTypeKey key,
/*0188*/ INSTANCE_CLASS currentClass);
/*0189*/METHOD getSpecialMethod(INSTANCE_CLASS thisClass, NameTypeKey key);
/*0190*/
/*0213*//*=========================================================================
/*0214./ * Iterators
/*0215./ *=======================================================================*/
/*0216*/
/*0217*/#define FOR_EACH_METHOD(__var__, methodTable) { \
/*0218*/ if (methodTable != NULL) { \
/*0219*/ METHOD __first_method__ = methodTable->methods; \
/*0220*/ METHOD __end_method__ = __first_method__ + methodTable->length; \
/*0221*/ METHOD __var__; \
/*0222*/ for (__var__ = __first_method__; __var__ < __end_method__; __var__++) {
/*0223*/
/*0224*/#define END_FOR_EACH_METHOD } } }
/*0225*/
/*0226*/#define FOR_EACH_FIELD(__var__, fieldTable) { \
/*0227*/ if (fieldTable != NULL) { \
/*0228*/ FIELD __first_field__ = fieldTable->fields; \
/*0229*/ FIELD __end_field__ = __first_field__ + fieldTable->length; \
/*0230*/ FIELD __var__; \
/*0231*/ for (__var__ = __first_field__; __var__ < __end_field__; __var__++) {
/*0232*/
/*0233*/#define END_FOR_EACH_FIELD } } }
/*0234*/
/*0235*//*=========================================================================
/*0236./ * Internal operations on signatures
/*0237./ *=======================================================================*/
/*0238*/
/*0239*/#define methodName(method) \
/*0240*/ (change_Key_to_Name((method)->nameTypeKey.nt.nameKey, NULL))
/*0241*/
/*0242*/#define fieldName(field) \
/*0243*/ (change_Key_to_Name((field)->nameTypeKey.nt.nameKey, NULL))
/*0244*/
/*0245*/#define getMethodSignature(method) \
/*0246*/ change_Key_to_MethodSignature((method)->nameTypeKey.nt.typeKey)
/*0247*/
/*0248*/#define getFieldSignature(field) \
/*0249*/ change_Key_to_FieldSignature((field)->nameTypeKey.nt.typeKey)
/*0250*/
/*0251*/char *change_Key_to_FieldSignature(FieldTypeKey);
/*0252*/char *change_Key_to_FieldSignature_inBuffer(FieldTypeKey, char *result);
/*0253*/
/*0254*/char *change_Key_to_MethodSignature(MethodTypeKey);
/*0255*/char *change_Key_to_MethodSignature_inBuffer(MethodTypeKey, char *result);
/*0256*/
/*0257*/FieldTypeKey change_FieldSignature_to_Key(CONST_CHAR_HANDLE, int offset,
/*0258*/ int length);
/*0259*/MethodTypeKey change_MethodSignature_to_Key(CONST_CHAR_HANDLE, int offset,
/*0260*/ int length);
/*0261*/
/*0262*/NameTypeKey getNameAndTypeKey(const char* name, const char* type);
/*0263*/
/*0264*/#define FIELD_KEY_ARRAY_SHIFT 13
/*0265*/#define FIELD_KEY_MASK 0x1FFF
/*0266*/#define MAX_FIELD_KEY_ARRAY_DEPTH 7
/*0267*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -