RTC Thumb2 JIT enhancements (diffs part 3)

ed at camswl.com ed at camswl.com
Thu Mar 11 03:25:35 PST 2010


diff -ruNE old/icedtea6/ports/hotspot/src/cpu/zero/vm/cppInterpreter_arm.S new2/icedtea6/ports/hotspot/src/cpu/zero/vm/cppInterpreter_arm.S
--- old/icedtea6/ports/hotspot/src/cpu/zero/vm/cppInterpreter_arm.S	2010-03-10 17:38:48.000000000 +0000
+++ new2/icedtea6/ports/hotspot/src/cpu/zero/vm/cppInterpreter_arm.S	2010-03-11 09:41:29.000000000 +0000
@@ -15,16 +15,16 @@
 @ 2 along with this work; if not, write to the Free Software Foundation,
 @ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 
-#undef THUMB2EE
+#undef T2JIT
 #if !defined(DISABLE_THUMB2) && defined(HOTSPOT_ASM) && !defined(SHARK)
-#define THUMB2EE
+#define T2JIT
 #endif
 
 #ifdef HOTSPOT_ASM
 
 #define ARMv4
 
-#if defined(SHARK) || defined(THUMB2EE)
+#if defined(SHARK) || defined(T2JIT)
 
 #define USE_COMPILER
 
@@ -36,8 +36,8 @@
 #define MP_COMPILE_THRESHOLD    0x10000         // 65536 - must be a single MOV constant
 #define UP_COMPILE_THRESHOLD    0x30000         // 196608 - must be a single MOV constant
 #else
-#define MP_COMPILE_THRESHOLD    0x2700		// 10000 - must be a single MOV constant
-#define UP_COMPILE_THRESHOLD    0x2700		// 10000 - must be a single MOV constant
+#define MP_COMPILE_THRESHOLD    0x1380		// 10000 - must be a single MOV constant
+#define UP_COMPILE_THRESHOLD    0x1380		// 10000 - must be a single MOV constant
 #endif
 
 #define MAX_FG_METHOD_SIZE      500
@@ -49,7 +49,7 @@
 #define DISABLE_BG_COMP_ON_NON_MP
 #endif
 
-#ifdef THUMB2EE
+#ifdef T2JIT
 #define FREQ_COUNT_OVERFLOW Thumb2_Compile
 #else
 #define FREQ_COUNT_OVERFLOW _ZN18InterpreterRuntime26frequency_counter_overflowEP10JavaThreadPh
@@ -73,12 +73,15 @@
 #define LEAF_STACK_SIZE	200
 #define STACK_SPARE	40
 
+#define TBIT 1
+
 #define stack		r4
 #define	jpc		r5
 #define dispatch	r6
 #define locals		r7
 #define istate		r8
 #define constpool	r9
+#define thread		r10
 #define arm_sp		r13
 
 #define tmp_xxx		r7
@@ -86,17 +89,23 @@
 #define tmp_vvv		r9
 
 #define tmp1		r11
-#define tmp2		r10
 
 #define regset		r4,r5,r6,r7,r9,r10,r11
 #define fast_regset	r8
 
+#define Rframe	r7
+
+#define FRAME_METHOD		(ISTATE_METHOD-ISTATE_NEXT_FRAME)
+#define FRAME_CONSTANTS		(ISTATE_CONSTANTS-ISTATE_NEXT_FRAME)
+#define FRAME_BCP		(ISTATE_BCP-ISTATE_NEXT_FRAME)
+#define FRAME_STACK_LIMIT	(ISTATE_STACK_LIMIT-ISTATE_NEXT_FRAME)
+#define FRAME_LOCALS		(ISTATE_LOCALS-ISTATE_NEXT_FRAME)
+#define FRAME_STACK		(ISTATE_STACK-ISTATE_NEXT_FRAME)
+
 #include "offsets_arm.s"
 
 #define last_implemented_bytecode 201
 
-#define CODE_ALIGN_SIZE 64
-
 	.macro	ALIGN_CODE
 	.align	6
 	.endm
@@ -113,6 +122,18 @@
 	.align	2
 	.endm
 
+#define SLOW_ENTRY_OFFSET 24
+#define FAST_ENTRY_OFFSET 40
+
+	.macro	SLOW_ENTRY
+	ALIGN_CODE
+	.word	0, 0, 0, 0, 0, 0
+	.endm
+
+	.macro	FAST_ENTRY
+	ALIGN_CODE
+	.endm
+
 @------------------------------------------------
 @ Software NULL Pointer check macro.
 @ Usage:
@@ -254,7 +275,7 @@
 @	T2	<thumb2 specific code>
 @------------------------------------------------
 	.macro	T2	p1, p2, p3, p4
-#ifdef THUMB2EE
+#ifdef T2JIT
   .ifnes "\p4", ""
         \p1 \p2, \p3, \p4
   .else
@@ -314,6 +335,11 @@
   .endif
 	.endm
 
+	.macro	LOAD_ISTATE
+	ldr	istate, [thread, #THREAD_TOP_ZERO_FRAME]
+	sub	istate, istate, #ISTATE_NEXT_FRAME
+	.endm
+
 	.macro	CACHE_JPC
 	ldr	jpc, [istate, #ISTATE_BCP]
 	.endm
@@ -330,10 +356,18 @@
 	ldr	constpool, [istate, #ISTATE_CONSTANTS]
 	.endm
 
+	.macro	DECACHE_STACK_USING_FRAME
+	str	stack, [Rframe, #FRAME_STACK]
+	.endm
+
 	.macro	DECACHE_STACK
 	str	stack, [istate, #ISTATE_STACK]
 	.endm
 
+	.macro	DECACHE_JPC_USING_FRAME
+	str	jpc, [Rframe, #FRAME_BCP]
+	.endm
+
 	.macro	DECACHE_JPC
 	str	jpc, [istate, #ISTATE_BCP]
 	.endm
@@ -660,38 +694,30 @@
 	.word	normal_entry		@ java_lang_math_log
 	.word	normal_entry		@ java_lang_math_log10
 
-	ALIGN_CODE
+	SLOW_ENTRY
 native_entry_synchronized:
-	b	fast_native_entry_synchronized
+	b	_ZN14CppInterpreter12native_entryEP13methodOopDesciP6Thread
 
-	ALIGN_CODE
+	FAST_ENTRY
 fast_native_entry_synchronized:
+	mov	r2, thread
 	b	_ZN14CppInterpreter12native_entryEP13methodOopDesciP6Thread
 
-	ALIGN_CODE
+	SLOW_ENTRY
 empty_entry:
-	b	fast_empty_entry
-
-	ALIGN_CODE
-fast_empty_entry:
-	ldr	r3, .L1359
-	ldr	r1, .L1359+4
-.LPIC19:
-	add	r3, pc, r3
-
-	ldr	ip, [r3, r1]
-	ldr	r3, [ip, #0]
-	cmp	r3, #0
-	bne	normal_entry_synchronized
-
 	ldrh	r3, [r0, #42]
 	ldr	r1, [r2, #THREAD_JAVA_SP]
 	add	r1, r1, r3, lsl #2
 	str	r1, [r2, #THREAD_JAVA_SP]
 	bx	lr
-.L1359:
-	.word	_GLOBAL_OFFSET_TABLE_-(.LPIC19+8)
-	.word	_ZN20SafepointSynchronize6_stateE(GOT)
+
+	FAST_ENTRY
+fast_empty_entry:
+	ldrh	r3, [r0, #42]
+	ldr	r1, [thread, #THREAD_JAVA_SP]
+	add	r1, r1, r3, lsl #2
+	str	r1, [thread, #THREAD_JAVA_SP]
+	bx	lr
 
 @ ---- START execute.s ---------------------------------------------------------------------
 
@@ -730,7 +756,7 @@
 	bx	lr
 #endif // HW_NULL_PTR_CHECK
 2:
-#ifdef THUMB2EE
+#ifdef T2JIT
 	b	Thumb2_Check_Null
 #else
 	mov	r0, #0
@@ -826,13 +852,14 @@
 #endif
 
 
-	ALIGN_CODE
+	SLOW_ENTRY
 native_entry:
 	stmfd	arm_sp!, {regset, lr}
+	mov	thread, r2
 	bl	fast_native_entry
 	ldmia	sp!, {regset, pc}
 
-	ALIGN_CODE
+	FAST_ENTRY
 fast_native_entry:
 	adrl	ip, dispatch_init_adcon
 	mov	r11, r0
@@ -841,12 +868,12 @@
 	add	dispatch, dispatch, ip
 	add	dispatch, dispatch, r7
 	ldrh	r1, [r11, #METHOD_SIZEOFPARAMETERS]
-	ldr	r4, [r2, #THREAD_JAVA_SP]
-	ldr	r3, [r2, #THREAD_TOP_ZERO_FRAME]
+	ldr	r4, [thread, #THREAD_JAVA_SP]
+	ldr	r3, [thread, #THREAD_TOP_ZERO_FRAME]
 	mov	r0, #0
 	mov	ip, #INTERPRETER_FRAME
 	sub	r9, r4, #FRAME_SIZE
-	str	r9, [r2, #THREAD_JAVA_SP]	@ drop stack
+	str	r9, [thread, #THREAD_JAVA_SP]	@ drop stack
 	sub	r5, r9, #4		@ stack limit = r9 - 4
 	str	r3, [r9, #ISTATE_NEXT_FRAME]
 	str	ip, [r9, #ISTATE_FRAME_TYPE]
@@ -855,44 +882,40 @@
 	str	r9, [r9, #ISTATE_STACK_BASE]
 	str	r0, [r9, #ISTATE_OOP_TEMP]
 
-@	str	r0, [r9, #ISTATE_CALLEE]
-@	str	r0, [r9, #ISTATE_PREV_LINK]
 	str	r0, [r9, #ISTATE_MSG]
-@	str	r0, [r9, #ISTATE_MDX]
 
-	ldr	r10, [r11, #METHOD_CONSTANTS]
+	ldr	ip, [r11, #METHOD_CONSTANTS]
 	sub	r7, r4, #4
 	mov	r5, #0
 	add	r7, r7, r1, lsl #2
 
-	ldr	r10, [r10, #CONSTANTPOOL_CACHE]
+	ldr	ip, [ip, #CONSTANTPOOL_CACHE]
 
-	str	r2, [r9, #ISTATE_THREAD]
+	str	thread, [r9, #ISTATE_THREAD]
 	str	r5, [r9, #ISTATE_BCP]
 	str	r7, [r9, #ISTATE_LOCALS]
-	str	r10, [r9, #ISTATE_CONSTANTS]
+	str	ip, [r9, #ISTATE_CONSTANTS]
 	str	r11, [r9, #ISTATE_METHOD]
 
-@	stmia	r9, {r2, r5, r7, r10, r11}
-	ldr	r1, [r2, #THREAD_STACK_SIZE]
-	ldr	r3, [r2, #THREAD_STACK_BASE]
+	ldr	r1, [thread, #THREAD_STACK_SIZE]
+	ldr	r3, [thread, #THREAD_STACK_BASE]
 	add	r0, r9, #72
-	mov	r9, r2
+
 	rsb	r3, r1, r3
 	rsb	r3, r3, arm_sp
 	cmp	r3, #4096
-	str	r0, [r9, #THREAD_TOP_ZERO_FRAME]
+	str	r0, [thread, #THREAD_TOP_ZERO_FRAME]
 	ldr	r5, [r11, #METHOD_SIGNATUREHANDLER]
 	blt	.fast_native_entry_throw_stack_overflow
 	cmp	r5, #0
 	bne	.fast_native_entry_got_handleraddr
-	str	r0, [r9, #THREAD_LAST_JAVA_SP]
-	mov	r0, r9
+	str	r0, [thread, #THREAD_LAST_JAVA_SP]
+	mov	r0, thread
 	mov	r1, r11
 	bl	_ZN18InterpreterRuntime19prepare_native_callEP10JavaThreadP13methodOopDesc
-	ldr	r11, [r9, #THREAD_TOP_ZERO_FRAME]
-	ldr	r1, [r9, #THREAD_PENDING_EXC]
-	str	r5, [r9, #THREAD_LAST_JAVA_SP]
+	ldr	r11, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r1, [thread, #THREAD_PENDING_EXC]
+	str	r5, [thread, #THREAD_LAST_JAVA_SP]
 	ldr	r11, [r11, #-72 + ISTATE_METHOD]
 	cmp	r1, #0
 	bne	.fast_native_entry_exception
@@ -901,19 +924,19 @@
 	ldr	r2, [dispatch, #InterpreterRuntime_slow_signature_handler_Address-XXX]
 	cmp	r5, r2
 	bne	.fast_native_entry_get_handler
-	ldr	r3, [r9, #THREAD_TOP_ZERO_FRAME]
+	ldr	r3, [thread, #THREAD_TOP_ZERO_FRAME]
 	mov	r2, #0
-	mov	r0, r9
-	str	r3, [r9, #THREAD_LAST_JAVA_SP]
+	mov	r0, thread
+	str	r3, [thread, #THREAD_LAST_JAVA_SP]
 	mov	r3, r2
 	mov	r1, r11
 	bl	_ZN18InterpreterRuntime22slow_signature_handlerEP10JavaThreadP13methodOopDescPiS4_
-	ldr	r11, [r9, #THREAD_TOP_ZERO_FRAME]
-	ldr	r1, [r9, #THREAD_PENDING_EXC]
+	ldr	r11, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r1, [thread, #THREAD_PENDING_EXC]
 	mov	r3, #0
 	ldr	r11, [r11, #-72 + ISTATE_METHOD]
 	cmp	r1, #0
-	str	r3, [r9, #THREAD_LAST_JAVA_SP]
+	str	r3, [thread, #THREAD_LAST_JAVA_SP]
 	mov	r5, r0
 	bne	.fast_native_entry_exception
 .fast_native_entry_get_handler:
@@ -931,7 +954,7 @@
 	add	r1, r5, #24
 
 	sub	arm_sp, arm_sp, lr, lsl #2
-	add	r2, r9, #THREAD_JNI_ENVIRONMENT
+	add	r2, thread, #THREAD_JNI_ENVIRONMENT
 
 	mov	lr, arm_sp
 	str	r2, [lr], #4
@@ -987,11 +1010,11 @@
 	bge	.fast_copy_args
 
 .fast_no_args:
-	ldr	r0, [r9, #THREAD_TOP_ZERO_FRAME]
+	ldr	r0, [thread, #THREAD_TOP_ZERO_FRAME]
 	mov	r2, #_thread_in_native
 
-	str	r0, [r9, #THREAD_LAST_JAVA_SP]
-	str	r2, [r9, #THREAD_STATE]
+	str	r0, [thread, #THREAD_LAST_JAVA_SP]
+	str	r2, [thread, #THREAD_STATE]
 
 	ldr	ip, [r11, #METHOD_NATIVEHANDLER]
 	ldrh	r11, [r11, #METHOD_SIZEOFPARAMETERS]
@@ -1003,11 +1026,11 @@
 	mov	arm_sp, r4
 
 	ldr	r3, [dispatch, #SafePointSynchronize_state_Address-XXX]
-	str	ip, [r9, #THREAD_STATE]
+	str	ip, [thread, #THREAD_STATE]
 
 	ldr	r3, [r3, #0]
 	cmp	r3, #0
-	ldreq	r3, [r9, #THREAD_SUSPEND_FLAGS]
+	ldreq	r3, [thread, #THREAD_SUSPEND_FLAGS]
 	cmpeq	r3, #0
 	bne	.fast_native_entry_do_special
 
@@ -1015,13 +1038,13 @@
 	mov	r3, #_thread_in_Java
 	mov	r2, #0
 
-	str	r3, [r9, #THREAD_STATE]
-	str	r2, [r9, #THREAD_LAST_JAVA_SP]
+	str	r3, [thread, #THREAD_STATE]
+	str	r2, [thread, #THREAD_LAST_JAVA_SP]
 
 	add	r2, r5, #24
 	ldr	r3, [r5, #4]
 
-	ldr	r5, [r9, #THREAD_TOP_ZERO_FRAME]
+	ldr	r5, [thread, #THREAD_TOP_ZERO_FRAME]
 
 	ldr	lr, [r5], #4
 
@@ -1031,7 +1054,7 @@
 	adr	r3, .return_type_table
 
 	ldrh	r2, [ip, #6]
-	ldr	ip, [r9, #THREAD_ACTIVE_HANDLES]
+	ldr	ip, [thread, #THREAD_ACTIVE_HANDLES]
 
 	mov	tmp1, #0
 	ldr	pc, [r3, r2, lsl #2]
@@ -1055,42 +1078,42 @@
 
 .fast_native_return_dw:
 	str	r0, [r5, #-8]!
-	str	lr, [r9, #THREAD_TOP_ZERO_FRAME]
+	str	lr, [thread, #THREAD_TOP_ZERO_FRAME]
 	str	tmp1, [ip, #JNIHANDLEBLOCK_TOP]
 	str	r1, [r5, #4]
-	str	r5, [r9, #THREAD_JAVA_SP]
+	str	r5, [thread, #THREAD_JAVA_SP]
 	ldmfd	arm_sp!, {fast_regset, pc}
 .fast_native_return_byte:
 	mov	r0, r0, lsl #24
-	str	lr, [r9, #THREAD_TOP_ZERO_FRAME]
+	str	lr, [thread, #THREAD_TOP_ZERO_FRAME]
 	mov	r0, r0, asr #24
 	str	tmp1, [ip, #JNIHANDLEBLOCK_TOP]
 	str	r0, [r5, #-4]!
-	str	r5, [r9, #THREAD_JAVA_SP]
+	str	r5, [thread, #THREAD_JAVA_SP]
 	ldmfd	arm_sp!, {fast_regset, pc}
 .fast_native_return_char:
 	mov	r0, r0, lsl #16
-	str	lr, [r9, #THREAD_TOP_ZERO_FRAME]
+	str	lr, [thread, #THREAD_TOP_ZERO_FRAME]
 	mov	r0, r0, lsr #16
 	str	tmp1, [ip, #JNIHANDLEBLOCK_TOP]
 	str	r0, [r5, #-4]!
-	str	r5, [r9, #THREAD_JAVA_SP]
+	str	r5, [thread, #THREAD_JAVA_SP]
 	ldmfd	arm_sp!, {fast_regset, pc}
 .fast_native_return_bool:
 	ands	r0, r0, #255
-	str	lr, [r9, #THREAD_TOP_ZERO_FRAME]
+	str	lr, [thread, #THREAD_TOP_ZERO_FRAME]
 	movne	r0, #1
 	str	tmp1, [ip, #JNIHANDLEBLOCK_TOP]
 	str	r0, [r5, #-4]!
-	str	r5, [r9, #THREAD_JAVA_SP]
+	str	r5, [thread, #THREAD_JAVA_SP]
 	ldmfd	arm_sp!, {fast_regset, pc}
 .fast_native_return_obj:
 	cmp	r0, #0
 	ldrne	r0, [r0]
 	str	r0, [r5, #-4]!
-	str	lr, [r9, #THREAD_TOP_ZERO_FRAME]
+	str	lr, [thread, #THREAD_TOP_ZERO_FRAME]
 	str	tmp1, [ip, #JNIHANDLEBLOCK_TOP]
-	str	r5, [r9, #THREAD_JAVA_SP]
+	str	r5, [thread, #THREAD_JAVA_SP]
 	ldmfd	arm_sp!, {fast_regset, pc}
 .fast_native_return_short:
 	mov	r0, r0, lsl #16
@@ -1098,23 +1121,23 @@
 .fast_native_return_w:
 	str	r0, [r5, #-4]!
 .fast_native_return_void:
-	str	lr, [r9, #THREAD_TOP_ZERO_FRAME]
+	str	lr, [thread, #THREAD_TOP_ZERO_FRAME]
 	str	tmp1, [ip, #JNIHANDLEBLOCK_TOP]
 .fast_native_exit:
-	str	r5, [r9, #THREAD_JAVA_SP]
+	str	r5, [thread, #THREAD_JAVA_SP]
 	ldmfd	arm_sp!, {fast_regset, pc}
 
 .fast_native_entry_throw_stack_overflow:
-	str	r0, [r9, #THREAD_LAST_JAVA_SP]
-	mov	r0, r9
+	str	r0, [thread, #THREAD_LAST_JAVA_SP]
+	mov	r0, thread
 	bl	_ZN18InterpreterRuntime24throw_StackOverflowErrorEP10JavaThread
 	mov	r3, #0
-	ldr	r1, [r9, #THREAD_PENDING_EXC]
-	str	r3, [r9, #THREAD_LAST_JAVA_SP]
+	ldr	r1, [thread, #THREAD_PENDING_EXC]
+	str	r3, [thread, #THREAD_LAST_JAVA_SP]
 .fast_native_entry_exception:
-	ldr	r5, [r9, #THREAD_TOP_ZERO_FRAME]
+	ldr	r5, [thread, #THREAD_TOP_ZERO_FRAME]
 	ldr	r3, [r5], #4
-	str	r3, [r9, #THREAD_TOP_ZERO_FRAME]
+	str	r3, [thread, #THREAD_TOP_ZERO_FRAME]
 
 	ldrh	r3, [r11, #METHOD_SIZEOFPARAMETERS]
 	add	r5, r5, r3, lsl #2
@@ -1122,7 +1145,7 @@
 
 .fast_native_entry_do_special:
 	stmdb	arm_sp!, {r0, r1}
-	mov	r0, r9
+	mov	r0, thread
 	bl	_ZN10JavaThread40check_special_condition_for_native_transEPS_
 	ldmia	arm_sp!, {r0, r1}
 	b	.fast_native_entry_do_return
@@ -1169,69 +1192,69 @@
 
 	Opcode	goto
         ldrsb   r1, [jpc, #1]
-        ldrb    tmp1, [jpc, #2]
+        ldrb    r2, [jpc, #2]
 branch_taken:
-        orr     tmp1, tmp1, r1, lsl #8
-        DISPATCH_START_REG	tmp1
-	cmp	tmp1, #0
+        orr     r2, r2, r1, lsl #8
+        DISPATCH_START_REG	r2
+	cmp	r2, #0
 	ble	do_backedge
 	DISPATCH_FINISH
 
 branch_taken_unsafe:
 	mov	r2, r2, lsl #24
-	orr	tmp1, r1, r2, asr #16
-        DISPATCH_START_REG	tmp1
-  USEC	cmp	tmp1, #0
+	orr	r2, r1, r2, asr #16
+        DISPATCH_START_REG	r2
+  USEC	cmp	r2, #0
   USEC	ble	do_backedge
 	DISPATCH_FINISH
 
 branch_taken_unsafe_1:
 	add	jpc, jpc, #1
-	orr	tmp1, ip, r1, lsl #8
-        DISPATCH_START_REG	tmp1
-  USEC	cmp	tmp1, #0
+	orr	r2, ip, r1, lsl #8
+        DISPATCH_START_REG	r2
+  USEC	cmp	r2, #0
   USEC	ble	do_backedge
 	DISPATCH_FINISH
 
 branch_taken_unsafe_2:
 	add	jpc, jpc, #2
-	orr	tmp1, ip, r1, lsl #8
-        DISPATCH_START_REG	tmp1
-  USEC	cmp	tmp1, #0
+	orr	r2, ip, r1, lsl #8
+        DISPATCH_START_REG	r2
+  USEC	cmp	r2, #0
   USEC	ble	do_backedge
 	DISPATCH_FINISH
 
 branch_taken_unsafe_3:
 	add	jpc, jpc, #3
-	orr	tmp1, ip, r1, lsl #8
-        DISPATCH_START_REG	tmp1
-  USEC	cmp	tmp1, #0
+	orr	r2, ip, r1, lsl #8
+        DISPATCH_START_REG	r2
+  USEC	cmp	r2, #0
   USEC	ble	do_backedge
 	DISPATCH_FINISH
 
 branch_taken_unsafe_4:
 	add	jpc, jpc, #4
-	orr	tmp1, ip, r1, lsl #8
-        DISPATCH_START_REG	tmp1
-  USEC	cmp	tmp1, #0
+	orr	r2, ip, r1, lsl #8
+        DISPATCH_START_REG	r2
+  USEC	cmp	r2, #0
   USEC	ble	do_backedge
 	DISPATCH_FINISH
 
 do_backedge:
-  USEC	ldr	tmp2, [istate, #ISTATE_METHOD]
+  USEC	ldr	tmp1, [istate, #ISTATE_METHOD]
   OSR	ldr	lr, [dispatch, #InterpreterInvocationLimit_Address-XXX]
-  USEC	ldr	r1, [tmp2, #METHOD_BACKEDGECOUNTER]
-  USEC	ldr	ip, [tmp2, #METHOD_INVOCATIONCOUNTER]
+  USEC	ldr	r1, [tmp1, #METHOD_BACKEDGECOUNTER]
+  USEC	ldr	ip, [tmp1, #METHOD_INVOCATIONCOUNTER]
   USEC	add	r1, r1, #INVOCATIONCOUNTER_COUNTINCREMENT
   OSR	ldr	lr, [lr]
   USEC	add	ip, ip, #INVOCATIONCOUNTER_COUNTINCREMENT
-  USEC	str	r1, [tmp2, #METHOD_BACKEDGECOUNTER]
-#ifdef THUMB2EE
+  USEC	str	r1, [tmp1, #METHOD_BACKEDGECOUNTER]
+#ifdef T2JIT
   OSR	cmp	r1, lr
 #else
   OSR	cmp	r1, lr, lsl #2
 #endif
-  USEC	str	ip, [tmp2, #METHOD_INVOCATIONCOUNTER]
+  USEC	str	ip, [tmp1, #METHOD_INVOCATIONCOUNTER]
   OSR	bcs	do_osr
 
 osr_continue:
@@ -1246,7 +1269,7 @@
 do_synchronize:
 	DECACHE_JPC
 	DECACHE_STACK
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	bl	Helper_SafePoint
 	CACHE_CP
 	CACHE_JPC
@@ -1256,12 +1279,12 @@
 
 #ifdef ON_STACK_REPLACEMENT
 
-#ifdef THUMB2EE
+#ifdef T2JIT
 do_osr:
-	ldr	r3, [tmp2, #METHOD_CONSTMETHOD]
+	ldr	r3, [tmp1, #METHOD_CONSTMETHOD]
 	DECACHE_JPC
 	DECACHE_STACK
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	sub	r1, jpc, r3
 	sub	r1, r1, #CONSTMETHOD_CODEOFFSET
 	bl	FREQ_COUNT_OVERFLOW
@@ -1281,27 +1304,26 @@
 	cmp	ip, #0
 	beq	osr_continue
 
-	ldr	r3, [tmp2, #METHOD_CONSTMETHOD]
+	ldr	r3, [tmp1, #METHOD_CONSTMETHOD]
 	DECACHE_JPC
 	ldrh	r3, [r3, #CONSTMETHOD_CODESIZE]
 	DECACHE_STACK
-	ldr	r0, [istate, #ISTATE_THREAD]
-	sub	r1, jpc, tmp1
+	mov	r0, thread
+	sub	r1, jpc, r2
 	cmp	r3, #MAX_FG_METHOD_SIZE
 	bcc	1f
-	ldr	tmp2, [dispatch, #BackgroundCompilation_Address-XXX]
+	ldr	tmp1, [dispatch, #BackgroundCompilation_Address-XXX]
 	mov	r3, #1
-	ldr	r5, [tmp2]
-	str	r3, [tmp2]
+	ldr	r5, [tmp1]
+	str	r3, [tmp1]
 	bl	FREQ_COUNT_OVERFLOW
-	str	r5, [tmp2]
+	str	r5, [tmp1]
 	b	2f
 1:
 	bl	FREQ_COUNT_OVERFLOW
 2:
-	ldr	r3, [istate, #ISTATE_THREAD]
 	CACHE_CP
-	ldr	r1, [r3, #THREAD_PENDING_EXC]
+	ldr	r1, [thread, #THREAD_PENDING_EXC]
 	CACHE_JPC
 	cmp	r1, #0
 	bne	handle_exception
@@ -1316,20 +1338,19 @@
 
 osr_migrate:
 	ldr	tmp1, [r0, #128]	@ osr_method->osr_entry()
-	mov	r0, r3
+	mov	r0, thread
 	bl	_ZN13SharedRuntime19OSR_migration_beginEP10JavaThread
 	mov	r1, r0
 	ldr	r0, [istate, #ISTATE_METHOD]
 	ldrh	lr, [r0, #METHOD_MAXLOCALS]
 	ldrh	ip, [r0, #METHOD_SIZEOFPARAMETERS]
-	ldr	r3, [istate, #ISTATE_THREAD]
 	sub	lr, lr, ip
-	ldr	r2, [r3, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
 	add	ip, r2, #4
 	ldr	r2, [r2]
 	add	ip, ip, lr, lsl #2
-	str	r2, [r3, #THREAD_TOP_ZERO_FRAME]
-	str	ip, [r3, #THREAD_JAVA_SP]
+	str	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	str	ip, [thread, #THREAD_JAVA_SP]
 	mov	r2, tmp1
 @ r0 = method
 @ r1 = osr_buf
@@ -1339,7 +1360,7 @@
 
 	ldmfd	arm_sp!, {fast_regset, pc}
 
-#endif // THUMB2EE
+#endif // T2JIT
 
 #endif // ON_STACK_REPLACEMENT
 
@@ -1347,7 +1368,7 @@
 	Opcode	ifnull
         POP     r3
         ldrsb   r1, [jpc, #1]
-        ldrb    tmp1, [jpc, #2]
+        ldrb    r2, [jpc, #2]
         cmp     r3, #0
 	beq	branch_taken
 	DISPATCH	3
@@ -1356,7 +1377,7 @@
 	Opcode	ifnonnull
         POP     r3
         ldrsb   r1, [jpc, #1]
-        ldrb    tmp1, [jpc, #2]
+        ldrb    r2, [jpc, #2]
         cmp     r3, #0
 	bne	branch_taken
 	DISPATCH	3
@@ -1364,7 +1385,7 @@
 	Opcode	iflt
         POP     r3
         ldrsb   r1, [jpc, #1]
-        ldrb    tmp1, [jpc, #2]
+        ldrb    r2, [jpc, #2]
         cmp     r3, #0
 	blt	branch_taken
 	DISPATCH	3
@@ -1372,7 +1393,7 @@
 	Opcode	ifge
         POP     r3
         ldrsb   r1, [jpc, #1]
-        ldrb    tmp1, [jpc, #2]
+        ldrb    r2, [jpc, #2]
         cmp     r3, #0
 	bge	branch_taken
 	DISPATCH	3
@@ -1380,7 +1401,7 @@
 	Opcode	ifgt
         POP     r3
         ldrsb   r1, [jpc, #1]
-        ldrb    tmp1, [jpc, #2]
+        ldrb    r2, [jpc, #2]
         cmp     r3, #0
 	bgt	branch_taken
 	DISPATCH	3
@@ -1388,7 +1409,7 @@
 	Opcode	ifle
         POP     r3
         ldrsb   r1, [jpc, #1]
-        ldrb    tmp1, [jpc, #2]
+        ldrb    r2, [jpc, #2]
         cmp     r3, #0
 	ble	branch_taken
 	DISPATCH	3
@@ -1397,7 +1418,7 @@
 	Opcode	if_acmpeq
         POP    r2, r3
         ldrsb   r1, [jpc, #1]
-        ldrb    tmp1, [jpc, #2]
+        ldrb    r2, [jpc, #2]
         cmp     r3, r2
 	beq	branch_taken
 	DISPATCH	3
@@ -1406,7 +1427,7 @@
 	Opcode	if_acmpne
         POP    r2, r3
         ldrsb   r1, [jpc, #1]
-        ldrb    tmp1, [jpc, #2]
+        ldrb    r2, [jpc, #2]
         cmp     r3, r2
 	bne	branch_taken
 	DISPATCH	3
@@ -1414,7 +1435,7 @@
 	Opcode	if_icmplt
         POP    r2, r3
         ldrsb   r1, [jpc, #1]
-        ldrb    tmp1, [jpc, #2]
+        ldrb    r2, [jpc, #2]
         cmp     r3, r2
 	blt	branch_taken
 	DISPATCH	3
@@ -1422,7 +1443,7 @@
 	Opcode	if_icmpge
         POP    r2, r3
         ldrsb   r1, [jpc, #1]
-        ldrb    tmp1, [jpc, #2]
+        ldrb    r2, [jpc, #2]
         cmp     r3, r2
 	bge	branch_taken
 	DISPATCH	3
@@ -1430,7 +1451,7 @@
 	Opcode	if_icmpgt
         POP    r2, r3
         ldrsb   r1, [jpc, #1]
-        ldrb    tmp1, [jpc, #2]
+        ldrb    r2, [jpc, #2]
         cmp     r3, r2
 	bgt	branch_taken
 	DISPATCH	3
@@ -1438,7 +1459,7 @@
 	Opcode	if_icmple
         POP    r2, r3
         ldrsb   r1, [jpc, #1]
-        ldrb    tmp1, [jpc, #2]
+        ldrb    r2, [jpc, #2]
         cmp     r3, r2
 	ble	branch_taken
 	DISPATCH	3
@@ -1455,7 +1476,7 @@
 	bne	handle_return
 	DECACHE_JPC
 	DECACHE_STACK
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	bl	Helper_SafePoint
 	CACHE_JPC
 	cmp	r0, #0
@@ -1465,13 +1486,12 @@
 resolve_get_put:
 	mov	r1, r0
 	mov	tmp1, lr
-        ldr     r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	DECACHE_JPC
         DECACHE_STACK
        	bl      _ZN18InterpreterRuntime15resolve_get_putEP10JavaThreadN9Bytecodes4CodeE
-        ldr     r0, [istate, #ISTATE_THREAD]
+        ldr     r3, [thread, #THREAD_PENDING_EXC]
 	CACHE_JPC
-        ldr     r3, [r0, #THREAD_PENDING_EXC]
 	CACHE_CP
         cmp     r3, #0
 	mov	lr, tmp1
@@ -1480,7 +1500,7 @@
         ldrb    r3, [jpc, #1]
         ldrb    r2, [jpc, #2]
         orr     r3, r3, r2, lsl #8      @ r3 = index
-	add	tmp2, constpool, r3, lsl #4	@ tmp2 = cache
+	add	tmp1, constpool, r3, lsl #4	@ tmp1 = cache
 	bx	lr
 
 accessor_non_w:
@@ -1504,28 +1524,28 @@
 	add	r0, r3, r1
 	ldm	r0, {r0, r1}
 	sub	ip, ip, #4
-	str	ip, [r2, #THREAD_JAVA_SP]
+	str	ip, [thread, #THREAD_JAVA_SP]
 	stmia	ip, {r0, r1}
 	bx	lr
 
 	Opcode	getfield
 	ldrb	r1, [jpc, #2]
-        add     tmp2, constpool, r1, lsl #12
-	add	tmp2, tmp2, r2, lsl #4
-	ldr	r3, [tmp2, #CP_OFFSET]
+        add     tmp1, constpool, r1, lsl #12
+	add	tmp1, tmp1, r2, lsl #4
+	ldr	r3, [tmp1, #CP_OFFSET]
         and     r3, r3, #0x00ff0000
         cmp     r3, #opc_getfield << 16
         blne    resolve_get_put
-  NFBC	POP	tmp1
-        ldr     r2, [tmp2, #CP_OFFSET+12]
-  NFBC	cmp	tmp1, #0
+  NFBC	POP	r3
+        ldr     r2, [tmp1, #CP_OFFSET+12]
+  NFBC	cmp	r3, #0
   NFBC	beq	null_ptr_exception
-  NFBC	ldr	tmp2, [tmp2, #CP_OFFSET+8]
+  NFBC	ldr	tmp1, [tmp1, #CP_OFFSET+8]
         movs    r2, r2, lsr #29
   FBC	movhi	r0, #opc_igetfield
         bls     getfield_non_w
-  NFBC	ldr	tmp2, [tmp1, tmp2]
-  NFBC	PUSH	tmp2
+  NFBC	ldr	tmp1, [r3, tmp1]
+  NFBC	PUSH	tmp1
   NFBC	DISPATCH 3
 
 #ifdef FAST_BYTECODES
@@ -1555,34 +1575,34 @@
 	b	rewrite_bytecode
 #else
 getfield_sh:
-	ldrsh	tmp2, [tmp1, tmp2]
-	PUSH	tmp2
+	ldrsh	tmp1, [r3, tmp1]
+	PUSH	tmp1
 	DISPATCH 3
 getfield_h:
-	ldrh	tmp2, [tmp1, tmp2]
-	PUSH	tmp2
+	ldrh	tmp1, [r3, tmp1]
+	PUSH	tmp1
 	DISPATCH 3
 getfield_sb:
-	ldrsb	tmp2, [tmp1, tmp2]
-	PUSH	tmp2
+	ldrsb	tmp1, [r3, tmp1]
+	PUSH	tmp1
 	DISPATCH 3
 getfield_dw:
-	add	tmp1, tmp1, tmp2
-	ldm	tmp1, {r2, tmp2}
-	PUSH	r2, tmp2
+	add	r3, r3, tmp1
+	ldm	r3, {r2, tmp1}
+	PUSH	r2, tmp1
 	DISPATCH 3
 #endif
 
 	Opcode	putfield
 	ldrb	r1, [jpc, #2]
-        add     tmp2, constpool, r1, lsl #12
-	add	tmp2, tmp2, r2, lsl #4
-	ldr	r3, [tmp2, #CP_OFFSET]
+        add     tmp1, constpool, r1, lsl #12
+	add	tmp1, tmp1, r2, lsl #4
+	ldr	r3, [tmp1, #CP_OFFSET]
         and     r3, r3, #0xff000000
         cmp     r3, #opc_putfield << 24
         blne    resolve_get_put
-        ldr     r2, [tmp2, #CP_OFFSET+12]
-  NFBC	ldr	tmp2, [tmp2, #CP_OFFSET+8]
+        ldr     r2, [tmp1, #CP_OFFSET+12]
+  NFBC	ldr	tmp1, [tmp1, #CP_OFFSET+8]
         movs    r2, r2, lsr #29
 	bls	putfield_non_w
   FBC   mov	r0, #opc_iputfield
@@ -1593,7 +1613,7 @@
   NFBC	POP	r2, r3
   NFBC	cmp	r3, #0
   NFBC	beq	null_ptr_exception
-  NFBC	str	r2, [r3, tmp2]
+  NFBC	str	r2, [r3, tmp1]
   NFBC	DISPATCH 3
 
 putfield_non_w:
@@ -1619,26 +1639,26 @@
 	POP	r2, r3
 	cmp	r3, #0
 	beq	null_ptr_exception
-	strh	r2, [r3, tmp2]
+	strh	r2, [r3, tmp1]
 	DISPATCH 3
 putfield_sb:
 	POP	r2, r3
 	cmp	r3, #0
 	beq	null_ptr_exception
-	strb	r2, [r3, tmp2]
+	strb	r2, [r3, tmp1]
 	DISPATCH 3
 putfield_dw:
 	POP	r2, r3, lr
 	cmp	lr, #0
 	beq	null_ptr_exception
-	add	tmp2, lr, tmp2
-	stm	tmp2, {r2, r3}
+	add	tmp1, lr, tmp1
+	stm	tmp1, {r2, r3}
 	DISPATCH 3
 putfield_a:
 	POP	r2, r3
 	cmp	r3, #0
 	beq	null_ptr_exception
-	str	r2, [r3, tmp2]
+	str	r2, [r3, tmp1]
 	mov	r0, r3
 	bl	Helper_aputfield
 	DISPATCH 3
@@ -1646,67 +1666,67 @@
 
 getstatic_sh:
 	DISPATCH_START	3
-	ldrsh	tmp2, [r3, lr]
+	ldrsh	tmp1, [r3, lr]
 	DISPATCH_NEXT
-	PUSH	tmp2
+	PUSH	tmp1
 	DISPATCH_FINISH
 getstatic_h:
 	DISPATCH_START	3
-	ldrh	tmp2, [r3, lr]
+	ldrh	tmp1, [r3, lr]
 	DISPATCH_NEXT
-	PUSH	tmp2
+	PUSH	tmp1
 	DISPATCH_FINISH
 getstatic_sb:
 	DISPATCH_START	3
-	ldrsb	tmp2, [r3, lr]
+	ldrsb	tmp1, [r3, lr]
 	DISPATCH_NEXT
-	PUSH	tmp2
+	PUSH	tmp1
 	DISPATCH_FINISH
 getstatic_dw:
 	DISPATCH_START	3
 	add	r3, r3, lr
-	ldm	r3, {r2, tmp2}
+	ldm	r3, {r2, tmp1}
 	DISPATCH_NEXT
-	PUSH	r2, tmp2
+	PUSH	r2, tmp1
 	DISPATCH_FINISH
 getstatic_w:
 	DISPATCH_START	3
-	ldr	tmp2, [r3, lr]
+	ldr	tmp1, [r3, lr]
 	DISPATCH_NEXT
-	PUSH	tmp2
+	PUSH	tmp1
 	DISPATCH_FINISH
 
 putstatic_sh:
 putstatic_h:
 	DISPATCH_START	3
-	POP	tmp2
+	POP	tmp1
 	DISPATCH_NEXT
-	strh	tmp2, [r3, r2]
+	strh	tmp1, [r3, r2]
 	DISPATCH_FINISH
 putstatic_w:
 	cmp	lr, #tos_atos >> 1	@ >> 1 due to lsr #29 above
 	beq	putstatic_a
 	DISPATCH_START	3
-	POP	tmp2
+	POP	tmp1
 	DISPATCH_NEXT
-	str	tmp2, [r3, r2]
+	str	tmp1, [r3, r2]
 	DISPATCH_FINISH
 putstatic_sb:
 	DISPATCH_START	3
-	POP	tmp2
+	POP	tmp1
 	DISPATCH_NEXT
-	strb	tmp2, [r3, r2]
+	strb	tmp1, [r3, r2]
 	DISPATCH_FINISH
 putstatic_dw:
 	DISPATCH_START	3
 	add	r2, r2, r3
-	POP	r3, tmp2
+	POP	r3, tmp1
 	DISPATCH_NEXT
-	stm	r2, {r3, tmp2}
+	stm	r2, {r3, tmp1}
 	DISPATCH_FINISH
 putstatic_a:
-	POP	tmp2
-	str	tmp2, [r3, r2]
+	POP	tmp1
+	str	tmp1, [r3, r2]
 	mov	r0, r3
 	bl	Helper_aputfield
 	DISPATCH 3
@@ -1724,13 +1744,12 @@
 	mov	r1, #opc_invokestatic
 resolve_invoke:
 	mov	tmp1, lr
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	DECACHE_JPC
 	DECACHE_STACK
 	bl	_ZN18InterpreterRuntime14resolve_invokeEP10JavaThreadN9Bytecodes4CodeE
-	ldr	r0, [istate, #ISTATE_THREAD]
 	CACHE_JPC
-	ldr	r3, [r0, #4]
+	ldr	r3, [thread, #THREAD_PENDING_EXC]
 	CACHE_CP
 	cmp	r3, #0
         ldrb    r3, [jpc, #1]
@@ -1763,19 +1782,18 @@
 	Opcode	newarray
 	ldrb	r1, [jpc, #1]	@ zero_extendqisi2
 	ldr	r2, [stack, #4]
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	DECACHE_JPC
 	DECACHE_STACK
 	bl	_ZN18InterpreterRuntime8newarrayEP10JavaThread9BasicTypei
-	ldr	r0, [istate, #ISTATE_THREAD]
+	ldr	ip, [thread, #THREAD_PENDING_EXC]
 	CACHE_JPC
-	ldr	ip, [r0, #THREAD_PENDING_EXC]
 	CACHE_CP
 	cmp	ip, #0
-	ldr	r2, [r0, #THREAD_VM_RESULT]
+	ldr	r2, [thread, #THREAD_VM_RESULT]
 	bne	handle_exception
 	str	r2, [stack, #4]
-	str	ip, [r0, #THREAD_VM_RESULT]
+	str	ip, [thread, #THREAD_VM_RESULT]
 	DISPATCH	2
 
 	Opcode	anewarray
@@ -1787,17 +1805,16 @@
 	DECACHE_JPC
 	DECACHE_STACK
 	ldr	r1, [lr, #METHOD_CONSTANTS]
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	bl	_ZN18InterpreterRuntime9anewarrayEP10JavaThreadP19constantPoolOopDescii
-	ldr	r0, [istate, #ISTATE_THREAD]
+	ldr	ip, [thread, #THREAD_PENDING_EXC]
 	CACHE_JPC
-	ldr	ip, [r0, #THREAD_PENDING_EXC]
 	CACHE_CP
 	cmp	ip, #0
-	ldr	r2, [r0, #THREAD_VM_RESULT]
+	ldr	r2, [thread, #THREAD_VM_RESULT]
 	bne	handle_exception
 	str	r2, [stack, #4]
-	str	ip, [r0, #THREAD_VM_RESULT]
+	str	ip, [thread, #THREAD_VM_RESULT]
 	DISPATCH	3
 
 	Opcode	arraylength
@@ -1819,7 +1836,7 @@
 	cmp	r1, #0
 	beq	null_ptr_exception
 	mov	r2, #0
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	mov	r3, r2
 	bl	_ZN12ThreadShadow21set_pending_exceptionEP7oopDescPKci
 	b	handle_exception
@@ -1863,197 +1880,29 @@
 	DISPATCH 3
 
 	Opcode	monitorenter
-	ldr	r1, [stack, #4]
-	cmp	r1, #0
-	beq	.monitorenter_4
-	ldr	r0, [istate, #ISTATE_MONITOR_BASE]
-	ldr	r2, [istate, #ISTATE_STACK_BASE]
-	cmp	r2, r0
-	beq	.monitorenter_5
-	mov	sl, #0
-.monitorenter_1:
-	ldr	r3, [r2, #4]
-	cmp	r3, #0
-	moveq	sl, r2
-	beq	.monitorenter_2
-	cmp	r1, r3
-	beq	.monitorenter_3
-.monitorenter_2:
-	add	r2, r2, #8
-	cmp	r2, r0
-	bne	.monitorenter_1
-.monitorenter_3:
-	cmp	sl, #0
-	beq	.monitorenter_5
-	str	r1, [sl, #4]
-	ldr	r3, [r1, #0]
-	mov	r0, sl
-	orr	tmp1, r3, #1
-	mov	r2, tmp1
-	str	tmp1, [sl, #0]
-	bl	cmpxchg_ptr
-	cmp	r0, tmp1
-	beq	.monitorenter_exit
-	ldr	r0, [istate, #ISTATE_THREAD]
-	bic	r1, tmp1, #3
-	bl	JavaThread_is_lock_owned
-	cmp	r0, #0
-	movne	lr, #0
-	strne	lr, [sl, #0]
-	bne	.monitorenter_exit
-	mov	r1, sl
-	DECACHE_JPC
-	DECACHE_STACK
-	ldr	r0, [istate, #ISTATE_THREAD]
-	bl	_ZN18InterpreterRuntime12monitorenterEP10JavaThreadP15BasicObjectLock
-	ldr	r0, [istate, #ISTATE_THREAD]
-	CACHE_JPC
-	ldr	r3, [r0, #THREAD_PENDING_EXC]
-	cmp	r3, #0
-	beq	.monitorenter_exit
-	b	handle_exception
-.monitorenter_4:
-	b	null_ptr_exception
-.monitorenter_5:
-	mov	lr, #0
-	DECACHE_JPC
-	DECACHE_STACK
-	ldr	r3, [istate, #ISTATE_THREAD]
-	ldr	ip, [istate, #ISTATE_THREAD]
-	ldr	r1, [r3, #THREAD_JAVA_SP]
-	ldr	r3, [r3, #THREAD_JAVA_STACK_BASE]
-	str	lr, [ip, #THREAD_LAST_JAVA_SP]
-	rsb	r3, r3, r1
-	cmp	r3, #7
-	ble	vm_fatal_error
-	sub	r3, r1, #8
-	ldr	r1, [istate, #ISTATE_THREAD]
-	str	r3, [r1, #THREAD_JAVA_SP]
-	ldr	r2, [istate, #ISTATE_STACK]
-	ldr	r1, [istate, #ISTATE_STACK_BASE]
-	add	r3, r2, #4
-	cmp	r1, r3
-	bls	.monitorenter_7
-	add	r0, r2, #8
-.monitorenter_6:
-	ldr	r3, [r0, #-4]
-	mov	r2, r0
-	str	r3, [r0, #-12]
-	add	r0, r0, #4
-	ldr	r1, [istate, #ISTATE_STACK_BASE]
-	cmp	r1, r2
-	bhi	.monitorenter_6
-	ldr	r2, [istate, #ISTATE_STACK]
-.monitorenter_7:
-	sub	r1, r1, #8
-	sub	r2, r2, #8
-	ldr	r3, [istate, #ISTATE_STACK_LIMIT]
-	str	r1, [istate, #ISTATE_STACK_BASE]
-	str	r2, [istate, #ISTATE_STACK]
-	sub	r3, r3, #8
-	mov	r0, #0
-	str	r3, [istate, #ISTATE_STACK_LIMIT]
-	str	r0, [r1, #4]
-	ldr	r1, [istate, #ISTATE_THREAD]
-	ldr	r3, [r1, #THREAD_TOP_ZERO_FRAME]
-	str	r3, [r1, #THREAD_LAST_JAVA_SP]
-	CACHE_STACK
-	ldr	sl, [istate, #ISTATE_STACK_BASE]
-	ldr	r3, [stack, #4]
-	CACHE_JPC
-	mov	r1, r3
-	str	r3, [sl, #4]
-	ldr	r2, [r3, #0]
-	mov	r0, sl
-	orr	tmp1, r2, #1
-	mov	r2, tmp1
-	str	tmp1, [sl, #0]
-	bl	cmpxchg_ptr
-	cmp	r0, tmp1
-	beq	.monitorenter_exit
-	ldr	r0, [istate, #ISTATE_THREAD]
-	bic	r1, tmp1, #3
-	bl	JavaThread_is_lock_owned
-	cmp	r0, #0
-	movne	ip, #0
-	strne	ip, [sl, #0]
-	bne	.monitorenter_exit
-	mov	r1, sl
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, r8
+	POP	r1
 	DECACHE_JPC
 	DECACHE_STACK
-	bl	_ZN18InterpreterRuntime12monitorenterEP10JavaThreadP15BasicObjectLock
-	ldr	r0, [istate, #ISTATE_THREAD]
+	bl	Helper_monitorenter
 	CACHE_JPC
-	ldr	r3, [r0, #THREAD_PENDING_EXC]
-	cmp	r3, #0
-	beq	.monitorenter_exit
-	b	handle_exception
-.monitorenter_exit:
 	CACHE_CP
-	add	stack, stack, #4
-	DISPATCH	1
+	CACHE_STACK		@ monitorenter may expand stack!!!
+	cmp	r0, #0
+	bne	handle_exception
+	DISPATCH 1
 
 	Opcode	monitorexit
-	ldr	sl, [stack, #4]
-	cmp	sl, #0
-	beq	.monitorexit_3
-	ldr	r2, [istate, #ISTATE_MONITOR_BASE]
-	ldr	tmp1, [istate, #ISTATE_STACK_BASE]
-	cmp	tmp1, r2
-	bne	.monitorexit_2
-	b	.monitorexit_4
-.monitorexit_1:
-	add	tmp1, tmp1, #8
-	cmp	tmp1, r2
-	beq	.monitorexit_4
-.monitorexit_2:
-	ldr	r3, [tmp1, #4]
-	cmp	sl, r3
-	bne	.monitorexit_1
-	ldr	r0, [tmp1, #0]
-	mov	lr, #0
-	cmp	r0, lr
-	str	lr, [tmp1, #4]
-	beq	.monitorexit_exit
-	mov	r1, sl
-	mov	r2, tmp1
-	bl	cmpxchg_ptr
-	cmp	tmp1, r0
-	beq	.monitorexit_exit
-	str	sl, [tmp1, #4]
-	mov	r1, tmp1
+	mov	r0, r8
+	POP	r1
 	DECACHE_JPC
 	DECACHE_STACK
-	ldr	r0, [istate, #ISTATE_THREAD]
-	bl	_ZN18InterpreterRuntime11monitorexitEP10JavaThreadP15BasicObjectLock
-	ldr	r0, [istate, #ISTATE_THREAD]
-	ldr	r3, [r0, #THREAD_PENDING_EXC]
+	bl	Helper_monitorexit
 	CACHE_JPC
-	cmp	r3, #0
-	beq	.monitorexit_exit
-	b	handle_exception
-.monitorexit_3:
-	b	null_ptr_exception
-.monitorexit_4:
-	ldr	r0, [istate, #ISTATE_THREAD]
-	DECACHE_JPC
-	DECACHE_STACK
-	bl	_ZN18InterpreterRuntime37throw_illegal_monitor_state_exceptionEP10JavaThread
-	b	handle_exception_with_bcp
-.monitorexit_exit:
-	add	stack, stack, #4
 	CACHE_CP
-	DISPATCH	1
-
-vm_fatal_error:
-	adr	r0, .fatal_filename
-	mov	r1, #99
-	bl	_Z28report_should_not_reach_herePKci
-	b	breakpoint
-.fatal_filename:
-	.ascii	"[Optimsed Assembler Interpreter Loop]\000"
-	ALIGN_WORD
+	cmp	r0, #0
+	bne	handle_exception
+	DISPATCH 1
 
 	Opcode	aastore
 	DECACHE_JPC
@@ -2135,10 +1984,10 @@
 	DISPATCH	4
 do_wide_ret:
 	ldr	r2, [istate, #ISTATE_METHOD]
-	ldr	r2, [r2, #8]
+	ldr	r2, [r2, #METHOD_CONSTMETHOD]
 	ldr	r1, [locals, -r1, lsl #2]
 	add	jpc, r2, r1
-	DISPATCH	48
+	DISPATCH	CONSTMETHOD_CODEOFFSET
 do_wide_iinc:
 	ldrsb	r2, [jpc, #4]
 	ldrb	r3, [jpc, #5]
@@ -2150,28 +1999,27 @@
 
 	Opcode	multianewarray
 	ldrb	tmp1, [jpc, #3]	@ zero_extendqisi2
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	add	r1, stack, tmp1, lsl #2
 	DECACHE_JPC
 	DECACHE_STACK
 	bl	_ZN18InterpreterRuntime14multianewarrayEP10JavaThreadPi
-	ldr	r0, [istate, #ISTATE_THREAD]
 	CACHE_JPC
-	ldr	r1, [r0, #THREAD_PENDING_EXC]
+	ldr	r1, [thread, #THREAD_PENDING_EXC]
 	CACHE_CP
 	cmp	r1, #0
-	ldr	r3, [r0, #THREAD_VM_RESULT]
+	ldr	r3, [thread, #THREAD_VM_RESULT]
 	bne	handle_exception
 	str	r3, [stack, tmp1, asl #2]!
-	str	r1, [r0, #THREAD_VM_RESULT]
+	str	r1, [thread, #THREAD_VM_RESULT]
 	sub	stack, stack, #4
 	DISPATCH	4
 
 	Opcode	jsr_w
 	ldr	r3, [istate, #ISTATE_METHOD]
-	ldr	r1, [r3, #8]
+	ldr	r1, [r3, #METHOD_CONSTMETHOD]
 	rsb	r2, r1, jpc
-	sub	r2, r2, #43
+	sub	r2, r2, #CONSTMETHOD_CODEOFFSET - 5
 	str	r2, [stack], #-4
 	b	do_goto_w
 
@@ -2194,7 +2042,7 @@
 	bne	1f
 	DECACHE_JPC
 	DECACHE_STACK
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	bl	Helper_SafePoint
 	CACHE_JPC
 	CACHE_CP
@@ -2207,20 +2055,19 @@
 	mov	r2, jpc
 	DECACHE_STACK
 	DECACHE_JPC
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	ldr	r1, [istate, #ISTATE_METHOD]
 	bl	_ZN18InterpreterRuntime24get_original_bytecode_atEP10JavaThreadP13methodOopDescPh
 	mov	tmp1, r0
-	ldr	r0, [istate, #ISTATE_THREAD]
-	ldr	r3, [r0, #THREAD_PENDING_EXC]
+	mov	r0, thread
+	ldr	r3, [thread, #THREAD_PENDING_EXC]
 	cmp	r3, #0
 	bne	handle_exception
 	ldr	r2, [istate, #ISTATE_BCP]
 	ldr	r1, [istate, #ISTATE_METHOD]
 	bl	_ZN18InterpreterRuntime11_breakpointEP10JavaThreadP13methodOopDescPh
-	ldr	r0, [istate, #ISTATE_THREAD]
 	CACHE_JPC
-	ldr	r3, [r0, #THREAD_PENDING_EXC]
+	ldr	r3, [thread, #THREAD_PENDING_EXC]
 	CACHE_CP
 	cmp	r3, #0
 	and	r0, tmp1, #255
@@ -2286,43 +2133,41 @@
 	beq	handle_return
 	DECACHE_JPC
 	DECACHE_STACK
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	bl	_ZN18InterpreterRuntime18register_finalizerEP10JavaThreadP7oopDesc
-	ldr	r0, [istate, #ISTATE_THREAD]
 	CACHE_JPC
-	ldr	r3, [r0, #THREAD_PENDING_EXC]
+	ldr	r3, [thread, #THREAD_PENDING_EXC]
 @ CACHE_LOCALS & CACHE_CP not require for handle_retuen / handle_exception
 	cmp	r3, #0
 	beq	handle_return
 	b	handle_exception
 
-	ALIGN_CODE
+	SLOW_ENTRY
 normal_entry_synchronized:
 	stmfd	arm_sp!, {regset, lr}
+	mov	thread, r2
+	ldr	r7, [thread, #THREAD_STACK_SIZE]
+	ldr	r3, [thread, #THREAD_STACK_BASE]
+	rsb	r3, r7, r3
+	rsb	r3, r3, arm_sp
+	cmp	r3, #32768
+	blt	stack_overflow_no_frame
 	bl	fast_normal_entry_synchronized
 	ldmfd	arm_sp!, {regset, pc}
 
-	ALIGN_CODE
+	FAST_ENTRY
 fast_normal_entry_synchronized:
 	stmfd	arm_sp!, {fast_regset, lr}
 
-	mov	sl, r0
-	mov	tmp1, r2
-
-	ldr	r0, [tmp1, #THREAD_STACK_SIZE]
-	ldr	r3, [tmp1, #THREAD_STACK_BASE]
-	rsb	r3, r0, r3
-	rsb	r3, r3, arm_sp
-	cmp	r3, #32768
-	blt	stack_overflow_before_frame
+	mov	tmp1, r0
 
-	ldrh	r2, [sl, #METHOD_MAXLOCALS]
-	ldrh	r3, [sl, #METHOD_SIZEOFPARAMETERS]
+	ldrh	r2, [tmp1, #METHOD_MAXLOCALS]
+	ldrh	r3, [tmp1, #METHOD_SIZEOFPARAMETERS]
 	rsb	r8, r3, r2
 
-	ldr	r1, [tmp1, #THREAD_JAVA_SP]
-	ldrh	r0, [sl, #METHOD_MAXSTACK]
-	ldr	r3, [tmp1, #THREAD_JAVA_STACK_BASE]
+	ldr	r1, [thread, #THREAD_JAVA_SP]
+	ldrh	r0, [tmp1, #METHOD_MAXSTACK]
+	ldr	r3, [thread, #THREAD_JAVA_STACK_BASE]
 
 	sub	r5, r1, r8, lsl #2
 	sub	r5, r5, #FRAME_SIZE+STACK_SPARE+LEAF_STACK_SIZE
@@ -2338,24 +2183,21 @@
 	subs	r8, r8, #1
 	str	r2, [r1, #-4]!
 	bgt	.zero_locals_synchronized
-	str	r1, [tmp1, #THREAD_JAVA_SP]
+	str	r1, [thread, #THREAD_JAVA_SP]
 
 .normal_entry_synchronized_no_locals:
-	mov	r2, tmp1
-	mov	r1, sl
-	add	r0, tmp1, #THREAD_JAVA_STACK_BASE
+	mov	r2, thread
+	mov	r1, tmp1
+	add	r0, thread, #THREAD_JAVA_STACK_BASE
 	bl	build_frame
-	mov	tmp_vvv, r0
-	ldr	r3, [tmp1, #THREAD_TOP_ZERO_FRAME]
-	sub	r0, r0, #72
-	mov	istate, r0
-	str	r3, [tmp_vvv, #0]
+	sub	istate, r0, #ISTATE_NEXT_FRAME
+	ldr	r3, [thread, #THREAD_TOP_ZERO_FRAME]
+	str	r0, [thread, #THREAD_TOP_ZERO_FRAME]
+	str	r0, [thread, #THREAD_LAST_JAVA_SP]
+	str	r3, [istate, #ISTATE_NEXT_FRAME]
 	adrl	ip, dispatch_init_adcon
 	ldm	ip, {r0, r1}
 	add	r0, r0, ip
-	str	tmp_vvv, [tmp1, #THREAD_TOP_ZERO_FRAME]
-@	CACHE_JPC
-	str	tmp_vvv, [tmp1, #THREAD_LAST_JAVA_SP]
 	add	dispatch, r1, r0
 	ldr	r0, [istate, #ISTATE_METHOD]
 	ldr	r3, [r0, #METHOD_ACCESSFLAGS]
@@ -2367,20 +2209,21 @@
 	CACHE_LOCALS
 	tst	r3, #JVM_ACC_STATIC
 	ldrne	r3, [r0, #METHOD_CONSTANTS]
-	ldreq	sl, [locals, #0]
-	ldrne	r2, [r3, #16]
-	ldr	tmp1, [istate, #ISTATE_MONITOR_BASE]
-	ldrne	sl, [r2, #60]
-	ldr	r3, [sl, #0]
+	ldreq	tmp1, [locals, #0]
+	ldrne	r2, [r3, #CONSTANTPOOL_POOL_HOLDER]
+	ldrne	tmp1, [r2, #KLASS_PART+KLASS_JAVA_MIRROR]
+	ldr	r3, [tmp1, #0]
 	orr	tmp_xxx, r3, #1
-	str	tmp_xxx, [tmp1, #-8]!
+	ldr	ip, [istate, #ISTATE_MONITOR_BASE]
+	str	tmp_xxx, [ip, #-8]
 .normal_do_synchronisation_2:
-	ldr	tmp_vvv, [sl, #0]
+	ldr	tmp_vvv, [tmp1, #0]
 	cmp	tmp_xxx, tmp_vvv
 	bne	.normal_do_synchronisation_3
 	mov	r0, tmp_xxx
-	mov	r1, tmp1
-	mov	r2, sl
+	ldr	r1, [istate, #ISTATE_MONITOR_BASE]
+	sub	r1, r1, #8
+	mov	r2, tmp1
 	mov	r3, #0xffffffc0
 	bic	r3, r3, #0xf000
 	blx	r3
@@ -2388,21 +2231,22 @@
 	bne	.normal_do_synchronisation_2
 	b	1f
 .normal_do_synchronisation_3:
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	bic	r1, tmp_xxx, #3
 	bl	JavaThread_is_lock_owned
 	cmp	r0, #0
 	beq	.normal_do_synchronisation_4
+	ldr	ip, [istate, #ISTATE_MONITOR_BASE]
 	mov	r3, #0
-	str	r3, [tmp1]
+	str	r3, [ip, #-8]
 	b	1f
 .normal_do_synchronisation_4:
-	mov	r1, tmp1
+	ldr	r1, [istate, #ISTATE_MONITOR_BASE]
+	sub	r1, r1, #8
 	DECACHE_STACK
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	bl	_ZN18InterpreterRuntime12monitorenterEP10JavaThreadP15BasicObjectLock
-	ldr	r0, [istate, #ISTATE_THREAD]
-	ldr	r3, [r0, #THREAD_PENDING_EXC]
+	ldr	r3, [thread, #THREAD_PENDING_EXC]
 	cmp	r3, #0
 	mov	r2, r0
 	bne	handle_exception_do_not_unlock
@@ -2425,15 +2269,15 @@
         ldr     r3, [r0, #METHOD_CONSTMETHOD]
         ldrh    r3, [r3, #CONSTMETHOD_CODESIZE]
 	mov	r1, #0
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
         cmp     r3, #MAX_FG_METHOD_SIZE
         bcc     1f
-        ldr     tmp2, [dispatch, #BackgroundCompilation_Address-XXX]
+        ldr     tmp1, [dispatch, #BackgroundCompilation_Address-XXX]
         mov     r3, #1
-        ldr     r5, [tmp2]
-        str     r3, [tmp2]
+        ldr     r5, [tmp1]
+        str     r3, [tmp1]
         bl      FREQ_COUNT_OVERFLOW
-        str     r5, [tmp2]
+        str     r5, [tmp1]
         b       2f
 1:
 	bl	FREQ_COUNT_OVERFLOW
@@ -2465,15 +2309,15 @@
 	SW_NPC	cmp	r2, #0
 	SW_NPC	beq	null_ptr_exception
 .abortentry110:
-	ldr	tmp2, [r2, #4]				@ rcvr->klass()
+	ldr	tmp1, [r2, #4]				@ rcvr->klass()
 	tst	r3, #flag_methodInterface
 	bne	.invokeinterface_methodInterface
 
 	ldr	lr, [r0, #CP_OFFSET+4]			@ lr = iclass
 
-	add	r1, tmp2, #INSTANCEKLASS_VTABLE_OFFSET
-	ldr	r2, [tmp2, #KLASS_PART+INSTANCEKLASS_VTABLE_LEN]
-	ldr	ip, [tmp2, #KLASS_PART+INSTANCEKLASS_ITABLE_LEN]
+	add	r1, tmp1, #INSTANCEKLASS_VTABLE_OFFSET
+	ldr	r2, [tmp1, #KLASS_PART+INSTANCEKLASS_VTABLE_LEN]
+	ldr	ip, [tmp1, #KLASS_PART+INSTANCEKLASS_ITABLE_LEN]
 	add	r2, r2, #1
 	bic	r2, r2, #1
 
@@ -2490,29 +2334,26 @@
 
 	ldr	r3, [r0, #CP_OFFSET+8]
 	ldr	r2, [r1, #-4]
-	add	r3, tmp2, r3, lsl #2
-	ldr	tmp2, [r3, r2]
-	cmp	tmp2, #0
+	add	r3, tmp1, r3, lsl #2
+	ldr	tmp1, [r3, r2]
+	cmp	tmp1, #0
 	beq	abstractmethod_exception
 .invokeinterface_invoke:
-	ldr	tmp1, [istate, #ISTATE_THREAD]
-@	str	tmp2, [istate, #ISTATE_CALLEE]
-	ldr	ip, [tmp2, #METHOD_FROM_INTERPRETED]
+	ldr	ip, [tmp1, #METHOD_FROM_INTERPRETED]
 	mov	r1, #0
-	str	ip, [istate, #36]
-	str	r1, [tmp1, #THREAD_LAST_JAVA_SP]
+	str	r1, [thread, #THREAD_LAST_JAVA_SP]
 
 	add	stack, stack, #4
-	str	stack, [tmp1, #THREAD_JAVA_SP]
+	str	stack, [thread, #THREAD_JAVA_SP]
 
 	ldr	r3, [ip]
 
-	mov	r0, tmp2
-	mov	r1, ip
-#ifndef SHARK
-	add	r3, r3, #CODE_ALIGN_SIZE
+	mov	r0, tmp1
+#ifdef SHARK
+	mov	r2, thread
+#else
+	add	r3, r3, #FAST_ENTRY_OFFSET
 #endif
-	mov	r2, tmp1
 	blx	r3
 
 	adrl	ip, dispatch_init_adcon
@@ -2522,18 +2363,17 @@
 
 	CACHE_LOCALS
 
-	ldr	ip, [istate, #ISTATE_THREAD]
 	CACHE_JPC
-	ldr	stack, [ip, #THREAD_JAVA_SP]
+	ldr	stack, [thread, #THREAD_JAVA_SP]
 	ldr	r2, [istate, #ISTATE_STACK_LIMIT]
 	sub	stack, stack, #4
 
-	ldr	r1, [ip, #THREAD_TOP_ZERO_FRAME]
+	ldr	r1, [thread, #THREAD_TOP_ZERO_FRAME]
 	add	r2, r2, #4
-	str	r2, [ip, #THREAD_JAVA_SP]
-	str	r1, [ip, #THREAD_LAST_JAVA_SP]
+	str	r2, [thread, #THREAD_JAVA_SP]
+	str	r1, [thread, #THREAD_LAST_JAVA_SP]
 	DISPATCH_START	5
-	ldr	r3, [ip, #4]
+	ldr	r3, [thread, #THREAD_PENDING_EXC]
 	DISPATCH_NEXT
 	DISPATCH_NEXT
 	cmp	r3, #0
@@ -2545,11 +2385,11 @@
 
 .invokeinterface_methodInterface:
 	tst	r3, #flag_vfinalMethod
-	ldrne	tmp2, [r0, #CP_OFFSET+8]
+	ldrne	tmp1, [r0, #CP_OFFSET+8]
 	bne	.invokeinterface_invoke
 	ldr	r1, [r0, #CP_OFFSET+8]
-	add	r3, tmp2, r1, lsl #2
-	ldr	tmp2, [r3, #INSTANCEKLASS_VTABLE_OFFSET]
+	add	r3, tmp1, r1, lsl #2
+	ldr	tmp1, [r3, #INSTANCEKLASS_VTABLE_OFFSET]
 	b	.invokeinterface_invoke
 
 #ifdef FAST_BYTECODES
@@ -2562,7 +2402,6 @@
 	DECACHE_JPC
 	add	r0, r2, asl #4
 	ldr	r3, [r0, #CP_OFFSET+12]
-	ldr	tmp1, [istate, #ISTATE_THREAD]
 	and	r1, r3, #255
 	ldr	r2, [stack, r1, asl #2]
 	mov	r1, #0
@@ -2571,15 +2410,13 @@
 .abortentry117:
 	HW_NPC	ldr	r3, [r2]		@ Only to provoke abort
 
-	ldr	tmp2, [r0, #CP_OFFSET+8]
+	ldr	tmp1, [r0, #CP_OFFSET+8]
 
-@	str	tmp2, [istate, #ISTATE_CALLEE]
-	ldr	ip, [tmp2, #METHOD_FROM_INTERPRETED]
-	str	r1, [tmp1, #THREAD_LAST_JAVA_SP]
-	str	ip, [istate, #36]
+	ldr	ip, [tmp1, #METHOD_FROM_INTERPRETED]
+	str	r1, [thread, #THREAD_LAST_JAVA_SP]
 
 	add	stack, stack, #4
-	str	stack, [tmp1, #THREAD_JAVA_SP]
+	str	stack, [thread, #THREAD_JAVA_SP]
 
 	ldr	r3, [ip, #0]
 	b	normal_dispatch_and_return
@@ -2604,20 +2441,19 @@
 #else
         DECACHE_STACK
 	DECACHE_JPC
-        ldr     tmp1, [istate, #ISTATE_THREAD]
         and     r1, r3, #255
         ldr     r2, [stack, r1, asl #2]
         mov     r1, #0
         cmp     r2, #0
         beq     null_ptr_exception
 
-        ldr     tmp2, [r0, #CP_OFFSET+8]
+        ldr     tmp1, [r0, #CP_OFFSET+8]
         tst     r3, #flag_vfinalMethod
         bne     1f
 
         ldr     r3, [r2, #4]
-        add     r3, r3, tmp2, lsl #2
-        ldr     tmp2, [r3, #INSTANCEKLASS_VTABLE_OFFSET]
+        add     r3, r3, tmp1, lsl #2
+        ldr     tmp1, [r3, #INSTANCEKLASS_VTABLE_OFFSET]
 1:
 #endif // FAST_BYTECODES
 
@@ -2631,37 +2467,33 @@
 	DECACHE_JPC
         add     r0, r0, r2, asl #4
         ldr     r3, [r0, #CP_OFFSET+12]
-        ldr     tmp1, [istate, #ISTATE_THREAD]
         and     r1, r3, #255
         ldr     r2, [stack, r1, asl #2]
         mov     r1, #0
         SW_NPC	cmp     r2, #0
         SW_NPC	beq     null_ptr_exception_jpc_0
 
-        ldr     tmp2, [r0, #CP_OFFSET+8]
+        ldr     tmp1, [r0, #CP_OFFSET+8]
 .abortentry104:
         ldr     r3, [r2, #4]
-        add     r3, r3, tmp2, lsl #2
-        ldr     tmp2, [r3, #INSTANCEKLASS_VTABLE_OFFSET]
+        add     r3, r3, tmp1, lsl #2
+        ldr     tmp1, [r3, #INSTANCEKLASS_VTABLE_OFFSET]
 #endif // FAST_BYTECODES
-
-@        str     tmp2, [istate, #ISTATE_CALLEE]
-        ldr     ip, [tmp2, #METHOD_FROM_INTERPRETED]
-        str     r1, [tmp1, #THREAD_LAST_JAVA_SP]
-        str     ip, [istate, #36]
+        ldr     ip, [tmp1, #METHOD_FROM_INTERPRETED]
+        str     r1, [thread, #THREAD_LAST_JAVA_SP]
 
         add     stack, stack, #4
-        str     stack, [tmp1, #THREAD_JAVA_SP]
+        str     stack, [thread, #THREAD_JAVA_SP]
 
         ldr     r3, [ip, #0]
 
 normal_dispatch_and_return:
-	mov	r0, tmp2
-	mov	r1, ip
-#ifndef SHARK
-	add	r3, r3, #CODE_ALIGN_SIZE
+	mov	r0, tmp1
+#ifdef SHARK
+	mov	r2, thread
+#else
+	add	r3, r3, #FAST_ENTRY_OFFSET
 #endif
-	mov	r2, tmp1
 	blx	r3
 
 	adrl	ip, dispatch_init_adcon
@@ -2671,18 +2503,17 @@
 
 	CACHE_LOCALS
 
-	ldr	ip, [istate, #ISTATE_THREAD]
 	CACHE_JPC
-	ldr	stack, [ip, #THREAD_JAVA_SP]
+	ldr	stack, [thread, #THREAD_JAVA_SP]
 	ldr	r2, [istate, #ISTATE_STACK_LIMIT]
 	sub	stack, stack, #4
 
-	ldr	r1, [ip, #THREAD_TOP_ZERO_FRAME]
+	ldr	r1, [thread, #THREAD_TOP_ZERO_FRAME]
 	add	r2, r2, #4
-	str	r2, [ip, #THREAD_JAVA_SP]
-	str	r1, [ip, #THREAD_LAST_JAVA_SP]
+	str	r2, [thread, #THREAD_JAVA_SP]
+	str	r1, [thread, #THREAD_LAST_JAVA_SP]
 	DISPATCH_START	3
-	ldr	r3, [ip, #4]
+	ldr	r3, [thread, #THREAD_PENDING_EXC]
 	DISPATCH_NEXT
 	DISPATCH_NEXT
 	cmp	r3, #0
@@ -2710,19 +2541,15 @@
 	DECACHE_JPC
   FBC	add	r0, r2, asl #4
 
-	ldr	tmp2, [r0, #CP_OFFSET+4]
+	ldr	tmp1, [r0, #CP_OFFSET+4]
 	mov	r1, #0
-@	str	tmp2, [istate, #ISTATE_CALLEE]
-	ldr	r3, [tmp2, #METHOD_FROM_INTERPRETED]
-	ldr	tmp1, [istate, #ISTATE_THREAD]
-	str	r3, [istate, #36]
-	str	r1, [tmp1, #THREAD_LAST_JAVA_SP]
+	ldr	r3, [tmp1, #METHOD_FROM_INTERPRETED]
+	str	r1, [thread, #THREAD_LAST_JAVA_SP]
 
 	add	stack, stack, #4
-	str	stack, [tmp1, #THREAD_JAVA_SP]
+	str	stack, [thread, #THREAD_JAVA_SP]
 
-	ldr	ip, [istate, #36]
-	ldr	r3, [ip, #0]
+	ldr	r3, [r3, #0]
 	b	normal_dispatch_and_return
 
 
@@ -2745,7 +2572,6 @@
   FBC	add	r0, r2, asl #4
 
 	ldr	r3, [r0, #CP_OFFSET+12]
-	ldr	tmp1, [istate, #ISTATE_THREAD]
 	and	r3, r3, #255
 	ldr	r2, [stack, r3, asl #2]
 	mov	r1, #0
@@ -2754,54 +2580,49 @@
 .abortentry118:
 	HW_NPC	ldr	r3, [r2]		@ Only to provoke abort
 
-	ldr	tmp2, [r0, #CP_OFFSET+4]
+	ldr	tmp1, [r0, #CP_OFFSET+4]
 
-@	str	tmp2, [istate, #ISTATE_CALLEE]
-	ldr	ip, [tmp2, #METHOD_FROM_INTERPRETED]
-	str	r1, [tmp1, #THREAD_LAST_JAVA_SP]
-	str	ip, [istate, #36]
+	ldr	ip, [tmp1, #METHOD_FROM_INTERPRETED]
+	str	r1, [thread, #THREAD_LAST_JAVA_SP]
 
 	add	stack, stack, #4
-	str	stack, [tmp1, #THREAD_JAVA_SP]
+	str	stack, [thread, #THREAD_JAVA_SP]
 
 	ldr	r3, [ip, #0]
 	b	normal_dispatch_and_return
 
-	ALIGN_CODE
+	SLOW_ENTRY
 normal_entry:
 	stmfd	arm_sp!, {regset, lr}
-
-	ldr	r7, [r2, #THREAD_STACK_SIZE]
-	ldr	r3, [r2, #THREAD_STACK_BASE]
+	mov	thread, r2
+	ldr	r7, [thread, #THREAD_STACK_SIZE]
+	ldr	r3, [thread, #THREAD_STACK_BASE]
 	rsb	r3, r7, r3
 	rsb	r3, r3, arm_sp
 	cmp	r3, #32768
 	blt	stack_overflow_no_frame
-
 	bl	fast_normal_entry
-
 	ldmfd	arm_sp!, {regset, pc}
 
-	ALIGN_CODE
+	FAST_ENTRY
 fast_normal_entry:
 	adrl	ip, dispatch_init_adcon
-	mov	tmp2, r0
+	mov	tmp1, r0
 	ldm	ip, {r0, r1}
-	mov	tmp1, r2
 	add	r0, r0, ip
-	ldr	stack, [tmp1, #THREAD_JAVA_SP]
+	ldr	stack, [thread, #THREAD_JAVA_SP]
 	add	dispatch, r1, r0
 
 	stmdb	arm_sp!, {fast_regset, lr}
 
-	ldrh	r0, [tmp2, #METHOD_MAXLOCALS]
+	ldrh	r0, [tmp1, #METHOD_MAXLOCALS]
 	mov	r1, #0
-	ldrh	r3, [tmp2, #METHOD_SIZEOFPARAMETERS]
+	ldrh	r3, [tmp1, #METHOD_SIZEOFPARAMETERS]
         mov     ip, #INTERPRETER_FRAME
-	ldrh	r2, [tmp2, #METHOD_MAXSTACK]
+	ldrh	r2, [tmp1, #METHOD_MAXSTACK]
         sub     r7, r0, r3
 
-	ldr	r3, [tmp1, #THREAD_JAVA_STACK_BASE]
+	ldr	r3, [thread, #THREAD_JAVA_STACK_BASE]
 	sub	r5, stack, r7, lsl #2
 	sub	r5, r5, #FRAME_SIZE+STACK_SPARE+LEAF_STACK_SIZE
 	sub	r5, r5, r2, lsl #2
@@ -2818,12 +2639,12 @@
         subs    r5, r5, #2
         bcs     1b
 3:
-	ldr	r3, [tmp1, #THREAD_TOP_ZERO_FRAME]
+	ldr	r3, [thread, #THREAD_TOP_ZERO_FRAME]
 	mov	lr, #0
         sub     istate, stack, #FRAME_SIZE
         sub     r2, istate, r2, lsl #2
         str     lr, [istate, #ISTATE_MSG]
-	str	r2, [tmp1, #THREAD_JAVA_SP]
+	str	r2, [thread, #THREAD_JAVA_SP]
         sub     r5, r2, #4                      @ stack limit = istate - stackwords - 4
 	str	r3, [istate, #ISTATE_NEXT_FRAME]
 	str	ip, [istate, #ISTATE_FRAME_TYPE]
@@ -2835,20 +2656,20 @@
 	str	r1, [istate, #ISTATE_OOP_TEMP]
         add     locals, locals, r0, lsl #2
         sub     stack, istate, #4
-        ldr     jpc, [tmp2, #METHOD_CONSTMETHOD]
-        ldr     constpool, [tmp2, #METHOD_CONSTANTS]
+        ldr     jpc, [tmp1, #METHOD_CONSTMETHOD]
+        ldr     constpool, [tmp1, #METHOD_CONSTANTS]
         add     ip, istate, #ISTATE_NEXT_FRAME
 	DISPATCH_START	CONSTMETHOD_CODEOFFSET
         ldr     constpool, [constpool, #CONSTANTPOOL_CACHE]
-        str     ip, [tmp1, #THREAD_TOP_ZERO_FRAME]
-  USEC	ldr	r3, [r10, #METHOD_INVOCATIONCOUNTER]
-        str     ip, [tmp1, #THREAD_LAST_JAVA_SP]
+        str     ip, [thread, #THREAD_TOP_ZERO_FRAME]
+  USEC	ldr	r3, [tmp1, #METHOD_INVOCATIONCOUNTER]
+        str     ip, [thread, #THREAD_LAST_JAVA_SP]
 	DISPATCH_NEXT
   USEC	ldr	lr, [dispatch, #InterpreterInvocationLimit_Address-XXX]
   USEC	add	r3, r3, #INVOCATIONCOUNTER_COUNTINCREMENT
-        str     tmp1, [istate, #ISTATE_THREAD]
+        str     thread, [istate, #ISTATE_THREAD]
   USEC	ldr	lr, [lr]
-  USEC	str	r3, [tmp2, #METHOD_INVOCATIONCOUNTER]
+  USEC	str	r3, [tmp1, #METHOD_INVOCATIONCOUNTER]
 	str	locals, [istate, #ISTATE_LOCALS]
   USEC	cmp	r3, lr
 	str	constpool, [istate, #ISTATE_CONSTANTS]
@@ -2856,27 +2677,27 @@
 	DISPATCH_NEXT
 	DISPATCH_NEXT
 	DISPATCH_NEXT
-	str	r10, [istate, #ISTATE_METHOD]
+	str	tmp1, [istate, #ISTATE_METHOD]
 @	mov	lr, #0
 @        str     lr, [istate, #ISTATE_PREV_LINK]
 @	str	lr, [istate, #ISTATE_CALLEE]
 	DISPATCH_FINISH
 #ifdef USE_COMPILER
 method_entry_freq_count_overflow:
-        ldr     r3, [r10, #METHOD_CONSTMETHOD]
+        ldr     r3, [tmp1, #METHOD_CONSTMETHOD]
 	DECACHE_JPC
         ldrh    r3, [r3, #CONSTMETHOD_CODESIZE]
-	str	r10, [istate, #ISTATE_METHOD]
+	str	tmp1, [istate, #ISTATE_METHOD]
 	mov	r1, #0
-	mov	r0, tmp1
+	mov	r0, thread
         cmp     r3, #MAX_FG_METHOD_SIZE
         bcc     1f
-        ldr     tmp2, [dispatch, #BackgroundCompilation_Address-XXX]
+        ldr     tmp1, [dispatch, #BackgroundCompilation_Address-XXX]
         mov     r3, #1
-        ldr     r5, [tmp2]
-        str     r3, [tmp2]
+        ldr     r5, [tmp1]
+        str     r3, [tmp1]
         bl      FREQ_COUNT_OVERFLOW
-        str     r5, [tmp2]
+        str     r5, [tmp1]
         b       2f
 1:
 	bl	FREQ_COUNT_OVERFLOW
@@ -2887,16 +2708,35 @@
 	CACHE_CP
 	DISPATCH	0
 
-#ifdef THUMB2EE
-#define THUMB2_MAXLOCALS 1000
+#ifdef T2JIT
+
+#define JAZ_V1	r5
+#define JAZ_V2	r6
+#define JAZ_V3	r7
+#define JAZ_V4	r8
+#define	JAZ_V5	r9
+#define	JAZ_V6	r11
+
+#define JAZ_REGSET	JAZ_V1,JAZ_V2,JAZ_V3,JAZ_V4,JAZ_V5,JAZ_V6
+#define JAZ_REGSET_LEN	6
+
 call_thumb2:
-	mov	ip, r1
-	sub	r1, locals, #THUMB2_MAXLOCALS * 4
-	ldr	r2, [istate, #ISTATE_THREAD]
-	sub	r3, locals, #31 * 4
+	stmdb	sp!, {JAZ_REGSET}
+	mov	ip, #0
+3:
+	ldrsh	r3, [r1], #2
+	cmp	r3, #-1
+	ldrne	r3, [locals, -r3, lsl #2]
+	strne	r3, [sp, ip, lsl #2]
+	add	ip, ip, #1
+	cmp	ip, #JAZ_REGSET_LEN
+	bne	3b
+
+	ldmia	sp!, {JAZ_REGSET}
+1:
 	add	stack, stack, #4
-	bx	ip
-#endif // THUMB2EE
+	bx	r0
+#endif // T2JIT
 
 #endif // USE_COMPILER
 	.global	Thumb2_Install
@@ -2906,24 +2746,23 @@
 	bx	lr
 
 handle_return:
-	ldr	tmp2, [istate, #ISTATE_MONITOR_BASE]	@ tmp2 = base
+	ldr	r9, [istate, #ISTATE_MONITOR_BASE]	@ r9 = base
 
 	ldr	tmp1, [istate, #ISTATE_STACK_BASE]	@ tmp1 = end
-	ldr	tmp_xxx, [istate, #ISTATE_THREAD]
 
-	cmp	tmp1, tmp2
+	cmp	tmp1, r9
 	blcc	return_check_monitors
 
 	mov	r3, #0
 	ldrb	lr, [jpc, #0]
 
-	ldr	r2, [tmp_xxx, #THREAD_TOP_ZERO_FRAME]
-	str	r3, [tmp_xxx, #THREAD_LAST_JAVA_SP]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	str	r3, [thread, #THREAD_LAST_JAVA_SP]
 	ldr	r0, [istate, #ISTATE_METHOD]
 	ldr	r3, [r2, #0]
 	ldrh	r0, [r0, #40]
 	add	r1, r2, #4
-	str	r3, [tmp_xxx, #THREAD_TOP_ZERO_FRAME]
+	str	r3, [thread, #THREAD_TOP_ZERO_FRAME]
 
 	add	r1, r1, r0, lsl #2
 
@@ -2937,28 +2776,28 @@
 	ldreq	r0, [stack, #4]
 	streq	r0, [r1, #-4]!
 
-	str	r1, [tmp_xxx, #THREAD_JAVA_SP]
+	str	r1, [thread, #THREAD_JAVA_SP]
 
 	ldmfd	arm_sp!, {fast_regset, pc}
 
 @ ----------------------------------------------------------------------------------------
 stack_overflow_no_frame:
-	mov	r0, tmp1
-	ldr	ip, [r0, #THREAD_TOP_ZERO_FRAME]
-	str	ip, [r0, #THREAD_LAST_JAVA_SP]
+	mov	r0, thread
+	ldr	ip, [thread, #THREAD_TOP_ZERO_FRAME]
+	str	ip, [thread, #THREAD_LAST_JAVA_SP]
 	bl	_ZN18InterpreterRuntime24throw_StackOverflowErrorEP10JavaThread
 	ldmfd	arm_sp!, {regset, pc}
 
 stack_overflow_before_frame:
-	mov	r0, tmp1
-	ldr	ip, [r0, #THREAD_TOP_ZERO_FRAME]
-	str	ip, [r0, #THREAD_LAST_JAVA_SP]
+	mov	r0, thread
+	ldr	ip, [thread, #THREAD_TOP_ZERO_FRAME]
+	str	ip, [thread, #THREAD_LAST_JAVA_SP]
 	bl	_ZN18InterpreterRuntime24throw_StackOverflowErrorEP10JavaThread
 	ldmfd	arm_sp!, {fast_regset, pc}
 
 handle_exception_do_not_unlock:
 	mov	r3, #1
-	strb	r3, [r2, #THREAD_DO_NOT_UNLOCK]
+	strb	r3, [thread, #THREAD_DO_NOT_UNLOCK]
 	b	handle_exception_with_bcp
 
 abstractmethod_exception:
@@ -2977,7 +2816,7 @@
 	mov	r2, r1
 	ldr	r1, [dispatch, #VmSymbols_symbols_Address-XXX]
 	ldr	r1, [r1, r0, lsl #2]
-        ldr     r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	bl	Helper_Raise
         b       handle_exception_with_bcp
 null_str:
@@ -3009,7 +2848,7 @@
 	beq	1f
 
 	mov	r0, istate
-	ldr	r1, [istate, #ISTATE_THREAD]
+	mov	r1, thread
 	bl	Helper_HandleException
 	cmp	r0, #0
 	beq	1f
@@ -3020,34 +2859,33 @@
 	CACHE_CP
 	DISPATCH 0
 1:
-	ldr	tmp2, [istate, #ISTATE_MONITOR_BASE]	@ tmp2 = base
+	ldr	r9, [istate, #ISTATE_MONITOR_BASE]	@ r9 = base
 
 	ldr	tmp1, [istate, #ISTATE_STACK_BASE]	@ tmp1 = end
-	ldr	tmp_xxx, [istate, #ISTATE_THREAD]
 
 	mov	r3, #0
-	ldrb	r0, [tmp_xxx, #THREAD_DO_NOT_UNLOCK]
-	strb	r3, [tmp_xxx, #THREAD_DO_NOT_UNLOCK]
+	ldrb	r0, [thread, #THREAD_DO_NOT_UNLOCK]
+	strb	r3, [thread, #THREAD_DO_NOT_UNLOCK]
 	cmp	r0, #0
 	bne	2f
 
-	cmp	tmp1, tmp2
+	cmp	tmp1, r9
 	blcc	return_check_monitors
 
 2:
 	mov	r3, #0
 
-	ldr	r2, [tmp_xxx, #THREAD_TOP_ZERO_FRAME]
-	str	r3, [tmp_xxx, #THREAD_LAST_JAVA_SP]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	str	r3, [thread, #THREAD_LAST_JAVA_SP]
 	ldr	r0, [istate, #ISTATE_METHOD]
 	ldr	r3, [r2, #0]
 	ldrh	r0, [r0, #40]
 	add	r1, r2, #4
-	str	r3, [tmp_xxx, #THREAD_TOP_ZERO_FRAME]
+	str	r3, [thread, #THREAD_TOP_ZERO_FRAME]
 
 	add	r1, r1, r0, lsl #2
 
-	str	r1, [tmp_xxx, #THREAD_JAVA_SP]
+	str	r1, [thread, #THREAD_JAVA_SP]
 
 	ldmfd	arm_sp!, {fast_regset, pc}
 
@@ -3057,15 +2895,15 @@
 	ldr	r2, [istate, #ISTATE_METHOD]
 	ldr	r4, [r2, #METHOD_ACCESSFLAGS]
 	tst	r4, #1<<5
-	subne	tmp2, tmp2, #8
-	cmp	tmp1, tmp2
+	subne	r9, r9, #8
+	cmp	tmp1, r9
 	bcs	2f
 1:
 	ldr	r3, [tmp1, #4]
 	cmp	r3, #0
 	bne	3f
 	add	tmp1, tmp1, #8
-	cmp	tmp1, tmp2
+	cmp	tmp1, r9
 	bcc	1b
 
 2:
@@ -3073,48 +2911,57 @@
 
 	ldmeqia	arm_sp!, {r4, pc}
 
-	ldr	tmp1, [tmp2, #4]		@ base->obj == NULL
+	ldr	tmp1, [r9, #4]		@ base->obj == NULL
 	cmp	tmp1, #0
 	beq	4f
 
-	ldr	r0, [tmp2, #0]			@ r0 = header
+	ldr	r0, [r9, #0]			@ r0 = header
 	mov	r3, #0
 	cmp	r0, #0
-	str	r3, [tmp2, #4]			@ base->obj = NULL
+	str	r3, [r9, #4]			@ base->obj = NULL
 
 	ldmeqia	arm_sp!, {r4, pc}
 
 	mov	r1, tmp1
-	mov	r2, tmp2
+	mov	r2, r9
 	bl	cmpxchg_ptr
-	cmp	tmp2, r0
+	cmp	r9, r0
 
 	ldmeqia	arm_sp!, {r4, pc}
 
-	str	tmp1, [tmp2, #4]
+	str	tmp1, [r9, #4]
 
-	mov	r1, tmp2
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r1, r9
+	mov	r0, thread
 	bl	Helper_synchronized_exit
 
 	ldmeqia	arm_sp!, {r4, pc}
 
 3:
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	bl	Helper_RaiseIllegalMonitorException
 	b	2b
 
 4:
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	bl	Helper_RaiseIllegalMonitorException
 	ldmia	arm_sp!, {r4, pc}
 
-	ALIGN_CODE
+	SLOW_ENTRY
 accessor_entry:
-	b	slow_accessor_entry
+	stmfd	arm_sp!, {regset, lr}
+	mov	thread, r2
+	ldr	r7, [thread, #THREAD_STACK_SIZE]
+	ldr	r3, [thread, #THREAD_STACK_BASE]
+	rsb	r3, r7, r3
+	rsb	r3, r3, arm_sp
+	cmp	r3, #32768
+	blt	stack_overflow_no_frame
+	bl	fast_accessor_entry
+	ldmia	sp!, {regset, pc}
 
-	ALIGN_CODE
-slow_accessor_entry:
+	FAST_ENTRY
+fast_accessor_entry:
   USEC	adrl	ip, dispatch_init_adcon
   USEC	ldr	r3, [ip]
   USEC	add	r3, r3, ip
@@ -3126,7 +2973,7 @@
   USEC	add	r3, r3, #INVOCATIONCOUNTER_COUNTINCREMENT
   USEC	str	r3, [r0, #METHOD_INVOCATIONCOUNTER]
   USEC	cmp	r3, ip
-  USEC	bcs	normal_entry
+  USEC	bcs	fast_normal_entry
 
 	ldr	r1, [r0, #METHOD_CONSTMETHOD]
 	ldrb	r3, [r1, #CONSTMETHOD_CODEOFFSET+2]
@@ -3137,14 +2984,14 @@
 
 	add	r1, ip, #CP_OFFSET
 	ldr	r3, [r1, r3, lsl #4]!		@ r1 = cache, r3 = flags
-	ldr	ip, [r2, #THREAD_JAVA_SP]			@ ip == stack
+	ldr	ip, [thread, #THREAD_JAVA_SP]			@ ip == stack
 	and	r3, r3, #0x00ff0000
 	cmp	r3, #opc_getfield << 16
 	ldr	r3, [ip, #0]
-	bne	normal_entry
+	bne	fast_normal_entry
 
 	cmp	r3, #0
-	beq	normal_entry
+	beq	fast_normal_entry
 
 	ldr	r0, [r1, #12]
 	ldr	r1, [r1, #8]
@@ -3155,46 +3002,6 @@
 	str	r0, [ip, #0]
 	bx	lr
 
-.fast_accessor_non_w:
-	bcs	.fast_accessor_h
-	beq	.fast_accessor_sb
-	tst	lr, #2
-	bne	.fast_accessor_dw
-.fast_accessor_sh:
-	DISPATCH_STATE	2
-	DISPATCH_NEXT
-	ldrsh	tmp1, [r2, r3]
-	DISPATCH_NEXT
-	DISPATCH_NEXT
-	PUT_STACK	0, tmp1
-	DISPATCH_FINISH
-.fast_accessor_h:
-	DISPATCH_STATE	2
-	DISPATCH_NEXT
-	ldrh	tmp1, [r2, r3]
-	DISPATCH_NEXT
-	DISPATCH_NEXT
-	PUT_STACK	0, tmp1
-	DISPATCH_FINISH
-.fast_accessor_sb:
-	DISPATCH_STATE	2
-	DISPATCH_NEXT
-	ldrsb	tmp1, [r2, r3]
-	DISPATCH_NEXT
-	DISPATCH_NEXT
-	PUT_STACK	0, tmp1
-	DISPATCH_FINISH
-.fast_accessor_dw:
-	DISPATCH_STATE	2
-	add	tmp1, r2, r3
-	DISPATCH_NEXT
-	ldm	tmp1, {tmp2, tmp1}
-	DISPATCH_NEXT
-	PUT_STACK	0, tmp1
-	DISPATCH_NEXT
-	PUSH	tmp2
-	DISPATCH_FINISH
-
 div_zero_jpc_1:
 	sub	jpc, jpc, #1
 .lrem_0:
@@ -3218,10 +3025,10 @@
 array_bound_exception_jpc_0_r3:
 	mov	r2, r3
 	b	array_bounds_exception
-array_bound_exception_jpc_1_tmp2:
+array_bound_exception_jpc_1_tmp1:
 	sub	jpc, jpc, #1
-array_bound_exception_jpc_0_tmp2:
-	mov	r2, tmp2
+array_bound_exception_jpc_0_tmp1:
+	mov	r2, tmp1
 	b	array_bounds_exception
 array_bound_exception_jpc_3:
 	sub	jpc, jpc, #1
@@ -3234,7 +3041,7 @@
 	DECACHE_JPC
         DECACHE_STACK
 	mov	r1, r2
-        ldr     r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	bl	Helper_RaiseArrayBoundException
         b       handle_exception_with_bcp
 
@@ -4167,7 +3974,7 @@
 
 #endif // USE_COMPILER
 
-#ifdef THUMB2EE
+#ifdef T2JIT
 	bl	Thumb2_Initialize
 #endif
 
@@ -4832,22 +4639,26 @@
 	.word	jrem_31
 	.word	jrem_32
 
-#ifdef THUMB2EE
+#ifdef T2JIT
+
+	.macro	LOAD_FRAME
+	ldr	Rframe, [thread, #THREAD_TOP_ZERO_FRAME]
+	.endm
+
 @ R0 = BCI
 @ R1 = index
-#define Rthread	r9
 	.global	Thumb2_invokeinterface_stub
 Thumb2_invokeinterface_stub:
+	LOAD_FRAME
 	stmdb	sp!, {ip, lr}
-	ldr	ip, [istate, #ISTATE_METHOD]
+	ldr	ip, [Rframe, #FRAME_METHOD]
 	sub	stack, stack, #4
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [Rframe, #FRAME_CONSTANTS]
 	ldr	ip, [ip, #METHOD_CONSTMETHOD]
-	DECACHE_STACK
+	str	stack, [Rframe, #FRAME_STACK]
 	add	jpc, ip, r0
-
         add     r0, r2, r1, lsl #4
-	DECACHE_JPC
+	str	jpc, [Rframe, #FRAME_BCP]
 
         ldr     r2, [r0, #CP_OFFSET]
         and     r2, r2, #0x00ff0000
@@ -4859,15 +4670,15 @@
 	ldr	r2, [stack, r2, lsl #2]
 	cmp	r2, #0
 	beq	istub_null_ptr_exception
-	ldr	tmp2, [r2, #4]				@ rcvr->klass()
+	ldr	tmp1, [r2, #4]				@ rcvr->klass()
 	tst	r3, #flag_methodInterface
 	bne	istub_methodInterface
 
 	ldr	lr, [r0, #CP_OFFSET+4]			@ lr = iclass
 
-	add	r1, tmp2, #INSTANCEKLASS_VTABLE_OFFSET
-	ldr	r2, [tmp2, #KLASS_PART+INSTANCEKLASS_VTABLE_LEN]
-	ldr	ip, [tmp2, #KLASS_PART+INSTANCEKLASS_ITABLE_LEN]
+	add	r1, tmp1, #INSTANCEKLASS_VTABLE_OFFSET
+	ldr	r2, [tmp1, #KLASS_PART+INSTANCEKLASS_VTABLE_LEN]
+	ldr	ip, [tmp1, #KLASS_PART+INSTANCEKLASS_ITABLE_LEN]
 	add	r2, r2, #1
 	bic	r2, r2, #1
 
@@ -4884,68 +4695,67 @@
 
 	ldr	r3, [r0, #CP_OFFSET+8]
 	ldr	r2, [r1, #-4]
-	add	r3, tmp2, r3, lsl #2
-	ldr	tmp2, [r3, r2]
-	cmp	tmp2, #0
+	add	r3, tmp1, r3, lsl #2
+	ldr	tmp1, [r3, r2]
+	cmp	tmp1, #0
 	beq	istub_abstractmethod_exception
 istub_invoke:
-	ldr	ip, [tmp2, #METHOD_FROM_INTERPRETED]
+	ldr	ip, [tmp1, #METHOD_FROM_INTERPRETED]
 	mov	r1, #0
-	str	ip, [istate, #36]
-	str	r1, [Rthread, #THREAD_LAST_JAVA_SP]
+	str	r1, [thread, #THREAD_LAST_JAVA_SP]
 
 	add	stack, stack, #4
-	str	stack, [Rthread, #THREAD_JAVA_SP]
+	str	stack, [thread, #THREAD_JAVA_SP]
 
 	ldr	r3, [ip]
 
-	mov	r0, tmp2
-	mov	r1, ip
-#ifndef SHARK
-	add	r3, r3, #CODE_ALIGN_SIZE
+	mov	r0, tmp1
+#ifdef SHARK
+	mov	r2, thread
+#else
+	add	r3, r3, #FAST_ENTRY_OFFSET
 #endif
-	mov	r2, Rthread
 	blx	r3
 
-	ldr	Rthread, [istate, #ISTATE_THREAD]
+	LOAD_FRAME
 
-	ldr	stack, [Rthread, #THREAD_JAVA_SP]
-	ldr	r2, [istate, #ISTATE_STACK_LIMIT]
+	ldr	stack, [thread, #THREAD_JAVA_SP]
+	ldr	r2, [Rframe, #FRAME_STACK_LIMIT]
 
-	ldr	r1, [Rthread, #THREAD_TOP_ZERO_FRAME]
 	add	r2, r2, #4
-	str	r2, [Rthread, #THREAD_JAVA_SP]
-	str	r1, [Rthread, #THREAD_LAST_JAVA_SP]
-	ldr	r3, [Rthread, #4]
+	str	r2, [thread, #THREAD_JAVA_SP]
+	str	Rframe, [thread, #THREAD_LAST_JAVA_SP]
+	ldr	r3, [thread, #4]
 	cmp	r3, #0
 	bne	istub_exception
 	ldmia	sp!, {ip, pc}
 
 istub_methodInterface:
 	tst	r3, #flag_vfinalMethod
-	ldrne	tmp2, [r0, #CP_OFFSET+8]
+	ldrne	tmp1, [r0, #CP_OFFSET+8]
 	bne	istub_invoke
 	ldr	r1, [r0, #CP_OFFSET+8]
-	add	r3, tmp2, r1, lsl #2
-	ldr	tmp2, [r3, #INSTANCEKLASS_VTABLE_OFFSET]
+	add	r3, tmp1, r1, lsl #2
+	ldr	tmp1, [r3, #INSTANCEKLASS_VTABLE_OFFSET]
 	b	istub_invoke
 
 istub_resolve:
-	mov	tmp2, r1
+	mov	tmp1, r1
 	mov	r1, #opc_invokeinterface
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	ldr	ip, resolve_invoke_adcon
 	blx	ip
-	ldr	r3, [Rthread, #4]
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r3, [thread, #4]
+	ldr	r2, [Rframe, #FRAME_CONSTANTS]
 	cmp	r3, #0
 	bne	istub_exception
-	add	r0, r2, tmp2, lsl #4	@ r1 = cache
+	add	r0, r2, tmp1, lsl #4	@ r1 = cache
 	b	2b
 
 istub_exception:
 	ldmia	sp!, {ip, lr}
 	ldr	ip, handle_exception_adcon
+	LOAD_ISTATE
 	bx	ip
 
 istub_null_ptr_exception:
@@ -4957,9 +4767,10 @@
 istub_incompatibleclass_exception:
 	mov	r0, #VMSYMBOLS_IncompatibleClassChangeError
 3:
-	CACHE_JPC
+	ldr	jpc, [Rframe, #FRAME_BCP]
 	ldmia	sp!, {ip, lr}
 	ldr	ip, raise_exception_adcon
+	LOAD_ISTATE
 	bx	ip
 
 resolve_invoke_adcon:
@@ -4972,21 +4783,23 @@
 	.word	raise_exception
 helper_aputfield_adcon:
 	.word	Helper_aputfield
+lr_to_bci_adcon:
+	.word	Thumb2_lr_to_bci
 
 @ R0 = BCI
 @ R1 = index
 	.global	Thumb2_invokevirtual_stub
 Thumb2_invokevirtual_stub:
+	LOAD_FRAME
 	stmdb	sp!, {ip, lr}
-        ldr     ip, [istate, #ISTATE_METHOD]
+        ldr     ip, [Rframe, #FRAME_METHOD]
         sub     stack, stack, #4
-        ldr     r2, [istate, #ISTATE_CONSTANTS]
+        ldr     r2, [Rframe, #FRAME_CONSTANTS]
         ldr     ip, [ip, #METHOD_CONSTMETHOD]
-        DECACHE_STACK
+	str	stack, [Rframe, #FRAME_STACK]
         add     jpc, ip, r0
-
         add     r0, r2, r1, lsl #4
-        DECACHE_JPC
+	str	jpc, [Rframe, #FRAME_BCP]
 
         ldr     r2, [r0, #CP_OFFSET]
         and     r2, r2, #0xff000000
@@ -5000,139 +4813,285 @@
         cmp     r2, #0
         beq     istub_null_ptr_exception
 
-        ldr     tmp2, [r0, #CP_OFFSET+8]
+        ldr     tmp1, [r0, #CP_OFFSET+8]
         tst     r3, #flag_vfinalMethod
         bne     1f
 
         ldr     r3, [r2, #4]
-        add     r3, r3, tmp2, lsl #2
-        ldr     tmp2, [r3, #INSTANCEKLASS_VTABLE_OFFSET]
+        add     r3, r3, tmp1, lsl #2
+        ldr     tmp1, [r3, #INSTANCEKLASS_VTABLE_OFFSET]
 1:
 	mov	r1, #0
-        ldr     ip, [tmp2, #METHOD_FROM_INTERPRETED]
-        str     r1, [Rthread, #THREAD_LAST_JAVA_SP]
-        str     ip, [istate, #36]
+        ldr     ip, [tmp1, #METHOD_FROM_INTERPRETED]
+        str     r1, [thread, #THREAD_LAST_JAVA_SP]
 
         add     stack, stack, #4
-        str     stack, [Rthread, #THREAD_JAVA_SP]
+        str     stack, [thread, #THREAD_JAVA_SP]
 
         ldr     r3, [ip, #0]
 
-	mov	r0, tmp2
-	mov	r1, ip
-#ifndef SHARK
-	add	r3, r3, #CODE_ALIGN_SIZE
+	mov	r0, tmp1
+#ifdef SHARK
+	mov	r2, thread
+#else
+	add	r3, r3, #FAST_ENTRY_OFFSET
 #endif
-	mov	r2, Rthread
 	blx	r3
+	LOAD_FRAME
 
-        ldr     Rthread, [istate, #ISTATE_THREAD]
-
-	ldr	stack, [Rthread, #THREAD_JAVA_SP]
-	ldr	r2, [istate, #ISTATE_STACK_LIMIT]
+	ldr	stack, [thread, #THREAD_JAVA_SP]
+	ldr	r2, [Rframe, #FRAME_STACK_LIMIT]
 
-	ldr	r1, [Rthread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r1, [thread, #THREAD_TOP_ZERO_FRAME]
 	add	r2, r2, #4
-	str	r2, [Rthread, #THREAD_JAVA_SP]
-	str	r1, [Rthread, #THREAD_LAST_JAVA_SP]
-	ldr	r3, [Rthread, #4]
+	str	r2, [thread, #THREAD_JAVA_SP]
+	str	r1, [thread, #THREAD_LAST_JAVA_SP]
+	ldr	r3, [thread, #4]
 	cmp	r3, #0
 	bne	istub_exception
 	ldmia	sp!, {ip, pc}
 
 ivstub_resolve:
-	mov	tmp2, r1
+	mov	tmp1, r1
 	mov	r1, #opc_invokevirtual
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	ldr	ip, resolve_invoke_adcon
 	blx	ip
-	ldr	r3, [Rthread, #4]
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r3, [thread, #4]
+	ldr	r2, [Rframe, #FRAME_CONSTANTS]
 	cmp	r3, #0
 	bne	istub_exception
-	add	r0, r2, tmp2, lsl #4	@ r1 = cache
+	add	r0, r2, tmp1, lsl #4	@ r1 = cache
 	b	2b
 
 @ R0 = BCI
 @ R1 = index
+	.global	Thumb2_invokevfinalresolved_stub
+Thumb2_invokevfinalresolved_stub:
+	LOAD_FRAME
+        stmdb   sp!, {ip, lr}
+        ldr     ip, [Rframe, #FRAME_METHOD]
+        sub     stack, stack, #4
+        ldr     r2, [Rframe, #FRAME_CONSTANTS]
+        ldr     ip, [ip, #METHOD_CONSTMETHOD]
+        DECACHE_STACK_USING_FRAME
+        add     jpc, ip, r0
+
+        add     r0, r2, r1, lsl #4
+        DECACHE_JPC_USING_FRAME
+        ldr     r3, [r0, #CP_OFFSET+12]
+        and     r2, r3, #255
+        ldr     r2, [stack, r2, asl #2]
+        cmp     r2, #0
+        beq     istub_null_ptr_exception
+
+        ldr     tmp1, [r0, #CP_OFFSET+8]
+        mov     r1, #0
+        ldr     ip, [tmp1, #METHOD_FROM_INTERPRETED]
+        str     r1, [thread, #THREAD_LAST_JAVA_SP]
+
+        add     stack, stack, #4
+        str     stack, [thread, #THREAD_JAVA_SP]
+
+        ldr     r3, [ip, #0]
+
+        mov     r0, tmp1
+#ifdef SHARK
+	mov	r2, thread
+#else
+        add     r3, r3, #FAST_ENTRY_OFFSET
+#endif
+        blx     r3
+	LOAD_FRAME
+
+        ldr     stack, [thread, #THREAD_JAVA_SP]
+        ldr     r2, [Rframe, #FRAME_STACK_LIMIT]
+
+        add     r2, r2, #4
+        str     r2, [thread, #THREAD_JAVA_SP]
+        str     Rframe, [thread, #THREAD_LAST_JAVA_SP]
+        ldr     r3, [thread, #4]
+        cmp     r3, #0
+        bne     istub_exception
+        ldmia   sp!, {ip, pc}
+
+@ R0 = BCI
+@ R1 = index
+	.global	Thumb2_invokevirtualresolved_stub
+Thumb2_invokevirtualresolved_stub:
+	LOAD_FRAME
+        stmdb   sp!, {ip, lr}
+        ldr     ip, [Rframe, #FRAME_METHOD]
+        sub     stack, stack, #4
+        ldr     r2, [Rframe, #FRAME_CONSTANTS]
+        ldr     ip, [ip, #METHOD_CONSTMETHOD]
+        DECACHE_STACK_USING_FRAME
+        add     jpc, ip, r0
+
+        add     r0, r2, r1, lsl #4
+        DECACHE_JPC_USING_FRAME
+
+        ldr     r3, [r0, #CP_OFFSET+12]
+        and     r2, r3, #255
+        ldr     r2, [stack, r2, asl #2]
+        cmp     r2, #0
+        beq     istub_null_ptr_exception
+
+        ldr     tmp1, [r0, #CP_OFFSET+8]
+        ldr     r3, [r2, #4]
+        add     r3, r3, tmp1, lsl #2
+        ldr     tmp1, [r3, #INSTANCEKLASS_VTABLE_OFFSET]
+        mov     r1, #0
+        ldr     ip, [tmp1, #METHOD_FROM_INTERPRETED]
+        str     r1, [thread, #THREAD_LAST_JAVA_SP]
+
+        add     stack, stack, #4
+        str     stack, [thread, #THREAD_JAVA_SP]
+
+        ldr     r3, [ip, #0]
+
+        mov     r0, tmp1
+#ifdef SHARK
+	mov	r2, thread
+#else
+        add     r3, r3, #FAST_ENTRY_OFFSET
+#endif
+        blx     r3
+	LOAD_FRAME
+
+        ldr     stack, [thread, #THREAD_JAVA_SP]
+        ldr     r2, [Rframe, #FRAME_STACK_LIMIT]
+
+        add     r2, r2, #4
+        str     r2, [thread, #THREAD_JAVA_SP]
+        str     Rframe, [thread, #THREAD_LAST_JAVA_SP]
+        ldr     r3, [thread, #4]
+        cmp     r3, #0
+        bne     istub_exception
+        ldmia   sp!, {ip, pc}
+
+@ R0 = BCI
+@ R1 = index
 	.global	Thumb2_invokestatic_stub
 Thumb2_invokestatic_stub:
+	LOAD_FRAME
         stmdb   sp!, {ip, lr}
-        ldr     ip, [istate, #ISTATE_METHOD]
+        ldr     ip, [Rframe, #FRAME_METHOD]
         sub     stack, stack, #4
-        ldr     r2, [istate, #ISTATE_CONSTANTS]
+        ldr     r2, [Rframe, #FRAME_CONSTANTS]
         ldr     ip, [ip, #METHOD_CONSTMETHOD]
-        DECACHE_STACK
+        DECACHE_STACK_USING_FRAME
         add     jpc, ip, r0
 
         add     r0, r2, r1, lsl #4
-        DECACHE_JPC
+        DECACHE_JPC_USING_FRAME
 
         ldr     r2, [r0, #CP_OFFSET]
 	and	r2, r2, #0x00ff0000
 	cmp	r2, #opc_invokestatic << 16
 	bne	isstub_resolve
 2:
-	ldr	tmp2, [r0, #CP_OFFSET+4]
+	ldr	tmp1, [r0, #CP_OFFSET+4]
 	mov	r1, #0
-	ldr	ip, [tmp2, #METHOD_FROM_INTERPRETED]
-	str	r1, [Rthread, #THREAD_LAST_JAVA_SP]
-	str	ip, [istate, #36]
+	ldr	ip, [tmp1, #METHOD_FROM_INTERPRETED]
+	str	r1, [thread, #THREAD_LAST_JAVA_SP]
 
 	add	stack, stack, #4
-	str	stack, [Rthread, #THREAD_JAVA_SP]
+	str	stack, [thread, #THREAD_JAVA_SP]
 
 	ldr	r3, [ip, #0]
 
-        mov     r0, tmp2
-        mov     r1, ip
-#ifndef SHARK
-        add     r3, r3, #CODE_ALIGN_SIZE
+        mov     r0, tmp1
+#ifdef SHARK
+	mov	r2, thread
+#else
+        add     r3, r3, #FAST_ENTRY_OFFSET
 #endif
-        mov     r2, Rthread
         blx     r3
+	LOAD_FRAME
 
-        ldr     Rthread, [istate, #ISTATE_THREAD]
-
-        ldr     stack, [Rthread, #THREAD_JAVA_SP]
-        ldr     r2, [istate, #ISTATE_STACK_LIMIT]
+        ldr     stack, [thread, #THREAD_JAVA_SP]
+        ldr     r2, [Rframe, #FRAME_STACK_LIMIT]
 
-        ldr     r1, [Rthread, #THREAD_TOP_ZERO_FRAME]
         add     r2, r2, #4
-        str     r2, [Rthread, #THREAD_JAVA_SP]
-        str     r1, [Rthread, #THREAD_LAST_JAVA_SP]
-        ldr     r3, [Rthread, #4]
+        str     r2, [thread, #THREAD_JAVA_SP]
+        str     Rframe, [thread, #THREAD_LAST_JAVA_SP]
+        ldr     r3, [thread, #4]
         cmp     r3, #0
         bne     istub_exception
         ldmia   sp!, {ip, pc}
 
 isstub_resolve:
-        mov     tmp2, r1
+        mov     tmp1, r1
         mov     r1, #opc_invokestatic
-        ldr     r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
         ldr     ip, resolve_invoke_adcon
         blx     ip
-        ldr     r3, [Rthread, #4]
-        ldr     r2, [istate, #ISTATE_CONSTANTS]
+        ldr     r3, [thread, #4]
+        ldr     r2, [Rframe, #FRAME_CONSTANTS]
         cmp     r3, #0
         bne     istub_exception
-        add     r0, r2, tmp2, lsl #4    @ r1 = cache
+        add     r0, r2, tmp1, lsl #4    @ r1 = cache
         b       2b
 
 @ R0 = BCI
 @ R1 = index
+	.global	Thumb2_invokestaticresolved_stub
+Thumb2_invokestaticresolved_stub:
+	LOAD_FRAME
+	stmdb	sp!, {ip, lr}
+        ldr     ip, [Rframe, #FRAME_METHOD]
+        sub     stack, stack, #4
+        ldr     r2, [Rframe, #FRAME_CONSTANTS]
+        ldr     ip, [ip, #METHOD_CONSTMETHOD]
+        DECACHE_STACK_USING_FRAME
+        add     jpc, ip, r0
+        add     r0, r2, r1, lsl #4
+        DECACHE_JPC_USING_FRAME
+        ldr     tmp1, [r0, #CP_OFFSET+4]
+        mov     r1, #0
+        ldr     ip, [tmp1, #METHOD_FROM_INTERPRETED]
+        str     r1, [thread, #THREAD_LAST_JAVA_SP]
+
+        add     stack, stack, #4
+        str     stack, [thread, #THREAD_JAVA_SP]
+        ldr     r3, [ip, #0]
+
+        mov     r0, tmp1
+#ifdef SHARK
+	mov	r2, thread
+#else
+        add     r3, r3, #FAST_ENTRY_OFFSET
+#endif
+        blx     r3
+	LOAD_FRAME
+
+        ldr     stack, [thread, #THREAD_JAVA_SP]
+        ldr     r2, [Rframe, #FRAME_STACK_LIMIT]
+
+        add     r2, r2, #4
+        str     r2, [thread, #THREAD_JAVA_SP]
+        str     Rframe, [thread, #THREAD_LAST_JAVA_SP]
+        ldr     r3, [thread, #4]
+        cmp     r3, #0
+        bne     istub_exception
+        ldmia   sp!, {ip, pc}
+
+@ R0 = BCI
+@ R1 = index
 	.global	Thumb2_invokespecial_stub
 Thumb2_invokespecial_stub:
+	LOAD_FRAME
         stmdb   sp!, {ip, lr}
-        ldr     ip, [istate, #ISTATE_METHOD]
+        ldr     ip, [Rframe, #FRAME_METHOD]
         sub     stack, stack, #4
-        ldr     r2, [istate, #ISTATE_CONSTANTS]
+        ldr     r2, [Rframe, #FRAME_CONSTANTS]
         ldr     ip, [ip, #METHOD_CONSTMETHOD]
-        DECACHE_STACK
+        DECACHE_STACK_USING_FRAME
         add     jpc, ip, r0
 
         add     r0, r2, r1, lsl #4
-        DECACHE_JPC
+        DECACHE_JPC_USING_FRAME
 
         ldr     r2, [r0, #CP_OFFSET]
 	and	r2, r2, #0x00ff0000
@@ -5145,57 +5104,106 @@
 	cmp	r2, #0
 	beq	istub_null_ptr_exception
 
-	ldr	tmp2, [r0, #CP_OFFSET+4]
+	ldr	tmp1, [r0, #CP_OFFSET+4]
 	mov	r1, #0
-	ldr	ip, [tmp2, #METHOD_FROM_INTERPRETED]
-	str	r1, [Rthread, #THREAD_LAST_JAVA_SP]
-	str	ip, [istate, #36]
+	ldr	ip, [tmp1, #METHOD_FROM_INTERPRETED]
+	str	r1, [thread, #THREAD_LAST_JAVA_SP]
 
 	add	stack, stack, #4
-	str	stack, [Rthread, #THREAD_JAVA_SP]
+	str	stack, [thread, #THREAD_JAVA_SP]
 
 	ldr	r3, [ip, #0]
 
-        mov     r0, tmp2
-        mov     r1, ip
-#ifndef SHARK
-        add     r3, r3, #CODE_ALIGN_SIZE
+        mov     r0, tmp1
+#ifdef SHARK
+	mov	r2, thread
+#else
+        add     r3, r3, #FAST_ENTRY_OFFSET
 #endif
-        mov     r2, Rthread
         blx     r3
+	LOAD_FRAME
 
-        ldr     Rthread, [istate, #ISTATE_THREAD]
-
-        ldr     stack, [Rthread, #THREAD_JAVA_SP]
-        ldr     r2, [istate, #ISTATE_STACK_LIMIT]
+        ldr     stack, [thread, #THREAD_JAVA_SP]
+        ldr     r2, [Rframe, #FRAME_STACK_LIMIT]
 
-        ldr     r1, [Rthread, #THREAD_TOP_ZERO_FRAME]
         add     r2, r2, #4
-        str     r2, [Rthread, #THREAD_JAVA_SP]
-        str     r1, [Rthread, #THREAD_LAST_JAVA_SP]
-        ldr     r3, [Rthread, #4]
+        str     r2, [thread, #THREAD_JAVA_SP]
+        str     Rframe, [thread, #THREAD_LAST_JAVA_SP]
+        ldr     r3, [thread, #4]
         cmp     r3, #0
         bne     istub_exception
         ldmia   sp!, {ip, pc}
 
 ispstub_resolve:
-        mov     tmp2, r1
+        mov     tmp1, r1
         mov     r1, #opc_invokespecial
-        ldr     r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
         ldr     ip, resolve_invoke_adcon
         blx     ip
-        ldr     r3, [Rthread, #4]
-        ldr     r2, [istate, #ISTATE_CONSTANTS]
+        ldr     r3, [thread, #4]
+        ldr     r2, [Rframe, #FRAME_CONSTANTS]
         cmp     r3, #0
         bne     istub_exception
-        add     r0, r2, tmp2, lsl #4    @ r1 = cache
+        add     r0, r2, tmp1, lsl #4    @ r1 = cache
         b       2b
 
 @ R0 = BCI
 @ R1 = index
+	.global	Thumb2_invokespecialresolved_stub
+Thumb2_invokespecialresolved_stub:
+	LOAD_FRAME
+        stmdb   sp!, {ip, lr}
+        ldr     ip, [Rframe, #FRAME_METHOD]
+        sub     stack, stack, #4
+        ldr     r2, [Rframe, #FRAME_CONSTANTS]
+        ldr     ip, [ip, #METHOD_CONSTMETHOD]
+        DECACHE_STACK_USING_FRAME
+        add     jpc, ip, r0
+
+        add     r0, r2, r1, lsl #4
+        DECACHE_JPC_USING_FRAME
+        ldr     r3, [r0, #CP_OFFSET+12]
+        and     r3, r3, #255
+        ldr     r2, [stack, r3, asl #2]
+        cmp     r2, #0
+        beq     istub_null_ptr_exception
+
+        ldr     tmp1, [r0, #CP_OFFSET+4]
+        mov     r1, #0
+        ldr     ip, [tmp1, #METHOD_FROM_INTERPRETED]
+        str     r1, [thread, #THREAD_LAST_JAVA_SP]
+
+        add     stack, stack, #4
+        str     stack, [thread, #THREAD_JAVA_SP]
+
+        ldr     r3, [ip, #0]
+
+        mov     r0, tmp1
+#ifdef SHARK
+	mov	r2, thread
+#else
+        add     r3, r3, #FAST_ENTRY_OFFSET
+#endif
+        blx     r3
+	LOAD_FRAME
+
+        ldr     stack, [thread, #THREAD_JAVA_SP]
+        ldr     r2, [Rframe, #FRAME_STACK_LIMIT]
+
+        add     r2, r2, #4
+        str     r2, [thread, #THREAD_JAVA_SP]
+        str     Rframe, [thread, #THREAD_LAST_JAVA_SP]
+        ldr     r3, [thread, #4]
+        cmp     r3, #0
+        bne     istub_exception
+        ldmia   sp!, {ip, pc}
+
+@ R0 = BCI
+@ R1 = index
 	.global	Thumb2_getfield_word_stub
 Thumb2_getfield_word_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0x00ff0000
@@ -5220,7 +5228,8 @@
 @ R1 = index
 	.global	Thumb2_getfield_sh_stub
 Thumb2_getfield_sh_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0x00ff0000
@@ -5245,7 +5254,8 @@
 @ R1 = index
 	.global	Thumb2_getfield_h_stub
 Thumb2_getfield_h_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0x00ff0000
@@ -5270,7 +5280,8 @@
 @ R1 = index
 	.global	Thumb2_getfield_sb_stub
 Thumb2_getfield_sb_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0x00ff0000
@@ -5295,7 +5306,8 @@
 @ R1 = index
 	.global	Thumb2_getfield_dw_stub
 Thumb2_getfield_dw_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0x00ff0000
@@ -5331,41 +5343,58 @@
 	mov	r2, #opc_getfield
 field_stub_unresolved:
 	stmdb	sp!, {r0, r1, ip, lr}
-        ldr     ip, [istate, #ISTATE_METHOD]
+	ldr	lr, [thread, #THREAD_TOP_ZERO_FRAME]
+        ldr     ip, [lr, #FRAME_METHOD]
 	sub	r3, stack, #4
 	ldr	ip, [ip, #METHOD_CONSTMETHOD]
-	str	r3, [istate, #ISTATE_STACK]	@ DECACHE_STACK
+	str	r3, [lr, #FRAME_STACK]	@ DECACHE_STACK
 	add	r3, ip, r0
-	str	r3, [istate, #ISTATE_BCP]	@ DECACHE_JPC
+	str	r3, [lr, #FRAME_BCP]	@ DECACHE_JPC
 	ldr	ip, resolve_get_put_adcon
 	mov	r1, r2
-	ldr	r0, [istate, #ISTATE_THREAD]
+	mov	r0, thread
 	blx	ip
 	ldmia	sp!, {r0, r1, ip, lr}
-	ldr	r3, [Rthread, #4]
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r3, [thread, #4]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	cmp	r3, #0
 	bne	field_exception
 	add	r2, r2, r1, lsl #4
 	bx	lr
 
 field_null_ptr_exception:
-        ldr     ip, [istate, #ISTATE_METHOD]
-        ldr     ip, [ip, #METHOD_CONSTMETHOD]
+	stmdb	sp!, {JAZ_REGSET}
+	ldr	ip, [thread, #THREAD_TOP_ZERO_FRAME]
+        ldr     r1, [ip, #FRAME_METHOD]
+	ldr	r3, [ip, #FRAME_LOCALS]
+        ldr     ip, [r1, #METHOD_CONSTMETHOD]
         add     jpc, ip, r0
 	mov	r0, #VMSYMBOLS_NullPointerException
+	bic	r0, lr, #TBIT
+	mov	r2, sp
+
+@ We already have BCI, so just call lr_to_bci to save the locals
+@ The result value is ignored
+	ldr	ip, lr_to_bci_adcon
+	blx	ip
+
+	add	sp, sp, #JAZ_REGSET_LEN * 4
 	ldr	ip, raise_exception_adcon
+	LOAD_ISTATE
 	bx	ip
 
 field_exception:
 	ldr	ip, handle_exception_adcon
+	LOAD_ISTATE
 	bx	ip
 
 @ R0 = BCI
 @ R1 = index
 	.global	Thumb2_putfield_word_stub
 Thumb2_putfield_word_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0xff000000
@@ -5387,7 +5416,8 @@
 
 	.global	Thumb2_putfield_h_stub
 Thumb2_putfield_h_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0xff000000
@@ -5409,7 +5439,8 @@
 
 	.global	Thumb2_putfield_b_stub
 Thumb2_putfield_b_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0xff000000
@@ -5431,7 +5462,8 @@
 
 	.global	Thumb2_putfield_a_stub
 Thumb2_putfield_a_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0xff000000
@@ -5455,7 +5487,8 @@
 
 	.global	Thumb2_putfield_dw_stub
 Thumb2_putfield_dw_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0xff000000
@@ -5479,7 +5512,8 @@
 @ R1 = index
 	.global	Thumb2_getstatic_word_stub
 Thumb2_getstatic_word_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0x00ff0000
@@ -5500,7 +5534,8 @@
 
 	.global	Thumb2_getstatic_h_stub
 Thumb2_getstatic_h_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0x00ff0000
@@ -5521,7 +5556,8 @@
 
 	.global	Thumb2_getstatic_sh_stub
 Thumb2_getstatic_sh_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0x00ff0000
@@ -5542,7 +5578,8 @@
 
 	.global	Thumb2_getstatic_sb_stub
 Thumb2_getstatic_sb_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0x00ff0000
@@ -5563,7 +5600,8 @@
 
 	.global	Thumb2_getstatic_dw_stub
 Thumb2_getstatic_dw_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0x00ff0000
@@ -5586,7 +5624,8 @@
 @ R1 = index
 	.global	Thumb2_putstatic_word_stub
 Thumb2_putstatic_word_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0xff000000
@@ -5609,7 +5648,8 @@
 @ R1 = index
 	.global	Thumb2_putstatic_h_stub
 Thumb2_putstatic_h_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0xff000000
@@ -5632,7 +5672,8 @@
 @ R1 = index
 	.global	Thumb2_putstatic_b_stub
 Thumb2_putstatic_b_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0xff000000
@@ -5655,7 +5696,8 @@
 @ R1 = index
 	.global	Thumb2_putstatic_dw_stub
 Thumb2_putstatic_dw_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0xff000000
@@ -5678,7 +5720,8 @@
 @ R1 = index
 	.global	Thumb2_putstatic_a_stub
 Thumb2_putstatic_a_stub:
-	ldr	r2, [istate, #ISTATE_CONSTANTS]
+	ldr	r2, [thread, #THREAD_TOP_ZERO_FRAME]
+	ldr	r2, [r2, #FRAME_CONSTANTS]
 	add	r2, r2, r1, lsl #4
 	ldr	r3, [r2, #CP_OFFSET]
 	and	r3, r3, #0xff000000
@@ -5699,7 +5742,7 @@
 	mov	lr, ip
 	b	2b
 
-#endif // THUMB2EE
+#endif // T2JIT
 
 	.global	Thumb2_stubs_end
 Thumb2_stubs_end:
@@ -6159,20 +6202,9 @@
 dc_18:
 	.word     0x38e38e39
 
-#define TBIT 1
-
 	.global	Thumb2_DivZero_Handler
 Thumb2_DivZero_Handler:
-#ifdef THUMB2EE
-
-#define JAZ_V1	r5
-#define JAZ_V2	r6
-#define JAZ_V3	r7
-#define	JAZ_V4	r10
-#define	JAZ_V5	r11
-
-#define JAZ_REGSET	JAZ_V1,JAZ_V2,JAZ_V3,JAZ_V4,JAZ_V5,ip
-#define JAZ_REGSET_LEN	6
+#ifdef T2JIT
 
 	adrl	r0, idiv_clz_ret
 	cmp	r0, lr
@@ -6180,22 +6212,24 @@
 	cmpne	r0, lr
 	beq	divide_by_zero_exception
 	stmdb	sp!, {JAZ_REGSET}
+	LOAD_FRAME
 	bic	r0, lr, #TBIT
-	ldr	r1, [istate, #ISTATE_METHOD]
+	ldr	r1, [Rframe, #FRAME_METHOD]
         ldr     jpc, [r1, #METHOD_CONSTMETHOD]
 	add	jpc, jpc, #CONSTMETHOD_CODEOFFSET
 	mov	r2, sp
-	ldr	r3, [istate, #ISTATE_LOCALS]
+	ldr	r3, [Rframe, #FRAME_LOCALS]
 	bl	Thumb2_lr_to_bci
 	add	sp, sp, #JAZ_REGSET_LEN * 4
 	cmp	r0, #-1
 	moveq	jpc, #0
 	addne	jpc, jpc, r0
 	bl	load_dispatch
-#endif // THUMB2EE
+	LOAD_ISTATE
+#endif // T2JIT
 	b	divide_by_zero_exception
 
-#ifdef THUMB2EE
+#ifdef T2JIT
 
 	.global	Thumb2_Handle_Exception
 	.global	Thumb2_Handle_Exception_NoRegs
@@ -6204,12 +6238,13 @@
 	.global Thumb2_Stack_Overflow
 Thumb2_ArrayBounds_Handler:
 	stmdb	sp!, {JAZ_REGSET}
+	LOAD_FRAME
 	bic	r0, lr, #TBIT
-	ldr	r1, [istate, #ISTATE_METHOD]
+	ldr	r1, [Rframe, #FRAME_METHOD]
         ldr     jpc, [r1, #METHOD_CONSTMETHOD]
 	add	jpc, jpc, #CONSTMETHOD_CODEOFFSET
 	mov	r2, sp
-	ldr	r3, [istate, #ISTATE_LOCALS]
+	ldr	r3, [Rframe, #FRAME_LOCALS]
 	bl	Thumb2_lr_to_bci
 	add	sp, sp, #JAZ_REGSET_LEN * 4
 	cmp	r0, #-1
@@ -6217,25 +6252,32 @@
 	addne	jpc, jpc, r0
 	bl	load_dispatch
 	mov	r0, #VMSYMBOLS_ArrayIndexOutOfBounds
+	LOAD_ISTATE
 	b	raise_exception
 Thumb2_Handle_Exception:
 	stmdb	sp!, {JAZ_REGSET}
+	LOAD_FRAME
 	bic	r0, lr, #TBIT
-	ldr	r1, [istate, #ISTATE_METHOD]
+	ldr	r1, [Rframe, #FRAME_METHOD]
         ldr     jpc, [r1, #METHOD_CONSTMETHOD]
 	add	jpc, jpc, #CONSTMETHOD_CODEOFFSET
 	mov	r2, sp
-	ldr	r3, [istate, #ISTATE_LOCALS]
+	ldr	r3, [Rframe, #FRAME_LOCALS]
 	bl	Thumb2_lr_to_bci
 	add	sp, sp, #JAZ_REGSET_LEN * 4
 	cmp	r0, #-1
 	moveq	jpc, #0
 	addne	jpc, jpc, r0
 	bl	load_dispatch
+	LOAD_ISTATE
 	b	handle_exception
 Thumb2_Handle_Exception_NoRegs:
+	LOAD_FRAME
+	ldr	r0, [Rframe, #FRAME_STACK_LIMIT]
+	add	r0, r0, #4
+	str	r0, [thread, #THREAD_JAVA_SP]
 	bic	r0, lr, #TBIT
-	ldr	r1, [istate, #ISTATE_METHOD]
+	ldr	r1, [Rframe, #FRAME_METHOD]
         ldr     jpc, [r1, #METHOD_CONSTMETHOD]
 	add	jpc, jpc, #CONSTMETHOD_CODEOFFSET
 	mov	r2, #0
@@ -6244,38 +6286,58 @@
 	moveq	jpc, #0
 	addne	jpc, jpc, r0
 	bl	load_dispatch
+	LOAD_ISTATE
 	b	handle_exception
 Thumb2_NullPtr_Handler:
 	stmdb	sp!, {JAZ_REGSET}
+	LOAD_FRAME
 	bic	r0, lr, #TBIT
-	ldr	r1, [istate, #ISTATE_METHOD]
+	ldr	r1, [Rframe, #FRAME_METHOD]
         ldr     jpc, [r1, #METHOD_CONSTMETHOD]
 	add	jpc, jpc, #CONSTMETHOD_CODEOFFSET
 	mov	r2, sp
-	ldr	r3, [istate, #ISTATE_LOCALS]
+	ldr	r3, [Rframe, #FRAME_LOCALS]
 	bl	Thumb2_lr_to_bci
 	add	sp, sp, #JAZ_REGSET_LEN * 4
 	cmp	r0, #-1
 	moveq	jpc, #0
 	addne	jpc, jpc, r0
 	bl	load_dispatch
+	LOAD_ISTATE
 	b	null_ptr_exception
 
 Thumb2_Stack_Overflow:
-	mov	r0, r2
-	ldr	ip, [r0, #THREAD_TOP_ZERO_FRAME]
-	str	ip, [r0, #THREAD_LAST_JAVA_SP]
+	mov	r0, thread
+	ldr	ip, [thread, #THREAD_TOP_ZERO_FRAME]
+	str	ip, [thread, #THREAD_LAST_JAVA_SP]
 	bl	_ZN18InterpreterRuntime24throw_StackOverflowErrorEP10JavaThread
 	ldmfd	arm_sp!, {fast_regset, pc}
 
 	.global	Thumb2_Exit_To_Interpreter
 Thumb2_Exit_To_Interpreter:
+	LOAD_ISTATE
 	bl	load_dispatch
 	sub	stack, stack, #4
 	CACHE_CP
 	CACHE_LOCALS
 	DISPATCH	0
 
+	.global	Thumb2_monitorenter
+Thumb2_monitorenter:
+	stmdb	sp!, {ip, lr}
+	sub	stack, stack, #4
+	mov	r0, r8
+	POP	r1
+	DECACHE_JPC
+	DECACHE_STACK
+	bl	Helper_monitorenter
+	CACHE_STACK		@ monitorenter may expand stack!!!
+	ldmia	sp!, {ip, lr}
+	cmp	r0, #0
+	bne	handle_exception
+	add	stack, stack, #4
+	bx	lr
+
 	.global	Thumb2_Clear_Cache
 Thumb2_Clear_Cache:
 	stmdb	sp!, {r7}
@@ -6286,7 +6348,7 @@
 	ldmia	sp!, {r7}
 	bx	lr
 
-#endif // THUMB2EE
+#endif // T2JIT
 
 	.section	.init_array,"aw",%init_array
 	.word	bci_init(target1)



More information about the distro-pkg-dev mailing list