directmem.h
来自「This is a resource based on j2me embedde」· C头文件 代码 · 共 1,006 行 · 第 1/3 页
H
1,006 行
/* * @(#)directmem.h 1.57 06/10/10 * * Copyright 1990-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). * * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. * *//* * This file is the definition of the direct memory interface. All * Java object and array accesses must go through this interface. */#ifndef _INCLUDED_DIRECTMEM_H#define _INCLUDED_DIRECTMEM_H#include "javavm/include/defs.h"#include "javavm/include/objects.h"#include "javavm/include/cstates.h"#include "javavm/include/interpreter.h"#include "javavm/include/utils.h"#include "javavm/include/globals.h"/* * This file is generated from the GC choice given at build time. */#include "generated/javavm/include/gc_config.h"#include "javavm/include/porting/doubleword.h"#include "javavm/include/porting/memory.h"#include "javavm/include/clib.h"/* * Read/write barriers (applying to arrays as well as objects) * * 1) Reference-typed (for reference-typed object fields and array elements) * 2) Non-reference typed * a) 64-bit wide (for long and double fields and array elements) * b) Int and Float * c) Short and Char * d) Byte and Bool * * There are a total of 8 read and 8 write barriers. * * The barriers are invoked right before the read or write takes * place. * * If a given type of barrier is not supplied by a particular GC * implementation, we just provide an empty implementation. * * Read barriers look like: * * CVMgcimplReadBarrier<T>(CVMObject* directObj, * <slotT>* slotAddr); * * where <T> is one of Int,Float,Short,Char,Bool,Byte,64 or Ref * and the corresponding <slotT> is one of * CVMJava{Int,Float,Short,Char,Bool,Byte,32} or CVMObject*. * * CVMgcimplReadBarrier<T> is called right before the system reads * the slot with address 'slotAddr' from object 'directObj'. * * Write barriers are very similar: * * CVMgcimplWriteBarrier<T>(CVMObject* directObj, * <slotT>* slotAddr, * <slotT> rhsValue); * * where <T> is one of Int,Float,Short,Char,Bool,Byte or Ref * and the corresponding <slotT> is one of * CVMJava{Int,Float,Short,Char,Bool,Byte} or CVMObject*. * * 64-bit value write barriers look very slightly different: * * CVMgcimplWriteBarrier64(CVMObject* directObj, * CVMJavaVal32* slotAddr, * CVMJavaVal32* rhsValue); * * in that rhsValue is a CVMJavaVal32* and not a 64-bit value * * CVMgcimplWriteBarrier<T> is called right before the system writes * the value 'rhsValue' to the slot with address 'slotAddr' in object * 'directObj'. *//* * If we don't have any non-reference barriers, then we can optimize * CVMjniGetPrimitiveArrayCritical and CVMjniReleasePrimitiveArrayCritical. */#if defined(CVMgcimplReadBarrierByte) || \ defined(CVMgcimplReadBarrierBoolean) || \ defined(CVMgcimplReadBarrierShort) || \ defined(CVMgcimplReadBarrierChar) || \ defined(CVMgcimplReadBarrierInt) || \ defined(CVMgcimplReadBarrierFloat) || \ defined(CVMgcimplReadBarrier64) || \ defined(CVMgcimplWriteBarrierByte) || \ defined(CVMgcimplWriteBarrierBoolean) || \ defined(CVMgcimplWriteBarrierShort) || \ defined(CVMgcimplWriteBarrierChar) || \ defined(CVMgcimplWriteBarrierInt) || \ defined(CVMgcimplWriteBarrierFloat) || \ defined(CVMgcimplWriteBarrier64)#define CVMGC_HAS_NONREF_BARRIERS#endif#undef CVMGC_HAS_NO_BYTE_READ_BARRIER#undef CVMGC_HAS_NO_BYTE_WRITE_BARRIER#undef CVMGC_HAS_NO_BOOLEAN_READ_BARRIER#undef CVMGC_HAS_NO_BOOLEAN_WRITE_BARRIER#undef CVMGC_HAS_NO_SHORT_READ_BARRIER#undef CVMGC_HAS_NO_SHORT_WRITE_BARRIER#undef CVMGC_HAS_NO_CHAR_READ_BARRIER#undef CVMGC_HAS_NO_CHAR_WRITE_BARRIER#undef CVMGC_HAS_NO_INT_READ_BARRIER#undef CVMGC_HAS_NO_INT_WRITE_BARRIER#undef CVMGC_HAS_NO_FLOAT_READ_BARRIER#undef CVMGC_HAS_NO_FLOAT_WRITE_BARRIER#undef CVMGC_HAS_NO_REF_READ_BARRIER#undef CVMGC_HAS_NO_REF_WRITE_BARRIER#undef CVMGC_HAS_NO_64BIT_READ_BARRIER#undef CVMGC_HAS_NO_64BIT_WRITE_BARRIER#ifndef CVMgcimplReadBarrierByte#define CVMgcimplReadBarrierByte(objRef, fieldLoc_)#define CVMGC_HAS_NO_BYTE_READ_BARRIER#endif#ifndef CVMgcimplReadBarrierBoolean#define CVMgcimplReadBarrierBoolean(objRef, fieldLoc_)#define CVMGC_HAS_NO_BOOLEAN_READ_BARRIER#endif#ifndef CVMgcimplReadBarrierShort#define CVMgcimplReadBarrierShort(objRef, fieldLoc_)#define CVMGC_HAS_NO_SHORT_READ_BARRIER#endif#ifndef CVMgcimplReadBarrierChar#define CVMgcimplReadBarrierChar(objRef, fieldLoc_)#define CVMGC_HAS_NO_CHAR_READ_BARRIER#endif#ifndef CVMgcimplReadBarrierInt#define CVMgcimplReadBarrierInt(objRef, fieldLoc_)#define CVMGC_HAS_NO_INT_READ_BARRIER#endif#ifndef CVMgcimplReadBarrierFloat#define CVMgcimplReadBarrierFloat(objRef, fieldLoc_)#define CVMGC_HAS_NO_FLOAT_READ_BARRIER#endif#ifndef CVMgcimplReadBarrierRef#define CVMgcimplReadBarrierRef(objRef, fieldLoc_)#define CVMGC_HAS_NO_REF_READ_BARRIER#endif#ifndef CVMgcimplReadBarrier64#define CVMgcimplReadBarrier64(objRef, fieldLoc_)#define CVMGC_HAS_NO_64BIT_READ_BARRIER#endif#ifndef CVMgcimplReadBarrierAddr#define CVMgcimplReadBarrierAddr(objRef, fieldLoc_)#define CVMGC_HAS_NO_ADDR_READ_BARRIER#endif#ifndef CVMgcimplWriteBarrierByte#define CVMgcimplWriteBarrierByte(objRef, fieldLoc_, rhs_)#define CVMGC_HAS_NO_BYTE_WRITE_BARRIER#endif#ifndef CVMgcimplWriteBarrierBoolean#define CVMgcimplWriteBarrierBoolean(objRef, fieldLoc_, rhs_)#define CVMGC_HAS_NO_BOOLEAN_WRITE_BARRIER#endif#ifndef CVMgcimplWriteBarrierShort#define CVMgcimplWriteBarrierShort(objRef, fieldLoc_, rhs_)#define CVMGC_HAS_NO_SHORT_WRITE_BARRIER#endif#ifndef CVMgcimplWriteBarrierChar#define CVMgcimplWriteBarrierChar(objRef, fieldLoc_, rhs_)#define CVMGC_HAS_NO_CHAR_WRITE_BARRIER#endif#ifndef CVMgcimplWriteBarrierInt#define CVMgcimplWriteBarrierInt(objRef, fieldLoc_, rhs_)#define CVMGC_HAS_NO_INT_WRITE_BARRIER#endif#ifndef CVMgcimplWriteBarrierFloat#define CVMgcimplWriteBarrierFloat(objRef, fieldLoc_, rhs_)#define CVMGC_HAS_NO_FLOAT_WRITE_BARRIER#endif#ifndef CVMgcimplWriteBarrierRef#define CVMgcimplWriteBarrierRef(objRef, fieldLoc_, rhs_)#define CVMGC_HAS_NO_REF_WRITE_BARRIER#endif#ifndef CVMgcimplWriteBarrierAddr#define CVMgcimplWriteBarrierAddr(objRef, fieldLoc_, rhs_)#define CVMGC_HAS_NO_ADDR_WRITE_BARRIER#endif#ifndef CVMgcimplWriteBarrier64#define CVMgcimplWriteBarrier64(objRef, fieldLoc_, location_)#define CVMGC_HAS_NO_64BIT_WRITE_BARRIER#endif/* * Array block copy, read and write routines. * * CVMD_arrayReadBody<type>(buf, arr, start, len) will read "len" * elements of type <type> from the array "arr" starting from index * "start". The elements will be written into the C buffer "buf". The * right read barrier will be invoked on an element by element basis. * * If a particular GC implementation defines * CVMgcimpArrayReadBody<type>, CVMD_arrayReadBody<type> will go * through that definition instead of the default. * * CVMD_arrayWriteBody<type>(buf, arr, start, len) will write "len" * elements of type <type> to the array "arr" starting from index * "start". The elements will be read from the C buffer "buf". The * right write barrier will be invoked on an element by element basis. * * If a particular GC implementation defines * CVMgcimpArrayWriteBody<type>, CVMD_arrayWriteBody<type> will go * through that definition instead of the default. * * CVMD_arrayCopy<type>(srcArr, srcIdx, dstArr, dstIdx, len) will copy * 'len' elements of type <type> from srcArr[srcIdx, srcIdx+len) into * dstArr[dstIdx, dstIdx+len). The right read and write barriers will * be invoked on an element by element basis. * * If a particular GC implementation defines * CVMgcimpArrayCopy<type>, CVMD_arrayCopy<type> will go * through that definition instead of the default. *//* * Default array block read, write and copy routines. */#define CVMDprivateDefaultArrayBodyRead(buf, arr, start, len, \ jType, accessor) \{ \ CVMJavaInt i; \ jType* bufPtr = (jType*)(buf); \ CVMassert((start) + (len) <= (arr)->length); \ for (i = (start); i < (start) + (len); i++, bufPtr++) { \ CVMD_arrayRead##accessor(arr, i, *bufPtr); \ } \}#define CVMDprivateDefaultArrayBodyWrite(buf, arr, start, len, \ jType, accessor) \{ \ CVMJavaInt i; \ jType* bufPtr = (jType*)(buf); \ CVMassert((start) + (len) <= (arr)->length); \ for (i = (start); i < (start) + (len); i++, bufPtr++) { \ CVMD_arrayWrite##accessor(arr, i, *bufPtr); \ } \}/* * The default no barrier version does what 'memmove' does. */#define CVMDprivateDefaultNoBarrierArrayCopy(srcArr, srcIdx, \ dstArr, dstIdx, \ len, jType, accessor) \{ \ jType volatile * srcElements_; \ jType volatile * dstElements_; \ CVMassert((srcIdx) + (len) <= (srcArr)->length); \ CVMassert((dstIdx) + (len) <= (dstArr)->length); \ srcElements_ = \ (jType volatile*)CVMDprivate_arrayElemLoc((srcArr), (srcIdx)); \ dstElements_ = \ (jType volatile*)CVMDprivate_arrayElemLoc((dstArr), (dstIdx)); \ CVMmemmove## accessor ((jType*)dstElements_, (jType*)srcElements_, \ (len) * sizeof(jType)); \}/* * The default does what 'memmove' does, but element-wise to get all the * barriers invoked */#define CVMDprivateDefaultArrayCopy(srcArr, srcIdx, \ dstArr, dstIdx, len, \ jType, accessor) \{ \ CVMJavaInt i, j; \ CVMassert((srcIdx) + (len) <= (srcArr)->length); \ CVMassert((dstIdx) + (len) <= (dstArr)->length); \ if (((dstArr) != (srcArr)) || ((dstIdx) < (srcIdx))) { \ for (i = (srcIdx), j = (dstIdx); i < (srcIdx) + (len); \ i++, j++) { \ jType elem; \ CVMD_arrayRead##accessor(srcArr, i, elem); \ CVMD_arrayWrite##accessor(dstArr, j, elem); \ } \ } else { \ for (i = (srcIdx) + (len) - 1, j = (dstIdx) + (len) - 1; \ i >= (srcIdx); \ i--, j--) { \ jType elem; \ CVMD_arrayRead##accessor(srcArr, i, elem); \ CVMD_arrayWrite##accessor(dstArr, j, elem); \ } \ } \
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?