< prev index next >

src/share/vm/prims/jni.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2012 Red Hat, Inc.
   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.


 918   va_list _ap;
 919 
 920   inline void get_bool()   {
 921     // Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and
 922     // 0 to JNI_FALSE.  Boolean return values from native are normalized the same in
 923     // TemplateInterpreterGenerator::generate_result_handler_for and
 924     // SharedRuntime::generate_native_wrapper.
 925     jboolean b = va_arg(_ap, jint);
 926     _arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE));
 927   }
 928   inline void get_char()   { _arguments->push_int(va_arg(_ap, jint)); } // char is coerced to int when using va_arg
 929   inline void get_short()  { _arguments->push_int(va_arg(_ap, jint)); } // short is coerced to int when using va_arg
 930   inline void get_byte()   { _arguments->push_int(va_arg(_ap, jint)); } // byte is coerced to int when using va_arg
 931   inline void get_int()    { _arguments->push_int(va_arg(_ap, jint)); }
 932 
 933   // each of these paths is exercized by the various jck Call[Static,Nonvirtual,][Void,Int,..]Method[A,V,] tests
 934 
 935   inline void get_long()   { _arguments->push_long(va_arg(_ap, jlong)); }
 936   inline void get_float()  { _arguments->push_float((jfloat)va_arg(_ap, jdouble)); } // float is coerced to double w/ va_arg
 937   inline void get_double() { _arguments->push_double(va_arg(_ap, jdouble)); }
 938   inline void get_object() { _arguments->push_jobject(va_arg(_ap, jobject)); }

 939 
 940   inline void set_ap(va_list rap) {
 941     va_copy(_ap, rap);
 942   }
 943 
 944  public:
 945   JNI_ArgumentPusherVaArg(Symbol* signature, va_list rap)
 946        : JNI_ArgumentPusher(signature) {
 947     set_ap(rap);
 948   }
 949   JNI_ArgumentPusherVaArg(jmethodID method_id, va_list rap)
 950       : JNI_ArgumentPusher(Method::resolve_jmethod_id(method_id)->signature()) {
 951     set_ap(rap);
 952   }
 953 
 954   // Optimized path if we have the bitvector form of signature
 955   void iterate( uint64_t fingerprint ) {
 956     if (fingerprint == (uint64_t)CONST64(-1)) {
 957       SignatureIterator::iterate(); // Must be too many arguments
 958     } else {


1007 class JNI_ArgumentPusherArray : public JNI_ArgumentPusher {
1008  protected:
1009   const jvalue *_ap;
1010 
1011   inline void get_bool()   {
1012     // Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and
1013     // 0 to JNI_FALSE.  Boolean return values from native are normalized the same in
1014     // TemplateInterpreterGenerator::generate_result_handler_for and
1015     // SharedRuntime::generate_native_wrapper.
1016     jboolean b = (_ap++)->z;
1017     _arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE));
1018   }
1019   inline void get_char()   { _arguments->push_int((jint)(_ap++)->c); }
1020   inline void get_short()  { _arguments->push_int((jint)(_ap++)->s); }
1021   inline void get_byte()   { _arguments->push_int((jint)(_ap++)->b); }
1022   inline void get_int()    { _arguments->push_int((jint)(_ap++)->i); }
1023 
1024   inline void get_long()   { _arguments->push_long((_ap++)->j);  }
1025   inline void get_float()  { _arguments->push_float((_ap++)->f); }
1026   inline void get_double() { _arguments->push_double((_ap++)->d);}
1027   inline void get_object() { _arguments->push_jobject((_ap++)->l); }
1028 
1029   inline void set_ap(const jvalue *rap) { _ap = rap; }
1030 
1031  public:
1032   JNI_ArgumentPusherArray(Symbol* signature, const jvalue *rap)
1033        : JNI_ArgumentPusher(signature) {
1034     set_ap(rap);
1035   }
1036   JNI_ArgumentPusherArray(jmethodID method_id, const jvalue *rap)
1037       : JNI_ArgumentPusher(Method::resolve_jmethod_id(method_id)->signature()) {
1038     set_ap(rap);
1039   }
1040 
1041   // Optimized path if we have the bitvector form of signature
1042   void iterate( uint64_t fingerprint ) {
1043     if (fingerprint == (uint64_t)CONST64(-1)) {
1044       SignatureIterator::iterate(); // Must be too many arguments
1045     } else {
1046       _return_type = (BasicType)((fingerprint >> static_feature_size) &
1047                                   result_feature_mask);


   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2012 Red Hat, Inc.
   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.


 918   va_list _ap;
 919 
 920   inline void get_bool()   {
 921     // Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and
 922     // 0 to JNI_FALSE.  Boolean return values from native are normalized the same in
 923     // TemplateInterpreterGenerator::generate_result_handler_for and
 924     // SharedRuntime::generate_native_wrapper.
 925     jboolean b = va_arg(_ap, jint);
 926     _arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE));
 927   }
 928   inline void get_char()   { _arguments->push_int(va_arg(_ap, jint)); } // char is coerced to int when using va_arg
 929   inline void get_short()  { _arguments->push_int(va_arg(_ap, jint)); } // short is coerced to int when using va_arg
 930   inline void get_byte()   { _arguments->push_int(va_arg(_ap, jint)); } // byte is coerced to int when using va_arg
 931   inline void get_int()    { _arguments->push_int(va_arg(_ap, jint)); }
 932 
 933   // each of these paths is exercized by the various jck Call[Static,Nonvirtual,][Void,Int,..]Method[A,V,] tests
 934 
 935   inline void get_long()   { _arguments->push_long(va_arg(_ap, jlong)); }
 936   inline void get_float()  { _arguments->push_float((jfloat)va_arg(_ap, jdouble)); } // float is coerced to double w/ va_arg
 937   inline void get_double() { _arguments->push_double(va_arg(_ap, jdouble)); }
 938   inline void get_object() { jobject l = va_arg(_ap, jobject);
 939                              _arguments->push_oop(Handle((oop *)l, false)); }
 940 
 941   inline void set_ap(va_list rap) {
 942     va_copy(_ap, rap);
 943   }
 944 
 945  public:
 946   JNI_ArgumentPusherVaArg(Symbol* signature, va_list rap)
 947        : JNI_ArgumentPusher(signature) {
 948     set_ap(rap);
 949   }
 950   JNI_ArgumentPusherVaArg(jmethodID method_id, va_list rap)
 951       : JNI_ArgumentPusher(Method::resolve_jmethod_id(method_id)->signature()) {
 952     set_ap(rap);
 953   }
 954 
 955   // Optimized path if we have the bitvector form of signature
 956   void iterate( uint64_t fingerprint ) {
 957     if (fingerprint == (uint64_t)CONST64(-1)) {
 958       SignatureIterator::iterate(); // Must be too many arguments
 959     } else {


1008 class JNI_ArgumentPusherArray : public JNI_ArgumentPusher {
1009  protected:
1010   const jvalue *_ap;
1011 
1012   inline void get_bool()   {
1013     // Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and
1014     // 0 to JNI_FALSE.  Boolean return values from native are normalized the same in
1015     // TemplateInterpreterGenerator::generate_result_handler_for and
1016     // SharedRuntime::generate_native_wrapper.
1017     jboolean b = (_ap++)->z;
1018     _arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE));
1019   }
1020   inline void get_char()   { _arguments->push_int((jint)(_ap++)->c); }
1021   inline void get_short()  { _arguments->push_int((jint)(_ap++)->s); }
1022   inline void get_byte()   { _arguments->push_int((jint)(_ap++)->b); }
1023   inline void get_int()    { _arguments->push_int((jint)(_ap++)->i); }
1024 
1025   inline void get_long()   { _arguments->push_long((_ap++)->j);  }
1026   inline void get_float()  { _arguments->push_float((_ap++)->f); }
1027   inline void get_double() { _arguments->push_double((_ap++)->d);}
1028   inline void get_object() { _arguments->push_oop(Handle((oop *)(_ap++)->l, false)); }
1029 
1030   inline void set_ap(const jvalue *rap) { _ap = rap; }
1031 
1032  public:
1033   JNI_ArgumentPusherArray(Symbol* signature, const jvalue *rap)
1034        : JNI_ArgumentPusher(signature) {
1035     set_ap(rap);
1036   }
1037   JNI_ArgumentPusherArray(jmethodID method_id, const jvalue *rap)
1038       : JNI_ArgumentPusher(Method::resolve_jmethod_id(method_id)->signature()) {
1039     set_ap(rap);
1040   }
1041 
1042   // Optimized path if we have the bitvector form of signature
1043   void iterate( uint64_t fingerprint ) {
1044     if (fingerprint == (uint64_t)CONST64(-1)) {
1045       SignatureIterator::iterate(); // Must be too many arguments
1046     } else {
1047       _return_type = (BasicType)((fingerprint >> static_feature_size) &
1048                                   result_feature_mask);


< prev index next >