src/cpu/zero/vm/jniTypes_zero.hpp

Wed, 22 Jan 2014 17:42:23 -0800

author
kvn
date
Wed, 22 Jan 2014 17:42:23 -0800
changeset 6503
a9becfeecd1b
parent 2314
f95d63e2154a
child 6876
710a3c8b516e
permissions
-rw-r--r--

Merge

never@1445 1 /*
stefank@2314 2 * Copyright (c) 1998, 2010, 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
stefank@2314 25 #ifndef CPU_ZERO_VM_JNITYPES_ZERO_HPP
stefank@2314 26 #define CPU_ZERO_VM_JNITYPES_ZERO_HPP
stefank@2314 27
stefank@2314 28 #include "memory/allocation.hpp"
stefank@2314 29 #include "oops/oop.hpp"
stefank@2314 30 #include "prims/jni.h"
stefank@2314 31
never@1445 32 // This file holds platform-dependent routines used to write primitive jni
never@1445 33 // types to the array of arguments passed into JavaCalls::call
never@1445 34
never@1445 35 class JNITypes : AllStatic {
never@1445 36 // These functions write a java primitive type (in native format)
never@1445 37 // to a java stack slot array to be passed as an argument to JavaCalls:calls.
never@1445 38 // I.e., they are functionally 'push' operations if they have a 'pos'
never@1445 39 // formal parameter. Note that jlong's and jdouble's are written
never@1445 40 // _in reverse_ of the order in which they appear in the interpreter
never@1445 41 // stack. This is because call stubs (see stubGenerator_zero.cpp)
never@1445 42 // reverse the argument list constructed by JavaCallArguments (see
never@1445 43 // javaCalls.hpp).
never@1445 44
never@1445 45 private:
never@1445 46 // Helper routines.
never@1445 47 static inline void put_int2 (jint *from, jint *to) { to[0] = from[0]; to[1] = from[1]; }
never@1445 48 static inline void put_int2 (jint *from, jint *to, int& pos) { put_int2 (from, (jint *)((intptr_t *)to + pos)); pos += 2; }
never@1445 49 static inline void put_int2r(jint *from, jint *to) { to[0] = from[1]; to[1] = from[0]; }
never@1445 50 static inline void put_int2r(jint *from, jint *to, int& pos) { put_int2r(from, (jint *)((intptr_t *)to + pos)); pos += 2; }
never@1445 51
never@1445 52 public:
never@1445 53 // Ints are stored in native format in one JavaCallArgument slot at *to.
never@1445 54 static inline void put_int(jint from, intptr_t *to) { *(jint *)(to + 0 ) = from; }
never@1445 55 static inline void put_int(jint from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = from; }
never@1445 56 static inline void put_int(jint *from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = *from; }
never@1445 57
never@1445 58 #ifdef _LP64
never@1445 59 // Longs are stored in native format in one JavaCallArgument slot at *(to+1).
never@1445 60 static inline void put_long(jlong from, intptr_t *to) { *(jlong *)(to + 1 + 0) = from; }
never@1445 61 static inline void put_long(jlong from, intptr_t *to, int& pos) { *(jlong *)(to + 1 + pos) = from; pos += 2; }
never@1445 62 static inline void put_long(jlong *from, intptr_t *to, int& pos) { *(jlong *)(to + 1 + pos) = *from; pos += 2; }
never@1445 63 #else
never@1445 64 // Longs are stored in reversed native word format in two JavaCallArgument slots at *to.
never@1445 65 // The high half is in *(to+1) and the low half in *to.
never@1445 66 static inline void put_long(jlong from, intptr_t *to) { put_int2r((jint *)&from, (jint *)to); }
never@1445 67 static inline void put_long(jlong from, intptr_t *to, int& pos) { put_int2r((jint *)&from, (jint *)to, pos); }
never@1445 68 static inline void put_long(jlong *from, intptr_t *to, int& pos) { put_int2r((jint *) from, (jint *)to, pos); }
never@1445 69 #endif
never@1445 70
never@1445 71 // Oops are stored in native format in one JavaCallArgument slot at *to.
never@1445 72 static inline void put_obj(oop from, intptr_t *to) { *(oop *)(to + 0 ) = from; }
never@1445 73 static inline void put_obj(oop from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = from; }
never@1445 74 static inline void put_obj(oop *from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = *from; }
never@1445 75
never@1445 76 // Floats are stored in native format in one JavaCallArgument slot at *to.
never@1445 77 static inline void put_float(jfloat from, intptr_t *to) { *(jfloat *)(to + 0 ) = from; }
never@1445 78 static inline void put_float(jfloat from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = from; }
never@1445 79 static inline void put_float(jfloat *from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = *from; }
never@1445 80
never@1445 81 #ifdef _LP64
never@1445 82 // Doubles are stored in native word format in one JavaCallArgument slot at *(to+1).
never@1445 83 static inline void put_double(jdouble from, intptr_t *to) { *(jdouble *)(to + 1 + 0) = from; }
never@1445 84 static inline void put_double(jdouble from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) = from; pos += 2; }
never@1445 85 static inline void put_double(jdouble *from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) = *from; pos += 2; }
never@1445 86 #else
never@1445 87 // Doubles are stored in reversed native word format in two JavaCallArgument slots at *to.
never@1445 88 static inline void put_double(jdouble from, intptr_t *to) { put_int2r((jint *)&from, (jint *)to); }
never@1445 89 static inline void put_double(jdouble from, intptr_t *to, int& pos) { put_int2r((jint *)&from, (jint *)to, pos); }
never@1445 90 static inline void put_double(jdouble *from, intptr_t *to, int& pos) { put_int2r((jint *) from, (jint *)to, pos); }
never@1445 91 #endif
never@1445 92
never@1445 93 // The get_xxx routines, on the other hand, actually _do_ fetch
never@1445 94 // java primitive types from the interpreter stack.
never@1445 95 static inline jint get_int(intptr_t *from) { return *(jint *)from; }
never@1445 96
never@1445 97 #ifdef _LP64
never@1445 98 static inline jlong get_long(intptr_t *from) { return *(jlong *)from; }
never@1445 99 #else
never@1445 100 static inline jlong get_long(intptr_t *from) { return ((jlong)(*( signed int *)((jint *)from )) << 32) |
never@1445 101 ((jlong)(*(unsigned int *)((jint *)from + 1)) << 0); }
never@1445 102 #endif
never@1445 103
never@1445 104 static inline oop get_obj(intptr_t *from) { return *(oop *)from; }
never@1445 105 static inline jfloat get_float(intptr_t *from) { return *(jfloat *)from; }
never@1445 106
never@1445 107 #ifdef _LP64
never@1445 108 static inline jdouble get_double(intptr_t *from) { return *(jdouble *)from; }
never@1445 109 #else
never@1445 110 static inline jdouble get_double(intptr_t *from) { jlong jl = ((jlong)(*( signed int *)((jint *)from )) << 32) |
never@1445 111 ((jlong)(*(unsigned int *)((jint *)from + 1)) << 0);
never@1445 112 return *(jdouble *)&jl; }
never@1445 113 #endif
never@1445 114
never@1445 115 };
stefank@2314 116
stefank@2314 117 #endif // CPU_ZERO_VM_JNITYPES_ZERO_HPP

mercurial