src/cpu/sparc/vm/jniTypes_sparc.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/cpu/sparc/vm/jniTypes_sparc.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,117 @@
     1.4 +/*
     1.5 + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef CPU_SPARC_VM_JNITYPES_SPARC_HPP
    1.29 +#define CPU_SPARC_VM_JNITYPES_SPARC_HPP
    1.30 +
    1.31 +#include "memory/allocation.hpp"
    1.32 +#include "oops/oop.hpp"
    1.33 +#include "prims/jni.h"
    1.34 +
    1.35 +// This file holds platform-dependent routines used to write primitive jni
    1.36 +// types to the array of arguments passed into JavaCalls::call
    1.37 +
    1.38 +class JNITypes : AllStatic {
    1.39 +  // These functions write a java primitive type (in native format)
    1.40 +  // to a java stack slot array to be passed as an argument to JavaCalls:calls.
    1.41 +  // I.e., they are functionally 'push' operations if they have a 'pos'
    1.42 +  // formal parameter.  Note that jlong's and jdouble's are written
    1.43 +  // _in reverse_ of the order in which they appear in the interpreter
    1.44 +  // stack.  This is because call stubs (see stubGenerator_sparc.cpp)
    1.45 +  // reverse the argument list constructed by JavaCallArguments (see
    1.46 +  // javaCalls.hpp).
    1.47 +
    1.48 +private:
    1.49 +  // Helper routines.
    1.50 +  static inline void    put_int2 (jint *from, jint *to)           { to[0] = from[0]; to[1] = from[1]; }
    1.51 +  static inline void    put_int2 (jint *from, jint *to, int& pos) { put_int2 (from, (jint *)((intptr_t *)to + pos)); pos += 2; }
    1.52 +  static inline void    put_int2r(jint *from, jint *to)           { to[0] = from[1]; to[1] = from[0]; }
    1.53 +  static inline void    put_int2r(jint *from, jint *to, int& pos) { put_int2r(from, (jint *)((intptr_t *)to + pos)); pos += 2; }
    1.54 +
    1.55 +public:
    1.56 +  // Ints are stored in native format in one JavaCallArgument slot at *to.
    1.57 +  static inline void    put_int(jint  from, intptr_t *to)               { *(jint *)(to +   0  ) =  from; }
    1.58 +  static inline void    put_int(jint  from, intptr_t *to, int& pos)     { *(jint *)(to + pos++) =  from; }
    1.59 +  static inline void    put_int(jint *from, intptr_t *to, int& pos)     { *(jint *)(to + pos++) = *from; }
    1.60 +
    1.61 +#ifdef _LP64
    1.62 +  // Longs are stored in native format in one JavaCallArgument slot at *(to+1).
    1.63 +  static inline void    put_long(jlong  from, intptr_t *to)             { *(jlong *)(to + 1 +   0) =  from; }
    1.64 +  static inline void    put_long(jlong  from, intptr_t *to, int& pos)   { *(jlong *)(to + 1 + pos) =  from; pos += 2; }
    1.65 +  static inline void    put_long(jlong *from, intptr_t *to, int& pos)   { *(jlong *)(to + 1 + pos) = *from; pos += 2; }
    1.66 +#else
    1.67 +  // Longs are stored in reversed native word format in two JavaCallArgument slots at *to.
    1.68 +  // The high half is in *(to+1) and the low half in *to.
    1.69 +  static inline void    put_long(jlong  from, intptr_t *to)            { put_int2r((jint *)&from, (jint *)to); }
    1.70 +  static inline void    put_long(jlong  from, intptr_t *to, int& pos)  { put_int2r((jint *)&from, (jint *)to, pos); }
    1.71 +  static inline void    put_long(jlong *from, intptr_t *to, int& pos)  { put_int2r((jint *) from, (jint *)to, pos); }
    1.72 +#endif
    1.73 +
    1.74 +  // Oops are stored in native format in one JavaCallArgument slot at *to.
    1.75 +  static inline void    put_obj(oop  from, intptr_t *to)                { *(oop *)(to +   0  ) =  from; }
    1.76 +  static inline void    put_obj(oop  from, intptr_t *to, int& pos)      { *(oop *)(to + pos++) =  from; }
    1.77 +  static inline void    put_obj(oop *from, intptr_t *to, int& pos)      { *(oop *)(to + pos++) = *from; }
    1.78 +
    1.79 +  // Floats are stored in native format in one JavaCallArgument slot at *to.
    1.80 +  static inline void    put_float(jfloat  from, intptr_t *to)           { *(jfloat *)(to +   0  ) =  from; }
    1.81 +  static inline void    put_float(jfloat  from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) =  from; }
    1.82 +  static inline void    put_float(jfloat *from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = *from; }
    1.83 +
    1.84 +#ifdef _LP64
    1.85 +  // Doubles are stored in native word format in one JavaCallArgument slot at *(to+1).
    1.86 +  static inline void    put_double(jdouble  from, intptr_t *to)           { *(jdouble *)(to + 1 +   0) =  from; }
    1.87 +  static inline void    put_double(jdouble  from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) =  from; pos += 2; }
    1.88 +  static inline void    put_double(jdouble *from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) = *from; pos += 2; }
    1.89 +#else
    1.90 +  // Doubles are stored in reversed native word format in two JavaCallArgument slots at *to.
    1.91 +  static inline void    put_double(jdouble  from, intptr_t *to)           { put_int2r((jint *)&from, (jint *)to); }
    1.92 +  static inline void    put_double(jdouble  from, intptr_t *to, int& pos) { put_int2r((jint *)&from, (jint *)to, pos); }
    1.93 +  static inline void    put_double(jdouble *from, intptr_t *to, int& pos) { put_int2r((jint *) from, (jint *)to, pos); }
    1.94 +#endif
    1.95 +
    1.96 +  // The get_xxx routines, on the other hand, actually _do_ fetch
    1.97 +  // java primitive types from the interpreter stack.
    1.98 +  static inline jint    get_int(intptr_t *from)         { return *(jint *)from; }
    1.99 +
   1.100 +#ifdef _LP64
   1.101 +  static inline jlong   get_long(intptr_t *from)        { return *(jlong *)from; }
   1.102 +#else
   1.103 +  static inline jlong   get_long(intptr_t *from)        { return ((jlong)(*(  signed int *)((jint *)from    )) << 32) |
   1.104 +                                                                 ((jlong)(*(unsigned int *)((jint *)from + 1)) <<  0); }
   1.105 +#endif
   1.106 +
   1.107 +  static inline oop     get_obj(intptr_t *from)         { return *(oop *)from; }
   1.108 +  static inline jfloat  get_float(intptr_t *from)       { return *(jfloat *)from; }
   1.109 +
   1.110 +#ifdef _LP64
   1.111 +  static inline jdouble get_double(intptr_t *from)      { return *(jdouble *)from; }
   1.112 +#else
   1.113 +  static inline jdouble get_double(intptr_t *from)      { jlong jl = ((jlong)(*(  signed int *)((jint *)from    )) << 32) |
   1.114 +                                                                     ((jlong)(*(unsigned int *)((jint *)from + 1)) <<  0);
   1.115 +                                                          return *(jdouble *)&jl; }
   1.116 +#endif
   1.117 +
   1.118 +};
   1.119 +
   1.120 +#endif // CPU_SPARC_VM_JNITYPES_SPARC_HPP

mercurial