📄 interpret.c
字号:
/*0001*//*
/*0002./ * Copyright (c) 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
/*0003./ *
/*0004./ * This software is the confidential and proprietary information of Sun
/*0005./ * Microsystems, Inc. ("Confidential Information"). You shall not
/*0006./ * disclose such Confidential Information and shall use it only in
/*0007./ * accordance with the terms of the license agreement you entered into
/*0008./ * with Sun.
/*0009./ *
/*0010./ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
/*0011./ * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
/*0012./ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
/*0013./ * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
/*0014./ * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
/*0015./ * THIS SOFTWARE OR ITS DERIVATIVES.
/*0016./ *
/*0017./ */
/*0018*/
/*0019*//*=========================================================================
/*0020./ * SYSTEM: KVM
/*0021./ * SUBSYSTEM: Bytecode interpreter
/*0022./ * FILE: interpret.c
/*0023./ * OVERVIEW: This file defines the general routines used by the
/*0024./ * Java bytecode interpreter.
/*0025./ * AUTHOR: Antero Taivalsaari, Sun Labs
/*0026./ * Major reorganization by Nik Shaylor 9/5/2000
/*0027./ * NOTE: In KVM 1.0.2, the interpreter has been restructured for
/*0028./ * better performance, but without sacrificing portability.
/*0029./ * The high-level interpreter loop is now defined in file
/*0030./ * execute.c. Actual bytecode definitions are in file
/*0031./ * bytecodes.c. Various high-level compilation flags
/*0032./ * for the interpreter have been documented in main.h
/*0033./ * and in the KVM Porting Guide.
/*0034./ *=======================================================================*/
/*0035*/
/*0036*//*=========================================================================
/*0037./ * Local include files
/*0038./ *=======================================================================*/
/*0039*/
/*0040*/#include <global.h>
/*0041*/
/*0042*//*=========================================================================
/*0043./ * Virtual machine global registers (see description in Interpreter.h)
/*0044./ *=======================================================================*/
/*0045*/
/*0046*/BYTE* ip_global; /* Instruction pointer (program counter) */
/*0047*/FRAME fp_global; /* Current frame pointer */
/*0048*/cell* sp_global; /* Execution stack pointer */
/*0049*/cell* lp_global; /* Local variable pointer */
/*0050*/CONSTANTPOOL cp_global; /* Constant pool pointer */
/*0051*/
/*0052*/#define ip ip_global
/*0053*/#define fp fp_global
/*0054*/#define sp sp_global
/*0055*/#define lp lp_global
/*0056*/#define cp cp_global
/*0057*/
/*0294*/
/*0295*//*=========================================================================
/*0296./ * Interpreter tracing & profiling functions
/*0297./ *=======================================================================*/
/*0298*/
/*0299*//*=========================================================================
/*0300./ * FUNCTION: getByteCodeName()
/*0301./ * TYPE: public debugging operation
/*0302./ * OVERVIEW: Given a bytecode value, get the mnemonic name of
/*0303./ * the bytecode.
/*0304./ * INTERFACE:
/*0305./ * parameters: bytecode as an integer
/*0306./ * returns: constant string containing the name of the bytecode
/*0307./ *=======================================================================*/
/*0308*/
/*0317*/# define getByteCodeName(token) ""
/*0319*/
/*0468*//*=========================================================================
/*0469./ * FUNCTION: fatalSlotError()
/*0470./ * TYPE: public debugging operation (consistency checking)
/*0471./ * OVERVIEW: Report missing field/method and exit
/*0472./ * INTERFACE:
/*0473./ * parameters: CONSTANTPOOL constantPool, int cpIndex
/*0474./ * returns: <nothing>
/*0475./ *=======================================================================*/
/*0476*/
/*0477*/void fatalSlotError(CONSTANTPOOL constantPool, int cpIndex) {
/*0478*/ CONSTANTPOOL_ENTRY thisEntry = &constantPool->entries[cpIndex];
/*0479*/ unsigned char thisTag = CONSTANTPOOL_TAG(constantPool, cpIndex);
/*0480*/ if (thisTag & CP_CACHEBIT) {
/*0481*/ if (thisTag == CONSTANT_Fieldref) {
/*0482*/ sprintf(str_buffer, KVM_MSG_NO_SUCH_FIELD_2STRPARAMS,
/*0483*/ fieldName((FIELD)(thisEntry->cache)),
/*0484*/ getFieldSignature((FIELD)thisEntry->cache));
/*0485*/ } else {
/*0486*/ sprintf(str_buffer, KVM_MSG_NO_SUCH_METHOD_2STRPARAMS,
/*0487*/ methodName((METHOD)thisEntry->cache),
/*0488*/ getMethodSignature((METHOD)thisEntry->cache));
/*0489*/ }
/*0490*/ } else {
/*0491*/ int nameTypeIndex = thisEntry->method.nameTypeIndex;
/*0492*/ NameTypeKey nameTypeKey =
/*0493*/ constantPool->entries[nameTypeIndex].nameTypeKey;
/*0494*/ NameKey nameKey = nameTypeKey.nt.nameKey;
/*0495*/ MethodTypeKey typeKey = nameTypeKey.nt.typeKey;
/*0496*/
/*0497*/ if (thisTag == CONSTANT_Fieldref) {
/*0498*/ sprintf(str_buffer, KVM_MSG_NO_SUCH_FIELD_2STRPARAMS,
/*0499*/ change_Key_to_Name(nameKey, NULL),
/*0500*/ change_Key_to_FieldSignature(typeKey));
/*0501*/ } else {
/*0502*/ sprintf(str_buffer, KVM_MSG_NO_SUCH_METHOD_2STRPARAMS,
/*0503*/ change_Key_to_Name(nameKey, NULL),
/*0504*/ change_Key_to_MethodSignature(typeKey));
/*0505*/ }
/*0506*/ }
/*0507*/ fatalError(str_buffer);
/*0508*/}
/*0509*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -