📄 frame.h
字号:
*=======================================================================*/
#define SIZEOF_FRAME StructSizeInCells(frameStruct)
#define SIZEOF_HANDLER StructSizeInCells(exceptionHandlerStruct)
#define SIZEOF_HANDLERTABLE(n) \
(StructSizeInCells(exceptionHandlerTableStruct) + (n - 1) * SIZEOF_HANDLER)
/*=========================================================================
* Stack frame execution modes (special return addresses)
*=======================================================================*/
#define KILLTHREAD ((BYTE*) 1)
/*=========================================================================
* Iterators
*=======================================================================*/
#define FOR_EACH_HANDLER(__var__, handlerTable) { \
HANDLER __first_handler__ = handlerTable->handlers; \
HANDLER __end_handler__ = __first_handler__ + handlerTable->length; \
HANDLER __var__; \
for (__var__ = __first_handler__; __var__ < __end_handler__; __var__++) {
#define END_FOR_EACH_HANDLER } }
/*=========================================================================
* Operations on stack frames
*=======================================================================*/
#ifdef CLDC11
/*=========================================================================
* Additional macros and definitions
*=======================================================================*/
#define POPFRAMEMACRO \
setSP(getFP()->previousSp); /* Restore previous stack pointer */ \
setIP(getFP()->previousIp); /* Restore previous instruction pointer */ \
setFP(getFP()->previousFp); /* Restore previous frame pointer */ \
setLP(FRAMELOCALS(getFP())); /* Restore previous locals pointer */ \
setCP(getFP()->thisMethod->ofClass->constPool);
void pushFrame(METHOD thisMethod);
#else
bool_t pushFrame(METHOD thisMethod);
#endif /* CLDC11 */
void popFrame(void);
/*=========================================================================
* Stack frame printing and debugging operations
*=======================================================================*/
#if INCLUDEDEBUGCODE
void printStackTrace(void);
void printExecutionStack(void);
#else
#define printStackTrace()
#define printExecutionStack()
#endif /* INCLUDEDEBUGCODE */
/*=========================================================================
* Actual exception handling operations
*=======================================================================*/
void throwException(THROWABLE_INSTANCE_HANDLE exception);
/*=========================================================================
* Operations for raising exceptions and errors from within the VM
*=======================================================================*/
/*=========================================================================
* COMMENTS:
* There are currently three ways by which the VM can report exceptions
* and errors it has found during execution:
*
* - raiseException is the most elegant one, allowing the VM to report
* errors via the normal Java exception handling mechanism. It should
* be used for reporting only those exceptions and errors which are
* known to be "safe" and "harmless" from the VM's point of view
* (i.e., the internal consistency and integrity of the VM should
* not be endangered in any way).
*
* - fatalError is similar to raiseException, except that program
* execution is terminated immediately. This function is used for
* reporting those Java-level errors which are not caused by the VM,
* but which might be harmful for the consistency of the VM.
* There are currently quite a lot of fatalError calls inside the VM,
* but in the long term it is expected that most of these could
* be replaced with raiseException calls.
*
* - fatalVMError calls are used for reporting internal (in)consistency
* problems or other VM-related errors. These errors typically indicate
* that there are bugs in the VM.
*
* UPDATED COMMENTS FOR KVM/CLDC 1.1:
*
* In KVM 1.1, the exception/error handling mechanisms have been
* generalized so that they should be able to handle any exception
* or error class supported by the full Java Language Specification.
* However, since CLDC 1.0/1.1 Specifications support only a limited
* set of error classes, we have intentionally left in some extra
* checks that prevent unavailable errors from being thrown. Error
* classes that are not found at runtime will be automatically converted
* into fatalError calls.
*=======================================================================*/
#ifdef __GNUC__
void raiseException(const char* exceptionClassName) __attribute__ ((noreturn));
void raiseExceptionWithMessage(const char* exceptionClassName,
const char* exceptionMessage) __attribute__ ((noreturn));
void fatalVMError(const char* errorMessage) __attribute__ ((noreturn));
void fatalError(const char* errorMessage) __attribute__ ((noreturn));
#else
#ifdef CLDC11
void raiseException(const char* exceptionClassName);
void raiseExceptionWithMessage(const char* exceptionClassName,
const char* exceptionMessage);
#endif /* CLDC11 */
void fatalVMError(const char* errorMessage);
void fatalError(const char* errorMessage);
#endif
/*=========================================================================
* Stack tracing operations
*=======================================================================*/
void fillInStackTrace(THROWABLE_INSTANCE_HANDLE exception);
void printExceptionStackTrace(THROWABLE_INSTANCE_HANDLE exception);
#ifdef CLDC11
/* We call this function when we are doing excessive method tracing */
#if INCLUDEDEBUGCODE
void frameTracing(METHOD method, char* glyph, int offset);
#else
#define frameTracing(method, glyph, offset)
#endif
#endif /* CLDC11 */
/*=========================================================================
* Exception handler debugging and tracing operations
*=======================================================================*/
#if INCLUDEDEBUGCODE
void printExceptionHandlerTable(HANDLERTABLE handlerTable);
#else
#define printExceptionHandlerTable(handlerTable)
#endif /* INCLUDEDEBUGCODE */
/*=========================================================================
* Shortcuts to the errors/exceptions that the VM may throw
*=======================================================================*/
#ifdef CLDC11
extern const char ArithmeticException[];
extern const char ArrayIndexOutOfBoundsException[];
extern const char ArrayStoreException[];
extern const char ClassCastException[];
extern const char ClassNotFoundException[];
extern const char IllegalAccessException[];
extern const char IllegalArgumentException[];
extern const char IllegalMonitorStateException[];
extern const char IllegalThreadStateException[];
extern const char IndexOutOfBoundsException[];
extern const char InstantiationException[];
extern const char InterruptedException[];
extern const char NegativeArraySizeException[];
extern const char NullPointerException[];
extern const char NumberFormatException[];
extern const char RuntimeException[];
extern const char SecurityException[];
extern const char StringIndexOutOfBoundsException[];
extern const char IOException[];
extern const char NoClassDefFoundError[];
extern const char OutOfMemoryError[];
extern const char VirtualMachineError[];
/* The following classes are not part of the CLDC Specification */
extern const char AbstractMethodError[];
extern const char ClassCircularityError[];
extern const char ClassFormatError[];
extern const char ExceptionInInitializerError[];
extern const char IllegalAccessError[];
extern const char IncompatibleClassChangeError[];
extern const char InstantiationError[];
extern const char NoSuchFieldError[];
extern const char NoSuchMethodError[];
extern const char StackOverflowError[];
extern const char VerifyError[];
/*
extern const char InternalError[];
extern const char LinkageError[];
extern const char UnknownError[];
extern const char UnsatisfiedLinkError[];
extern const char UnsupportedClassVersionError[];
*/
#else
extern const char NullPointerException[];
extern const char IndexOutOfBoundsException[];
extern const char ArrayIndexOutOfBoundsException[];
extern const char ArrayStoreException[];
extern const char ArithmeticException[];
extern const char ClassCastException[];
extern const char NegativeArraySizeException[];
extern const char JavaLangError_name[]; /* JavaLangError is the class */
/*=========================================================================
* Additional macros and definitions
*=======================================================================*/
/* We call this function when we are doing excessive method tracing. */
#if INCLUDEDEBUGCODE
void frameTracing(METHOD method, char *glyph, int offset);
#else
# define frameTracing(method, glyph, offset)
#endif
#define POPFRAMEMACRO \
setSP(getFP()->previousSp); /* Restore previous stack pointer */ \
setIP(getFP()->previousIp); /* Restore previous instruction pointer */ \
setFP(getFP()->previousFp); /* Restore previous frame pointer */ \
setLP(FRAMELOCALS(getFP())); /* Restore previous locals pointer */ \
setCP(getFP()->thisMethod->ofClass->constPool);
#endif /* CLDC11 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -