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