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