Tue, 26 Jul 2016 17:06:17 +0800
Add multiply word to GPR instruction (mul) in MIPS assembler.
aoqi@1 | 1 | /* |
aoqi@1 | 2 | * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. |
aoqi@1 | 3 | * Copyright (c) 2015, 2016, Loongson Technology. All rights reserved. |
aoqi@1 | 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@1 | 5 | * |
aoqi@1 | 6 | * This code is free software; you can redistribute it and/or modify it |
aoqi@1 | 7 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@1 | 8 | * published by the Free Software Foundation. |
aoqi@1 | 9 | * |
aoqi@1 | 10 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@1 | 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@1 | 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@1 | 13 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@1 | 14 | * accompanied this code). |
aoqi@1 | 15 | * |
aoqi@1 | 16 | * You should have received a copy of the GNU General Public License version |
aoqi@1 | 17 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@1 | 18 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@1 | 19 | * |
aoqi@1 | 20 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@1 | 21 | * or visit www.oracle.com if you need additional information or have any |
aoqi@1 | 22 | * questions. |
aoqi@1 | 23 | * |
aoqi@1 | 24 | */ |
aoqi@1 | 25 | |
aoqi@1 | 26 | #ifndef CPU_MIPS_VM_JNITYPES_MIPS_HPP |
aoqi@1 | 27 | #define CPU_MIPS_VM_JNITYPES_MIPS_HPP |
aoqi@1 | 28 | |
aoqi@1 | 29 | #include "memory/allocation.hpp" |
aoqi@1 | 30 | #include "oops/oop.hpp" |
aoqi@1 | 31 | #include "prims/jni.h" |
aoqi@1 | 32 | |
aoqi@1 | 33 | // This file holds platform-dependent routines used to write primitive jni |
aoqi@1 | 34 | // types to the array of arguments passed into JavaCalls::call |
aoqi@1 | 35 | |
aoqi@1 | 36 | class JNITypes : AllStatic { |
aoqi@1 | 37 | // These functions write a java primitive type (in native format) |
aoqi@1 | 38 | // to a java stack slot array to be passed as an argument to JavaCalls:calls. |
aoqi@1 | 39 | // I.e., they are functionally 'push' operations if they have a 'pos' |
aoqi@1 | 40 | // formal parameter. Note that jlong's and jdouble's are written |
aoqi@1 | 41 | // _in reverse_ of the order in which they appear in the interpreter |
aoqi@1 | 42 | // stack. This is because call stubs (see stubGenerator_sparc.cpp) |
aoqi@1 | 43 | // reverse the argument list constructed by JavaCallArguments (see |
aoqi@1 | 44 | // javaCalls.hpp). |
aoqi@1 | 45 | |
aoqi@1 | 46 | private: |
aoqi@1 | 47 | |
aoqi@1 | 48 | #ifndef AMD64 |
aoqi@1 | 49 | // 32bit Helper routines. |
aoqi@1 | 50 | static inline void put_int2r(jint *from, intptr_t *to) { *(jint *)(to++) = from[1]; |
aoqi@1 | 51 | *(jint *)(to ) = from[0]; |
aoqi@1 | 52 | } |
aoqi@1 | 53 | static inline void put_int2r(jint *from, intptr_t *to, int& pos) { put_int2r(from, to + pos); pos += 2; } |
aoqi@1 | 54 | #endif // AMD64 |
aoqi@1 | 55 | |
aoqi@1 | 56 | public: |
aoqi@1 | 57 | #ifdef _LP64 |
aoqi@1 | 58 | // Jin: In MIPS64, the sizeof intptr_t is 8 bytes, and each unit in JavaCallArguments::_value_buffer[] |
aoqi@1 | 59 | // is 8 bytes. |
aoqi@1 | 60 | // If we only write the low 4 bytes with (jint *), the high 4-bits will be left with uncertain values. |
aoqi@1 | 61 | // Then, in JavaCallArguments::parameters(), the whole 8 bytes of a T_INT parameter is loaded. |
aoqi@1 | 62 | // This error occurs in ReflectInvoke.java |
aoqi@1 | 63 | // The parameter of DD(int) should be 4 instead of 0x550000004. |
aoqi@1 | 64 | // |
aoqi@1 | 65 | // See: [runtime/javaCalls.hpp] |
aoqi@1 | 66 | |
aoqi@1 | 67 | static inline void put_int(jint from, intptr_t *to) { *(intptr_t *)(to + 0 ) = from; } |
aoqi@1 | 68 | static inline void put_int(jint from, intptr_t *to, int& pos) { *(intptr_t *)(to + pos++) = from; } |
aoqi@1 | 69 | static inline void put_int(jint *from, intptr_t *to, int& pos) { *(intptr_t *)(to + pos++) = *from; } |
aoqi@1 | 70 | #else |
aoqi@1 | 71 | // Ints are stored in native format in one JavaCallArgument slot at *to. |
aoqi@1 | 72 | static inline void put_int(jint from, intptr_t *to) { *(jint *)(to + 0 ) = from; } |
aoqi@1 | 73 | static inline void put_int(jint from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = from; } |
aoqi@1 | 74 | static inline void put_int(jint *from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = *from; } |
aoqi@1 | 75 | #endif |
aoqi@1 | 76 | |
aoqi@1 | 77 | #ifdef _LP64 |
aoqi@1 | 78 | // Longs are stored in native format in one JavaCallArgument slot at |
aoqi@1 | 79 | // *(to). |
aoqi@1 | 80 | // In theory, *(to + 1) is an empty slot. But, for several Java2D testing programs (TestBorderLayout, SwingTest), |
aoqi@1 | 81 | // *(to + 1) must contains a copy of the long value. Otherwise it will corrupts. |
aoqi@1 | 82 | static inline void put_long(jlong from, intptr_t *to) { |
aoqi@1 | 83 | *(jlong*) (to + 1) = from; |
aoqi@1 | 84 | *(jlong*) (to) = from; |
aoqi@1 | 85 | } |
aoqi@1 | 86 | |
aoqi@1 | 87 | /* Jin: A long parameter occupies two slot. |
aoqi@1 | 88 | * It must fit the layout rule in methodHandle. |
aoqi@1 | 89 | * |
aoqi@1 | 90 | * See: [runtime/reflection.cpp] Reflection::invoke() |
aoqi@1 | 91 | * assert(java_args.size_of_parameters() == method->size_of_parameters(), "just checking"); |
aoqi@1 | 92 | */ |
aoqi@1 | 93 | static inline void put_long(jlong from, intptr_t *to, int& pos) { |
aoqi@1 | 94 | *(jlong*) (to + 1 + pos) = from; |
aoqi@1 | 95 | *(jlong*) (to + pos) = from; |
aoqi@1 | 96 | pos += 2; |
aoqi@1 | 97 | } |
aoqi@1 | 98 | |
aoqi@1 | 99 | static inline void put_long(jlong *from, intptr_t *to, int& pos) { |
aoqi@1 | 100 | *(jlong*) (to + 1 + pos) = *from; |
aoqi@1 | 101 | *(jlong*) (to + pos) = *from; |
aoqi@1 | 102 | pos += 2; |
aoqi@1 | 103 | } |
aoqi@1 | 104 | #else |
aoqi@1 | 105 | // Longs are stored in big-endian word format in two JavaCallArgument slots at *to. |
aoqi@1 | 106 | // The high half is in *to and the low half in *(to+1). |
aoqi@1 | 107 | static inline void put_long(jlong from, intptr_t *to) { put_int2r((jint *)&from, to); } |
aoqi@1 | 108 | static inline void put_long(jlong from, intptr_t *to, int& pos) { put_int2r((jint *)&from, to, pos); } |
aoqi@1 | 109 | static inline void put_long(jlong *from, intptr_t *to, int& pos) { put_int2r((jint *) from, to, pos); } |
aoqi@1 | 110 | #endif // AMD64 |
aoqi@1 | 111 | |
aoqi@1 | 112 | // Oops are stored in native format in one JavaCallArgument slot at *to. |
aoqi@1 | 113 | static inline void put_obj(oop from, intptr_t *to) { *(oop *)(to + 0 ) = from; } |
aoqi@1 | 114 | static inline void put_obj(oop from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = from; } |
aoqi@1 | 115 | static inline void put_obj(oop *from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = *from; } |
aoqi@1 | 116 | |
aoqi@1 | 117 | // Floats are stored in native format in one JavaCallArgument slot at *to. |
aoqi@1 | 118 | static inline void put_float(jfloat from, intptr_t *to) { *(jfloat *)(to + 0 ) = from; } |
aoqi@1 | 119 | static inline void put_float(jfloat from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = from; } |
aoqi@1 | 120 | static inline void put_float(jfloat *from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = *from; } |
aoqi@1 | 121 | |
aoqi@1 | 122 | #undef _JNI_SLOT_OFFSET |
aoqi@1 | 123 | #define _JNI_SLOT_OFFSET 0 |
aoqi@1 | 124 | |
aoqi@1 | 125 | #ifdef _LP64 |
aoqi@1 | 126 | // Longs are stored in native format in one JavaCallArgument slot at |
aoqi@1 | 127 | // *(to). |
aoqi@1 | 128 | // In theory, *(to + 1) is an empty slot. But, for several Java2D testing programs (TestBorderLayout, SwingTest), |
aoqi@1 | 129 | // *(to + 1) must contains a copy of the long value. Otherwise it will corrupts. |
aoqi@1 | 130 | static inline void put_double(jdouble from, intptr_t *to) { |
aoqi@1 | 131 | *(jdouble*) (to + 1) = from; |
aoqi@1 | 132 | *(jdouble*) (to) = from; |
aoqi@1 | 133 | } |
aoqi@1 | 134 | |
aoqi@1 | 135 | /* Jin: A long parameter occupies two slot. |
aoqi@1 | 136 | * It must fit the layout rule in methodHandle. |
aoqi@1 | 137 | * |
aoqi@1 | 138 | * See: [runtime/reflection.cpp] Reflection::invoke() |
aoqi@1 | 139 | * assert(java_args.size_of_parameters() == method->size_of_parameters(), "just checking"); |
aoqi@1 | 140 | */ |
aoqi@1 | 141 | static inline void put_double(jdouble from, intptr_t *to, int& pos) { |
aoqi@1 | 142 | *(jdouble*) (to + 1 + pos) = from; |
aoqi@1 | 143 | *(jdouble*) (to + pos) = from; |
aoqi@1 | 144 | pos += 2; |
aoqi@1 | 145 | } |
aoqi@1 | 146 | |
aoqi@1 | 147 | static inline void put_double(jdouble *from, intptr_t *to, int& pos) { |
aoqi@1 | 148 | *(jdouble*) (to + 1 + pos) = *from; |
aoqi@1 | 149 | *(jdouble*) (to + pos) = *from; |
aoqi@1 | 150 | pos += 2; |
aoqi@1 | 151 | } |
aoqi@1 | 152 | #else |
aoqi@1 | 153 | // Doubles are stored in big-endian word format in two JavaCallArgument slots at *to. |
aoqi@1 | 154 | // The high half is in *to and the low half in *(to+1). |
aoqi@1 | 155 | static inline void put_double(jdouble from, intptr_t *to) { put_int2r((jint *)&from, to); } |
aoqi@1 | 156 | static inline void put_double(jdouble from, intptr_t *to, int& pos) { put_int2r((jint *)&from, to, pos); } |
aoqi@1 | 157 | static inline void put_double(jdouble *from, intptr_t *to, int& pos) { put_int2r((jint *) from, to, pos); } |
aoqi@1 | 158 | #endif |
aoqi@1 | 159 | |
aoqi@1 | 160 | |
aoqi@1 | 161 | // The get_xxx routines, on the other hand, actually _do_ fetch |
aoqi@1 | 162 | // java primitive types from the interpreter stack. |
aoqi@1 | 163 | // No need to worry about alignment on Intel. |
aoqi@1 | 164 | static inline jint get_int (intptr_t *from) { return *(jint *) from; } |
aoqi@1 | 165 | static inline jlong get_long (intptr_t *from) { return *(jlong *) (from + _JNI_SLOT_OFFSET); } |
aoqi@1 | 166 | static inline oop get_obj (intptr_t *from) { return *(oop *) from; } |
aoqi@1 | 167 | static inline jfloat get_float (intptr_t *from) { return *(jfloat *) from; } |
aoqi@1 | 168 | static inline jdouble get_double(intptr_t *from) { return *(jdouble *)(from + _JNI_SLOT_OFFSET); } |
aoqi@1 | 169 | #undef _JNI_SLOT_OFFSET |
aoqi@1 | 170 | }; |
aoqi@1 | 171 | |
aoqi@1 | 172 | #endif // CPU_MIPS_VM_JNITYPES_MIPS_HPP |