classmethod.h
来自「kaffe Java 解释器语言,源码,Java的子集系统,开放源代码」· C头文件 代码 · 共 571 行 · 第 1/2 页
H
571 行
/* * classMethod.h * Class, method and field tables. * * Copyright (c) 1996, 1997 * Transvirtual Technologies, Inc. All rights reserved. * * See the file "license.terms" for information on usage and redistribution * of this file. */#ifndef __classmethod_h#define __classmethod_h#include "gtypes.h"#include "access.h"#include "object.h"#include "md.h" /* XXX: need this here so KAFFE_PROFILER is accurately def'd */#include "constants.h"#include "errors.h"#include "jthread.h"#define MAXMETHOD 64/* Class state */typedef enum { CSTATE_FAILED = -1, CSTATE_UNLOADED, CSTATE_LOADED, CSTATE_LOADED_SUPER, CSTATE_PRELOADED, CSTATE_VERIFIED, CSTATE_DOING_PREPARE, CSTATE_PREPARED, CSTATE_DOING_LINK, CSTATE_LINKED, CSTATE_CONSTINIT, CSTATE_DOING_SUPER, CSTATE_USABLE, CSTATE_DOING_INIT, CSTATE_COMPLETE} class_state_t;struct _classEntry;struct _innerClass;struct Hjava_lang_String;#include <java_lang_ClassLoader.h>struct Hjava_lang_Class { Hjava_lang_Object head; /* A class is an object too */ struct _iLock* lock; /* Lock for internal use */ /* Link to class entry */ struct _classEntry* centry; Utf8Const* name; int packageLength; char* sourcefile; /* source file name if known */ accessFlags accflags; /* If non-NULL, a pointer to the superclass. * However, if state < CSTATE_DOING_PREPARE, then * (int) superclass is a constant pool index. */ struct Hjava_lang_Class* superclass; struct _constants constants; /* For regular classes, an array of the methods defined in this class. For array types, used for CLASS_ELEMENT_TYPE. For primitive types, used by CLASS_ARRAY_CACHE. */ Method* methods; short nmethods; /* Number of methods in the dtable. */ /* If CLASS_IS_PRIMITIVE, then the CLASS_PRIM_SIG. */ short msize; /* Pointer to array of Fields, on for each field. Static fields come first. */ Field* fields; /* The size of the non-static fields, in bytes. For a primitive type, the length in bytes. Also used temporarily while reading fields. */ int bfsize; /* Number of fields, including static fields. */ short nfields; /* Number of static fields. */ short nsfields; struct _dispatchTable* dtable; /* all interfaces supported by this class */ struct Hjava_lang_Class** interfaces; short* if2itable; /* redundant now */ void** itable2dtable; short interface_len; short total_interface_len; /* indices for all classes implementing this interface */ short* implementors; /* interfaces only */ int impl_index; Hjava_lang_ClassLoader* loader; /* A bitmap describing the layout of instances of that class. It contains CLASS_FSIZE/ALIGNMENTVOIDP bits. The MSB corresponds to the dtable field. */ int* gc_layout; class_state_t state; void* processingThread; Method* finalizer; int alloc_type; /* allocation type */ /* array containing static data */ void* static_data; /* InnerClasses attribute */ short this_index; short this_inner_index; short nr_inner_classes; struct _innerClass* inner_classes; void* gcjPeer; /* only needed if GCJ_SUPPORT */#ifdef KAFFE_VMDEBUG int live_count;#endif};#ifndef __DEFINED_CLASS#define __DEFINED_CLASStypedef struct Hjava_lang_Class Hjava_lang_Class;#endif/* * Functions for locking and waiting on *internal* class * bits. This is not for static+synchronized methods. * Use the centry lock, as it is convenient and available. */#define lockClass(C) lockMutex(((C)))#define unlockClass(C) unlockMutex(((C)))#define waitOnClass(C) waitCond(((C)), 0)#define signalOnClass(C) signalCond(((C)))#define broadcastOnClass(C) broadcastCond(((C)))#define METHOD_TRANSLATED(M) ((M)->accflags & ACC_TRANSLATED)#define METHOD_JITTED(M) ((M)->accflags & ACC_JITTED)#if defined(TRANSLATOR)#define METHOD_NATIVECODE(M) (((M)->idx == -1) ? \ ((M)->ncode) : \ ((M)->class->dtable->method[(M)->idx]))#else/* INTERPRETER */#define METHOD_NATIVECODE(M) ((M)->ncode)#endif/* Like METHOD_NATIVECODE, except we take the address --- * gcc doesn't compile &( ? : ) expressions for some reason */#define PMETHOD_NATIVECODE(M) (((M)->idx == -1) ? \ (void*)&((M)->ncode) : \ &((M)->class->dtable->method[(M)->idx]))#define METHOD_CODE_START(M) ((M)->c.ncode.ncode_start)#define SET_METHOD_NATIVECODE(M, C) METHOD_NATIVECODE(M) = (C); \ (M)->accflags |= ACC_TRANSLATED#define SET_METHOD_JITCODE(M, C) METHOD_NATIVECODE(M) = (C); \ (M)->accflags |= ACC_TRANSLATED|ACC_JITTED#if defined(TRANSLATOR)#define METHOD_INDIRECTMETHOD(M) METHOD_NATIVECODE(M)#else#define METHOD_INDIRECTMETHOD(M) (M)#endif/* * Stats for the nameMapping object. * * searching - The system is searching for this particular class. * loading - The system is loading this particular class and/or its parents. * If a circularity exists in the hierarchy it will be detected in this * state. * loaded - The class and its parents have been loaded. * done - The class have been loaded and verified. */typedef enum { NMS_EMPTY, NMS_SEARCHING, NMS_LOADING, NMS_LOADED, NMS_DONE} name_mapping_state_t;/* * Class hash entry. */typedef struct _classEntry { struct _classEntry* next; Utf8Const* name; struct _iLock* lock; name_mapping_state_t state; Hjava_lang_ClassLoader* loader; union { jthread_t thread; struct Hjava_lang_Class *cl; } data;} classEntry;/* * The nameDependency structure is used to detect cycles between classes. * Basically, its used as a simple deadlock detection system. * * next - The next object in the list. * thread - The thread that is blocked on "mapping". * mapping - The mapping that "thread" is waiting for. */typedef struct _nameDependency { struct _nameDependency *next; jthread_t thread; classEntry *mapping;} nameDependency;typedef struct _innerClass { u2 outer_class; u2 inner_class; u2 inner_class_accflags;} innerClass;typedef struct _parsed_signature { Utf8Const* signature; u2 nargs; u2 ret_and_args[1]; /* index into signature */ /* ret_and_args[0]: return value ret_and_args[1]: first argument etc */} parsed_signature_t;typedef struct _methods { Utf8Const* name; parsed_signature_t* parsed_sig; accessFlags accflags; long idx; /* Index into class->dtable */ u2 stacksz; u2 localsz; /* Only used for static/final/constructor methods */ nativecode* ncode; union { struct { nativecode* ncode_start; nativecode* ncode_end; } ncode; struct { unsigned char* code; int codelen; } bcode; } c; Hjava_lang_Class* class; struct _lineNumbers* lines; struct _jexception* exception_table; int ndeclared_exceptions; union { constIndex* local_exceptions; struct _methods* remote_exceptions; } declared_exceptions_u;#define declared_exceptions declared_exceptions_u.local_exceptions int framesize; /* JIT only: size of frame */#if defined(KAFFE_PROFILER) profiler_click_t jitClicks; profiler_click_t totalClicks; profiler_click_t totalChildrenClicks; int callsCount;#endif} methods;#define METHOD_NAME(M) ((M)->name)#define METHOD_NAMED(M) (METHOD_NAME(M)->data)#define PSIG_UTF8(sig) ((sig)->signature)#define PSIG_DATA(sig) (PSIG_UTF8((sig))->data)#define PSIG_RET(sig) ((sig)->ret_and_args[0])
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?