src/cpu/x86/vm/jniTypes_x86.hpp

Thu, 24 May 2018 17:06:56 +0800

author
aoqi
date
Thu, 24 May 2018 17:06:56 +0800
changeset 8604
04d83ba48607
parent 6876
710a3c8b516e
permissions
-rw-r--r--

Merge

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

mercurial