Fri, 13 Mar 2009 11:35:17 -0700
6378821: bitCount() should use POPC on SPARC processors and AMD+10h
Summary: bitCount() should use POPC on SPARC processors where POPC is implemented directly in hardware.
Reviewed-by: kvn, never
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 1998-2003 Sun Microsystems, Inc. All Rights Reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | // This file holds platform-dependent routines used to write primitive jni |
duke@435 | 26 | // types to the array of arguments passed into JavaCalls::call |
duke@435 | 27 | |
duke@435 | 28 | class JNITypes : AllStatic { |
duke@435 | 29 | // These functions write a java primitive type (in native format) |
duke@435 | 30 | // to a java stack slot array to be passed as an argument to JavaCalls:calls. |
duke@435 | 31 | // I.e., they are functionally 'push' operations if they have a 'pos' |
duke@435 | 32 | // formal parameter. Note that jlong's and jdouble's are written |
duke@435 | 33 | // _in reverse_ of the order in which they appear in the interpreter |
duke@435 | 34 | // stack. This is because call stubs (see stubGenerator_sparc.cpp) |
duke@435 | 35 | // reverse the argument list constructed by JavaCallArguments (see |
duke@435 | 36 | // javaCalls.hpp). |
duke@435 | 37 | |
duke@435 | 38 | private: |
duke@435 | 39 | |
duke@435 | 40 | #ifndef AMD64 |
duke@435 | 41 | // 32bit Helper routines. |
duke@435 | 42 | static inline void put_int2r(jint *from, intptr_t *to) { *(jint *)(to++) = from[1]; |
duke@435 | 43 | *(jint *)(to ) = from[0]; } |
duke@435 | 44 | static inline void put_int2r(jint *from, intptr_t *to, int& pos) { put_int2r(from, to + pos); pos += 2; } |
duke@435 | 45 | #endif // AMD64 |
duke@435 | 46 | |
duke@435 | 47 | public: |
duke@435 | 48 | // Ints are stored in native format in one JavaCallArgument slot at *to. |
duke@435 | 49 | static inline void put_int(jint from, intptr_t *to) { *(jint *)(to + 0 ) = from; } |
duke@435 | 50 | static inline void put_int(jint from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = from; } |
duke@435 | 51 | static inline void put_int(jint *from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = *from; } |
duke@435 | 52 | |
duke@435 | 53 | #ifdef AMD64 |
duke@435 | 54 | // Longs are stored in native format in one JavaCallArgument slot at |
duke@435 | 55 | // *(to+1). |
duke@435 | 56 | static inline void put_long(jlong from, intptr_t *to) { |
duke@435 | 57 | *(jlong*) (to + 1) = from; |
duke@435 | 58 | } |
duke@435 | 59 | |
duke@435 | 60 | static inline void put_long(jlong from, intptr_t *to, int& pos) { |
duke@435 | 61 | *(jlong*) (to + 1 + pos) = from; |
duke@435 | 62 | pos += 2; |
duke@435 | 63 | } |
duke@435 | 64 | |
duke@435 | 65 | static inline void put_long(jlong *from, intptr_t *to, int& pos) { |
duke@435 | 66 | *(jlong*) (to + 1 + pos) = *from; |
duke@435 | 67 | pos += 2; |
duke@435 | 68 | } |
duke@435 | 69 | #else |
duke@435 | 70 | // Longs are stored in big-endian word format in two JavaCallArgument slots at *to. |
duke@435 | 71 | // The high half is in *to and the low half in *(to+1). |
duke@435 | 72 | static inline void put_long(jlong from, intptr_t *to) { put_int2r((jint *)&from, to); } |
duke@435 | 73 | static inline void put_long(jlong from, intptr_t *to, int& pos) { put_int2r((jint *)&from, to, pos); } |
duke@435 | 74 | static inline void put_long(jlong *from, intptr_t *to, int& pos) { put_int2r((jint *) from, to, pos); } |
duke@435 | 75 | #endif // AMD64 |
duke@435 | 76 | |
duke@435 | 77 | // Oops are stored in native format in one JavaCallArgument slot at *to. |
duke@435 | 78 | static inline void put_obj(oop from, intptr_t *to) { *(oop *)(to + 0 ) = from; } |
duke@435 | 79 | static inline void put_obj(oop from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = from; } |
duke@435 | 80 | static inline void put_obj(oop *from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = *from; } |
duke@435 | 81 | |
duke@435 | 82 | // Floats are stored in native format in one JavaCallArgument slot at *to. |
duke@435 | 83 | static inline void put_float(jfloat from, intptr_t *to) { *(jfloat *)(to + 0 ) = from; } |
duke@435 | 84 | static inline void put_float(jfloat from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = from; } |
duke@435 | 85 | static inline void put_float(jfloat *from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = *from; } |
duke@435 | 86 | |
duke@435 | 87 | #undef _JNI_SLOT_OFFSET |
duke@435 | 88 | #ifdef AMD64 |
duke@435 | 89 | #define _JNI_SLOT_OFFSET 1 |
duke@435 | 90 | // Doubles are stored in native word format in one JavaCallArgument |
duke@435 | 91 | // slot at *(to+1). |
duke@435 | 92 | static inline void put_double(jdouble from, intptr_t *to) { |
duke@435 | 93 | *(jdouble*) (to + 1) = from; |
duke@435 | 94 | } |
duke@435 | 95 | |
duke@435 | 96 | static inline void put_double(jdouble from, intptr_t *to, int& pos) { |
duke@435 | 97 | *(jdouble*) (to + 1 + pos) = from; |
duke@435 | 98 | pos += 2; |
duke@435 | 99 | } |
duke@435 | 100 | |
duke@435 | 101 | static inline void put_double(jdouble *from, intptr_t *to, int& pos) { |
duke@435 | 102 | *(jdouble*) (to + 1 + pos) = *from; |
duke@435 | 103 | pos += 2; |
duke@435 | 104 | } |
duke@435 | 105 | #else |
duke@435 | 106 | #define _JNI_SLOT_OFFSET 0 |
duke@435 | 107 | // Doubles are stored in big-endian word format in two JavaCallArgument slots at *to. |
duke@435 | 108 | // The high half is in *to and the low half in *(to+1). |
duke@435 | 109 | static inline void put_double(jdouble from, intptr_t *to) { put_int2r((jint *)&from, to); } |
duke@435 | 110 | static inline void put_double(jdouble from, intptr_t *to, int& pos) { put_int2r((jint *)&from, to, pos); } |
duke@435 | 111 | static inline void put_double(jdouble *from, intptr_t *to, int& pos) { put_int2r((jint *) from, to, pos); } |
duke@435 | 112 | #endif // AMD64 |
duke@435 | 113 | |
duke@435 | 114 | |
duke@435 | 115 | // The get_xxx routines, on the other hand, actually _do_ fetch |
duke@435 | 116 | // java primitive types from the interpreter stack. |
duke@435 | 117 | // No need to worry about alignment on Intel. |
duke@435 | 118 | static inline jint get_int (intptr_t *from) { return *(jint *) from; } |
duke@435 | 119 | static inline jlong get_long (intptr_t *from) { return *(jlong *) (from + _JNI_SLOT_OFFSET); } |
duke@435 | 120 | static inline oop get_obj (intptr_t *from) { return *(oop *) from; } |
duke@435 | 121 | static inline jfloat get_float (intptr_t *from) { return *(jfloat *) from; } |
duke@435 | 122 | static inline jdouble get_double(intptr_t *from) { return *(jdouble *)(from + _JNI_SLOT_OFFSET); } |
duke@435 | 123 | #undef _JNI_SLOT_OFFSET |
duke@435 | 124 | }; |