changeset 1722:c7458f207acf

Edward Nevill (ed@camswl.com)
author "Edward Nevill (ed@camswl.com)"
date Mon, 05 Oct 2009 14:13:48 +0100
parents 66ad418c7b91
children f61b94ebf46a
files ChangeLog contrib/jck/compile-native-code.sh ports/hotspot/src/cpu/zero/vm/asm_helper.cpp ports/hotspot/src/cpu/zero/vm/bytecodes_arm.def ports/hotspot/src/cpu/zero/vm/bytecodes_zero.cpp ports/hotspot/src/cpu/zero/vm/bytecodes_zero.hpp ports/hotspot/src/cpu/zero/vm/cppInterpreter_arm.S
diffstat 7 files changed, 288 insertions(+), 177 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Oct 01 11:24:55 2009 +0200
+++ b/ChangeLog	Mon Oct 05 14:13:48 2009 +0100
@@ -1,3 +1,11 @@
+2009-10-05  Edward Nevill    <ed@camswl.com>
+
+	* Support for generation of native libraries for JCK on ARM
+	* Addition / updating of copyright notices
+	* Support for building icedteat-debug (incomplete)
+	* Minor performance optimisations
+	* Fix to stack overflow checking
+
 2009-10-01  Robert Schuster  <robertschuster@fsfe.org>
 
 	* configure.ac: Added --with-cacao-src-dir option.
--- a/contrib/jck/compile-native-code.sh	Thu Oct 01 11:24:55 2009 +0200
+++ b/contrib/jck/compile-native-code.sh	Mon Oct 05 14:13:48 2009 +0100
@@ -19,6 +19,9 @@
 
 arch=$(uname -m)
 case "$arch" in
+  arm*)
+    MFLAG=
+    ;;
   i?86|ppc)
     MFLAG=-m32
     ;;
--- a/ports/hotspot/src/cpu/zero/vm/asm_helper.cpp	Thu Oct 01 11:24:55 2009 +0200
+++ b/ports/hotspot/src/cpu/zero/vm/asm_helper.cpp	Mon Oct 05 14:13:48 2009 +0100
@@ -10,6 +10,10 @@
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #include "incls/_precompiled.incl"
@@ -74,8 +78,8 @@
 	print_def("THREAD_STATE", offset_of(JavaThread, _thread_state));
 	print_def("THREAD_DO_NOT_UNLOCK", offset_of(JavaThread, _do_not_unlock_if_synchronized));
 
-	print_def("THREAD_JAVA_STACK_BASE", offset_of(JavaThread, _zero_stack) + ZeroStack::base_offset());
-	print_def("THREAD_JAVA_SP", offset_of(JavaThread, _zero_stack) + ZeroStack::sp_offset());
+	print_def("THREAD_JAVA_STACK_BASE", offset_of(JavaThread, _zero_stack) + in_bytes(ZeroStack::base_offset()));
+	print_def("THREAD_JAVA_SP", offset_of(JavaThread, _zero_stack) + in_bytes(ZeroStack::sp_offset()));
 	print_def("THREAD_TOP_ZERO_FRAME", offset_of(JavaThread, _top_zero_frame));
 	print_def("THREAD_SPECIALRUNTIMEEXITCONDITION", offset_of(JavaThread, _special_runtime_exit_condition));
 	nl();
--- a/ports/hotspot/src/cpu/zero/vm/bytecodes_arm.def	Thu Oct 01 11:24:55 2009 +0200
+++ b/ports/hotspot/src/cpu/zero/vm/bytecodes_arm.def	Mon Oct 05 14:13:48 2009 +0100
@@ -1,3 +1,20 @@
+@ Copyright 2009 Edward Nevill
+@ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+@
+@ This code is free software; you can redistribute it and/or modify it
+@ under the terms of the GNU General Public License version 2 only, as
+@ published by the Free Software Foundation.
+@
+@ This code is distributed in the hope that it will be useful, but WITHOUT
+@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+@ version 2 for more details (a copy is included in the LICENSE file that
+@ accompanied this code).
+@
+@ You should have received a copy of the GNU General Public License version
+@ 2 along with this work; if not, write to the Free Software Foundation,
+@ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
 #ifndef DISABLE_HW_FP
 #define HW_FP
 #endif
@@ -281,7 +298,7 @@
 }
 
 (aconst_null,fconst_0) u4const_0 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
         mov     lr, #0
 	DISPATCH_NEXT
 	PUSH	lr
@@ -290,13 +307,13 @@
 
 (iconst_m1,iconst_0,iconst_1,iconst_2,iconst_3,iconst_4,iconst_5) iconst_N {
 	sub	lr, r0, #opc_iconst_0
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	PUSH	lr
 	DISPATCH_FINISH
 }
 
 (lconst_0,dconst_0) u8const_0 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
         mov     tmp1, #0
 	DISPATCH_NEXT
 	PUSH	tmp1
@@ -308,7 +325,7 @@
 }
 
 (lconst_1) lconst_1 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
         mov     tmp2, #1
 	DISPATCH_NEXT
         mov     tmp1, #0
@@ -320,7 +337,7 @@
 }
 
 (fconst_1) fconst_1 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
         mov     tmp1, #0x3f800000
 	DISPATCH_NEXT
 	PUSH	tmp1
@@ -328,7 +345,7 @@
 }
 
 (fconst_2) fconst_2 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
         mov     r2, #0x40000000
 	DISPATCH_NEXT
 	PUSH	r2
@@ -336,7 +353,7 @@
 }
 
 (dconst_1) dconst_1 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
         mov     tmp1, #0x3f000000
 	DISPATCH_NEXT
         orr     tmp1, tmp1, #0x00f00000
@@ -363,12 +380,12 @@
 @ r2 = [jpc, #1]
 @ r1 = [jpc, #2]
 (sipush) sipush {
-	DISPATCH_START	\seq_len
-	mov	tmp1, r1
+	ldrb	r1, [jpc, #2]
+	DISPATCH_START	\seq_len
 	DISPATCH_NEXT
 	mov	r2, r2, lsl #24
-	DISPATCH_NEXT
-        orr     tmp1, tmp1, r2, asr #16
+        orr     tmp1, r1, r2, asr #16
+	DISPATCH_NEXT
 	DISPATCH_NEXT
 	DISPATCH_NEXT
 	PUSH	tmp1
@@ -403,7 +420,7 @@
 
 (aload_0,aload_1,aload_2,aload_3) {
 	rsb	tmp1, r0, #opc_aload_0
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	DISPATCH_NEXT
 	ldr	tmp1, [locals, tmp1, lsl #2]
 	DISPATCH_NEXT
@@ -415,7 +432,7 @@
 
 (iload_0,iload_1,iload_2,iload_3) {
 	rsb	tmp1, r0, #opc_iload_0
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	DISPATCH_NEXT
 	ldr	tmp1, [locals, tmp1, lsl #2]
 	DISPATCH_NEXT
@@ -427,7 +444,7 @@
 
 (fload_0,fload_1,fload_2,fload_3) {
 	rsb	tmp1, r0, #opc_fload_0
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	DISPATCH_NEXT
 	ldr	tmp1, [locals, tmp1, lsl #2]
 	DISPATCH_NEXT
@@ -438,7 +455,7 @@
 }
 
 (lload_0,dload_0) u8load_0 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
         ldmda   locals, {tmp2-tmp1}
 	DISPATCH_NEXT
 	PUSH	tmp1
@@ -450,7 +467,7 @@
 }
 
 (lload_1,dload_1) u8load_1 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
         ldmdb   locals, {tmp2-tmp1}
 	DISPATCH_NEXT
 	PUSH	tmp1
@@ -462,7 +479,7 @@
 }
 
 (lload_2,dload_2) u8load_2 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	ldr	tmp2, [locals, #-12]
 	DISPATCH_NEXT
 	ldr	tmp1, [locals, #-8]
@@ -474,7 +491,7 @@
 }
 
 (lload_3,dload_3) u8load_3 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	ldr	tmp2, [locals, #-16]
 	DISPATCH_NEXT
 	ldr	tmp1, [locals, #-12]
@@ -486,8 +503,10 @@
 }
 
 (iaload,faload,aaload) u4aload {
-	POP	r2, r3			@ r2 = index, r3 = arrayref
-	DISPATCH_START	\seq_len
+	GET_STACK	1, r3
+	DISPATCH_START_R2_R0
+	POP	r2
+	DISPATCH_START_R2_JPC
 	SW_NPC	cmp	r3, #0
 	SW_NPC	beq	null_ptr_exception_jpc_1
 .abortentry5:
@@ -500,13 +519,15 @@
 	DISPATCH_NEXT
 	ldr	tmp1, [r3, #12]
 	DISPATCH_NEXT
-	PUSH	tmp1
+	PUT_STACK	0, tmp1
 	DISPATCH_FINISH
 }
 
 (laload,daload) u8aload {
-	POP	r2, r3
-	DISPATCH_START	\seq_len
+	GET_STACK	1, r3
+	DISPATCH_START_R2_R0
+	GET_STACK	0, r2
+	DISPATCH_START_R2_JPC
 	SW_NPC	cmp	r3, #0
 	SW_NPC	beq	null_ptr_exception_jpc_1
 .abortentry6:
@@ -520,13 +541,16 @@
 	DISPATCH_NEXT
 	ldr	tmp1, [r3, #20]
 	DISPATCH_NEXT
-	PUSH	tmp2, tmp1
+	PUT_STACK	1, tmp1
+	PUT_STACK	0, tmp2
 	DISPATCH_FINISH
 }
 
 (baload) baload {
-	POP	r2, r3			@ r2 = index, r3 = arrayref
-	DISPATCH_START	\seq_len
+	GET_STACK	1, r3
+	DISPATCH_START_R2_R0
+	POP	r2
+	DISPATCH_START_R2_JPC
 	SW_NPC	cmp	r3, #0
 	SW_NPC	beq	null_ptr_exception_jpc_1
 .abortentry7:
@@ -539,13 +563,15 @@
 	DISPATCH_NEXT
 	ldrsb	tmp1, [r3, #12]
 	DISPATCH_NEXT
-	PUSH	tmp1
+	PUT_STACK	0, tmp1
 	DISPATCH_FINISH
 }
 
 (caload) caload {
-	POP	r2, r3			@ r2 = index, r3 = arrayref
-	DISPATCH_START	\seq_len
+	GET_STACK	1, r3
+	DISPATCH_START_R2_R0
+	POP	r2
+	DISPATCH_START_R2_JPC
 	SW_NPC	cmp	r3, #0
 	SW_NPC	beq	null_ptr_exception_jpc_1
 .abortentry8:
@@ -558,13 +584,15 @@
 	DISPATCH_NEXT
 	ldrh	tmp1, [r3, #12]
 	DISPATCH_NEXT
-	PUSH	tmp1
+	PUT_STACK	0, tmp1
 	DISPATCH_FINISH
 }
 
 (saload) saload {
-	POP	r2, r3			@ r2 = index, r3 = arrayref
-	DISPATCH_START	\seq_len
+	GET_STACK	1, r3
+	DISPATCH_START_R2_R0
+	POP	r2
+	DISPATCH_START_R2_JPC
 	SW_NPC	cmp	r3, #0
 	SW_NPC	beq	null_ptr_exception_jpc_1
 .abortentry9:
@@ -577,7 +605,7 @@
 	DISPATCH_NEXT
 	ldrsh	tmp1, [r3, #12]
 	DISPATCH_NEXT
-	PUSH	tmp1
+	PUT_STACK	0, tmp1
 	DISPATCH_FINISH
 }
 
@@ -608,7 +636,7 @@
 }
 
 (astore_0,istore_0,fstore_0) u4store_0 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	DISPATCH_NEXT
 	POP	tmp1
 	DISPATCH_NEXT
@@ -619,7 +647,7 @@
 }
 
 (astore_1,istore_1,fstore_1) u4store_1 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	DISPATCH_NEXT
 	POP	tmp1
 	DISPATCH_NEXT
@@ -630,7 +658,7 @@
 }
 
 (astore_2,istore_2,fstore_2) u4store_2 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	DISPATCH_NEXT
 	POP	tmp1
 	DISPATCH_NEXT
@@ -641,7 +669,7 @@
 }
 
 (astore_3,istore_3,fstore_3) u4store_3 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	DISPATCH_NEXT
 	POP	tmp1
 	DISPATCH_NEXT
@@ -652,7 +680,7 @@
 }
 
 (lstore_0,dstore_0) u8store_0 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	DISPATCH_NEXT
 	POP	tmp2, tmp1
 	DISPATCH_NEXT
@@ -663,7 +691,7 @@
 }
 
 (lstore_1,dstore_1) u8store_1 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	DISPATCH_NEXT
 	POP	tmp2, tmp1
 	DISPATCH_NEXT
@@ -674,7 +702,7 @@
 }
 
 (lstore_2,dstore_2) u8store_2 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	tmp2, tmp1
 	DISPATCH_NEXT
         str     tmp2, [locals, #-12]
@@ -686,7 +714,7 @@
 }
 
 (lstore_3,dstore_3) u8store_3 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	tmp2, tmp1
 	DISPATCH_NEXT
         str     tmp2, [locals, #-16]
@@ -699,7 +727,7 @@
 
 (iastore,fastore) u4astore {
 	POP	r3, tmp2, tmp1		@ r3 = value, tmp2 = index, tmp1 = arrayref
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	SW_NPC	cmp	tmp1, #0
 	SW_NPC	beq	null_ptr_exception_jpc_1
 .abortentry10:
@@ -715,8 +743,8 @@
 }
 
 (lastore,dastore) u8astore {
-	POP	r2, r3, tmp2, tmp1		@ r2,r3 = value, tmp2 = index, tmp1 = arrayref
-	DISPATCH_START	\seq_len
+	POP	r1, r3, tmp2, tmp1		@ r1,r3 = value, tmp2 = index, tmp1 = arrayref
+	DISPATCH_START_R2
 	SW_NPC	cmp	tmp1, #0
 	SW_NPC	beq	null_ptr_exception_jpc_1
 .abortentry11:
@@ -726,7 +754,7 @@
 	bcs	array_bound_exception_jpc_1_tmp2
 	DISPATCH_NEXT
 	add	tmp2, tmp1, tmp2, lsl #3
-	str	r2, [tmp2, #16]
+	str	r1, [tmp2, #16]
 	DISPATCH_NEXT
 	DISPATCH_NEXT
 	str	r3, [tmp2, #20]
@@ -735,7 +763,7 @@
 
 (bastore) bastore {
 	POP	r3, tmp2, tmp1		@ r3 = value, tmp2 = index, tmp1 = arrayref
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	SW_NPC	cmp	tmp1, #0
 	SW_NPC	beq	null_ptr_exception_jpc_1
 .abortentry12:
@@ -752,7 +780,7 @@
 
 (castore,sastore) u2astore {
 	POP	r3, tmp2, tmp1		@ r3 = value, tmp2 = index, tmp1 = arrayref
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	SW_NPC	cmp	tmp1, #0
 	SW_NPC	beq	null_ptr_exception_jpc_1
 .abortentry13:
@@ -768,19 +796,19 @@
 }
 
 (pop) jpop {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
         add     stack, stack, #4
 	DISPATCH_FINISH
 }
 
 (pop2) jpop2 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
         add     stack, stack, #8
 	DISPATCH_FINISH
 }
 
 (dup) dup {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	ldr	lr, [stack, #4]
 	DISPATCH_NEXT
 	PUSH	lr
@@ -788,7 +816,7 @@
 }
 
 (dup_x1) dup_x1 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3
 	DISPATCH_NEXT
 	PUSH	r2
@@ -798,7 +826,7 @@
 }
 
 (dup_x2) dup_x2 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3, lr
 	DISPATCH_NEXT
 	PUSH	r2
@@ -808,7 +836,7 @@
 }
 
 (dup2) dup2 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	ldmib	stack, {r2, r3}
 	DISPATCH_NEXT
 	PUSH	r2, r3
@@ -816,7 +844,7 @@
 }
 
 (dup2_x1) dup2_x1 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3, lr
 	DISPATCH_NEXT
 	PUSH	r2, r3
@@ -826,7 +854,7 @@
 }
 
 (dup2_x2) dup2_x2 {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3, tmp1, lr
 	DISPATCH_NEXT
 	PUSH	r2, r3
@@ -835,7 +863,7 @@
 }
 
 (swap) swap {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3
 	DISPATCH_NEXT
 	PUSH	r2
@@ -846,7 +874,7 @@
 
 
 (iadd) iadd {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	tmp2, tmp1
 	DISPATCH_NEXT
 	add	tmp2, tmp2, tmp1
@@ -858,7 +886,7 @@
 }
 
 (ladd) ladd {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3, tmp1, lr
 	DISPATCH_NEXT
 	adds	r2, r2, tmp1
@@ -869,7 +897,7 @@
 }
 
 (isub) isub {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	tmp2, tmp1
 	DISPATCH_NEXT
 	sub	tmp2, tmp1, tmp2
@@ -881,7 +909,7 @@
 }
 
 (lsub) lsub {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3, tmp1, lr
 	DISPATCH_NEXT
 	subs	r2, tmp1, r2
@@ -892,7 +920,7 @@
 }
 
 (imul) imul {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, tmp1
 	DISPATCH_NEXT
 	mul	tmp2, r2, tmp1
@@ -904,11 +932,11 @@
 }
 
 (lmul) lmul {
-	POP	r2, tmp1, ip, lr
-        umull   r3, r0, ip, r2
+	POP	r1, tmp1, ip, lr
+        umull   r3, r0, ip, r1
         mla     tmp1, ip, tmp1, r0
-	DISPATCH_START	\seq_len
-        mla     tmp1, lr, r2, tmp1
+	DISPATCH_START_R2
+        mla     tmp1, lr, r1, tmp1
 	DISPATCH_NEXT
 	PUSH	r3, tmp1
 	DISPATCH_FINISH
@@ -957,7 +985,7 @@
 }
 
 (ineg) ineg {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	tmp1
 	DISPATCH_NEXT
         rsb     tmp1, tmp1, #0
@@ -969,7 +997,7 @@
 }
 
 (lneg) lneg {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3
 	DISPATCH_NEXT
 	rsbs	r2, r2, #0
@@ -980,7 +1008,7 @@
 }
 
 (fneg) fneg {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2
 	DISPATCH_NEXT
 	eor	r2, r2, #0x80000000
@@ -990,7 +1018,7 @@
 }
 
 (dneg) dneg {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	GET_STACK	1, r2
 	DISPATCH_NEXT
 	eor	r2, r2, #0x80000000
@@ -1000,7 +1028,7 @@
 }
 
 (ishl) ishl {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3
 	DISPATCH_NEXT
 	and	r2, r2, #31
@@ -1011,7 +1039,7 @@
 }
 
 (lshl) lshl {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3, lr
 	DISPATCH_NEXT
 	tst	r2, #32
@@ -1027,7 +1055,7 @@
 }
 
 (ishr) ishr {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3
 	DISPATCH_NEXT
 	and	r2, r2, #31
@@ -1038,7 +1066,7 @@
 }
 
 (lshr) lshr {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3, tmp1
 	DISPATCH_NEXT
 	tst	r2, #32
@@ -1054,7 +1082,7 @@
 }
 
 (iushr) iushr {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3
 	DISPATCH_NEXT
 	and	r2, r2, #31
@@ -1065,7 +1093,7 @@
 }
 
 (lushr) lushr {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3, tmp1
 	DISPATCH_NEXT
 	tst	r2, #32
@@ -1081,7 +1109,7 @@
 }
 
 (iand) iand {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	tmp2, tmp1
 	DISPATCH_NEXT
 	and	tmp2, tmp1, tmp2
@@ -1093,7 +1121,7 @@
 }
 
 (land) land {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3, tmp1, lr
 	DISPATCH_NEXT
 	and	r2, tmp1, r2
@@ -1104,7 +1132,7 @@
 }
 
 (ior) ior {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	tmp2, tmp1
 	DISPATCH_NEXT
 	orr	tmp2, tmp1, tmp2
@@ -1116,7 +1144,7 @@
 }
 
 (lor) lor {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3, tmp1, lr
 	DISPATCH_NEXT
 	orr	r2, tmp1, r2
@@ -1127,7 +1155,7 @@
 }
 
 (ixor) ixor {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	tmp2, tmp1
 	DISPATCH_NEXT
 	eor	tmp2, tmp1, tmp2
@@ -1139,7 +1167,7 @@
 }
 
 (lxor) lxor {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2, r3, tmp1, lr
 	DISPATCH_NEXT
 	eor	r2, tmp1, r2
@@ -1165,7 +1193,7 @@
 }
 
 (i2l) i2l {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r2
 	DISPATCH_NEXT
 	mov	r3, r2, asr #31
@@ -1189,7 +1217,7 @@
 }
 
 (l2i) l2i {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r3
 	DISPATCH_NEXT
 	PUT_STACK	0, r3
@@ -1253,7 +1281,7 @@
 }
 
 (i2b) i2b {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r3
 	DISPATCH_NEXT
         mov     r3, r3, asl #24
@@ -1264,7 +1292,7 @@
 }
 
 (i2c) i2c {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r3
 	DISPATCH_NEXT
         mov     r3, r3, asl #16
@@ -1275,7 +1303,7 @@
 }
 
 (i2s) i2s {
-	DISPATCH_START	\seq_len
+	DISPATCH_START_R2
 	POP	r3
 	DISPATCH_NEXT
         mov     r3, r3, asl #16
@@ -1286,16 +1314,16 @@
 }
 
 (lcmp) lcmp {
-	POP	r2, r3, tmp1, lr
-	DISPATCH_START	\seq_len
-	subs	r2, tmp1, r2
-	movne	r2, #1
+	POP	r1, r3, tmp1, lr
+	DISPATCH_START_R2
+	subs	r1, tmp1, r1
+	movne	r1, #1
 	sbcs	lr, lr, r3
 	DISPATCH_NEXT
-	movne	r2, #1
-	rsblt	r2, r2, #0
-	DISPATCH_NEXT
-	PUSH	r2
+	movne	r1, #1
+	rsblt	r1, r1, #0
+	DISPATCH_NEXT
+	PUSH	r1
 	DISPATCH_FINISH
 }
 
@@ -1304,6 +1332,7 @@
 @ r2 = [jpc, #1]
 @ r1 = [jpc, #2]
 (ifeq,ifnull) ifeq_unsafe {
+	ldrb	r1, [jpc, #2]
 	POP	r3
 	mov	r2, r2, lsl #24
         cmp     r3, #0
@@ -1316,6 +1345,7 @@
 }
 
 (ifne,ifnonnull) ifne_unsafe {
+	ldrb	r1, [jpc, #2]
 	POP	r3
 	mov	r2, r2, lsl #24
         cmp     r3, #0
@@ -1328,6 +1358,7 @@
 }
 
 (iflt) iflt_unsafe {
+	ldrb	r1, [jpc, #2]
 	POP	r3
 	mov	r2, r2, lsl #24
         cmp     r3, #0
@@ -1340,6 +1371,7 @@
 }
 
 (ifge) ifge_unsafe {
+	ldrb	r1, [jpc, #2]
 	POP	r3
 	mov	r2, r2, lsl #24
         cmp     r3, #0
@@ -1352,6 +1384,7 @@
 }
 
 (ifgt) ifgt_unsafe {
+	ldrb	r1, [jpc, #2]
 	POP	r3
 	mov	r2, r2, lsl #24
         cmp     r3, #0
@@ -1364,6 +1397,7 @@
 }
 
 (ifle) ifle_unsafe {
+	ldrb	r1, [jpc, #2]
 	POP	r3
 	mov	r2, r2, lsl #24
         cmp     r3, #0
@@ -1376,6 +1410,7 @@
 }
 
 (if_icmpeq,if_acmpeq) if_icmpeq_unsafe {
+	ldrb	r1, [jpc, #2]
 	POP	r3, tmp1
 	mov	r2, r2, lsl #24
         cmp     tmp1, r3
@@ -1388,6 +1423,7 @@
 }
 
 (if_icmpne,if_acmpne) if_icmpne_unsafe {
+	ldrb	r1, [jpc, #2]
 	POP	r3, tmp1
 	mov	r2, r2, lsl #24
         cmp     tmp1, r3
@@ -1400,6 +1436,7 @@
 }
 
 (if_icmplt) if_icmplt_unsafe {
+	ldrb	r1, [jpc, #2]
 	POP	r3, tmp1
 	mov	r2, r2, lsl #24
         cmp     tmp1, r3
@@ -1412,6 +1449,7 @@
 }
 
 (if_icmpge) if_icmpge_unsafe {
+	ldrb	r1, [jpc, #2]
 	POP	r3, tmp1
 	mov	r2, r2, lsl #24
         cmp     tmp1, r3
@@ -1424,6 +1462,7 @@
 }
 
 (if_icmpgt) if_icmpgt_unsafe {
+	ldrb	r1, [jpc, #2]
 	POP	r3, tmp1
 	mov	r2, r2, lsl #24
         cmp     tmp1, r3
@@ -1436,6 +1475,7 @@
 }
 
 (if_icmple) if_icmple_unsafe {
+	ldrb	r1, [jpc, #2]
 	POP	r3, tmp1
 	mov	r2, r2, lsl #24
         cmp     tmp1, r3
@@ -1448,6 +1488,7 @@
 }
 
 (goto) goto_unsafe {
+	ldrb	r1, [jpc, #2]
 	mov	r2, r2, lsl #24
         orr     ip, r1, r2, asr #16
         DISPATCH_START_REG	ip
@@ -1556,9 +1597,10 @@
 
 #ifdef FAST_BYTECODES
 (igetfield) igetfield {
+	ldrb	r1, [jpc, #2]
 	DISPATCH_START	3
+	POP	tmp1
         add     tmp2, constpool, r1, lsl #12
-	POP	tmp1
 	add	tmp2, tmp2, r2, lsl #4
 	DISPATCH_NEXT
 	SW_NPC	cmp	tmp1, #0
@@ -1574,9 +1616,10 @@
 }
 
 (bgetfield) bgetfield {
+	ldrb	r1, [jpc, #2]
 	DISPATCH_START	3
+	POP	tmp1
         add     tmp2, constpool, r1, lsl #12
-	POP	tmp1
 	add	tmp2, tmp2, r2, lsl #4
 	DISPATCH_NEXT
 	SW_NPC	cmp	tmp1, #0
@@ -1592,9 +1635,10 @@
 }
 
 (cgetfield) cgetfield {
+	ldrb	r1, [jpc, #2]
 	DISPATCH_START	3
+	POP	tmp1
         add     tmp2, constpool, r1, lsl #12
-	POP	tmp1
 	add	tmp2, tmp2, r2, lsl #4
 	DISPATCH_NEXT
 	SW_NPC	cmp	tmp1, #0
@@ -1610,9 +1654,10 @@
 }
 
 (sgetfield) sgetfield {
+	ldrb	r1, [jpc, #2]
 	DISPATCH_START	3
+	POP	tmp1
         add     tmp2, constpool, r1, lsl #12
-	POP	tmp1
 	add	tmp2, tmp2, r2, lsl #4
 	DISPATCH_NEXT
 	SW_NPC	cmp	tmp1, #0
@@ -1628,9 +1673,10 @@
 }
 
 (lgetfield) lgetfield {
+	ldrb	r1, [jpc, #2]
 	DISPATCH_START	3
+	POP	tmp1
         add     tmp2, constpool, r1, lsl #12
-	POP	tmp1
 	add	tmp2, tmp2, r2, lsl #4
 	DISPATCH_NEXT
 	SW_NPC	cmp	tmp1, #0
@@ -1647,9 +1693,10 @@
 }
 
 (iputfield) iputfield {
+	ldrb	r1, [jpc, #2]
 	DISPATCH_START	3
+	POP	r3, tmp1		@ r3 = value, tmp1 = object
         add     tmp2, constpool, r1, lsl #12
-	POP	r3, tmp1		@ r3 = value, tmp1 = object
 	add	tmp2, tmp2, r2, lsl #4
 	DISPATCH_NEXT
 	SW_NPC	cmp	tmp1, #0
@@ -1664,9 +1711,10 @@
 }
 
 (cputfield) cputfield {
+	ldrb	r1, [jpc, #2]
 	DISPATCH_START	3
+	POP	r3, tmp1		@ r3 = value, tmp1 = object
         add     tmp2, constpool, r1, lsl #12
-	POP	r3, tmp1		@ r3 = value, tmp1 = object
 	add	tmp2, tmp2, r2, lsl #4
 	DISPATCH_NEXT
 	SW_NPC	cmp	tmp1, #0
@@ -1681,9 +1729,10 @@
 }
 
 (bputfield) bputfield {
+	ldrb	r1, [jpc, #2]
 	DISPATCH_START	3
+	POP	r3, tmp1		@ r3 = value, tmp1 = object
         add     tmp2, constpool, r1, lsl #12
-	POP	r3, tmp1		@ r3 = value, tmp1 = object
 	add	tmp2, tmp2, r2, lsl #4
 	DISPATCH_NEXT
 	SW_NPC	cmp	tmp1, #0
@@ -1698,9 +1747,10 @@
 }
 
 (aputfield) aputfield {
+	ldrb	r1, [jpc, #2]
 	GET_STACK	1, r0		@ r0 = object
+	POP	oop_value_tmp			@ r1 = value
         add     r3, constpool, r1, lsl #12
-	POP	oop_value_tmp			@ r1 = value
 	add	r3, r3, r2, lsl #4
 	ldr	r3, [r3, #CP_OFFSET+8]
 	SW_NPC	cmp	r0, #0
@@ -1723,9 +1773,10 @@
 }
 
 (lputfield) lputfield {
+	ldrb	r1, [jpc, #2]
 	DISPATCH_START	3
+	POP	r3, tmp1, lr		@ r3, tmp1 = value, lr = object
         add     tmp2, constpool, r1, lsl #12
-	POP	r3, tmp1, lr		@ r3, tmp1 = value, lr = object
 	add	tmp2, tmp2, r2, lsl #4
 	DISPATCH_NEXT
 	SW_NPC	cmp	lr, #0
@@ -1745,6 +1796,7 @@
 @ r2 = [jpc, #1]
 @ r1 = [jpc, #2]
 (getstatic) getstatic {
+	ldrb	r1, [jpc, #2]
         add     tmp2, constpool, r1, lsl #12
 	add	tmp2, tmp2, r2, lsl #4
         ldr     r3, [tmp2, #CP_OFFSET]
@@ -1766,6 +1818,7 @@
 @ r2 = [jpc, #1]
 @ r1 = [jpc, #2]
 (putstatic) putstatic {
+	ldrb	r1, [jpc, #2]
         add     tmp2, constpool, r1, lsl #12
 	add	tmp2, tmp2, r2, lsl #4
         ldr     r3, [tmp2, #CP_OFFSET]
@@ -2342,7 +2395,7 @@
 #ifdef HW_FP
 
 (fadd) fadd_vfp {
-	DISPATCH_START	1
+	DISPATCH_START_R2
 	vldr	s15, [stack, #8]
 	vldr	s14, [stack, #4]
 	DISPATCH_NEXT
@@ -2356,7 +2409,7 @@
 }
 
 (dadd) dadd_vfp {
-	DISPATCH_START	1
+	DISPATCH_START_R2
 	vldr	d7, [stack, #12]
 	vldr	d6, [stack, #4]
 	DISPATCH_NEXT
@@ -2370,7 +2423,7 @@
 }
 
 (fsub) fsub_vfp {
-	DISPATCH_START	1
+	DISPATCH_START_R2
 	vldr	s15, [stack, #8]
 	vldr	s14, [stack, #4]
 	DISPATCH_NEXT
@@ -2384,7 +2437,7 @@
 }
 
 (fmul) fmul_vfp {
-	DISPATCH_START	1
+	DISPATCH_START_R2
 	vldr	s15, [stack, #8]
 	vldr	s14, [stack, #4]
 	DISPATCH_NEXT
@@ -2399,7 +2452,7 @@
 
 (dmul) dmul_vfp {
 	FBC	cmp	r2, #opc_dadd
-	DISPATCH_START	1
+	DISPATCH_START_R2
 	FBC	beq	1f
 2:
 	vldr	d7, [stack, #12]
@@ -2438,7 +2491,7 @@
 #endif // FAST_BYTECODES
 
 (fdiv) fdiv_vfp {
-	DISPATCH_START	1
+	DISPATCH_START_R2
 	vldr	s15, [stack, #8]
 	vldr	s14, [stack, #4]
 	DISPATCH_NEXT
@@ -2452,7 +2505,7 @@
 }
 
 (ddiv) ddiv_vfp {
-	DISPATCH_START	1
+	DISPATCH_START_R2
 	vldr	d7, [stack, #12]
 	vldr	d6, [stack, #4]
 	DISPATCH_NEXT
@@ -2466,7 +2519,7 @@
 }
 
 (fcmpl) fcmpl_vfp {
-	DISPATCH_START 1
+	DISPATCH_START_R2
 	flds	s14, [stack, #8]
 	flds	s15, [stack, #4]
 	DISPATCH_NEXT
@@ -2490,7 +2543,7 @@
 }
 
 (fcmpg) fcmpg_vfp {
-	DISPATCH_START	1
+	DISPATCH_START_R2
 	flds	s14, [stack, #8]
 	flds	s15, [stack, #4]
 	DISPATCH_NEXT
@@ -2514,7 +2567,7 @@
 }
 
 (dcmpl) dcmpl_vfp {
-	DISPATCH_START	1
+	DISPATCH_START_R2
 	fldd	d6, [stack, #12]
 	fldd	d7, [stack, #4]
 	DISPATCH_NEXT
@@ -2538,7 +2591,7 @@
 }
 
 (dcmpg) dcmpg_vfp {
-	DISPATCH_START	1
+	DISPATCH_START_R2
 	fldd	d6, [stack, #12]
 	fldd	d7, [stack, #4]
 	DISPATCH_NEXT
--- a/ports/hotspot/src/cpu/zero/vm/bytecodes_zero.cpp	Thu Oct 01 11:24:55 2009 +0200
+++ b/ports/hotspot/src/cpu/zero/vm/bytecodes_zero.cpp	Mon Oct 05 14:13:48 2009 +0100
@@ -1,6 +1,7 @@
 /*
  * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
  * Copyright 2007 Red Hat, Inc.
+ * Copyright 2009 Edward Nevill
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +29,12 @@
 
 void Bytecodes::pd_initialize() {
 #ifdef HOTSPOT_ASM
+  // Because iaccess_N can trap, we must say aload_N can trap, otherwise
+  // we get an assertion failure
+  def(_aload_1, "aload_1", "b", NULL, T_OBJECT ,  1, true);
+  def(_aload_2, "aload_2", "b", NULL, T_OBJECT ,  1, true);
+  def(_aload_3, "aload_3", "b", NULL, T_OBJECT ,  1, true);
+
   def(_iaccess_0, "_iaccess_0", "b_jj", NULL, T_INT,  1, true, _aload_0);
   def(_iaccess_1, "_iaccess_1", "b_jj", NULL, T_INT,  1, true, _aload_1);
   def(_iaccess_2, "_iaccess_2", "b_jj", NULL, T_INT,  1, true, _aload_2);
--- a/ports/hotspot/src/cpu/zero/vm/bytecodes_zero.hpp	Thu Oct 01 11:24:55 2009 +0200
+++ b/ports/hotspot/src/cpu/zero/vm/bytecodes_zero.hpp	Mon Oct 05 14:13:48 2009 +0100
@@ -1,6 +1,7 @@
 /*
  * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
  * Copyright 2009 Red Hat, Inc.
+ * Copyright 2009 Edward Nevill
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/ports/hotspot/src/cpu/zero/vm/cppInterpreter_arm.S	Thu Oct 01 11:24:55 2009 +0200
+++ b/ports/hotspot/src/cpu/zero/vm/cppInterpreter_arm.S	Mon Oct 05 14:13:48 2009 +0100
@@ -1,3 +1,20 @@
+@ Copyright 2009 Edward Nevill
+@ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+@
+@ This code is free software; you can redistribute it and/or modify it
+@ under the terms of the GNU General Public License version 2 only, as
+@ published by the Free Software Foundation.
+@
+@ This code is distributed in the hope that it will be useful, but WITHOUT
+@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+@ version 2 for more details (a copy is included in the LICENSE file that
+@ accompanied this code).
+@
+@ You should have received a copy of the GNU General Public License version
+@ 2 along with this work; if not, write to the Free Software Foundation,
+@ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
 #ifdef HOTSPOT_ASM
 
 #define ARMv4
@@ -33,7 +50,6 @@
 
 #define tmp_xxx		r7
 #define tmp_yyy		r5
-#define tmp_zzz		r8
 #define tmp_vvv		r9
 
 #define tmp1		r11
@@ -542,6 +558,22 @@
 	ldrb	r0, [jpc, \reg]!
 	.endm
 
+	.macro	DISPATCH_START_R2_R0
+	.set	dispatch_state, 1
+	mov	r0, r2
+	.endm
+
+	.macro	DISPATCH_START_R2_JPC
+	.set	dispatch_state, 1
+	add	jpc, jpc, #1
+	.endm
+
+	.macro	DISPATCH_START_R2
+	.set	dispatch_state, 1
+	add	jpc, jpc, #1
+	mov	r0, r2
+	.endm
+
 #ifdef DISPATCH_LOOP
 	.macro	DISPATCH_NEXT
 	.endm
@@ -560,7 +592,7 @@
 	.endm
 #else
 	.macro	DISPATCH_1
-        ldrb    r1, [jpc, #2]
+@        ldrb    r1, [jpc, #2]
 	.endm
 
 	.macro	DISPATCH_2
@@ -613,34 +645,31 @@
         moveq   pc, ip
 	ldrb	r1, [jpc, lr]
         bic     ip, ip, #7
-        ldr     ip, [ip, r1, lsl #2]
-        mov     pc, ip
+        ldr     pc, [ip, r1, lsl #2]
 	.set	dispatch_state, 0
 	.endm
 
 	.macro	DISPATCH_BYTECODE
-        ldrb    r1, [jpc, #2]
+@        ldrb    r1, [jpc, #2]
         ldr     ip, [dispatch, r0, lsl #2]
         ldrb    r2, [jpc, #1]
         ands    lr, ip, #7
         moveq   pc, ip
 	ldrb	r1, [jpc, lr]
         bic     ip, ip, #7
-        ldr     ip, [ip, r1, lsl #2]
-        mov     pc, ip
+        ldr     pc, [ip, r1, lsl #2]
 	.endm
 
 	.macro	DISPATCH step=0
 	ldrb	r0, [jpc, #\step]!
-        ldrb    r1, [jpc, #2]
+@        ldrb    r1, [jpc, #2]
         ldr     ip, [dispatch, r0, lsl #2]
         ldrb    r2, [jpc, #1]
         ands    lr, ip, #7
         moveq   pc, ip
 	ldrb	r1, [jpc, lr]
         bic     ip, ip, #7
-        ldr     ip, [ip, r1, lsl #2]
-        mov     pc, ip
+        ldr     pc, [ip, r1, lsl #2]
 	.endm
 #endif // DISPATCH_LOOP
 
@@ -2818,6 +2847,7 @@
 	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]
@@ -2882,6 +2912,7 @@
 #endif
 
 	Opcode	putfield
+	ldrb	r1, [jpc, #2]
         add     tmp2, constpool, r1, lsl #12
 	add	tmp2, tmp2, r2, lsl #4
 	ldr	r3, [tmp2, #CP_OFFSET]
@@ -3069,6 +3100,7 @@
 # r2 = [jpc, #1]
 # r1 = [jpc, #2]
 	Opcode	new
+	ldrb	r1, [jpc, #2]
 #define k_entry		tmp2
 #define new_result	r7
 #define top_addr	r7
@@ -3253,6 +3285,7 @@
 # r2 = [jpc, #1]
 # r1 = [jpc, #2]
 	Opcode	checkcast
+	ldrb	r1, [jpc, #2]
 	ldr	r3, [istate, #ISTATE_METHOD]
 	ldr	r0, [stack, #4]
 	ldr	r3, [r3, #METHOD_CONSTANTS]		@ R3 = METHOD->constants()
@@ -3355,6 +3388,7 @@
 # r2 = [jpc, #1]
 # r1 = [jpc, #2]
 	Opcode	instanceof
+	ldrb	r1, [jpc, #2]
 	ldr	r3, [istate, #ISTATE_METHOD]
 	ldr	r0, [stack, #4]
 	ldr	r3, [r3, #METHOD_CONSTANTS]
@@ -3903,16 +3937,34 @@
 	stmfd	arm_sp!, {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_no_frame
+
 	ldrh	r2, [sl, #METHOD_MAXLOCALS]
 	ldrh	r3, [sl, #METHOD_SIZEOFPARAMETERS]
-	rsb	tmp_zzz, r3, r2
-	cmp	tmp_zzz, #0
+	rsb	r8, r3, r2
+
+	ldr	r1, [tmp1, #THREAD_JAVA_SP]
+	ldrh	r0, [sl, #METHOD_MAXSTACK]
+	ldr	r3, [tmp1, #THREAD_JAVA_STACK_BASE]
+
+	sub	r5, r1, r8, lsl #2
+	sub	r5, r5, #FRAME_SIZE+4
+	sub	r5, r5, r0, lsl #2
+	cmp	r3, r5
+	bcs	stack_overflow_no_frame
+
+	cmp	r8, #0
 	ble	.normal_entry_synchronized_no_locals
 
 	mov	r2, #0
-	ldr	r1, [tmp1, #THREAD_JAVA_SP]
 .zero_locals_synchronized:
-	subs	tmp_zzz, tmp_zzz, #1
+	subs	r8, r8, #1
 	str	r2, [r1, #-4]!
 	bgt	.zero_locals_synchronized
 	str	r1, [tmp1, #THREAD_JAVA_SP]
@@ -3927,23 +3979,13 @@
 	sub	r0, r0, #72
 	mov	istate, r0
 	str	r3, [tmp_vvv, #0]
-	ldr	r0, [tmp1, #THREAD_STACK_SIZE]
-	ldr	r3, [tmp1, #THREAD_STACK_BASE]
-	ldr	r2, [tmp1, #THREAD_JAVA_SP]
-	ldr	r1, [tmp1, #THREAD_JAVA_STACK_BASE]
 	adrl	ip, dispatch_init_adcon
-	rsb	r3, r0, r3
-	rsb	r2, r1, r2
 	ldm	ip, {r0, r1}
-	rsb	r3, r3, arm_sp
-	cmp	r2, #4096
-	cmpge	r3, #32768
 	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
-	blt	.throw_stack_overflow
 	ldr	r0, [istate, #ISTATE_METHOD]
 	CACHE_STACK
 	ldr	r3, [r0, #METHOD_ACCESSFLAGS]
@@ -4009,6 +4051,7 @@
 # r2 = [jpc, #1]
 # r1 = [jpc, #2]
 	Opcode	invokeinterface
+	ldrb	r1, [jpc, #2]
 	DECACHE_STACK
         add     r0, constpool, r1, lsl #12
 	add	r0, r0, r2, asl #4
@@ -4069,9 +4112,11 @@
 
 	mov	tmp_invoke_len, #5
 
+#ifdef FASTPATH_ENTRY
 	adr	r0, normal_entry
 	cmp	r3, r0
 	beq	fast_normal_entry_with_len
+#endif
 
 	mov	r0, tmp2
 	mov	r1, ip
@@ -4114,6 +4159,7 @@
 # r2 = [jpc, #1]
 # r1 = [jpc, #2]
 	Opcode	invokevfinal
+	ldrb	r1, [jpc, #2]
 	DECACHE_STACK
 	add	r0, constpool, r1, lsl #12
 	DECACHE_JPC
@@ -4158,6 +4204,7 @@
 # r2 = [jpc, #1]
 # r1 = [jpc, #2]
         Opcode  invokevirtual
+	ldrb	r1, [jpc, #2]
         add     r0, constpool, r1, lsl #12
 	add	r0, r0, r2, asl #4
         ldr     r2, [r0, #CP_OFFSET]
@@ -4194,6 +4241,7 @@
 # r2 = [jpc, #1]
 # r1 = [jpc, #2]
         Opcode  invokeresolved
+	ldrb	r1, [jpc, #2]
         DECACHE_STACK
         add     r0, constpool, r1, lsl #12
 	DECACHE_JPC
@@ -4267,6 +4315,7 @@
 	DISPATCH_FINISH
 
 	Opcode	invokestatic
+	ldrb	r1, [jpc, #2]
         add     r0, constpool, r1, lsl #12
 	add	r0, r0, r2, asl #4
         ldr     r2, [r0, #CP_OFFSET]
@@ -4277,6 +4326,7 @@
   FBC	b	rewrite_bytecode
 
   FBC	Opcode	invokestaticresolved
+  FBC	ldrb	r1, [jpc, #2]
         DECACHE_STACK
   FBC   add     r0, constpool, r1, lsl #12
 	DECACHE_JPC
@@ -4332,12 +4382,10 @@
 	cmp	r3, #32768
 	bge	fast_normal_entry_with_len
 
-	mov	r0, tmp1
-        bl      _ZN18InterpreterRuntime24throw_StackOverflowErrorEP10JavaThread
-
-	ldmfd	arm_sp!, {regset, pc}
+	b	stack_overflow_before_frame
 
 	Opcode	invokespecial
+     	ldrb	r1, [jpc, #2]
         add     r0, constpool, r1, lsl #12
 	add	r0, r0, r2, asl #4
         ldr     r2, [r0, #CP_OFFSET]
@@ -4348,6 +4396,7 @@
   FBC	b	rewrite_bytecode
 
   FBC	Opcode	invokespecialresolved
+  FBC	ldrb	r1, [jpc, #2]
         DECACHE_STACK
   FBC   add     r0, constpool, r1, lsl #12
 	DECACHE_JPC
@@ -4456,6 +4505,14 @@
 	ldrh	r2, [tmp2, #METHOD_MAXSTACK]
         bic     ip, ip, #0x35000000
         sub     r7, r0, r3
+
+	ldr	r3, [tmp1, #THREAD_JAVA_STACK_BASE]
+	sub	r5, stack, r7, lsl #2
+	sub	r5, r5, #FRAME_SIZE+4
+	sub	r5, r5, r2, lsl #2
+	cmp	r3, r5
+	bcs	stack_overflow_before_frame
+
         subs    r5, r7, #2
         tst     r7, #1
         bic     ip, ip, #0x14000
@@ -4482,7 +4539,6 @@
         sub     locals, stack, #4
 	str	r1, [istate, #ISTATE_OOP_TEMP]
         add     locals, locals, r0, lsl #2
-        ldr     r3, [tmp1, #THREAD_JAVA_STACK_BASE]
         sub     stack, istate, #4
         ldr     jpc, [tmp2, #METHOD_CONSTMETHOD]
         ldr     constpool, [tmp2, #METHOD_CONSTANTS]
@@ -4490,15 +4546,12 @@
 	DISPATCH_START	48
         ldr     constpool, [constpool, #CONSTANTPOOL_CACHE]
         str     ip, [tmp1, #THREAD_TOP_ZERO_FRAME]
-        rsb     r2, r3, r2
         str     ip, [tmp1, #THREAD_LAST_JAVA_SP]
 	DISPATCH_NEXT
         str     tmp1, [istate, #ISTATE_THREAD]
 	str	locals, [istate, #ISTATE_LOCALS]
 	str	constpool, [istate, #ISTATE_CONSTANTS]
 	DISPATCH_NEXT
-        cmp     r2, #4096
-	blt	1f
 	DISPATCH_NEXT
 	DISPATCH_NEXT
 	str	r10, [istate, #ISTATE_METHOD]
@@ -4506,13 +4559,6 @@
 @        str     lr, [istate, #ISTATE_PREV_LINK]
 @	str	lr, [istate, #ISTATE_CALLEE]
 	DISPATCH_FINISH
-1:
-	str	r10, [istate, #ISTATE_METHOD]
-	DECACHE_JPC
-	ldr	stack, [istate, #ISTATE_STACK_BASE]
-	sub	stack, stack, #4
-	DECACHE_STACK
-	b	.throw_stack_overflow
 
 handle_return:
 @	CHECK_CONSTPOOL
@@ -4687,28 +4733,17 @@
 	b	handle_exception_with_bcp
 
 @ ----------------------------------------------------------------------------------------
-.throw_stack_overflow:
-	ldr	r0, [istate, #ISTATE_THREAD]
+stack_overflow_no_frame:
+	mov	tmp_invoke_len, #0
+stack_overflow_before_frame:
+	mov	r0, tmp1
+	ldr	ip, [r0, #THREAD_TOP_ZERO_FRAME]
+	str	ip, [r0, #THREAD_LAST_JAVA_SP]
+	mov	tmp1, tmp_invoke_len
 	bl	_ZN18InterpreterRuntime24throw_StackOverflowErrorEP10JavaThread
-	ldr	r3, [istate, #ISTATE_THREAD]
-	ldr	ip, [istate, #ISTATE_THREAD]
-	ldr	r2, [r3, #THREAD_TOP_ZERO_FRAME]
-	mov	r3, #0
-	add	r1, r2, #4
-	str	r3, [ip, #THREAD_LAST_JAVA_SP]
-	str	r1, [ip, #THREAD_JAVA_SP]
-	ldr	r3, [r2, #0]
-	str	r3, [ip, #THREAD_TOP_ZERO_FRAME]
-	ldr	r2, [istate, #ISTATE_METHOD]
-	ldrh	r3, [r2, #40]
-	mov	r3, r3, asl #2
-	add	r1, r1, r3
-	str	r1, [ip, #THREAD_JAVA_SP]
-	ldr	ip, [istate, #ISTATE_ADVANCE_PC]
-	ldr	istate, [istate, #ISTATE_NEXT_FRAME]
-	cmp	ip, #0
-	ldmeqfd	arm_sp!, {regset, pc}
-	b	fast_handle_return
+	cmp	tmp1, #0
+	bne	handle_exception_with_bcp
+	ldmfd	arm_sp!, {regset, pc}
 
 handle_exception_do_not_unlock:
 	mov	r3, #1