📄 interpret.h
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* interpret.h
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
*
*
* Author:
* -------
*
*
*==============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/
/*
* Copyright ?2003 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*/
/*=========================================================================
* SYSTEM: KVM
* SUBSYSTEM: Bytecode interpreter
* FILE: interpret.h
* OVERVIEW: This file defines the general routines used by the
* Java bytecode interpreter.
* AUTHOR: Antero Taivalsaari, Sun Labs, 1998
* Major reorganization by Nik Shaylor 9/5/2000
* NOTE: In KVM 1.0.2, the interpreter was restructured for
* better performance, but without sacrificing portability.
* The high-level interpreter loop is now defined in file
* execute.c. Actual bytecode definitions are in file
* bytecodes.c. Various high-level compilation flags
* for the interpreter have been documented in main.h
* and in the KVM Porting Guide.
*=======================================================================*/
#ifndef _INTERPRET_H
#define _INTERPRET_H
/*=========================================================================
* Include files
*=======================================================================*/
#include "events.h"
/*=========================================================================
* Virtual machine global registers
*=======================================================================*/
/*=========================================================================
* These variables form the heart of the virtual machine. IP holds
* the current instruction pointer, SP holds a pointer to the top
* of the execution stack, FP holds a pointer to the currently active
* stack frame, LP holds a pointer to the local variables of the
* current stack frame, and CP is a pointer to the current constant
* pool.
*
* Note that these values are thread-specific, i.e., their
* values are changed every time a thread switch takes place.
*=========================================================================
* GENERAL COMMENT:
* The main reason why virtual machines written in high-level languages
* such as C/C++ are inherently slower than machine-coded ones is that
* C/C++ does not provide any mechanism to allocate global variables
* in hardware registers. KVM provides a compilation option
* (LOCALVMREGISTERS, see main.h) to accomplish this in a portable
* fashion.
*=======================================================================*/
#if ASMBYTECODE
struct GlobalStateStruct {
cell* gs_sp; /* Execution stack pointer */
BYTE* gs_ip; /* Instruction pointer (program counter) */
cell* gs_lp; /* Local variable pointer */
CONSTANTPOOL gs_cp; /* Constant pool pointer */
int* firstbytecodeaddrR; /* for ASM interpreter */
};
extern FRAME fp_global;
#else
struct GlobalStateStruct {
#if UPTODOWNSTACK
cell* gs_sp; /* Execution stack pointer */
BYTE* gs_ip; /* Instruction pointer (program counter) */
#else
BYTE* gs_ip; /* Instruction pointer (program counter) */
cell* gs_sp; /* Execution stack pointer */
#endif /* UPTODOWNSTACK */
cell* gs_lp; /* Local variable pointer */
CONSTANTPOOL gs_cp; /* Constant pool pointer */
FRAME gs_fp; /* Current frame pointer */
};
#endif /* ASMBYTECODE */
extern struct GlobalStateStruct GlobalState;
#define ip_global GlobalState.gs_ip
#define sp_global GlobalState.gs_sp
#define lp_global GlobalState.gs_lp
#define cp_global GlobalState.gs_cp
#if !ASMBYTECODE
#define fp_global GlobalState.gs_fp
#endif /* end of #if !ASMBYTECODE */
/* These get and set macros provide better control */
/* over the way VM registers are accessed. */
#define getIP() (ip_global)
#define getSP() (sp_global)
#define getLP() (lp_global)
#define getFP() (fp_global)
#define getCP() (cp_global)
#define setIP(x) (ip_global = (x))
#define setSP(x) (sp_global = (x))
#define setLP(x) (lp_global = (x))
#define setFP(x) (fp_global = (x))
#define setCP(x) (cp_global = (x))
/*=========================================================================
* Bytecode declarations
*=======================================================================*/
typedef enum {
NOP = 0x00,
ACONST_NULL = 0x01,
ICONST_M1 = 0x02,
ICONST_0 = 0x03,
ICONST_1 = 0x04,
ICONST_2 = 0x05,
ICONST_3 = 0x06,
ICONST_4 = 0x07,
ICONST_5 = 0x08,
LCONST_0 = 0x09,
LCONST_1 = 0x0A,
FCONST_0 = 0x0B,
FCONST_1 = 0x0C,
FCONST_2 = 0x0D,
DCONST_0 = 0x0E,
DCONST_1 = 0x0F,
BIPUSH = 0x10,
SIPUSH = 0x11,
LDC = 0x12,
LDC_W = 0x13,
LDC2_W = 0x14,
ILOAD = 0x15,
LLOAD = 0x16,
FLOAD = 0x17,
DLOAD = 0x18,
ALOAD = 0x19,
ILOAD_0 = 0x1A,
ILOAD_1 = 0x1B,
ILOAD_2 = 0x1C,
ILOAD_3 = 0x1D,
LLOAD_0 = 0x1E,
LLOAD_1 = 0x1F,
LLOAD_2 = 0x20,
LLOAD_3 = 0x21,
FLOAD_0 = 0x22,
FLOAD_1 = 0x23,
FLOAD_2 = 0x24,
FLOAD_3 = 0x25,
DLOAD_0 = 0x26,
DLOAD_1 = 0x27,
DLOAD_2 = 0x28,
DLOAD_3 = 0x29,
ALOAD_0 = 0x2A,
ALOAD_1 = 0x2B,
ALOAD_2 = 0x2C,
ALOAD_3 = 0x2D,
IALOAD = 0x2E,
LALOAD = 0x2F,
FALOAD = 0x30,
DALOAD = 0x31,
AALOAD = 0x32,
BALOAD = 0x33,
CALOAD = 0x34,
SALOAD = 0x35,
ISTORE = 0x36,
LSTORE = 0x37,
FSTORE = 0x38,
DSTORE = 0x39,
ASTORE = 0x3A,
ISTORE_0 = 0x3B,
ISTORE_1 = 0x3C,
ISTORE_2 = 0x3D,
ISTORE_3 = 0x3E,
LSTORE_0 = 0x3F,
LSTORE_1 = 0x40,
LSTORE_2 = 0x41,
LSTORE_3 = 0x42,
FSTORE_0 = 0x43,
FSTORE_1 = 0x44,
FSTORE_2 = 0x45,
FSTORE_3 = 0x46,
DSTORE_0 = 0x47,
DSTORE_1 = 0x48,
DSTORE_2 = 0x49,
DSTORE_3 = 0x4A,
ASTORE_0 = 0x4B,
ASTORE_1 = 0x4C,
ASTORE_2 = 0x4D,
ASTORE_3 = 0x4E,
IASTORE = 0x4F,
LASTORE = 0x50,
FASTORE = 0x51,
DASTORE = 0x52,
AASTORE = 0x53,
BASTORE = 0x54,
CASTORE = 0x55,
SASTORE = 0x56,
POP = 0x57,
POP2 = 0x58,
DUP = 0x59,
DUP_X1 = 0x5A,
DUP_X2 = 0x5B,
DUP2 = 0x5C,
DUP2_X1 = 0x5D,
DUP2_X2 = 0x5E,
SWAP = 0x5F,
IADD = 0x60,
LADD = 0x61,
FADD = 0x62,
DADD = 0x63,
ISUB = 0x64,
LSUB = 0x65,
FSUB = 0x66,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -