ARM: fix java.lang.Math.log10

Xerxes Rånby xerxes at zafena.se
Tue Jan 17 04:28:55 PST 2012


2012-01-16 19:41, Andrew Haley skrev:
> In JCK testing we discovered that java.lang.Math.log10 causes a crash.
> 
> In HotSpot there is a special table of method kinds, and it was
> updated to include java.dyn.MethodHandles::invoke.  Unfortunately,
> this entry was added in the middle of the list, rather than at the
> end, so the java.lang.Math.* entries all move up by one.
> java.lang.Math.log10 was at the end of the table, and it fell off.
> :-)

I have verified that your patch do make java.lang.Math.log10 work for the ARM asm interpreter.
This patch are OK for icedtea6 HEAD and icedtea6-1.11.

Some observations that need attention:

(oddity no 1)
Interesting... The crash itself are still not explained.
When java.lang.Math.log10 "entry no 15" fall of the end of the list then it make the whole function return 0.
The Zero cpp interpreter will notice this and installs its own non-asm version of java.lang.Math.log10 as fall-back.
See: openjdk/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp AbstractInterpreterGenerator::generate_method_entry .

The crash triggers after the Zero c++ fall-back entry for java.lang.Math.log10
have both executed and returned.
To me this indicate that something in the inter-working between the c++ Zero interpreter
and the asm Zero interpreter are still broken.

(oddity no 2)
When installing vm_fatal_error as entry to handle the "java.dyn.MethodHandles::invoke" causes a signal 11
I would have expected it to call report_should_not_reach_here and exit cleanly.

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (os_linux_zero.cpp:270), pid=11232, tid=1090544752
#  fatal error: caught unhandled signal 11

Cheers Xerxes

> 
> Fixed thusly.
> 
> Andrew.
> 
> 
> 2012-01-16  Andrew Haley  <aph at redhat.com>
> 
> 	* openjdk/hotspot/src/cpu/zero/vm/cppInterpreter_arm.S (asm_method_table):
> 	Add entry for java.dyn.MethodHandles::invoke.
> 	(asm_generate_method_entry): Replace constant 14 with calculation
> 	based on the size of asm_method_table.
> 	Add some comments.
> 
> diff -r 2bbcc83417ae -r f57f03c70b52 arm_port/hotspot/src/cpu/zero/vm/cppInterpreter_arm.S
> --- a/arm_port/hotspot/src/cpu/zero/vm/cppInterpreter_arm.S	Mon Jan 16 13:25:01 2012 -0500
> +++ b/arm_port/hotspot/src/cpu/zero/vm/cppInterpreter_arm.S	Mon Jan 16 13:28:17 2012 -0500
> @@ -782,28 +782,33 @@
>  	cmp	r2, #0
>  	bne	1f
> 
> -	cmp	r3, #14
> +	cmp	r3, #((3f-2f)/4) // i.e. sizeof asm_method_table
>  	adrcc	ip, asm_method_table
>  	ldrcc	r0, [ip, r3, lsl #2]
>  #endif // PRODUCT
>  1:
>  	bx	lr
> +
> +// This table must be kept in sync with AbstractInterpreter::MethodKind
>  asm_method_table:
> -	.word	normal_entry
> -	.word	normal_entry_synchronized
> -	.word	native_entry
> -	.word	native_entry_synchronized
> -	.word	empty_entry
> -	.word	accessor_entry
> -	.word	normal_entry		@ abstract entry
> -	.word	normal_entry		@ java_lang_math_sin
> -	.word	normal_entry		@ java_lang_math_cos
> -	.word	normal_entry		@ java_lang_math_tan
> -	.word	normal_entry		@ java_lang_math_abs
> -	.word	normal_entry		@ java_lang_math_sqrt
> -	.word	normal_entry		@ java_lang_math_log
> -	.word	normal_entry		@ java_lang_math_log10
> -
> +2:
> +        .word   normal_entry                    // method needs locals initialization
> +        .word   normal_entry_synchronized       // method needs locals initialization & is synchronized
> +        .word   native_entry                    // native method
> +        .word   native_entry_synchronized       // native method & is synchronized
> +        .word   empty_entry                     // empty method (code: _return)
> +        .word   accessor_entry                  // accessor method (code: _aload_0, _getfield, _(a|i)return)
> +        .word   normal_entry                    // abstract method (throws an AbstractMethodException)
> +        .word   vm_fatal_error                  // java.dyn.MethodHandles::invoke
> +        .word   normal_entry                    // implementation of java.lang.Math.sin   (x)
> +        .word   normal_entry                    // implementation of java.lang.Math.cos   (x)
> +        .word   normal_entry                    // implementation of java.lang.Math.tan   (x)
> +        .word   normal_entry                    // implementation of java.lang.Math.abs   (x)
> +        .word   normal_entry                    // implementation of java.lang.Math.sqrt  (x)
> +        .word   normal_entry                    // implementation of java.lang.Math.log   (x)
> +        .word   normal_entry                    // implementation of java.lang.Math.log10 (x)
> +3:
> +	
>  	ALIGN_CODE
>  native_entry_synchronized:
>  	b	fast_native_entry_synchronized
> 




More information about the distro-pkg-dev mailing list