📄 execute.h
字号:
/* * 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: Bytecode interpreter * FILE: execute.h * OVERVIEW: This file defines macros for the Java interpreter * execution loop. These macros are needed by the * redesigned interpreter loop. * AUTHOR: Nik Shaylor 9/5/2000 *=======================================================================*//*========================================================================= * Include files *=======================================================================*//*========================================================================= * Additional build options (standard options are defined in main.h) *=======================================================================*//* The following options are intended for interpreter debugging * and customization. Normally you should not change these * definitions, and that's why they are here instead of * main.h where the user-level customization options are. *//* COMMONBRANCHING effects the BRANCHIF macro. The original macro * would load the ip in the body of the macro. This option causes a * branch to a common place where this is done. There seems no * disadvantage to doing it this way. */#ifndef COMMONBRANCHING#define COMMONBRANCHING 1#endif/* Private instrumentation code that is just useful for measuring changed * to the interpreter. */#ifndef INSTRUMENT#define INSTRUMENT 0#endif/* Turn this on to do a GC between every bytecode. (Very slow....) */#ifndef VERY_EXCESSIVE_GARBAGE_COLLECTION#define VERY_EXCESSIVE_GARBAGE_COLLECTION 0#endif/*========================================================================= * Setup default local register values if LOCALVMREGISTERS is enabled *=======================================================================*/#if LOCALVMREGISTERS/* IP = Instruction pointer */#ifndef IPISLOCAL#define IPISLOCAL 1#endif/* SP = (Operand) Stack pointer */#ifndef SPISLOCAL#define SPISLOCAL 1#endif/* LP = Locals Pointer */#ifndef LPISLOCAL#define LPISLOCAL 1#endif/* FP = Frame Pointer */#ifndef FPISLOCAL#define FPISLOCAL 0#endif/* CP = Constant Pool Pointer */#ifndef CPISLOCAL#define CPISLOCAL 0#endif#else/*========================================================================= * Setup default local register values if LOCALVMREGISTERS is not enabled *=======================================================================*/#ifdef IPISLOCAL#undef IPISLOCAL#endif#ifdef SPISLOCAL#undef SPISLOCAL#endif#ifdef LPISLOCAL#undef LPISLOCAL#endif#ifdef FPISLOCAL#undef FPISLOCAL#endif#ifdef CPISLOCAL#undef CPISLOCAL#endif#define IPISLOCAL 0#define FPISLOCAL 0#define SPISLOCAL 0#define LPISLOCAL 0#define CPISLOCAL 0#endif /* LOCALVMREGISTERS *//*========================================================================= * Extreme debug option to call the garbage collector before every bytecode *=======================================================================*/#if VERY_EXCESSIVE_GARBAGE_COLLECTION#define DO_VERY_EXCESSIVE_GARBAGE_COLLECTION { \ VMSAVE \ garbageCollect(0); \ VMRESTORE \}#else#if ASYNCHRONOUS_NATIVE_FUNCTIONS && EXCESSIVE_GARBAGE_COLLECTION#define DO_VERY_EXCESSIVE_GARBAGE_COLLECTION { \ extern bool_t veryExcessiveGCrequested; \ if (veryExcessiveGCrequested) { \ VMSAVE \ garbageCollect(0); \ VMRESTORE \ veryExcessiveGCrequested = FALSE; \ } \}#else#define DO_VERY_EXCESSIVE_GARBAGE_COLLECTION /**/#endif#endif/*========================================================================= * Instrumentation macros *=======================================================================*/#if INSTRUMENT#define INC_CALLS calls++;#define INC_RESHED reshed++;#define INC_BYTECODES bytecodes++;#define INC_SLOWCODES slowcodes++;#define INC_BRANCHES branches++;#else#define INC_CALLS /**/#define INC_RESHED /**/#define INC_BYTECODES /**/#define INC_SLOWCODES /**/#define INC_BRANCHES /**/#endif /* INSTRUMENT *//*========================================================================= * SELECT - Macros To define bytecode(s) *=======================================================================*/#define SELECT(l1) case l1: {#define SELECT2(l1, l2) case l1: case l2: {#define SELECT3(l1, l2, l3) case l1: case l2: case l3: {#define SELECT4(l1, l2, l3, l4) case l1: case l2: case l3: case l4: {#define SELECT5(l1, l2, l3, l4, l5) case l1: case l2: case l3: case l4: case l5: {#define SELECT6(l1, l2, l3, l4, l5, l6) case l1: case l2: case l3: case l4: case l5: case l6: {/*========================================================================= * DONE - To end a bytecode definition and increment ip *=======================================================================*/#define DONE(n) } goto next##n;/*========================================================================= * DONEX - To end a bytecode definition without goto *=======================================================================*/#define DONEX }/*========================================================================= * DONE_R - To end a bytecode definition and test for thread rescheduling *=======================================================================*/#define DONE_R } goto reschedulePoint;/*========================================================================= * CHECKARRAY - To check for valid array access *=======================================================================*/#define CHECKARRAY(thisArray, index) \ if (thisArray) { \ /* Check that the given index is within array boundaries */ \ if (index >= 0 && index < (long)thisArray->length) {/*========================================================================= * ENDCHECKARRAY - Finish the check for valid array access *=======================================================================*/#define ENDCHECKARRAY \ } else goto handleArrayIndexOutOfBoundsException; \ } else goto handleNullPointerException; \/*========================================================================= * CALL_VIRTUAL_METHOD - Branch to common code for Invokevirtual *=======================================================================*/#define CALL_VIRTUAL_METHOD { \ goto callMethod_virtual; \}/*========================================================================= * CALL_STATIC_METHOD - Branch to common code for Invokestatic *=======================================================================*/#define CALL_STATIC_METHOD { \ goto callMethod_static; \}/*========================================================================= * CALL_SPECIAL_METHOD - Branch to common code for Invokespecial *=======================================================================*/#define CALL_SPECIAL_METHOD { \ goto callMethod_special; \}/*========================================================================= * CALL_INTERFACE_METHOD - Branch to common code for Invokeinterface *=======================================================================*/#define CALL_INTERFACE_METHOD { \ goto callMethod_interface; \}/*========================================================================= * CHECK_NOT_NULL - Throw an exception of an object is null * * Use the following macro to place null checks where a NullPointerException * should be thrown (e.g. invoking a virtual method on a null object). * As this macro executes a continue statement, it must only be used where
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -