src/cpu/sparc/vm/jniTypes_sparc.hpp

changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/cpu/sparc/vm/jniTypes_sparc.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,108 @@
     1.4 +/*
     1.5 + * Copyright 1998-2002 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +// This file holds platform-dependent routines used to write primitive jni
    1.29 +// types to the array of arguments passed into JavaCalls::call
    1.30 +
    1.31 +class JNITypes : AllStatic {
    1.32 +  // These functions write a java primitive type (in native format)
    1.33 +  // to a java stack slot array to be passed as an argument to JavaCalls:calls.
    1.34 +  // I.e., they are functionally 'push' operations if they have a 'pos'
    1.35 +  // formal parameter.  Note that jlong's and jdouble's are written
    1.36 +  // _in reverse_ of the order in which they appear in the interpreter
    1.37 +  // stack.  This is because call stubs (see stubGenerator_sparc.cpp)
    1.38 +  // reverse the argument list constructed by JavaCallArguments (see
    1.39 +  // javaCalls.hpp).
    1.40 +
    1.41 +private:
    1.42 +  // Helper routines.
    1.43 +  static inline void    put_int2 (jint *from, jint *to)           { to[0] = from[0]; to[1] = from[1]; }
    1.44 +  static inline void    put_int2 (jint *from, jint *to, int& pos) { put_int2 (from, (jint *)((intptr_t *)to + pos)); pos += 2; }
    1.45 +  static inline void    put_int2r(jint *from, jint *to)           { to[0] = from[1]; to[1] = from[0]; }
    1.46 +  static inline void    put_int2r(jint *from, jint *to, int& pos) { put_int2r(from, (jint *)((intptr_t *)to + pos)); pos += 2; }
    1.47 +
    1.48 +public:
    1.49 +  // Ints are stored in native format in one JavaCallArgument slot at *to.
    1.50 +  static inline void    put_int(jint  from, intptr_t *to)               { *(jint *)(to +   0  ) =  from; }
    1.51 +  static inline void    put_int(jint  from, intptr_t *to, int& pos)     { *(jint *)(to + pos++) =  from; }
    1.52 +  static inline void    put_int(jint *from, intptr_t *to, int& pos)     { *(jint *)(to + pos++) = *from; }
    1.53 +
    1.54 +#ifdef _LP64
    1.55 +  // Longs are stored in native format in one JavaCallArgument slot at *(to+1).
    1.56 +  static inline void    put_long(jlong  from, intptr_t *to)             { *(jlong *)(to + 1 +   0) =  from; }
    1.57 +  static inline void    put_long(jlong  from, intptr_t *to, int& pos)   { *(jlong *)(to + 1 + pos) =  from; pos += 2; }
    1.58 +  static inline void    put_long(jlong *from, intptr_t *to, int& pos)   { *(jlong *)(to + 1 + pos) = *from; pos += 2; }
    1.59 +#else
    1.60 +  // Longs are stored in reversed native word format in two JavaCallArgument slots at *to.
    1.61 +  // The high half is in *(to+1) and the low half in *to.
    1.62 +  static inline void    put_long(jlong  from, intptr_t *to)            { put_int2r((jint *)&from, (jint *)to); }
    1.63 +  static inline void    put_long(jlong  from, intptr_t *to, int& pos)  { put_int2r((jint *)&from, (jint *)to, pos); }
    1.64 +  static inline void    put_long(jlong *from, intptr_t *to, int& pos)  { put_int2r((jint *) from, (jint *)to, pos); }
    1.65 +#endif
    1.66 +
    1.67 +  // Oops are stored in native format in one JavaCallArgument slot at *to.
    1.68 +  static inline void    put_obj(oop  from, intptr_t *to)                { *(oop *)(to +   0  ) =  from; }
    1.69 +  static inline void    put_obj(oop  from, intptr_t *to, int& pos)      { *(oop *)(to + pos++) =  from; }
    1.70 +  static inline void    put_obj(oop *from, intptr_t *to, int& pos)      { *(oop *)(to + pos++) = *from; }
    1.71 +
    1.72 +  // Floats are stored in native format in one JavaCallArgument slot at *to.
    1.73 +  static inline void    put_float(jfloat  from, intptr_t *to)           { *(jfloat *)(to +   0  ) =  from; }
    1.74 +  static inline void    put_float(jfloat  from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) =  from; }
    1.75 +  static inline void    put_float(jfloat *from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = *from; }
    1.76 +
    1.77 +#ifdef _LP64
    1.78 +  // Doubles are stored in native word format in one JavaCallArgument slot at *(to+1).
    1.79 +  static inline void    put_double(jdouble  from, intptr_t *to)           { *(jdouble *)(to + 1 +   0) =  from; }
    1.80 +  static inline void    put_double(jdouble  from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) =  from; pos += 2; }
    1.81 +  static inline void    put_double(jdouble *from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) = *from; pos += 2; }
    1.82 +#else
    1.83 +  // Doubles are stored in reversed native word format in two JavaCallArgument slots at *to.
    1.84 +  static inline void    put_double(jdouble  from, intptr_t *to)           { put_int2r((jint *)&from, (jint *)to); }
    1.85 +  static inline void    put_double(jdouble  from, intptr_t *to, int& pos) { put_int2r((jint *)&from, (jint *)to, pos); }
    1.86 +  static inline void    put_double(jdouble *from, intptr_t *to, int& pos) { put_int2r((jint *) from, (jint *)to, pos); }
    1.87 +#endif
    1.88 +
    1.89 +  // The get_xxx routines, on the other hand, actually _do_ fetch
    1.90 +  // java primitive types from the interpreter stack.
    1.91 +  static inline jint    get_int(intptr_t *from)         { return *(jint *)from; }
    1.92 +
    1.93 +#ifdef _LP64
    1.94 +  static inline jlong   get_long(intptr_t *from)        { return *(jlong *)from; }
    1.95 +#else
    1.96 +  static inline jlong   get_long(intptr_t *from)        { return ((jlong)(*(  signed int *)((jint *)from    )) << 32) |
    1.97 +                                                                 ((jlong)(*(unsigned int *)((jint *)from + 1)) <<  0); }
    1.98 +#endif
    1.99 +
   1.100 +  static inline oop     get_obj(intptr_t *from)         { return *(oop *)from; }
   1.101 +  static inline jfloat  get_float(intptr_t *from)       { return *(jfloat *)from; }
   1.102 +
   1.103 +#ifdef _LP64
   1.104 +  static inline jdouble get_double(intptr_t *from)      { return *(jdouble *)from; }
   1.105 +#else
   1.106 +  static inline jdouble get_double(intptr_t *from)      { jlong jl = ((jlong)(*(  signed int *)((jint *)from    )) << 32) |
   1.107 +                                                                     ((jlong)(*(unsigned int *)((jint *)from + 1)) <<  0);
   1.108 +                                                          return *(jdouble *)&jl; }
   1.109 +#endif
   1.110 +
   1.111 +};

mercurial