1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/cpu/x86/vm/jniTypes_x86.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,124 @@ 1.4 +/* 1.5 + * Copyright 1998-2003 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +// This file holds platform-dependent routines used to write primitive jni 1.29 +// types to the array of arguments passed into JavaCalls::call 1.30 + 1.31 +class JNITypes : AllStatic { 1.32 + // These functions write a java primitive type (in native format) 1.33 + // to a java stack slot array to be passed as an argument to JavaCalls:calls. 1.34 + // I.e., they are functionally 'push' operations if they have a 'pos' 1.35 + // formal parameter. Note that jlong's and jdouble's are written 1.36 + // _in reverse_ of the order in which they appear in the interpreter 1.37 + // stack. This is because call stubs (see stubGenerator_sparc.cpp) 1.38 + // reverse the argument list constructed by JavaCallArguments (see 1.39 + // javaCalls.hpp). 1.40 + 1.41 +private: 1.42 + 1.43 +#ifndef AMD64 1.44 + // 32bit Helper routines. 1.45 + static inline void put_int2r(jint *from, intptr_t *to) { *(jint *)(to++) = from[1]; 1.46 + *(jint *)(to ) = from[0]; } 1.47 + static inline void put_int2r(jint *from, intptr_t *to, int& pos) { put_int2r(from, to + pos); pos += 2; } 1.48 +#endif // AMD64 1.49 + 1.50 +public: 1.51 + // Ints are stored in native format in one JavaCallArgument slot at *to. 1.52 + static inline void put_int(jint from, intptr_t *to) { *(jint *)(to + 0 ) = from; } 1.53 + static inline void put_int(jint from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = from; } 1.54 + static inline void put_int(jint *from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = *from; } 1.55 + 1.56 +#ifdef AMD64 1.57 + // Longs are stored in native format in one JavaCallArgument slot at 1.58 + // *(to+1). 1.59 + static inline void put_long(jlong from, intptr_t *to) { 1.60 + *(jlong*) (to + 1) = from; 1.61 + } 1.62 + 1.63 + static inline void put_long(jlong from, intptr_t *to, int& pos) { 1.64 + *(jlong*) (to + 1 + pos) = from; 1.65 + pos += 2; 1.66 + } 1.67 + 1.68 + static inline void put_long(jlong *from, intptr_t *to, int& pos) { 1.69 + *(jlong*) (to + 1 + pos) = *from; 1.70 + pos += 2; 1.71 + } 1.72 +#else 1.73 + // Longs are stored in big-endian word format in two JavaCallArgument slots at *to. 1.74 + // The high half is in *to and the low half in *(to+1). 1.75 + static inline void put_long(jlong from, intptr_t *to) { put_int2r((jint *)&from, to); } 1.76 + static inline void put_long(jlong from, intptr_t *to, int& pos) { put_int2r((jint *)&from, to, pos); } 1.77 + static inline void put_long(jlong *from, intptr_t *to, int& pos) { put_int2r((jint *) from, to, pos); } 1.78 +#endif // AMD64 1.79 + 1.80 + // Oops are stored in native format in one JavaCallArgument slot at *to. 1.81 + static inline void put_obj(oop from, intptr_t *to) { *(oop *)(to + 0 ) = from; } 1.82 + static inline void put_obj(oop from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = from; } 1.83 + static inline void put_obj(oop *from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = *from; } 1.84 + 1.85 + // Floats are stored in native format in one JavaCallArgument slot at *to. 1.86 + static inline void put_float(jfloat from, intptr_t *to) { *(jfloat *)(to + 0 ) = from; } 1.87 + static inline void put_float(jfloat from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = from; } 1.88 + static inline void put_float(jfloat *from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = *from; } 1.89 + 1.90 +#undef _JNI_SLOT_OFFSET 1.91 +#ifdef AMD64 1.92 +#define _JNI_SLOT_OFFSET 1 1.93 + // Doubles are stored in native word format in one JavaCallArgument 1.94 + // slot at *(to+1). 1.95 + static inline void put_double(jdouble from, intptr_t *to) { 1.96 + *(jdouble*) (to + 1) = from; 1.97 + } 1.98 + 1.99 + static inline void put_double(jdouble from, intptr_t *to, int& pos) { 1.100 + *(jdouble*) (to + 1 + pos) = from; 1.101 + pos += 2; 1.102 + } 1.103 + 1.104 + static inline void put_double(jdouble *from, intptr_t *to, int& pos) { 1.105 + *(jdouble*) (to + 1 + pos) = *from; 1.106 + pos += 2; 1.107 + } 1.108 +#else 1.109 +#define _JNI_SLOT_OFFSET 0 1.110 + // Doubles are stored in big-endian word format in two JavaCallArgument slots at *to. 1.111 + // The high half is in *to and the low half in *(to+1). 1.112 + static inline void put_double(jdouble from, intptr_t *to) { put_int2r((jint *)&from, to); } 1.113 + static inline void put_double(jdouble from, intptr_t *to, int& pos) { put_int2r((jint *)&from, to, pos); } 1.114 + static inline void put_double(jdouble *from, intptr_t *to, int& pos) { put_int2r((jint *) from, to, pos); } 1.115 +#endif // AMD64 1.116 + 1.117 + 1.118 + // The get_xxx routines, on the other hand, actually _do_ fetch 1.119 + // java primitive types from the interpreter stack. 1.120 + // No need to worry about alignment on Intel. 1.121 + static inline jint get_int (intptr_t *from) { return *(jint *) from; } 1.122 + static inline jlong get_long (intptr_t *from) { return *(jlong *) (from + _JNI_SLOT_OFFSET); } 1.123 + static inline oop get_obj (intptr_t *from) { return *(oop *) from; } 1.124 + static inline jfloat get_float (intptr_t *from) { return *(jfloat *) from; } 1.125 + static inline jdouble get_double(intptr_t *from) { return *(jdouble *)(from + _JNI_SLOT_OFFSET); } 1.126 +#undef _JNI_SLOT_OFFSET 1.127 +};