src/cpu/zero/vm/jniTypes_zero.hpp

Thu, 27 May 2010 19:08:38 -0700

author
trims
date
Thu, 27 May 2010 19:08:38 -0700
changeset 1907
c18cbe5936b8
parent 1445
354d3184f6b2
child 2314
f95d63e2154a
permissions
-rw-r--r--

6941466: Oracle rebranding changes for Hotspot repositories
Summary: Change all the Sun copyrights to Oracle copyright
Reviewed-by: ohair

never@1445 1 /*
trims@1907 2 * Copyright (c) 1998, 2002, Oracle and/or its affiliates. All rights reserved.
never@1445 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
never@1445 4 *
never@1445 5 * This code is free software; you can redistribute it and/or modify it
never@1445 6 * under the terms of the GNU General Public License version 2 only, as
never@1445 7 * published by the Free Software Foundation.
never@1445 8 *
never@1445 9 * This code is distributed in the hope that it will be useful, but WITHOUT
never@1445 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
never@1445 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
never@1445 12 * version 2 for more details (a copy is included in the LICENSE file that
never@1445 13 * accompanied this code).
never@1445 14 *
never@1445 15 * You should have received a copy of the GNU General Public License version
never@1445 16 * 2 along with this work; if not, write to the Free Software Foundation,
never@1445 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
never@1445 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
never@1445 22 *
never@1445 23 */
never@1445 24
never@1445 25 // This file holds platform-dependent routines used to write primitive jni
never@1445 26 // types to the array of arguments passed into JavaCalls::call
never@1445 27
never@1445 28 class JNITypes : AllStatic {
never@1445 29 // These functions write a java primitive type (in native format)
never@1445 30 // to a java stack slot array to be passed as an argument to JavaCalls:calls.
never@1445 31 // I.e., they are functionally 'push' operations if they have a 'pos'
never@1445 32 // formal parameter. Note that jlong's and jdouble's are written
never@1445 33 // _in reverse_ of the order in which they appear in the interpreter
never@1445 34 // stack. This is because call stubs (see stubGenerator_zero.cpp)
never@1445 35 // reverse the argument list constructed by JavaCallArguments (see
never@1445 36 // javaCalls.hpp).
never@1445 37
never@1445 38 private:
never@1445 39 // Helper routines.
never@1445 40 static inline void put_int2 (jint *from, jint *to) { to[0] = from[0]; to[1] = from[1]; }
never@1445 41 static inline void put_int2 (jint *from, jint *to, int& pos) { put_int2 (from, (jint *)((intptr_t *)to + pos)); pos += 2; }
never@1445 42 static inline void put_int2r(jint *from, jint *to) { to[0] = from[1]; to[1] = from[0]; }
never@1445 43 static inline void put_int2r(jint *from, jint *to, int& pos) { put_int2r(from, (jint *)((intptr_t *)to + pos)); pos += 2; }
never@1445 44
never@1445 45 public:
never@1445 46 // Ints are stored in native format in one JavaCallArgument slot at *to.
never@1445 47 static inline void put_int(jint from, intptr_t *to) { *(jint *)(to + 0 ) = from; }
never@1445 48 static inline void put_int(jint from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = from; }
never@1445 49 static inline void put_int(jint *from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = *from; }
never@1445 50
never@1445 51 #ifdef _LP64
never@1445 52 // Longs are stored in native format in one JavaCallArgument slot at *(to+1).
never@1445 53 static inline void put_long(jlong from, intptr_t *to) { *(jlong *)(to + 1 + 0) = from; }
never@1445 54 static inline void put_long(jlong from, intptr_t *to, int& pos) { *(jlong *)(to + 1 + pos) = from; pos += 2; }
never@1445 55 static inline void put_long(jlong *from, intptr_t *to, int& pos) { *(jlong *)(to + 1 + pos) = *from; pos += 2; }
never@1445 56 #else
never@1445 57 // Longs are stored in reversed native word format in two JavaCallArgument slots at *to.
never@1445 58 // The high half is in *(to+1) and the low half in *to.
never@1445 59 static inline void put_long(jlong from, intptr_t *to) { put_int2r((jint *)&from, (jint *)to); }
never@1445 60 static inline void put_long(jlong from, intptr_t *to, int& pos) { put_int2r((jint *)&from, (jint *)to, pos); }
never@1445 61 static inline void put_long(jlong *from, intptr_t *to, int& pos) { put_int2r((jint *) from, (jint *)to, pos); }
never@1445 62 #endif
never@1445 63
never@1445 64 // Oops are stored in native format in one JavaCallArgument slot at *to.
never@1445 65 static inline void put_obj(oop from, intptr_t *to) { *(oop *)(to + 0 ) = from; }
never@1445 66 static inline void put_obj(oop from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = from; }
never@1445 67 static inline void put_obj(oop *from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = *from; }
never@1445 68
never@1445 69 // Floats are stored in native format in one JavaCallArgument slot at *to.
never@1445 70 static inline void put_float(jfloat from, intptr_t *to) { *(jfloat *)(to + 0 ) = from; }
never@1445 71 static inline void put_float(jfloat from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = from; }
never@1445 72 static inline void put_float(jfloat *from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = *from; }
never@1445 73
never@1445 74 #ifdef _LP64
never@1445 75 // Doubles are stored in native word format in one JavaCallArgument slot at *(to+1).
never@1445 76 static inline void put_double(jdouble from, intptr_t *to) { *(jdouble *)(to + 1 + 0) = from; }
never@1445 77 static inline void put_double(jdouble from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) = from; pos += 2; }
never@1445 78 static inline void put_double(jdouble *from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) = *from; pos += 2; }
never@1445 79 #else
never@1445 80 // Doubles are stored in reversed native word format in two JavaCallArgument slots at *to.
never@1445 81 static inline void put_double(jdouble from, intptr_t *to) { put_int2r((jint *)&from, (jint *)to); }
never@1445 82 static inline void put_double(jdouble from, intptr_t *to, int& pos) { put_int2r((jint *)&from, (jint *)to, pos); }
never@1445 83 static inline void put_double(jdouble *from, intptr_t *to, int& pos) { put_int2r((jint *) from, (jint *)to, pos); }
never@1445 84 #endif
never@1445 85
never@1445 86 // The get_xxx routines, on the other hand, actually _do_ fetch
never@1445 87 // java primitive types from the interpreter stack.
never@1445 88 static inline jint get_int(intptr_t *from) { return *(jint *)from; }
never@1445 89
never@1445 90 #ifdef _LP64
never@1445 91 static inline jlong get_long(intptr_t *from) { return *(jlong *)from; }
never@1445 92 #else
never@1445 93 static inline jlong get_long(intptr_t *from) { return ((jlong)(*( signed int *)((jint *)from )) << 32) |
never@1445 94 ((jlong)(*(unsigned int *)((jint *)from + 1)) << 0); }
never@1445 95 #endif
never@1445 96
never@1445 97 static inline oop get_obj(intptr_t *from) { return *(oop *)from; }
never@1445 98 static inline jfloat get_float(intptr_t *from) { return *(jfloat *)from; }
never@1445 99
never@1445 100 #ifdef _LP64
never@1445 101 static inline jdouble get_double(intptr_t *from) { return *(jdouble *)from; }
never@1445 102 #else
never@1445 103 static inline jdouble get_double(intptr_t *from) { jlong jl = ((jlong)(*( signed int *)((jint *)from )) << 32) |
never@1445 104 ((jlong)(*(unsigned int *)((jint *)from + 1)) << 0);
never@1445 105 return *(jdouble *)&jl; }
never@1445 106 #endif
never@1445 107
never@1445 108 };

mercurial