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