Mercurial > hg > graal-jvmci-8
comparison src/share/vm/prims/jni.cpp @ 23842:d109bda16490
Merge
author | asaha |
---|---|
date | Tue, 05 Apr 2016 08:55:39 -0700 |
parents | 392f8722fc51 |
children | b5f3a471e646 20dbd8a8e6b7 |
comparison
equal
deleted
inserted
replaced
23834:b5b3db42efca | 23842:d109bda16490 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * Copyright (c) 2012 Red Hat, Inc. | 3 * Copyright (c) 2012 Red Hat, Inc. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 * | 5 * |
6 * This code is free software; you can redistribute it and/or modify it | 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 | 7 * under the terms of the GNU General Public License version 2 only, as |
1119 | 1119 |
1120 class JNI_ArgumentPusherVaArg : public JNI_ArgumentPusher { | 1120 class JNI_ArgumentPusherVaArg : public JNI_ArgumentPusher { |
1121 protected: | 1121 protected: |
1122 va_list _ap; | 1122 va_list _ap; |
1123 | 1123 |
1124 inline void get_bool() { _arguments->push_int(va_arg(_ap, jint)); } // bool is coerced to int when using va_arg | 1124 inline void get_bool() { |
1125 // Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and | |
1126 // 0 to JNI_FALSE. Boolean return values from native are normalized the same in | |
1127 // TemplateInterpreterGenerator::generate_result_handler_for and | |
1128 // SharedRuntime::generate_native_wrapper. | |
1129 jboolean b = va_arg(_ap, jint); | |
1130 _arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE)); | |
1131 } | |
1125 inline void get_char() { _arguments->push_int(va_arg(_ap, jint)); } // char is coerced to int when using va_arg | 1132 inline void get_char() { _arguments->push_int(va_arg(_ap, jint)); } // char is coerced to int when using va_arg |
1126 inline void get_short() { _arguments->push_int(va_arg(_ap, jint)); } // short is coerced to int when using va_arg | 1133 inline void get_short() { _arguments->push_int(va_arg(_ap, jint)); } // short is coerced to int when using va_arg |
1127 inline void get_byte() { _arguments->push_int(va_arg(_ap, jint)); } // byte is coerced to int when using va_arg | 1134 inline void get_byte() { _arguments->push_int(va_arg(_ap, jint)); } // byte is coerced to int when using va_arg |
1128 inline void get_int() { _arguments->push_int(va_arg(_ap, jint)); } | 1135 inline void get_int() { _arguments->push_int(va_arg(_ap, jint)); } |
1129 | 1136 |
1165 assert(fingerprint, "Fingerprint should not be 0"); | 1172 assert(fingerprint, "Fingerprint should not be 0"); |
1166 fingerprint = fingerprint >> (static_feature_size + result_feature_size); | 1173 fingerprint = fingerprint >> (static_feature_size + result_feature_size); |
1167 while ( 1 ) { | 1174 while ( 1 ) { |
1168 switch ( fingerprint & parameter_feature_mask ) { | 1175 switch ( fingerprint & parameter_feature_mask ) { |
1169 case bool_parm: | 1176 case bool_parm: |
1177 get_bool(); | |
1178 break; | |
1170 case char_parm: | 1179 case char_parm: |
1180 get_char(); | |
1181 break; | |
1171 case short_parm: | 1182 case short_parm: |
1183 get_short(); | |
1184 break; | |
1172 case byte_parm: | 1185 case byte_parm: |
1186 get_byte(); | |
1187 break; | |
1173 case int_parm: | 1188 case int_parm: |
1174 get_int(); | 1189 get_int(); |
1175 break; | 1190 break; |
1176 case obj_parm: | 1191 case obj_parm: |
1177 get_object(); | 1192 get_object(); |
1201 | 1216 |
1202 class JNI_ArgumentPusherArray : public JNI_ArgumentPusher { | 1217 class JNI_ArgumentPusherArray : public JNI_ArgumentPusher { |
1203 protected: | 1218 protected: |
1204 const jvalue *_ap; | 1219 const jvalue *_ap; |
1205 | 1220 |
1206 inline void get_bool() { _arguments->push_int((jint)(_ap++)->z); } | 1221 inline void get_bool() { |
1222 // Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and | |
1223 // 0 to JNI_FALSE. Boolean return values from native are normalized the same in | |
1224 // TemplateInterpreterGenerator::generate_result_handler_for and | |
1225 // SharedRuntime::generate_native_wrapper. | |
1226 jboolean b = (_ap++)->z; | |
1227 _arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE)); | |
1228 } | |
1207 inline void get_char() { _arguments->push_int((jint)(_ap++)->c); } | 1229 inline void get_char() { _arguments->push_int((jint)(_ap++)->c); } |
1208 inline void get_short() { _arguments->push_int((jint)(_ap++)->s); } | 1230 inline void get_short() { _arguments->push_int((jint)(_ap++)->s); } |
1209 inline void get_byte() { _arguments->push_int((jint)(_ap++)->b); } | 1231 inline void get_byte() { _arguments->push_int((jint)(_ap++)->b); } |
1210 inline void get_int() { _arguments->push_int((jint)(_ap++)->i); } | 1232 inline void get_int() { _arguments->push_int((jint)(_ap++)->i); } |
1211 | 1233 |
2826 if (JvmtiExport::should_post_field_modification()) { \ | 2848 if (JvmtiExport::should_post_field_modification()) { \ |
2827 jvalue field_value; \ | 2849 jvalue field_value; \ |
2828 field_value.unionType = value; \ | 2850 field_value.unionType = value; \ |
2829 o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, SigType, (jvalue *)&field_value); \ | 2851 o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, SigType, (jvalue *)&field_value); \ |
2830 } \ | 2852 } \ |
2853 if (SigType == 'Z') { value = ((jboolean)value) & 1; } \ | |
2831 o->Fieldname##_field_put(offset, value); \ | 2854 o->Fieldname##_field_put(offset, value); \ |
2832 ReturnProbe; \ | 2855 ReturnProbe; \ |
2833 JNI_END | 2856 JNI_END |
2834 | 2857 |
2835 DEFINE_SETFIELD(jboolean, bool, Boolean, 'Z', z | 2858 DEFINE_SETFIELD(jboolean, bool, Boolean, 'Z', z |
3130 if (JvmtiExport::should_post_field_modification()) { \ | 3153 if (JvmtiExport::should_post_field_modification()) { \ |
3131 jvalue field_value; \ | 3154 jvalue field_value; \ |
3132 field_value.unionType = value; \ | 3155 field_value.unionType = value; \ |
3133 JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \ | 3156 JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \ |
3134 } \ | 3157 } \ |
3158 if (SigType == 'Z') { value = ((jboolean)value) & 1; } \ | |
3135 id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \ | 3159 id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \ |
3136 ReturnProbe;\ | 3160 ReturnProbe;\ |
3137 JNI_END | 3161 JNI_END |
3138 | 3162 |
3139 DEFINE_SETSTATICFIELD(jboolean, bool, Boolean, 'Z', z | 3163 DEFINE_SETSTATICFIELD(jboolean, bool, Boolean, 'Z', z |