⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cache.h

📁 java 1.1 gemini 08_16
💻 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:
 * ---------
 *  cache.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 (c) 1998-2002 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: Internal runtime structures
 * FILE:      cache.h
 * OVERVIEW:  Inline caching support.
 * AUTHOR:    Antero Taivalsaari, Sun Labs
 *=======================================================================*/

/*=========================================================================
 * COMMENTS:
 * In order to reach reasonable execution performance without fancy
 * compilation techniques, we are using a simple Deutsch-Schiffman
 * Smalltalk-style inline caching for optimizing message sending
 * and other bytecodes.
 *
 * If the optimization mode is enabled (ENABLEFASTBYTECODES), many
 * bytecodes are patched at runtime with inline cache entries so
 * that we can avoid costly constant pool and method table
 * lookup in most situations. Since Java message sending
 * bytecodes do not have enough space for truly inlined
 * parameters, a special inline cache area is allocated
 * separately and individual inline cache entries are
 * referenced by indices from the code.
 *
 * Code before optimization:
 *             ...  +----+--------+ ...
 *                  | BC | PARAM  |     BC = "slow" bytecode (8 bits)
 *             ...  +----+--------+ ... PARAM = parameter for BC (16 bits)
 *
 * Code after optimization:
 *             ...  +----+--------+ ...
 *                  | BF | ICIDX  |     BF    = "fast" bytecode (8 bits)
 *             ...  +----+--------+ ... ICIDX = inline cache index (16 bits)
 *
 * The optimization process is fully reversible and repeatable,
 * i.e., we can de-optimize code at any point if necessary.
 *=======================================================================*/

/*=========================================================================
 * Include files
 *=======================================================================*/

/*=========================================================================
 * Global variables and definitions
 *=======================================================================*/

/* The master inline cache in the system */
/* In principle, each thread could have its own inline cache area, */
/* but this would not improve performance substantially. */
extern ICACHE InlineCache;

/* Index of the next inline cache entry to be used */
extern int InlineCachePointer;

/*=========================================================================
 * Inline cache structures
 *=======================================================================*/

/*=========================================================================
 * COMMENTS:
 * ICACHE is a structure for storing individual inline cache entries.
 * The whole inline cache is simply a contiguous array of ICACHE entries.
 *
 * Each inline cache entry contains a forward pointer to the actual method
 * to be executed, a backpointer to the location of code referring to
 * to inline cache entry, and the original contents of code (before
 * inline patching) so that inline cached can be removed if necessary.
 *
 * There is a fixed number of inline cache entries in the system.
 * Once the inline cache area is full, we start reusing the oldest
 * entries starting from the beginning of the icache area.
 * The code of the methods referring to the reused icache entries
 * is replaced with the original (pre-inline cache) code. In other
 * words, the whole inline caching process is completely reversable
 * and repeatable.
 *
 * Note: in order to avoid garbage collection problems, we
 * do not store any dynamic heap pointers in inline caches!
 * This ensures that we can simply ignore the whole inline cache
 * area during garbage collection.
 *=======================================================================*/

/* ICACHE (allocated in inline cache area) */
struct icacheStruct {
    cell* contents;  /* Cache contents (used differently in different entries) */
    BYTE* codeLoc;   /* Backpointer to the code location using this icache */
    short origParam; /* Original bytecode parameter in (codeLoc+1) */
    BYTE  origInst;  /* Original bytecode instruction in codeLoc */
};

#define SIZEOF_ICACHE            StructSizeInCells(icacheStruct)

#if ENABLEFASTBYTECODES

/*=========================================================================
 * Constructor/destructors for (re)initializing inline caching
 *=======================================================================*/

void InitializeInlineCaching(void);
void FinalizeInlineCaching(void);

/*=========================================================================
 * Constructors/destructors for individual icache entries
 *=======================================================================*/

int createInlineCacheEntry(cell* contents, BYTE* originalCode);

/*=========================================================================
 * Operations on individual icache entries
 *=======================================================================*/

ICACHE getInlineCache(int index);

/*=========================================================================
 * Macro for high performance!
 *=======================================================================*/

#if ENABLE_JAVA_DEBUGGER

#define REPLACE_BYTECODE(ip, bytecode)          \
        if (*ip == BREAKPOINT) {                \
            VMSAVE                              \
            replaceEventOpcode(bytecode);       \
            VMRESTORE                           \
        } else {                                \
            *ip = bytecode;                     \
        }

#else /* !ENABLE_JAVA_DEBUGGER */

#define REPLACE_BYTECODE(ip, bytecode) *ip = bytecode;

#endif /* ENABLE_JAVA_DEBUGGER */

#define CREATE_CACHE_ENTRY(cellp, ip)           \
        iCacheIndex = createInlineCacheEntry((cell*)cellp, ip);

#define GETINLINECACHE(index) (&InlineCache[index])

#else /* !ENABLEFASTBYTECODES */

#define InitializeInlineCaching()
#define FinalizeInlineCaching()

#define createInlineCacheEntry(contents, originalCode) 0
#define getInlineCache(index) NULL

#endif /* ENABLEFASTBYTECODES */


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -