提交 14df0dda 编写于 作者: K kevinw

8149170: Better byte behavior for native arguments

Summary: Arguments coming from native should be converted to 0=false, 1-255=true
Reviewed-by: coleenp
上级 53898d60
......@@ -1121,7 +1121,14 @@ class JNI_ArgumentPusherVaArg : public JNI_ArgumentPusher {
protected:
va_list _ap;
inline void get_bool() { _arguments->push_int(va_arg(_ap, jint)); } // bool is coerced to int when using va_arg
inline void get_bool() {
// Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and
// 0 to JNI_FALSE. Boolean return values from native are normalized the same in
// TemplateInterpreterGenerator::generate_result_handler_for and
// SharedRuntime::generate_native_wrapper.
jboolean b = va_arg(_ap, jint);
_arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE));
}
inline void get_char() { _arguments->push_int(va_arg(_ap, jint)); } // char is coerced to int when using va_arg
inline void get_short() { _arguments->push_int(va_arg(_ap, jint)); } // short is coerced to int when using va_arg
inline void get_byte() { _arguments->push_int(va_arg(_ap, jint)); } // byte is coerced to int when using va_arg
......@@ -1167,9 +1174,17 @@ class JNI_ArgumentPusherVaArg : public JNI_ArgumentPusher {
while ( 1 ) {
switch ( fingerprint & parameter_feature_mask ) {
case bool_parm:
get_bool();
break;
case char_parm:
get_char();
break;
case short_parm:
get_short();
break;
case byte_parm:
get_byte();
break;
case int_parm:
get_int();
break;
......@@ -1203,7 +1218,14 @@ class JNI_ArgumentPusherArray : public JNI_ArgumentPusher {
protected:
const jvalue *_ap;
inline void get_bool() { _arguments->push_int((jint)(_ap++)->z); }
inline void get_bool() {
// Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and
// 0 to JNI_FALSE. Boolean return values from native are normalized the same in
// TemplateInterpreterGenerator::generate_result_handler_for and
// SharedRuntime::generate_native_wrapper.
jboolean b = (_ap++)->z;
_arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE));
}
inline void get_char() { _arguments->push_int((jint)(_ap++)->c); }
inline void get_short() { _arguments->push_int((jint)(_ap++)->s); }
inline void get_byte() { _arguments->push_int((jint)(_ap++)->b); }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册