src/cpu/sparc/vm/jniTypes_sparc.hpp

Print this page


   1 /*
   2  * Copyright (c) 1998, 2002, 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 // This file holds platform-dependent routines used to write primitive jni
  26 // types to the array of arguments passed into JavaCalls::call
  27 
  28 class JNITypes : AllStatic {
  29   // These functions write a java primitive type (in native format)
  30   // to a java stack slot array to be passed as an argument to JavaCalls:calls.
  31   // I.e., they are functionally 'push' operations if they have a 'pos'
  32   // formal parameter.  Note that jlong's and jdouble's are written
  33   // _in reverse_ of the order in which they appear in the interpreter
  34   // stack.  This is because call stubs (see stubGenerator_sparc.cpp)
  35   // reverse the argument list constructed by JavaCallArguments (see
  36   // javaCalls.hpp).
  37 
  38 private:
  39   // Helper routines.
  40   static inline void    put_int2 (jint *from, jint *to)           { to[0] = from[0]; to[1] = from[1]; }
  41   static inline void    put_int2 (jint *from, jint *to, int& pos) { put_int2 (from, (jint *)((intptr_t *)to + pos)); pos += 2; }
  42   static inline void    put_int2r(jint *from, jint *to)           { to[0] = from[1]; to[1] = from[0]; }
  43   static inline void    put_int2r(jint *from, jint *to, int& pos) { put_int2r(from, (jint *)((intptr_t *)to + pos)); pos += 2; }
  44 


  89 
  90 #ifdef _LP64
  91   static inline jlong   get_long(intptr_t *from)        { return *(jlong *)from; }
  92 #else
  93   static inline jlong   get_long(intptr_t *from)        { return ((jlong)(*(  signed int *)((jint *)from    )) << 32) |
  94                                                                  ((jlong)(*(unsigned int *)((jint *)from + 1)) <<  0); }
  95 #endif
  96 
  97   static inline oop     get_obj(intptr_t *from)         { return *(oop *)from; }
  98   static inline jfloat  get_float(intptr_t *from)       { return *(jfloat *)from; }
  99 
 100 #ifdef _LP64
 101   static inline jdouble get_double(intptr_t *from)      { return *(jdouble *)from; }
 102 #else
 103   static inline jdouble get_double(intptr_t *from)      { jlong jl = ((jlong)(*(  signed int *)((jint *)from    )) << 32) |
 104                                                                      ((jlong)(*(unsigned int *)((jint *)from + 1)) <<  0);
 105                                                           return *(jdouble *)&jl; }
 106 #endif
 107 
 108 };


   1 /*
   2  * Copyright (c) 1998, 2010, 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_SPARC_VM_JNITYPES_SPARC_HPP
  26 #define CPU_SPARC_VM_JNITYPES_SPARC_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_sparc.cpp)
  42   // reverse the argument list constructed by JavaCallArguments (see
  43   // javaCalls.hpp).
  44 
  45 private:
  46   // Helper routines.
  47   static inline void    put_int2 (jint *from, jint *to)           { to[0] = from[0]; to[1] = from[1]; }
  48   static inline void    put_int2 (jint *from, jint *to, int& pos) { put_int2 (from, (jint *)((intptr_t *)to + pos)); pos += 2; }
  49   static inline void    put_int2r(jint *from, jint *to)           { to[0] = from[1]; to[1] = from[0]; }
  50   static inline void    put_int2r(jint *from, jint *to, int& pos) { put_int2r(from, (jint *)((intptr_t *)to + pos)); pos += 2; }
  51 


  96 
  97 #ifdef _LP64
  98   static inline jlong   get_long(intptr_t *from)        { return *(jlong *)from; }
  99 #else
 100   static inline jlong   get_long(intptr_t *from)        { return ((jlong)(*(  signed int *)((jint *)from    )) << 32) |
 101                                                                  ((jlong)(*(unsigned int *)((jint *)from + 1)) <<  0); }
 102 #endif
 103 
 104   static inline oop     get_obj(intptr_t *from)         { return *(oop *)from; }
 105   static inline jfloat  get_float(intptr_t *from)       { return *(jfloat *)from; }
 106 
 107 #ifdef _LP64
 108   static inline jdouble get_double(intptr_t *from)      { return *(jdouble *)from; }
 109 #else
 110   static inline jdouble get_double(intptr_t *from)      { jlong jl = ((jlong)(*(  signed int *)((jint *)from    )) << 32) |
 111                                                                      ((jlong)(*(unsigned int *)((jint *)from + 1)) <<  0);
 112                                                           return *(jdouble *)&jl; }
 113 #endif
 114 
 115 };
 116 
 117 #endif // CPU_SPARC_VM_JNITYPES_SPARC_HPP