src/cpu/mips/vm/jniTypes_mips.hpp

Thu, 07 Sep 2017 09:12:16 +0800

author
aoqi
date
Thu, 07 Sep 2017 09:12:16 +0800
changeset 6880
52ea28d233d2
parent 1
2d8a650513c2
child 9459
814e9e335067
permissions
-rw-r--r--

#5745 [Code Reorganization] code cleanup and code style fix
This is a huge patch, but only code cleanup, code style fix and useless code deletion are included, for example:
tab -> two spaces, deleted spacees at the end of a line, delete useless comments.

This patch also included:
Declaration and definition of class MacroAssembler is moved from assembler_mips.h/cpp to macroAssembler_mips.h/cpp

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

mercurial