Re-enable ARM32 JIT compiler

Andrew Hughes gnu.andrew at redhat.com
Mon Mar 17 12:31:38 UTC 2014



----- Original Message -----
> The bug was actually in the asm interpreter, but it broke the JIT.
> Here:
> 
> @@ -870,7 +873,7 @@
> 
>  	SLOW_ENTRY
>  empty_entry:
> -	ldrh	r3, [r0, #42]
> +	ldrh	r3, [r0, #METHOD_SIZEOFPARAMETERS]
> 
> This code adjusts the stack pointer after an empty method is called.
> 42 is wrong: it should be the field offset of
> methodOopDesc::_size_of_parameters.  While I was at it I found a
> couple more literals and changed them to symbolic names.
> 
> I also took the opportunity to fix a few bugs.  I made the tracing
> code more robust, and commented out some debugging calls that slow
> down the interpreter.  I also fixed a bug in the helper routines that
> were using a static local to hold the address of the card table base:
> this is pointlessly slower than using a non-static local.
> 
> Andrew.
> 
> 
> # HG changeset patch
> # User aph
> # Date 1395056000 0
> # Node ID 2de808a5820a68b390d05ab56934dbca8dbd9dcf
> # Parent  720c95f2266397040d878e255015b638d63c8c56
> Re-enable ARM32 JIT compiler.
> 
> Replace literal offsets for METHOD_SIZEOFPARAMETERS and
> ISTATE_NEXT_FRAME with correct symbolic names.
> Fix trace code not to dereference null pointers.
> Correct Helper_aputfield and helper_aastore not to use static
> _byte_map_base.
> Comment-out calls to TRACE.
> Make sure that ISTATE_METHOD and ISTATE_SELF_LINK are set even when
> JITting fails.
> 
> diff -r 720c95f22663 -r 2de808a5820a src/cpu/zero/vm/asm_helper.cpp
> --- a/src/cpu/zero/vm/asm_helper.cpp	Thu Feb 20 15:02:19 2014 +0000
> +++ b/src/cpu/zero/vm/asm_helper.cpp	Mon Mar 17 11:33:20 2014 +0000
> @@ -378,22 +378,16 @@
>  	  goto handle_exception;
>  	}
>        }
> -      oop* elem_loc = (oop*)(((address) arrayref->base(T_OBJECT)) + index *
> sizeof(oop));
> -      // *(oop*)(((address) arrayref->base(T_OBJECT)) + index * sizeof(oop))
> = value;
> -      *elem_loc = value;
> -      // Mark the card
> -      BarrierSet* bs = Universe::heap()->barrier_set();
> -      static volatile jbyte* _byte_map_base = (volatile
> jbyte*)(((CardTableModRefBS*)bs)->byte_map_base);
> -      OrderAccess::release_store(&_byte_map_base[(uintptr_t)elem_loc >>
> CardTableModRefBS::card_shift], 0);
> +      ((objArrayOopDesc *) arrayref)->obj_at_put(index, value);
>      }
>  handle_exception:
>      return istate->thread()->pending_exception();
>  }
> 
> -extern "C" void Helper_aputfield(oop obj)
> +extern "C" void Helper_aputfield(oop obj, oop val, int offset)
>  {
>        BarrierSet* bs = Universe::heap()->barrier_set();
> -      static volatile jbyte* _byte_map_base = (volatile
> jbyte*)(((CardTableModRefBS*)bs)->byte_map_base);
> +      jbyte* _byte_map_base = (((CardTableModRefBS*)bs)->byte_map_base);
>        OrderAccess::release_store(&_byte_map_base[(uintptr_t)obj >>
>        CardTableModRefBS::card_shift], 0);
>  }
> 
> diff -r 720c95f22663 -r 2de808a5820a src/cpu/zero/vm/cppInterpreter_arm.S
> --- a/src/cpu/zero/vm/cppInterpreter_arm.S	Thu Feb 20 15:02:19 2014 +0000
> +++ b/src/cpu/zero/vm/cppInterpreter_arm.S	Mon Mar 17 11:33:20 2014 +0000
> @@ -526,10 +526,13 @@
>  	mrs	r4, cpsr
>  	mov	r0, jpc
>  	ldr	r1, [thread, #THREAD_TOP_ZERO_FRAME]
> +	cmp	r1, #0
>  	sub	r1, r1, #ISTATE_NEXT_FRAME
> +	beq	0f
> +	DECACHE_JPC
>  	ldr	r2, =my_trace
>  	blx	r2
> -	msr	cpsr, r4
> +0:	msr	cpsr, r4
>  	ldmfd	sp!, {r0, r1, r2, r3, r4, ip, lr}
>  	.endm
>  	
> @@ -551,7 +554,7 @@
>      .elseif dispatch_state == 4
>  	DISPATCH_4
>      .endif
> -	TRACE
> +@	TRACE
>          moveq   pc, ip
>  	ldrb	r1, [jpc, lr]
>          bic     ip, ip, #7
> @@ -561,7 +564,7 @@
>  	.endm
> 
>  	.macro	DISPATCH_BYTECODE
> -	TRACE
> +@	TRACE
>  @        ldrb    r1, [jpc, #2]
>          ldr     ip, [dispatch, r0, lsl #2]
>          ldrb    r2, [jpc, #1]
> @@ -870,7 +873,7 @@
> 
>  	SLOW_ENTRY
>  empty_entry:
> -	ldrh	r3, [r0, #42]
> +	ldrh	r3, [r0, #METHOD_SIZEOFPARAMETERS]
>  	ldr	r1, [r2, #THREAD_JAVA_SP]
>  	add	r1, r1, r3, lsl #2
>  	str	r1, [r2, #THREAD_JAVA_SP]
> @@ -879,7 +882,7 @@
> 
>  	FAST_ENTRY
>  fast_empty_entry:
> -	ldrh	r3, [r0, #42]
> +	ldrh	r3, [r0, #METHOD_SIZEOFPARAMETERS]
>  	ldr	r1, [thread, #THREAD_JAVA_SP]
>  	add	r1, r1, r3, lsl #2
>  	str	r1, [thread, #THREAD_JAVA_SP]
> @@ -1081,7 +1084,7 @@
> 
>  	ldr	r1, [thread, #THREAD_STACK_SIZE]
>  	ldr	r3, [thread, #THREAD_STACK_BASE]
> -	add	r0, r9, #72
> +	add	r0, r9, #ISTATE_NEXT_FRAME
> 
>  	rsb	r3, r1, r3
>  	rsb	r3, r3, arm_sp
> @@ -1104,7 +1107,7 @@
>  	str	r5, [thread, #THREAD_LAST_JAVA_FP]
>  	ldr	r5, [thread, #THREAD_JAVA_SP]
>  	str	r5, [thread, #THREAD_LAST_JAVA_SP]
> -	ldr	r11, [r11, #-72 + ISTATE_METHOD]
> +	ldr	r11, [r11, #-ISTATE_NEXT_FRAME + ISTATE_METHOD]
>  	cmp	r1, #0
>  	bne	.fast_native_entry_exception
>  	ldr	r5, [r11, #METHOD_SIGNATUREHANDLER]
> @@ -1127,7 +1130,7 @@
>  	ldr	r11, [thread, #THREAD_TOP_ZERO_FRAME]
>  	ldr	r1, [thread, #THREAD_PENDING_EXC]
>  	mov	r3, #0
> -	ldr	r11, [r11, #-72 + ISTATE_METHOD]
> +	ldr	r11, [r11, #-ISTATE_NEXT_FRAME + ISTATE_METHOD]
>  	cmp	r1, #0
>  	str	r3, [thread, #THREAD_LAST_JAVA_SP]
>  	str	r3, [thread, #THREAD_LAST_JAVA_FP]
> @@ -3353,12 +3356,12 @@
>  	str	locals, [istate, #ISTATE_LOCALS]
>    USEC	cmp	r3, lr
>  	str	constpool, [istate, #ISTATE_CONSTANTS]
> +	str	tmp1, [istate, #ISTATE_METHOD]
> + 	str	istate, [istate, #ISTATE_SELF_LINK]
>    USEC	bcs	method_entry_freq_count_overflow
>  	DISPATCH_NEXT
>  	DISPATCH_NEXT
>  	DISPATCH_NEXT
> -	str	tmp1, [istate, #ISTATE_METHOD]
> - 	str	istate, [istate, #ISTATE_SELF_LINK]
>  @	mov	lr, #0
>  @        str     lr, [istate, #ISTATE_PREV_LINK]
>  @	str	lr, [istate, #ISTATE_CALLEE]
> 

Committed: http://icedtea.classpath.org/hg/icedtea7-forest/hotspot/rev/ee50fa9e8791

For some reason, this came through inline, so I had to manually copy and paste it
over. It also didn't apply cleanly, but the code seems identical, from manual
examination.

I didn't spot that the longer Changelog had got missed until later. Sorry. I'll
make sure to include it in the release notes instead, so it isn't lost.

Thanks for fixing this,
-- 
Andrew :)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

PGP Key: 248BDC07 (https://keys.indymedia.org/)
Fingerprint = EC5A 1F5E C0AD 1D15 8F1F  8F91 3B96 A578 248B DC07



More information about the distro-pkg-dev mailing list