📄 global.h
字号:
extern bool_t JamRepeat;
/*=========================================================================
* Macros for controlling global execution tracing modes
*=======================================================================*/
/* The following isn't really intended to be unreadable, but it simplifies
* the maintenance of the various execution tracing flags.
*
* NOTE: Logically these operations belong to VmExtra directory,
* since this code is not useful for those ports that do not support
* command line operation. However, since this code is intimately
* tied with the tracing capabilities of the core KVM, we'll keep
* these definitions in this file for the time being.
*
* The intent is that you can call
* FOR_EACH_TRACE_FLAG(Macro_Of_Two_Arguments)
* where Macro_Of_Two_Arguments is a two-argument macro whose first argument
* is the name of a variable, and the second argument is the string the user
* enters to turn on that flag.
*/
#define FOR_EACH_TRACE_FLAG(Macro) \
FOR_EACH_ORDINARY_TRACE_FLAG(Macro) \
FOR_EACH_DEBUGGER_TRACE_FLAG(Macro) \
FOR_EACH_JAM_TRACE_FLAG(Macro)
/* The ordinary trace flags are those included in any debugging build */
#if INCLUDEDEBUGCODE
# define FOR_EACH_ORDINARY_TRACE_FLAG(Macro) \
Macro(tracememoryallocation, "-traceallocation") \
Macro(tracegarbagecollection, "-tracegc") \
Macro(tracegarbagecollectionverbose, "-tracegcverbose") \
Macro(traceclassloading, "-traceclassloading") \
Macro(traceclassloadingverbose, "-traceclassloadingverbose") \
Macro(traceverifier, "-traceverifier") \
Macro(tracestackmaps, "-tracestackmaps") \
Macro(tracebytecodes, "-tracebytecodes") \
Macro(tracemethodcalls, "-tracemethods") \
Macro(tracemethodcallsverbose, "-tracemethodsverbose") \
Macro(tracestackchunks, "-tracestackchunks") \
Macro(traceframes, "-traceframes") \
Macro(traceexceptions, "-traceexceptions") \
Macro(traceevents, "-traceevents") \
Macro(tracemonitors, "-tracemonitors") \
Macro(tracethreading, "-tracethreading") \
Macro(tracenetworking, "-tracenetworking")
#else
# define FOR_EACH_ORDINARY_TRACE_FLAG(Macro)
#endif
/* The debugger tracing flags are those included only if we support KWDP */
#if INCLUDEDEBUGCODE && ENABLE_JAVA_DEBUGGER
# define FOR_EACH_DEBUGGER_TRACE_FLAG(Macro) \
Macro(tracedebugger, "-tracedebugger")
#else
# define FOR_EACH_DEBUGGER_TRACE_FLAG(Macro)
#endif
/* The debugger tracing flags are those included only if we support KWDP */
#if INCLUDEDEBUGCODE && USE_JAM
# define FOR_EACH_JAM_TRACE_FLAG(Macro) \
Macro(tracejam, "-tracejam")
#else
# define FOR_EACH_JAM_TRACE_FLAG(Macro)
#endif
/* Declare each of the trace flags to be external. Note that we define
* a two-variable macro, then use that macro as an argument to
* FOR_EACH_TRACE_FLAG
*/
#define DECLARE_TRACE_VAR_EXTERNAL(varName, userName) \
extern int varName;
FOR_EACH_TRACE_FLAG(DECLARE_TRACE_VAR_EXTERNAL)
/*=========================================================================
* Most frequently called functions are "inlined" here
*=======================================================================*/
/*=========================================================================
* Quick operations for stack manipulation (for manipulating stack
* frames and operands).
*=======================================================================*/
#define topStack (*getSP())
#define secondStack (*(getSP()-1))
#define thirdStack (*(getSP()-2))
#define fourthStack (*(getSP()-3))
#define topStackAsType(_type_) (*(_type_ *)(getSP()))
#define secondStackAsType(_type_) (*(_type_ *)(getSP() - 1))
#define thirdStackAsType(_type_) (*(_type_ *)(getSP() - 2))
#define fourthStackAsType(_type_) (*(_type_ *)(getSP() - 3))
#define oneMore getSP()++
#define oneLess getSP()--
#define moreStack(n) getSP() += (n)
#define lessStack(n) getSP() -= (n)
#define popStack() (*getSP()--)
#define popStackAsType(_type_) (*(_type_ *)(getSP()--))
#define pushStack(data) *++getSP() = (data)
#define pushStackAsType(_type_, data) *(_type_ *)(++getSP()) = (data)
/*=========================================================================
* The equivalent macros to the above for use when the stack being
* manipulated is not for the currently executing thread. In all cases
* the additional parameter is the THREAD pointer.
*=======================================================================*/
#define topStackForThread(t) (*((t)->spStore))
#define secondStackForThread(t) (*((t)->spStore - 1))
#define thirdStackForThread(t) (*((t)->spStore - 2))
#define fourthStackForThread(t) (*((t)->spStore - 3))
#define popStackForThread(t) (*((t)->spStore--))
#define pushStackForThread(t, data) (*(++(t)->spStore) = (data))
#define popStackAsTypeForThread(t, _type_) \
(*(_type_*)((t)->spStore--))
#define pushStackAsTypeForThread(t, _type_, data) \
(*(_type_ *)(++(t)->spStore) = (data))
#define moreStackForThread(t, n) ((t)->spStore += (n))
#define lessStackForThread(t, n) ((t)->spStore -= (n))
#define oneMoreForThread(t) ((t)->spStore++)
#define oneLessForThread(t) ((t)->spStore--)
#define spForThread(t) ((t)->spStore)
/*=========================================================================
* Error handling definitions
*=======================================================================*/
/*
#ifndef ERROR_TRY
# include <setjmp.h>
# define ERROR_TRY \
{ jmp_buf *__prev__ = topJumpBuffer; \
int *__prev__value = topJumpBuffer_value; \
jmp_buf __jmp_buf__; \
int __value__; \
int __state__; \
topJumpBuffer = &__jmp_buf__; \
topJumpBuffer_value = &__value__; \
if ((__state__ = setjmp(__jmp_buf__)) == 0) {
# define ERROR_CATCH(var) \
} \
topJumpBuffer = __prev__; \
topJumpBuffer_value = __prev__value; \
if (__state__ != 0) { \
long var = __value__;
# define ERROR_END_CATCH } }
# define ERROR_THROW(i) \
*topJumpBuffer_value = i; \
longjmp(*topJumpBuffer, i)
extern jmp_buf *topJumpBuffer;
extern int *topJumpBuffer_value;
#define NEED_GLOBAL_JUMPBUFFER 1
#endif /* ERROR_TRY */
#define MB_CUR_MAX 2
#define ERROR_TRY
#define ERROR_END_CATCH
# define ERROR_THROW(i)
# define ERROR_CATCH(var)
#ifndef FATAL_ERROR_EXIT_CODE
#define FATAL_ERROR_EXIT_CODE 127
#endif
/*=========================================================================
* Operations for handling memory fetches and stores
*=======================================================================*/
/*=========================================================================
* These macros define Java-specific memory read/write operations
* for reading high-endian numbers.
*=======================================================================*/
/* Get a 32-bit value from the given memory location */
#define getCell(addr) \
((((long)(((unsigned char *)(addr))[0])) << 24) | \
(((long)(((unsigned char *)(addr))[1])) << 16) | \
(((long)(((unsigned char *)(addr))[2])) << 8) | \
(((long)(((unsigned char *)(addr))[3])) << 0))
#if BIG_ENDIAN
#define getAlignedCell(addr) (*(long *)(addr))
#else
#define getAlignedCell(addr) getCell(addr)
#endif
/* Get an unsigned 16-bit value from the given memory location */
#define getUShort(addr) \
((((unsigned short)(((unsigned char *)(addr))[0])) << 8) | \
(((unsigned short)(((unsigned char *)(addr))[1])) << 0))
/* Get a 16-bit value from the given memory location */
#define getShort(addr) ((short)(getUShort(addr)))
/* Store a 16-bit value in the given memory location */
#define putShort(addr, value) \
((unsigned char *)(addr))[0] = (unsigned char)((value) >> 8); \
((unsigned char *)(addr))[1] = (unsigned char)((value) & 0xFF)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -