You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ge...@apache.org on 2005/10/08 06:29:29 UTC
svn commit: r307257 [21/24] - in
/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm: ./ bootJVM/
bootJVM/jni/ bootJVM/jni/src/ bootJVM/jni/src/gnu/
bootJVM/jni/src/gnu/classpath/ bootJVM/jni/src/gnu/classpath/0.16/
bootJVM/jni/src/gnu/classpath...
Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/opcode.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/opcode.h?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/opcode.h (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/opcode.h Fri Oct 7 21:27:56 2005
@@ -0,0 +1,349 @@
+#ifndef _opcode_h_included_
+#define _opcode_h_included_
+
+/*!
+ * @file opcode.h
+ *
+ * @brief Implementation of <em>The Java Virtual Machine Specification,
+ * version 2, Section 9, Operation Mnemonics by Opcode</em>.
+ *
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/opcode.h $ \$Id: opcode.h 0 09/28/2005 dlydick $
+ *
+ * Copyright 2005 The Apache Software Foundation
+ * or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 ("the License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied.
+ *
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * @version \$LastChangedRevision: 0 $
+ *
+ * @date \$LastChangedDate: 09/28/2005 $
+ *
+ * @author \$LastChangedBy: dlydick $
+ * Original code contributed by Daniel Lydick on 09/28/2005.
+ *
+ * @section Reference
+ *
+ */
+
+ARCH_COPYRIGHT_APACHE(opcode, h, "$URL: https://svn.apache.org/path/name/opcode.h $ $Id: opcode.h 0 09/28/2005 dlydick $");
+
+
+/*!
+ * @name Java Virtual Machine operation codes, standard set
+ *
+ */
+
+/*@{ */ /* Begin grouped definitions */
+
+#define OPCODE_00_NOP 0x00 /**< 00 (0x00) nop */
+#define OPCODE_01_ACONST_NULL 0x01 /**< 01 (0x01) aconst_null */
+#define OPCODE_02_ICONST_M1 0x02 /**< 02 (0x02) iconst_m1 */
+#define OPCODE_03_ICONST_0 0x03 /**< 03 (0x03) iconst_0 */
+#define OPCODE_04_ICONST_1 0x04 /**< 04 (0x04) iconst_1 */
+#define OPCODE_05_ICONST_2 0x05 /**< 05 (0x05) iconst_2 */
+#define OPCODE_06_ICONST_3 0x06 /**< 06 (0x06) iconst_3 */
+#define OPCODE_07_ICONST_4 0x07 /**< 07 (0x07) iconst_4 */
+#define OPCODE_08_ICONST_5 0x08 /**< 08 (0x08) iconst_5 */
+#define OPCODE_09_LCONST_0 0x09 /**< 09 (0x09) lconst_0 */
+#define OPCODE_0A_LCONST_1 0x0a /**< 10 (0x0a) lconst_1 */
+#define OPCODE_0B_FCONST_0 0x0b /**< 11 (0x0b) fconst_0 */
+#define OPCODE_0C_FCONST_1 0x0c /**< 12 (0x0c) fconst_1 */
+#define OPCODE_0D_FCONST_2 0x0d /**< 13 (0x0d) fconst_2 */
+#define OPCODE_0E_DCONST_0 0x0e /**< 14 (0x0e) dconst_0 */
+#define OPCODE_0F_DCONST_1 0x0f /**< 15 (0x0f) dconst_1 */
+#define OPCODE_10_BIPUSH 0x10 /**< 16 (0x10) bipush */
+#define OPCODE_11_SIPUSH 0x11 /**< 17 (0x11) sipush */
+#define OPCODE_12_LDC 0x12 /**< 18 (0x12) Ldc */
+#define OPCODE_13_LDC_W 0x13 /**< 19 (0x13) ldc_w */
+#define OPCODE_14_LDC2_W 0x14 /**< 20 (0x14) ldc2_w */
+#define OPCODE_15_ILOAD 0x15 /**< 21 (0x15) iload */
+#define OPCODE_16_LLOAD 0x16 /**< 22 (0x16) lload */
+#define OPCODE_17_FLOAD 0x17 /**< 23 (0x17) fload */
+#define OPCODE_18_DLOAD 0x18 /**< 24 (0x18) dload */
+#define OPCODE_19_ALOAD 0x19 /**< 25 (0x19) aload */
+#define OPCODE_1A_ILOAD_0 0x1a /**< 26 (0x1a) iload_0 */
+#define OPCODE_1B_ILOAD_1 0x1b /**< 27 (0x1b) iload_1 */
+#define OPCODE_1C_ILOAD_2 0x1c /**< 28 (0x1c) iload_2 */
+#define OPCODE_1D_ILOAD_3 0x1d /**< 29 (0x1d) iload_3 */
+#define OPCODE_1E_LLOAD_0 0x1e /**< 30 (0x1e) lload_0 */
+#define OPCODE_1F_LLOAD_1 0x1f /**< 31 (0x1f) lload_1 */
+#define OPCODE_20_LLOAD_2 0x20 /**< 32 (0x20) lload_2 */
+#define OPCODE_21_LLOAD_3 0x21 /**< 33 (0x21) lload_3 */
+#define OPCODE_22_FLOAD_0 0x22 /**< 34 (0x22) fload_0 */
+#define OPCODE_23_FLOAD_1 0x23 /**< 35 (0x23) fload_1 */
+#define OPCODE_24_FLOAD_2 0x24 /**< 36 (0x24) fload_2 */
+#define OPCODE_25_FLOAD_3 0x25 /**< 37 (0x25) fload_3 */
+#define OPCODE_26_DLOAD_0 0x26 /**< 38 (0x26) dload_0 */
+#define OPCODE_27_DLOAD_1 0x27 /**< 39 (0x27) dload_1 */
+#define OPCODE_28_DLOAD_2 0x28 /**< 40 (0x28) dload_2 */
+#define OPCODE_29_DLOAD_3 0x29 /**< 41 (0x29) dload_3 */
+#define OPCODE_2A_ALOAD_0 0x2a /**< 42 (0x2a) aload_0 */
+#define OPCODE_2B_ALOAD_1 0x2b /**< 43 (0x2b) aload_1 */
+#define OPCODE_2C_ALOAD_2 0x2c /**< 44 (0x2c) aload_2 */
+#define OPCODE_2D_ALOAD_3 0x2d /**< 45 (0x2d) aload_3 */
+#define OPCODE_2E_IALOAD 0x2e /**< 46 (0x2e) iaload */
+#define OPCODE_2F_LALOAD 0x2f /**< 47 (0x2f) laload */
+#define OPCODE_30_FALOAD 0x30 /**< 48 (0x30) faload */
+#define OPCODE_31_DALOAD 0x31 /**< 49 (0x31) daload */
+#define OPCODE_32_AALOAD 0x32 /**< 50 (0x32) aaload */
+#define OPCODE_33_BALOAD 0x33 /**< 51 (0x33) baload */
+#define OPCODE_34_CALOAD 0x34 /**< 52 (0x34) caload */
+#define OPCODE_35_SALOAD 0x35 /**< 53 (0x35) saload */
+#define OPCODE_36_ISTORE 0x36 /**< 54 (0x36) istore */
+#define OPCODE_37_LSTORE 0x37 /**< 55 (0x37) lstore */
+#define OPCODE_38_FSTORE 0x38 /**< 56 (0x38) fstore */
+#define OPCODE_39_DSTORE 0x39 /**< 57 (0x39) dstore */
+#define OPCODE_3A_ASTORE 0x3a /**< 58 (0x3a) astore */
+#define OPCODE_3B_ISTORE_0 0x3b /**< 59 (0x3b) istore_0 */
+#define OPCODE_3C_ISTORE_1 0x3c /**< 60 (0x3c) istore_1 */
+#define OPCODE_3D_ISTORE_2 0x3d /**< 61 (0x3d) istore_2 */
+#define OPCODE_3E_ISTORE_3 0x3e /**< 62 (0x3e) istore_3 */
+#define OPCODE_3F_LSTORE_0 0x3f /**< 63 (0x3f) lstore_0 */
+#define OPCODE_40_LSTORE_1 0x40 /**< 64 (0x40) lstore_1 */
+#define OPCODE_41_LSTORE_2 0x41 /**< 65 (0x41) lstore_2 */
+#define OPCODE_42_LSTORE_3 0x42 /**< 66 (0x42) lstore_3 */
+#define OPCODE_43_FSTORE_0 0x43 /**< 67 (0x43) fstore_0 */
+#define OPCODE_44_FSTORE_1 0x44 /**< 68 (0x44) fstore_1 */
+#define OPCODE_45_FSTORE_2 0x45 /**< 69 (0x45) fstore_2 */
+#define OPCODE_46_FSTORE_3 0x46 /**< 70 (0x46) fstore_3 */
+#define OPCODE_47_DSTORE_0 0x47 /**< 71 (0x47) dstore_0 */
+#define OPCODE_48_DSTORE_1 0x48 /**< 72 (0x48) dstore_1 */
+#define OPCODE_49_DSTORE_2 0x49 /**< 73 (0x49) dstore_2 */
+#define OPCODE_4A_DSTORE_3 0x4a /**< 74 (0x4a) dstore_3 */
+#define OPCODE_4B_ASTORE_0 0x4b /**< 75 (0x4b) astore_0 */
+#define OPCODE_4C_ASTORE_1 0x4c /**< 76 (0x4c) astore_1 */
+#define OPCODE_4D_ASTORE_2 0x4d /**< 77 (0x4d) astore_2 */
+#define OPCODE_4E_ASTORE_3 0x4e /**< 78 (0x4e) astore_3 */
+#define OPCODE_4F_IASTORE 0x4f /**< 79 (0x4f) iastore */
+#define OPCODE_50_LASTORE 0x50 /**< 80 (0x50) lastore */
+#define OPCODE_51_FASTORE 0x51 /**< 81 (0x51) fastore */
+#define OPCODE_52_DASTORE 0x52 /**< 82 (0x52) dastore */
+#define OPCODE_53_AASTORE 0x53 /**< 83 (0x53) aastore */
+#define OPCODE_54_BASTORE 0x54 /**< 84 (0x54) bastore */
+#define OPCODE_55_CASTORE 0x55 /**< 85 (0x55) castore */
+#define OPCODE_56_SASTORE 0x56 /**< 86 (0x56) sastore */
+#define OPCODE_57_POP 0x57 /**< 87 (0x57) Pop */
+#define OPCODE_58_POP2 0x58 /**< 88 (0x58) pop2 */
+#define OPCODE_59_DUP 0x59 /**< 089 (0x59) dup */
+#define OPCODE_5A_DUP_X1 0x5a /**< 090 (0x5a) dup_x1 */
+#define OPCODE_5B_DUP_X2 0x5b /**< 091 (0x5b) dup_x2 */
+#define OPCODE_5C_DUP2 0x5C /**< 092 (0x5C) dup2 */
+#define OPCODE_5D_DUP2_X1 0x5d /**< 093 (0x5d) dup2_x1 */
+#define OPCODE_5E_DUP2_X2 0x5e /**< 094 (0x5e) dup2_x2 */
+#define OPCODE_5F_SWAP 0x5f /**< 095 (0x5f) swap */
+#define OPCODE_60_IADD 0x60 /**< 096 (0x60) iadd */
+#define OPCODE_61_LADD 0x61 /**< 097 (0x61) ladd */
+#define OPCODE_62_FADD 0x62 /**< 098 (0x62) fadd */
+#define OPCODE_63_DADD 0x63 /**< 099 (0x63) dadd */
+#define OPCODE_64_ISUB 0x64 /**< 100 (0x64) isub */
+#define OPCODE_65_LSUB 0x65 /**< 101 (0x65) lsub */
+#define OPCODE_66_FSUB 0x66 /**< 102 (0x66) fsub */
+#define OPCODE_67_DSUB 0x67 /**< 103 (0x67) dsub */
+#define OPCODE_68_IMUL 0x68 /**< 104 (0x68) imul */
+#define OPCODE_69_LMUL 0x69 /**< 105 (0x69) lmul */
+#define OPCODE_6A_FMUL 0x6a /**< 106 (0x6a) fmul */
+#define OPCODE_6B_DMUL 0x6b /**< 107 (0x6b) dmul */
+#define OPCODE_6C_IDIV 0x6c /**< 108 (0x6c) idiv */
+#define OPCODE_6D_LDIV 0x6d /**< 109 (0x6d) ldiv */
+#define OPCODE_6E_FDIV 0x6e /**< 110 (0x6e) fdiv */
+#define OPCODE_6F_DDIV 0x6f /**< 111 (0x6f) ddiv */
+#define OPCODE_70_IREM 0x70 /**< 112 (0x70) irem */
+#define OPCODE_71_LREM 0x71 /**< 113 (0x71) lrem */
+#define OPCODE_72_FREM 0x72 /**< 114 (0x72) frem */
+#define OPCODE_73_DREM 0x73 /**< 115 (0x73) drem */
+#define OPCODE_74_INEG 0x74 /**< 116 (0x74) ineg */
+#define OPCODE_75_LNEG 0x75 /**< 117 (0x75) lneg */
+#define OPCODE_76_FNEG 0x76 /**< 118 (0x76) fneg */
+#define OPCODE_77_DNEG 0x77 /**< 119 (0x77) dneg */
+#define OPCODE_78_ISHL 0x78 /**< 120 (0x78) ishl */
+#define OPCODE_79_LSHL 0x79 /**< 121 (0x79) lshl */
+#define OPCODE_7A_ISHR 0x7a /**< 122 (0x7a) ishr */
+#define OPCODE_7B_LSHR 0x7b /**< 123 (0x7b) lshr */
+#define OPCODE_7C_IUSHR 0x7c /**< 124 (0x7c) iushr */
+#define OPCODE_7D_LUSHR 0x7d /**< 125 (0x7d) lushr */
+#define OPCODE_7E_IAND 0x7e /**< 126 (0x7e) iand */
+#define OPCODE_7F_LAND 0x7f /**< 127 (0x7f) land */
+#define OPCODE_80_IOR 0x80 /**< 128 (0x80) ior */
+#define OPCODE_81_LOR 0x81 /**< 129 (0x81) lor */
+#define OPCODE_82_IXOR 0x82 /**< 130 (0x82) ixor */
+#define OPCODE_83_LXOR 0x83 /**< 131 (0x83) lxor */
+#define OPCODE_84_IINC 0x84 /**< 132 (0x84) iinc */
+#define OPCODE_85_I2L 0x85 /**< 133 (0x85) i2l */
+#define OPCODE_86_I2F 0x86 /**< 134 (0x86) i2f */
+#define OPCODE_87_I2D 0x87 /**< 135 (0x87) i2d */
+#define OPCODE_88_L2I 0x88 /**< 136 (0x88) l2i */
+#define OPCODE_89_L2F 0x89 /**< 137 (0x89) l2f */
+#define OPCODE_8A_L2D 0x8a /**< 138 (0x8a) l2d */
+#define OPCODE_8B_F2I 0x8b /**< 139 (0x8b) f2i */
+#define OPCODE_8C_F2L 0x8c /**< 140 (0x8c) f2l */
+#define OPCODE_8D_F2D 0x8d /**< 141 (0x8d) f2d */
+#define OPCODE_8E_D2I 0x8e /**< 142 (0x8e) d2i */
+#define OPCODE_8F_D2L 0x8f /**< 143 (0x8f) d2l */
+#define OPCODE_90_D2F 0x90 /**< 144 (0x90) d2f */
+#define OPCODE_91_I2B 0x91 /**< 145 (0x91) i2b */
+#define OPCODE_92_I2C 0x92 /**< 146 (0x92) i2c */
+#define OPCODE_93_I2S 0x93 /**< 147 (0x93) i2s */
+#define OPCODE_94_LCMP 0x94 /**< 148 (0x94) lcmp */
+#define OPCODE_95_FCMPL 0x95 /**< 149 (0x95) fcmpl */
+#define OPCODE_96_FCMPG 0x96 /**< 150 (0x96) fcmpg */
+#define OPCODE_97_DCMPL 0x97 /**< 151 (0x97) dcmpl */
+#define OPCODE_98_DCMPG 0x98 /**< 152 (0x98) dcmpg */
+#define OPCODE_99_IFEQ 0x99 /**< 153 (0x99) ifeq */
+#define OPCODE_9A_IFNE 0x9a /**< 154 (0x9a) ifne */
+#define OPCODE_9B_IFLT 0x9b /**< 155 (0x9b) iflt */
+#define OPCODE_9C_IFGE 0x9c /**< 156 (0x9c) ifge */
+#define OPCODE_9D_IFGT 0x9d /**< 157 (0x9d) ifgt */
+#define OPCODE_9E_IFLE 0x9e /**< 158 (0x9e) ifle */
+#define OPCODE_9F_IF_ICMPEQ 0x9f /**< 159 (0x9f) if_icmpeq */
+#define OPCODE_A0_IF_ICMPNE 0xa0 /**< 160 (0xa0) if_icmpne */
+#define OPCODE_A1_IF_ICMPLT 0xa1 /**< 161 (0xa1) if_icmplt */
+#define OPCODE_A2_IF_ICMPGE 0xa2 /**< 162 (0xa2) if_icmpge */
+#define OPCODE_A3_IF_ICMPGT 0xa3 /**< 163 (0xa3) if_icmpgt */
+#define OPCODE_A4_IF_ICMPLE 0xa4 /**< 164 (0xa4) if_icmple */
+#define OPCODE_A5_IF_ACMPEQ 0xa5 /**< 165 (0xa5) if_acmpeq */
+#define OPCODE_A6_IF_ACMPNE 0xa6 /**< 166 (0xa6) if_acmpne */
+#define OPCODE_A7_GOTO 0xa7 /**< 167 (0xa7) goto */
+#define OPCODE_A8_JSR 0xa8 /**< 168 (0xa8) jsr */
+#define OPCODE_A9_RET 0xa9 /**< 169 (0xa9) ret */
+#define OPCODE_AA_TABLESWITCH 0xaa /**< 170 (0xaa) tableswitch */
+#define OPCODE_AB_LOOKUPSWITCH 0xab /**< 171 (0xab) lookupswitch */
+#define OPCODE_AC_IRETURN 0xac /**< 172 (0xac) ireturn */
+#define OPCODE_AD_LRETURN 0xad /**< 173 (0xad) lreturn */
+#define OPCODE_AE_FRETURN 0xae /**< 174 (0xae) freturn */
+#define OPCODE_AF_DRETURN 0xaf /**< 175 (0xaf) dreturn */
+#define OPCODE_B0_ARETURN 0xb0 /**< 176 (0xb0) areturn */
+#define OPCODE_B1_RETURN 0xb1 /**< 177 (0xb1) return */
+#define OPCODE_B2_GETSTATIC 0xb2 /**< 178 (0xb2) getstatic */
+#define OPCODE_B3_PUTSTATIC 0xb3 /**< 179 (0xb3) putstatic */
+#define OPCODE_B4_GETFIELD 0xb4 /**< 180 (0xb4) getfield */
+#define OPCODE_B5_PUTFIELD 0xb5 /**< 181 (0xb5) putfield */
+#define OPCODE_B6_INVOKEVIRTUAL 0xb6 /**< 182 (0xb6) invokevirtual */
+#define OPCODE_B7_INVOKESPECIAL 0xb7 /**< 183 (0xb7) invokespecial */
+#define OPCODE_B8_INVOKESTATIC 0xb8 /**< 184 (0xb8) invokestatic */
+#define OPCODE_B9_INVOKEINTERFACE 0xb9 /**< 185 (0xb9)invokeinterface*/
+#define OPCODE_BA_XXXUNUSEDXXX1 0xba /**< 186 (0xba) xxxunusedxxx1 */
+#define OPCODE_BB_NEW 0xbb /**< 187 (0xbb) new */
+#define OPCODE_BC_NEWARRAY 0xbc /**< 188 (0xbc) newarray */
+#define OPCODE_BD_ANEWARRAY 0xbd /**< 189 (0xbd) anewarray */
+#define OPCODE_BE_ARRAYLENGTH 0xbe /**< 190 (0xbe) arraylength */
+#define OPCODE_BF_ATHROW 0xbf /**< 191 (0xbf) athrow */
+#define OPCODE_C0_CHECKCAST 0xc0 /**< 192 (0xc0) checkcast */
+#define OPCODE_C1_INSTANCEOF 0xc1 /**< 193 (0xc1) instanceof */
+#define OPCODE_C2_MONITORENTER 0xc2 /**< 194 (0xc2) monitorenter */
+#define OPCODE_C3_MONITOREXIT 0xc3 /**< 195 (0xc3) monitorexit */
+#define OPCODE_C4_WIDE 0xc4 /**< 196 (0xc4) wide */
+#define OPCODE_C5_MULTIANEWARRAY 0xc5 /**< 197 (0xc5) multianewarray*/
+#define OPCODE_C6_IFNULL 0xc6 /**< 198 (0xc6) ifnull */
+#define OPCODE_C7_IFNONNULL 0xc7 /**< 199 (0xc7) ifnonnull */
+#define OPCODE_C8_GOTO_W 0xc8 /**< 200 (0xc8) goto_w */
+#define OPCODE_C9_JSR_W 0xc9 /**< 201 (0xc9) jsr_w */
+#define OPCODE_CA_BREAKPOINT 0xca /**< 202 (0xca) breakpoint */
+
+/*@} */ /* End of grouped definitions */
+
+
+/*!
+ * @name Java Virtual Machine operation codes, reserved and unused set
+ *
+ */
+
+/*@{ */ /* Begin grouped definitions */
+
+#define OPCODE_CB_UNUSED 0xcb /**< 203 (0xcb) unused */
+#define OPCODE_CC_UNUSED 0xcc /**< 204 (0xcc) unused */
+#define OPCODE_CD_UNUSED 0xcd /**< 205 (0xcd) unused */
+#define OPCODE_CE_UNUSED 0xce /**< 206 (0xce) unused */
+#define OPCODE_CF_UNUSED 0xcf /**< 207 (0xcf) unused */
+
+#define OPCODE_D0_UNUSED 0xd0 /**< 208 (0xd0) unused */
+#define OPCODE_D1_UNUSED 0xd1 /**< 209 (0xd1) unused */
+#define OPCODE_D2_UNUSED 0xd2 /**< 210 (0xd2) unused */
+#define OPCODE_D3_UNUSED 0xd3 /**< 211 (0xd3) unused */
+#define OPCODE_D4_UNUSED 0xd4 /**< 212 (0xd4) unused */
+#define OPCODE_D5_UNUSED 0xd5 /**< 213 (0xd5) unused */
+#define OPCODE_D6_UNUSED 0xd6 /**< 214 (0xd6) unused */
+#define OPCODE_D7_UNUSED 0xd7 /**< 215 (0xd7) unused */
+#define OPCODE_D8_UNUSED 0xd8 /**< 216 (0xd8) unused */
+#define OPCODE_D9_UNUSED 0xd9 /**< 217 (0xd9) unused */
+#define OPCODE_DA_UNUSED 0xda /**< 218 (0xda) unused */
+#define OPCODE_DB_UNUSED 0xdb /**< 219 (0xdb) unused */
+#define OPCODE_DC_UNUSED 0xdc /**< 220 (0xdc) unused */
+#define OPCODE_DD_UNUSED 0xdd /**< 221 (0xdd) unused */
+#define OPCODE_DE_UNUSED 0xde /**< 222 (0xde) unused */
+#define OPCODE_DF_UNUSED 0xdf /**< 223 (0xdf) unused */
+
+#define OPCODE_E0_UNUSED 0xe0 /**< 224 (0xe0) unused */
+#define OPCODE_E1_UNUSED 0xe1 /**< 225 (0xe1) unused */
+#define OPCODE_E2_UNUSED 0xe2 /**< 226 (0xe2) unused */
+#define OPCODE_E3_UNUSED 0xe3 /**< 227 (0xe3) unused */
+#define OPCODE_E4_UNUSED 0xe4 /**< 228 (0xe4) unused */
+#define OPCODE_E5_UNUSED 0xe5 /**< 229 (0xe5) unused */
+#define OPCODE_E6_UNUSED 0xe6 /**< 230 (0xe6) unused */
+#define OPCODE_E7_UNUSED 0xe7 /**< 231 (0xe7) unused */
+#define OPCODE_E8_UNUSED 0xe8 /**< 232 (0xe8) unused */
+#define OPCODE_E9_UNUSED 0xe9 /**< 233 (0xe9) unused */
+#define OPCODE_EA_UNUSED 0xea /**< 234 (0xea) unused */
+#define OPCODE_EB_UNUSED 0xeb /**< 234 (0xeb) unused */
+#define OPCODE_EC_UNUSED 0xec /**< 235 (0xec) unused */
+#define OPCODE_ED_UNUSED 0xed /**< 237 (0xed) unused */
+#define OPCODE_EE_UNUSED 0xee /**< 238 (0xee) unused */
+#define OPCODE_EF_UNUSED 0xef /**< 239 (0xef) unused */
+
+#define OPCODE_F0_UNUSED 0xf0 /**< 240 (0xf0) unused */
+#define OPCODE_F1_UNUSED 0xf1 /**< 241 (0xf1) unused */
+#define OPCODE_F2_UNUSED 0xf2 /**< 242 (0xf2) unused */
+#define OPCODE_F3_UNUSED 0xf3 /**< 243 (0xf3) unused */
+#define OPCODE_F4_UNUSED 0xf4 /**< 244 (0xf4) unused */
+#define OPCODE_F5_UNUSED 0xf5 /**< 245 (0xf5) unused */
+#define OPCODE_F6_UNUSED 0xf6 /**< 246 (0xf6) unused */
+#define OPCODE_F7_UNUSED 0xf7 /**< 247 (0xf7) unused */
+#define OPCODE_F8_UNUSED 0xf8 /**< 248 (0xf8) unused */
+#define OPCODE_F9_UNUSED 0xf9 /**< 249 (0xf9) unused */
+#define OPCODE_FA_UNUSED 0xfa /**< 250 (0xfa) unused */
+#define OPCODE_FB_UNUSED 0xfb /**< 251 (0xfb) unused */
+#define OPCODE_FC_UNUSED 0xfc /**< 252 (0xfc) unused */
+#define OPCODE_FD_UNUSED 0xfd /**< 253 (0xfd) unused */
+
+/*@} */ /* End of grouped definitions */
+
+/*!
+@name Java Virtual Machine operation codes, implementation-dependent set
+ *
+ */
+
+/*@{ */ /* Begin grouped definitions */
+
+#define OPCODE_FE_IMPDEP1 0xfe /**< 254 (0xfe) impdep1 */
+#define OPCODE_FF_IMPDEP2 0xff /**< 255 (0xff) impdep2 */
+
+/*@} */ /* End of grouped definitions */
+
+
+/* Prototypes and selected externs for functions in 'opcode.c' */
+
+extern rboolean opcode_calling_java_lang_linkageerror;
+
+extern rvoid opcode_load_run_throwable(rchar *pThrowableEvent,
+ jvm_thread_index thridx);
+
+extern rboolean opcode_run(jvm_thread_index thridx,
+ rboolean check_timeslice);
+
+#endif /* _opcode_h_included_ */
+
+/* EOF */
Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/stdio.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/stdio.c?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/stdio.c (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/stdio.c Fri Oct 7 21:27:56 2005
@@ -0,0 +1,300 @@
+/*!
+ * @file stdio.c
+ *
+ * @brief Standard Output and Standard Error print functions that are
+ * isolated from certain compile requirements of the other code.
+ *
+ * USE THESE FUNCTIONS IN PLACE OF fprintf() AND sprintf() IN ALL
+ * CODE DUE TO STRUCTURE PACKING OPTIONS CAUSING @b SIGSEGV IN
+ * SOME ARCHITECTURES (specifically Solaris 32-bit) WITH 'GCC'
+ *
+ * THIS FILE MUST BE COMPILED WITH STRUCTURE PACKING OFF
+ * (at least for the default GCC stdio library) OR IN THE
+ * SAME MANNER IN WHICH YOUR COMPILER'S RUNTIME LIBRARY
+ * HAS IT COMPILED. (You may get unexplainable @b SIGSEGV
+ * errors otherwise.)
+ *
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/stdio.c $ \$Id: stdio.c 0 09/28/2005 dlydick $
+ *
+ * Copyright 2005 The Apache Software Foundation
+ * or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 ("the License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied.
+ *
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * @version \$LastChangedRevision: 0 $
+ *
+ * @date \$LastChangedDate: 09/28/2005 $
+ *
+ * @author \$LastChangedBy: dlydick $
+ * Original code contributed by Daniel Lydick on 09/28/2005.
+ *
+ * @section Reference
+ *
+ */
+
+#include "arch.h"
+ARCH_COPYRIGHT_APACHE(stdio, c, "$URL: https://svn.apache.org/path/name/stdio.c $ $Id: stdio.c 0 09/28/2005 dlydick $");
+
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#define SUPPRESS_STDIO_REDIRECTION /* All other files redirect here */
+#include "jvmcfg.h"
+
+ /* Defeat compiler complaints about @c @b extern */
+#define I_AM_STDIO_C
+
+#include "util.h"
+
+/*!
+ * @name printf() style printing to standard error and
+ * buffer formatting.
+ *
+ * There are three versions of this routine. One conditionally
+ * prints a message to stderr based on a debug level.
+ * The others perform unconditional actions.
+ *
+ * Create a variable-argument message to standard error or a buffer
+ * in a fashion with a tag string on the front telling what type
+ * of error it is.
+ *
+ *
+ * @param dml Debug msg level @link #DML0 DML0@endlink through
+ * @link #DML10 DML10@endlink
+ *
+ * @param bfr Buffer to format
+ *
+ * @param fn Function name of caller or other unique "string"
+ *
+ * @param fmt printf() style format string
+ *
+ * _param ... printf() style argument list, zero or more
+ *
+ *
+ * @returns number of characters emitted or formatted
+ *
+ */
+
+/*@{ */ /* Begin grouped definitions */
+
+int sysDbgMsg(rint dml, rchar *fn, rchar *fmt, ...)
+{
+ /* Display @e nothing if debug messages are disabled */
+ if (rfalse == JVMCFG_DEBUG_MESSAGE_ENABLE)
+ {
+ return(0);
+ }
+
+ if (jvmutil_get_dml() < dml)
+ {
+ return(0);
+ }
+
+ /* If debug levels are satisfied, proceed to print message */
+
+ rchar extfmt[JVMCFG_STDIO_BFR]; /* WARNING! On the stack! */
+
+ /* Load up format string w/ user specification */
+
+ va_list ap;
+ va_start(ap, fmt);
+
+ sprintf(extfmt, "%s: %s\n", fn, fmt);
+ int rc = vfprintf(stderr, extfmt, ap);
+
+ va_end(ap);
+
+ fflush(stderr);
+ JVMCFG_DEBUG_ECLIPSE_FLUSH_STDIO_BETTER;
+ return(rc);
+
+} /* END of sysDbgMsg() */
+
+
+int sysErrMsg(rchar *fn, rchar *fmt, ...)
+{
+ rchar extfmt[JVMCFG_STDIO_BFR]; /* WARNING! On the stack! */
+
+ /* Load up format string w/ user specification */
+
+ va_list ap;
+ va_start(ap, fmt);
+
+ sprintf(extfmt, "%s: %s\n", fn, fmt);
+ int rc = vfprintf(stderr, extfmt, ap);
+
+ va_end(ap);
+
+ fflush(stderr);
+ JVMCFG_DEBUG_ECLIPSE_FLUSH_STDIO_BETTER;
+ return(rc);
+
+} /* END of sysErrMsg() */
+
+
+int sysErrMsgBfrFormat(rchar *bfr, rchar *fn, rchar *fmt, ...)
+{
+ rchar extfmt[JVMCFG_STDIO_BFR]; /* WARNING! On the stack! */
+
+ /* Load up format string w/ user specification */
+
+ va_list ap;
+ va_start(ap, fmt);
+
+ sprintf(extfmt, "%s: %s\n", fn, fmt);
+ int rc = vsprintf(bfr, extfmt, ap);
+
+ va_end(ap);
+
+ return(rc);
+
+} /* END of sysErrMsgBfrFormat() */
+
+/*@} */ /* End of grouped definitions */
+
+
+/*!
+ * @name Macro support for local standard output utilities
+ *
+ */
+
+/*@{ */ /* Begin grouped definitions */
+
+#define LOCAL_FPRINTF(FP) \
+ va_list ap; \
+ va_start(ap, fmt); \
+ \
+ int rc = vfprintf(FP, fmt, ap); \
+ \
+ va_end(ap); \
+ fflush(FP); \
+ JVMCFG_DEBUG_ECLIPSE_FLUSH_STDIO_BETTER; \
+ return(rc)
+
+#define LOCAL_SPRINTF \
+ va_list ap; \
+ va_start(ap, fmt); \
+ \
+ int rc = vsprintf(bfr, fmt, ap); \
+ \
+ va_end(ap); \
+ return(rc)
+
+/*@} */ /* End of grouped definitions */
+
+/*!
+ * @name Local version of standard output routines.
+ *
+ * Local implementations of @c @b sprintf(3) and @c @b fprintf(3)
+ * are provided for both stdout and stderr. These functions are
+ * intended to bypass the structure packing mismatch between the
+ * requirements of parts of this application and the manner in
+ * which any compiler's runtime library was compiled.
+ *
+ * In the same manner as the printf() style printing functions
+ * above, there are three versions of this routine. In this
+ * case, one writes to standard output, another to standard error,
+ * and the third formats a buffer.
+ *
+ * @param fmt printf() style format string
+ *
+ * _param ... printf() style argument list, zero or more
+ *
+ *
+ * @returns number of characters emitted or formatted
+ *
+ */
+
+/*@{ */ /* Begin grouped definitions */
+
+int fprintfLocalStdout(rchar *fmt, ...)
+{
+ LOCAL_FPRINTF(stdout);
+
+} /* END of fprintfLocalStdout() */
+
+
+int fprintfLocalStderr(rchar *fmt, ...)
+{
+ LOCAL_FPRINTF(stderr);
+
+} /* END of fprintfLocalStderr() */
+
+int sprintfLocal(rchar *bfr, rchar *fmt, ...)
+{
+ LOCAL_SPRINTF;
+
+} /* END of sprintfLocal() */
+
+/*@} */ /* End of grouped definitions */
+
+
+/*!
+ * @name Magic redirection of selected standard I/O functions.
+ *
+ * In @link jvm/src/jvmcfg.h jvmcfg.h@endlink, there are
+ * several @c @b \#define statements that redirect @c @b printf()
+ * and @c @b fprintf() and @c @b sprintf() from the
+ * @c @b \<stdio.h\> linkages to local linkages.
+ *
+ * This magic redirection used the compile-time definition
+ * @c @b SUPPRESS_STDIO_REDIRECTION to co-opt these standard I/O
+ * calls and redirect them to local version so as to avoid @b SIGSEGV
+ * problems with certain configurations. * These routines are meant
+ * to encourage use of proper functions above.
+ *
+ * @param fp @c @b FILE handle to standard I/O file handle.
+ *
+ * @param bfr Buffer to format
+ *
+ * @param fmt printf() style format string
+ *
+ * _param ... printf() style argument list, zero or more
+ *
+ *
+ * @returns number of characters emitted or formatted
+ */
+
+/*@{ */ /* Begin grouped definitions */
+
+int _printfLocal(const rchar *fmt, ...)
+{
+ return(sysErrMsg("_printfLocal",
+ "Please use 'printfLocal' function instead"));
+
+} /* END of _printfLocal() */
+
+int _fprintfLocal(FILE *fp, const rchar *fmt, ...)
+{
+ return(sysErrMsg("_fprintfLocal",
+ "Please use 'fprintfLocal' function instead"));
+
+} /* END of _fprintfLocal() */
+
+int _sprintfLocal(rchar *bfr, const rchar *fmt, ...)
+{
+ return(sysErrMsg("_sprintfLocal",
+ "Please use 'sprintfLocal' function instead"));
+
+} /* END of _sprintfLocal() */
+
+/*@} */ /* End of grouped definitions */
+
+
+/* EOF */
Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/thread.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/thread.c?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/thread.c (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/thread.c Fri Oct 7 21:27:56 2005
@@ -0,0 +1,1102 @@
+/*!
+ * @file thread.c
+ *
+ * @brief Create and manage real machine Java thread structures.
+ *
+ *
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/thread.c $ \$Id: thread.c 0 09/28/2005 dlydick $
+ *
+ * Copyright 2005 The Apache Software Foundation
+ * or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 ("the License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied.
+ *
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * @version \$LastChangedRevision: 0 $
+ *
+ * @date \$LastChangedDate: 09/28/2005 $
+ *
+ * @author \$LastChangedBy: dlydick $
+ * Original code contributed by Daniel Lydick on 09/28/2005.
+ *
+ * @section Reference
+ *
+ */
+
+#include "arch.h"
+ARCH_COPYRIGHT_APACHE(thread, c, "$URL: https://svn.apache.org/path/name/thread.c $ $Id: thread.c 0 09/28/2005 dlydick $");
+
+
+
+#include <strings.h>
+
+#include "jvmcfg.h"
+#include "cfmacros.h"
+#include "classfile.h"
+#include "exit.h"
+#include "gc.h"
+#include "jvm.h"
+#include "jvmclass.h"
+#include "linkage.h"
+#include "method.h"
+#include "util.h"
+#include "utf.h"
+
+
+/*!
+ * @brief Initialize the thread area of the JVM model.
+ *
+ *
+ * @b Parameters: @link #rvoid rvoid@endlink
+ *
+ *
+ * @returns @link #rvoid rvoid@endlink
+ *
+ */
+rvoid thread_init()
+{
+ for (CURRENT_THREAD = jvm_thread_index_null;
+ CURRENT_THREAD < JVMCFG_MAX_THREADS;
+ CURRENT_THREAD++)
+ {
+ jvm_thread_index thridx = CURRENT_THREAD;
+
+ /********** Init thread state ******************/
+
+ THREAD(thridx).id = thridx;
+
+ THREAD(thridx).name = HEAP_GET_DATA(THREAD_NAME_MAX_LEN,rfalse);
+ sprintfLocal(THREAD(thridx).name, "thread %d", thridx);
+
+ THREAD(thridx).thread_objhash = jvm_object_hash_null;
+
+ THREAD(thridx).priority = THREAD_PRIORITY_MIN;
+
+ THREAD(thridx).status = THREAD_STATUS_EMPTY;
+
+ THREAD(thridx).prev_state = THREAD_STATE_DEAD;
+ THREAD(thridx).this_state = THREAD_STATE_DEAD;
+ THREAD(thridx).next_state = THREAD_STATE_DEAD;
+
+ THREAD(thridx).jointarget = jvm_thread_index_null;
+ THREAD(thridx).sleeptime = 0;
+ THREAD(thridx).locktarget = jvm_object_hash_null;
+
+
+ /********** Init thread's code facilities ******/
+
+ PUT_PC_IMMEDIATE(thridx,
+ jvm_class_index_null,
+ jvm_method_index_bad,
+ jvm_attribute_index_bad,
+ jvm_attribute_index_bad,
+ jvm_pc_offset_bad);
+
+ THREAD(thridx).pass_instruction_count = 0;
+ THREAD(thridx).thread_instruction_count = 0;
+
+ THREAD(thridx).stack = (jint *) rnull;
+ THREAD(thridx).sp = JVMCFG_NULL_SP;
+ THREAD(thridx).fp = JVMCFG_NULL_SP;
+ THREAD(thridx).fp_end_program = JVMCFG_NULL_SP;
+
+ } /* For CURRENT_THREAD */
+
+ /*! @todo What should the priority be on these threads? */
+ /*
+ * Forcibly allocate jvmcfg_thread_index_null thread,
+ * system thread, and GC thread. (These threads are
+ * @e never deallocated.)
+ */
+ THREAD(jvm_thread_index_null).priority = THREAD_PRIORITY_MAX;
+ THREAD(jvm_thread_index_null).status = THREAD_STATUS_INUSE |
+ THREAD_STATUS_NULL;
+ THREAD(jvm_thread_index_null).this_state = THREAD_STATE_NEW;
+ THREAD(jvm_thread_index_null).next_state = THREAD_STATE_NEW;
+
+ THREAD(JVMCFG_SYSTEM_THREAD).priority = THREAD_PRIORITY_MIN;
+ THREAD(JVMCFG_SYSTEM_THREAD).status = THREAD_STATUS_EMPTY;
+
+ THREAD(JVMCFG_GC_THREAD).priority = THREAD_PRIORITY_MAX;
+ THREAD(JVMCFG_GC_THREAD).status = THREAD_STATUS_INUSE;
+ THREAD(JVMCFG_GC_THREAD).this_state = THREAD_STATE_NEW;
+ THREAD(JVMCFG_GC_THREAD).next_state = THREAD_STATE_NEW;
+
+
+ /* Last thread allocated */
+ pjvm->thread_new_last = JVMCFG_GC_THREAD;
+
+ /* First thread to run */
+ CURRENT_THREAD = JVMCFG_SYSTEM_THREAD;
+
+ /* Declare this module initialized */
+ jvm_thread_initialized = rtrue;
+
+ return;
+
+} /* END of thread_init() */
+
+
+/*!
+ * @brief Look up table for names of thread states.
+ *
+ */
+const rchar *thread_state_names[THREAD_STATE_MAX_STATE + 1 + 1] =
+{
+ THREAD_STATE_NEW_DESC,
+ THREAD_STATE_START_DESC,
+ THREAD_STATE_RUNNABLE_DESC,
+ THREAD_STATE_RUNNING_DESC,
+ THREAD_STATE_COMPLETE_DESC,
+ THREAD_STATE_BLOCKINGEVENT_DESC,
+ THREAD_STATE_BLOCKED_DESC,
+ THREAD_STATE_UNBLOCKED_DESC,
+ THREAD_STATE_SYNCHRONIZED_DESC,
+ THREAD_STATE_RELEASE_DESC,
+ THREAD_STATE_WAIT_DESC,
+ THREAD_STATE_NOTIFY_DESC,
+ THREAD_STATE_LOCK_DESC,
+ THREAD_STATE_ACQUIRE_DESC,
+ THREAD_STATE_DEAD_DESC,
+ THREAD_STATE_BADLOGIC_DESC,
+
+ /* For out of bounds indices, both <0 and >max */
+ THREAD_STATE_ILLEGAL_DESC
+};
+
+/*!
+ * @brief Map state numbers to state names.
+ *
+ *
+ * @param state state number per @b THREAD_STATE_xxx definitions
+ *
+ * @returns string name of that state
+ *
+ */
+const rchar *thread_state_get_name(rushort state)
+{
+
+/* Unsigned type makes this unnecessary **
+ if (THREAD_STATE_MIN_STATE > state)
+ {
+ ** illegal state number **
+ return(thread_state_names[THREAD_STATE_MAX_STATE + 1]);
+ }
+*/
+
+ if (THREAD_STATE_MAX_STATE < state)
+ {
+ /* illegal state number */
+ return(thread_state_names[THREAD_STATE_MAX_STATE + 1]);
+ }
+
+ return(thread_state_names[state]);
+
+} /* END of thread_state_get_name() */
+
+
+/*!
+ * @brief Locate an unused thread table slot for a new thread.
+ *
+ *
+ * @b Parameters: @link #rvoid rvoid@endlink
+ *
+ *
+ * @returns Thread table index of an empty slot.
+ * Throw error if no slots.
+ *
+ *
+ * @throws JVMCLASS_JAVA_LANG_OUTOFMEMORYERROR
+ * @link #JVMCLASS_JAVA_LANG_OUTOFMEMORYERROR
+ * if no thread slots are available@endlink.
+ *
+ */
+static jvm_thread_index thread_allocate_slot(rvoid)
+{
+ jvm_thread_index thridx =
+ (JVMCFG_MAX_THREADS == (1 + pjvm->thread_new_last))
+ ? 1 + pjvm->thread_new_last
+ : JVMCFG_FIRST_THREAD;
+
+ /* Count allocated slots in case all slots are full */
+ jvm_thread_index count = 0;
+
+ while(rtrue)
+ {
+ if (THREAD(thridx).status & THREAD_STATUS_INUSE)
+ {
+ /* Point to next slot, wrap around at end */
+ thridx++;
+
+ if (thridx == JVMCFG_MAX_THREADS)
+ {
+ thridx = JVMCFG_FIRST_THREAD;
+ }
+
+ /* Limit high value to end of table */
+ if (pjvm->thread_new_last == JVMCFG_MAX_THREADS - 1)
+ {
+ pjvm->thread_new_last = JVMCFG_FIRST_THREAD;
+ }
+
+
+ /* Count this attempt and keep looking */
+ count++;
+
+ if (count == (JVMCFG_MAX_THREADS - JVMCFG_FIRST_THREAD))
+ {
+ /* No more slots, cannot continue */
+ exit_throw_exception(EXIT_JVM_THREAD,
+ JVMCLASS_JAVA_LANG_OUTOFMEMORYERROR);
+/*NOTREACHED*/
+ }
+
+ /* Keep looking */
+ continue;
+ }
+
+ /*
+ * Declare slot in use, but not initialized.
+ */
+ THREAD(thridx).status =
+ THREAD_STATUS_INUSE | THREAD_STATUS_NULL;
+
+
+ /* This slot is empty, report it for allocation */
+
+ pjvm->thread_new_last = thridx;
+
+ return(thridx);
+ }
+/*NOTREACHED*/
+ return(jvm_thread_index_null); /* Satisfy compiler */
+
+} /* END of thread_allocate_slot() */
+
+
+/*!
+ * @name Thread allocation and loading.
+ *
+ * @brief Allocate a new thread from the thread area and load a class
+ * to run on it.
+ *
+ * Activity on the system thread @link #JVMCFG_SYSTEM_THREAD
+ JVMCFG_SYSTEM_THREAD@endlink will @e not attempt to load a
+ * @c @b java.lang.Thread to represent a thread as an object.
+ * This is because the system thread is for internal use only outside
+ * the normal JVM runtime environment.
+ *
+ * As a variation, allocate the system thread
+ * (@link #JVMCFG_SYSTEM_THREAD JVMCFG_SYSTEM_THREAD@endlink)
+ * for an internal task. This method-- thread_new_common()-- is the
+ * common routine, where thread_new() is the general-purpose function
+ * and thread_new_system() is for loading a class onto the system
+ * thread.
+ *
+ * @warning Do @e not attempt to call this function
+ * with @b codeatridx set to @link #jvm_attribute_index_native
+ jvm_attribute_index_native@endlink because this code
+ * does not apply to native methods. Call that native
+ * method directly from the code instead!
+ *
+ * @param thridx Thread index of unused thread-- for
+ * thread_new_common() only-- the others
+ * generate this value and pass it in.
+ *
+ * @param clsidx Class index of code to run
+ *
+ * @param mthidx Method index of code to run
+ *
+ * @param codeatridx Method's attribute index of code to run
+ *
+ * @param excpatridx Method's attribute index of exception index tbl
+ *
+ * @param priority @link #THREAD_PRIORITY_NORM
+ THREAD_PRIORITY_xxx@endlink value for
+ * thread priority
+ *
+ * @param isdaemon Daemon thread, @link #rtrue rtrue@endlink or
+ * @link #rfalse rfalse@endlink
+ *
+ *
+ * @returns index to thread slot containing this thread.
+ *
+ *
+ * @throws JVMCLASS_JAVA_LANG_STACKOVERFLOWERROR
+ * @link #JVMCLASS_JAVA_LANG_STACKOVERFLOWERROR
+ * if loading the class on this thread would overfill
+ * the JVM stack for this thread.@endlink.
+ * for this thread.
+ *
+ * @throws JVMCLASS_JAVA_LANG_OUTOFMEMORYERROR
+ * @link #JVMCLASS_JAVA_LANG_OUTOFMEMORYERROR
+ * if no class slots or thread slots are available.@endlink.
+ *
+ *
+ */
+
+/*@{ */ /* Begin grouped definitions */
+
+/*!
+ * @brief Common function to load a class on a thread to be run.
+ *
+ * Given a thread index, load a method onto it to be run.
+ * <em>Do not</em> use this function to load a method onto
+ * a thread that has existing JVM execution active because
+ * the stack is initialized and the method entry point loaded
+ * into the PC. See @link #opcode_run() opcode_run()@endlink
+ * for examples of how to accomplish this in other ways.
+ *
+ */
+static jvm_thread_index thread_new_common(jvm_thread_index thridx,
+ jvm_class_index clsidx,
+ jvm_method_index mthidx,
+ jvm_attribute_index codeatridx,
+ jvm_attribute_index excpatridx,
+ rint priority,
+ rboolean isdaemon)
+{
+ /*
+ * Declare slot in use, but not initialized.
+ * (Redundant for most situations where
+ * thread_allocate_slot() was called, but needed
+ * for initializing classes like JVMCFG_NULL_THREAD
+ * or JVMCFG_SYSTEM_THREAD with an absolute slot
+ * number that was not searched for by the allocator.)
+ */
+ THREAD(thridx).status = THREAD_STATUS_INUSE | THREAD_STATUS_NULL;
+
+ /* Check for stack overflow if this frame is loaded */
+ ClassFile *pcfs = CLASS_OBJECT_LINKAGE(clsidx)->pcfs;
+ Code_attribute *pca = (Code_attribute *)
+ &pcfs->methods[mthidx]->attributes[codeatridx];
+
+ /* Check if this causes stack overflow, throw StackOverflowError */
+ if (JVMCFG_MAX_SP <= GET_SP(thridx) +
+ JVMREG_STACK_MIN_FRAME_HEIGHT +
+ JVMREG_STACK_PC_HEIGHT +
+ pca->max_stack +
+ pca->max_locals)
+ {
+ exit_throw_exception(EXIT_THREAD_STACK,
+ JVMCLASS_JAVA_LANG_STACKOVERFLOWERROR);
+/*NOTREACHED*/
+ }
+
+ /*!
+ * If no stack overflow would occur during execution,
+ * continue to load up a new thread. Unless this class
+ * will run on the system thread, start out by generating
+ * a new @c @b java.lang.Thread object to represent
+ * this thread in the object table.
+ *
+ * @todo Need to also implement java.lang.ThreadGroup as a
+ * preparatory step to instantiating java.lang.Thread
+ */
+ if (JVMCFG_SYSTEM_THREAD == thridx)
+ {
+ THREAD(thridx).thread_objhash = jvm_object_hash_null;
+ }
+ else
+ {
+ jvm_class_index clsidxTHR =
+ class_find_by_prchar(JVMCLASS_JAVA_LANG_THREAD);
+
+ if (jvm_class_index_null == clsidxTHR)
+ {
+ /* unreserve thread and quit */
+ THREAD(thridx).status = THREAD_STATUS_EMPTY;
+
+ /* No more slots, cannot continue */
+ exit_throw_exception(EXIT_JVM_THREAD,
+ JVMCLASS_JAVA_LANG_OUTOFMEMORYERROR);
+/*NOTREACHED*/
+ }
+
+ jvm_table_linkage *ptl = CLASS_OBJECT_LINKAGE(clsidxTHR);
+
+ jvm_object_hash objhashTHR =
+ object_instance_new(OBJECT_STATUS_EMPTY,
+ ptl->pcfs,
+ ptl->clsidx,
+ LOCAL_CONSTANT_NO_ARRAY_DIMS,
+ (jint *) rnull,
+ rtrue,
+ thridx);
+
+ THREAD(thridx).thread_objhash = objhashTHR;
+ (rvoid) GC_OBJECT_MKREF_FROM_OBJECT(jvm_object_hash_null,
+ THREAD(thridx).thread_objhash);
+ }
+
+ /*
+ * Only allocate stack to an allocated thread
+ * (not in thread_init()), and thereafter keep
+ * that allocation until thread_die().
+ */
+ if (rnull == THREAD(thridx).stack)
+ {
+ THREAD(thridx).stack =
+ (jint *) HEAP_GET_STACK(JVMCFG_STACK_SIZE, rfalse);
+ }
+
+ /*
+ * First two word of stack are reserved
+ */
+ PUT_SP_IMMEDIATE(thridx, JVMCFG_NULL_SP);
+
+ /*
+ * First 1 word meaningless in and of itself, but
+ * when setting up the frame pointer for the first frame,
+ * the fact that it is zero will mean that the inner
+ * @c @b while() loop will not exit until a
+ * @c @b return is done from the very last frame.
+ */
+ PUT_SP_WORD(thridx, GET_SP(thridx), CLASSFILE_MAGIC);
+
+ /*
+ * FINAL fp MUST be @e zero (null SP) so CHECK_FINAL_STACK_FRAME()
+ * works, if used.
+ */
+ PUT_FP_IMMEDIATE(thridx, GET_SP(thridx));
+
+ /* with jvm_class_index_null class index, other fields meaningless*/
+ PUT_PC_IMMEDIATE(thridx,
+ jvm_class_index_null,
+ jvm_method_index_bad,
+ jvm_attribute_index_bad,
+ jvm_attribute_index_bad,
+ jvm_pc_offset_bad);
+
+ /*
+ * Reserve first full stack frame, 1st amount of locals,
+ * null FP, null PC.
+ *
+ * @note jvmutil_print_stack_common() requires FP to hold a
+ * value of @link #JVMCFG_NULL_SP JVMCFG_NULL_SP@endlink
+ * as its terminating condition. So also should @e any
+ * logic that scans the stack. See in particular the
+ * @link #FIRST_STACK_FRAME() FIRST_STACK_FRAME()@endlink and
+ * @link #NEXT_STACK_FRAME() NEXT_STACK_FRAME()@endlink and
+ * @link #CHECK_FINAL_STACK_FRAME
+ CHECK_FINAL_STACK_FRAME()@endlink macros.
+ */
+ PUSH_FRAME(thridx, pca->max_locals);
+
+ /*
+ * Stack frame now can accept operand stacking, including
+ * requests for PUSH_FRAME(), which is used when calling
+ * a JVM method or other subroutine.
+ *
+ * Upon final POP_FRAME(), the FP and PC will both be
+ * empty, @link #JVMCFG_NULL_SP JVMCFG_NULL_SP@endlink and
+ * @link #jvm_class_index_null jvm_class_index_null@endlink,
+ * respectively. At this point, the JVM thread
+ * should stop running since there is nothing else
+ * to do.
+ *
+ * Allocation complete, set priority and ISDAEMON status (as
+ * requrested), and move next thread state to @b NEW, then
+ * report to caller.
+ */
+ THREAD(thridx).priority = priority;
+ threadstate_request_new(thridx);
+ threadstate_activate_new(thridx);
+
+ /*!
+ * @todo Any time the isdaemon field is modified, MAKE SURE
+ * that the value in the @c @b java.lang.Thread
+ * instance variable is set to the same value. This
+ * should @e never be an issue except when instantiating
+ * a new @c @b java.lang.Thread object since the
+ * API docs say that it can only be set @e once.
+ */
+ if (rtrue == isdaemon)
+ {
+ THREAD(thridx).status |= THREAD_STATUS_ISDAEMON;
+ }
+
+ /* Thread slot completely initialized */
+ THREAD(thridx).status &= ~THREAD_STATUS_NULL;
+
+ /* Load JVM program counter for first instruction */
+ PUT_PC_IMMEDIATE(thridx,
+ clsidx,
+ mthidx,
+ codeatridx,
+ excpatridx,
+ CODE_CONSTRAINT_START_PC);
+
+ return(thridx);
+
+} /* END of thread_new_common() */
+
+
+/*!
+ * @brief Reserve the system thread and load a class to run on it.
+ *
+ * Reserve the system thread specifically-- see description
+ * above for thread_new_common()
+ *
+ */
+static jvm_thread_index thread_new_system(jvm_class_index clsidx,
+ jvm_method_index mthidx,
+ jvm_attribute_index codeatridx,
+ jvm_attribute_index excpatridx,
+ rint priority,
+ rboolean isdaemon)
+{
+ /* Check if system thread is already in use */
+ if (THREAD(JVMCFG_SYSTEM_THREAD).status & THREAD_STATUS_INUSE)
+ {
+ /* Somebody goofed */
+ exit_throw_exception(EXIT_JVM_INTERNAL,
+ JVMCLASS_JAVA_LANG_INTERNALERROR);
+/*NOTREACHED*/
+ }
+
+ /* If not already in use, reserve it and perform thread setup */
+ return(thread_new_common(JVMCFG_SYSTEM_THREAD,
+ clsidx,
+ mthidx,
+ codeatridx,
+ excpatridx,
+ priority,
+ isdaemon));
+
+} /* END of thread_new_system() */
+
+
+/*!
+ * @brief Allocate a new thread from the thread area and
+ * load a class to run on it.
+ *
+ * General-purpuse version-- see description above for
+ * thread_new_common()
+ *
+ */
+static jvm_thread_index thread_new(jvm_class_index clsidx,
+ jvm_method_index mthidx,
+ jvm_attribute_index codeatridx,
+ jvm_attribute_index excpatridx,
+ rint priority,
+ rboolean isdaemon)
+{
+ jvm_thread_index thridx = thread_allocate_slot();
+
+ /* Set up thread resources and finish */
+ return(thread_new_common(thridx,
+ clsidx,
+ mthidx,
+ codeatridx,
+ excpatridx,
+ priority,
+ isdaemon));
+
+} /* END of thread_new() */
+
+/*@} */ /* End of grouped definitions */
+
+
+
+/*!
+ * @brief Load a class onto a thread during JVM initialization.
+ *
+ * Allocate a new thread and load a class (array or non-array),
+ * prepare to invoke @c @b static methods, and prepare
+ * to start thread.
+ *
+ * Classes loaded through this function will not be marked as
+ * referenced, but will also not be marked for garbage collection,
+ * either.
+ *
+ *
+ * @param clsname Name of class to load.
+ *
+ * @param mthname Name of method in class.
+ *
+ * @param mthdesc Description of method parameters and
+ * return type.
+ *
+ * @param priority THREAD_PRIORITY_xxx value for thread
+ * priority.
+ *
+ * @param isdaemon Daemon thread, @link #rtrue rtrue@endlink
+ * or @link #rfalse rfalse@endlink
+ *
+ * @param usesystemthread Allocate the system thread with
+ * thread_new_system() instead of
+ * a user thread via thread_new_system(),
+ * @link #rtrue rtrue@endlink
+ * or @link #rfalse rfalse@endlink.
+ *
+ * @param find_registerNatives When @link #rtrue rtrue@endlink,
+ * will return the ordinal for
+ * @link #JVMCFG_JLOBJECT_NMO_REGISTER
+ JVMCFG_JLOBJECT_NMO_REGISTER@endlink and
+ * @link #JVMCFG_JLOBJECT_NMO_UNREGISTER
+ JVMCFG_JLOBJECT_NMO_UNREGISTER@endlink
+ * as well as the other ordinals. Once JVM
+ * initialization is complete, this should
+ * always be @link #rfalse rfalse@endlink
+ * because all future classes should @e never
+ * have local ordinals.
+ *
+ *
+ * @returns Thread index of NEW thread, ready to move to START state,
+ * or throw error if no slots.
+ *
+ *
+ * @throws JVMCLASS_JAVA_LANG_OUTOFMEMORYERROR
+ * @link #JVMCLASS_JAVA_LANG_OUTOFMEMORYERROR
+ * if no class slots or thread slots are available.@endlink.
+ *
+ * @throws JVMCLASS_JAVA_LANG_CLASSNOTFOUNDEXCEPTION
+ * @link #JVMCLASS_JAVA_LANG_CLASSNOTFOUNDEXCEPTION
+ * if class cannot be located.@endlink.
+ *
+ * @throws JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR
+ * @link #JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR
+ * if the requested method is not found in the class
+ * or has no code area.@endlink.
+ *
+ * @throws JVMCLASS_JAVA_LANG_STACKOVERFLOWERROR
+ * @link #JVMCLASS_JAVA_LANG_STACKOVERFLOWERROR
+ * if loading the class on this thread would overfill
+ * the JVM stack for this thread.@endlink.
+ *
+ */
+jvm_thread_index thread_class_load(rchar *clsname,
+ rchar *mthname,
+ rchar *mthdesc,
+ rint priority,
+ rboolean isdaemon,
+ rboolean usesystemthread,
+ rboolean find_registerNatives)
+{
+ /*
+ * Attempt to load requested class. Notice that
+ * an object is @e not being instantiated here,
+ * so the @b arraylength parm (parm 3) can be
+ * @link #rnull rnull@endlink.
+ */
+ jvm_class_index clsidx = class_load_from_prchar(clsname,
+ find_registerNatives,
+ (jint *) rnull);
+
+ /* Point to @e this class structure, then get immediate superclass*/
+ ClassFile *pcfs = CLASS_OBJECT_LINKAGE(clsidx)->pcfs;
+ ClassFile *pcfs_recurse = pcfs;
+
+ /*
+ * Make special exception for @c @b java.lang.Object,
+ * no superclass
+ */
+ if (CONSTANT_CP_DEFAULT_INDEX == pcfs_recurse->super_class)
+ {
+ pcfs_recurse = (ClassFile *) rnull;
+ }
+ else
+ {
+ pcfs_recurse =
+ CLASS_OBJECT_LINKAGE(
+ class_find_by_prchar(
+ PTR_CP1_CLASS_NAME_STRNAME(pcfs_recurse,
+ pcfs_recurse->super_class)))
+ ->pcfs;
+ }
+
+ /* Iterate through class table looking for superclasses */
+ while(rnull != pcfs_recurse)
+ {
+ /* case (1), check if class is actually an interface */
+ if (ACC_INTERFACE & pcfs_recurse->access_flags)
+ {
+ exit_throw_exception(EXIT_JVM_CLASS,
+ JVMCLASS_JAVA_LANG_INCOMPATIBLECLASSCHANGEERROR);
+/*NOTREACHED*/
+ }
+
+ /*
+ * Take care of special case where
+ * @link robject#super_class super_class@link is zero, namely
+ * represents @c @b java.lang.Object, the only class
+ * without a direct superclass. This condition @e must be
+ * the end of the scan. If this condition is never met,
+ * the possibility of a class circularity error is probably
+ * almost 100%.
+ */
+ if (CONSTANT_CP_DEFAULT_INDEX == pcfs_recurse->super_class)
+ {
+ break;
+ }
+
+ /* case (2), check if class eventually references itself */
+ if (0 == utf_prchar_classname_strcmp(
+ clsname,
+ pcfs_recurse,
+ pcfs_recurse->super_class))
+ {
+ /*
+ * Don't permit recursive call to error handler
+ * (this one should @e never happen)
+ */
+ if (0 == strcmp(clsname,
+ JVMCLASS_JAVA_LANG_CLASSCIRCULARITYERROR))
+ {
+ exit_throw_exception(EXIT_JVM_CLASS,
+ JVMCLASS_JAVA_LANG_CLASSCIRCULARITYERROR);
+/*NOTREACHED*/
+ }
+ }
+
+ /* Go get next higher superclass and scan again */
+ pcfs_recurse =
+ CLASS_OBJECT_LINKAGE(
+ class_find_by_prchar(
+ PTR_CP1_CLASS_NAME_STRNAME(pcfs_recurse,
+ pcfs_recurse->super_class)))
+ ->pcfs;
+
+ } /* while pcfs_recurse */
+
+ /*
+ * Locate starting PC in this class for this method with
+ * this descriptor by scanning method[] table.
+ * Since this function is @e never called from the JVM runtime,
+ * the use of (rchar *) strings for mthname and mthdesc is
+ * acceptable. Normal usage would call method_find() directly
+ * using pointers to UTF8 constant_pool entries.
+ */
+
+ jvm_method_index mthidx = method_find_by_prchar(clsidx,
+ mthname,
+ mthdesc);
+
+ /* Failed to locate method name, throw ClassNotFoundException */
+ if (jvm_method_index_bad == mthidx)
+ {
+ exit_throw_exception(EXIT_JVM_CLASS,
+ JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR);
+/* NOTREACHED*/
+ }
+
+ /* Since method name and description match, go run thread */
+ jvm_attribute_index codeatridx =
+ pcfs->methods[mthidx]->LOCAL_method_binding.codeatridxJVM;
+
+ /* Load exception index table also, if present */
+ jvm_attribute_index excpatridx =
+ pcfs->methods[mthidx]->LOCAL_method_binding.excpatridxJVM;
+
+ /* Load native method ordinal number, if applicable */
+ /* jvm_native_method_ordinal nmord =
+ pcfs->methods[mthidx]->LOCAL_method_binding.nmordJVM; */
+
+ /* Typically will not happen-- if have valid method,also have code*/
+ if (jvm_attribute_index_bad == codeatridx)
+ {
+ exit_throw_exception(EXIT_JVM_ATTRIBUTE,
+ JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR);
+/* NOTREACHED*/
+ }
+
+ /* Do not permit this operation for a native method request */
+ if (jvm_attribute_index_native == codeatridx)
+ {
+ exit_throw_exception(EXIT_JVM_INTERNAL,
+ JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR);
+/*NOTREACHED*/
+ }
+
+ /*
+ * Everything was found. Now allocate thread to run this
+ * static method of this class.
+ */
+ if (rtrue == usesystemthread)
+ {
+ return(thread_new_system(clsidx,
+ mthidx,
+ codeatridx,
+ excpatridx,
+ priority,
+ isdaemon));
+ }
+ else
+ {
+ return(thread_new(clsidx,
+ mthidx,
+ codeatridx,
+ excpatridx,
+ priority,
+ isdaemon));
+ }
+
+} /* END of thread_class_load() */
+
+
+/*!
+ * @brief Terminate and deallocate a thread that is currently in
+ * the @b DEAD state.
+ *
+ *
+ * @param thridx thread index of thread to be deallocated.
+ *
+ * @returns @link #rtrue rtrue@endlink if successful,
+ * else @link #rfalse rfalse@endlink.
+ *
+ */
+
+rboolean thread_die(jvm_thread_index thridx)
+{
+ if (THREAD_STATE_DEAD == THREAD(thridx).this_state)
+ {
+ /*!
+ * Mark ONLY fields requiring it, leave rest alone for
+ * post-mortem use by developer.
+ *
+ * @todo Could leave stack in place for post-mortem if
+ * it is assumed that there would be a reasonable
+ * amount of contents still valid in memory.
+ */
+ HEAP_FREE_STACK(THREAD(thridx).stack);
+ THREAD(thridx).stack = (jint *) rnull;
+
+ THREAD(thridx).status &= ~THREAD_STATUS_INUSE;
+
+ return(rtrue);
+ }
+
+ return(rfalse);
+
+} /* END of thread_die() */
+
+
+/*!
+ * @brief Shut down the thread area of the JVM model
+ * at the end of JVM execution.
+ *
+ *
+ * @b Parameters: @link #rvoid rvoid@endlink
+ *
+ *
+ * @returns @link #rvoid rvoid@endlink
+ *
+ */
+rvoid thread_shutdown()
+{
+ jvm_thread_index thridx;
+
+ for (thridx = jvm_thread_index_null;
+ thridx < JVMCFG_MAX_THREADS;
+ thridx++)
+ {
+ if (THREAD_STATUS_INUSE & THREAD(thridx).status)
+ {
+ /*
+ * check stack frames only if stack area present
+ */
+ if (rnull != THREAD(thridx).stack)
+ {
+ /* Locate first (top) stack frame's FP */
+ jvm_sp fp = FIRST_STACK_FRAME(thridx);
+
+ /*
+ * First frame is @e greater than 0, and @e contains
+ * the NULL frame pointer.
+ */
+ if (JVMCFG_NULL_SP == fp)
+ {
+ continue;
+ }
+
+ /*
+ * Pop all stack frames, free local storage,
+ * clear object references, etc. (via POP_FRAME() macro)
+ */
+ while(!CHECK_FINAL_STACK_FRAME_GENERIC(thridx, fp))
+ {
+ /*
+ * Get next FP @e before popping that storage
+ * location off of the stack!
+ */
+ fp = NEXT_STACK_FRAME_GENERIC(thridx, fp);
+
+ POP_FRAME(thridx);
+ }
+
+ /*
+ * The current implementation does some of these steps
+ * internally, but be thorough so it does not break when
+ * the implementation changes.
+ */
+ threadstate_request_badlogic(thridx);
+ threadstate_activate_badlogic(thridx);
+ threadstate_process_badlogic(thridx);
+ threadstate_request_complete(thridx);
+ threadstate_activate_complete(thridx);
+ threadstate_process_complete(thridx);
+ threadstate_request_dead(thridx);
+ threadstate_activate_dead(thridx);
+ threadstate_process_dead(thridx);
+ }
+ }
+
+ /*
+ * Keep thread name around usually
+ * (not wiped out in thread_die() function)
+ */
+ if (rnull != THREAD(thridx).name)
+ {
+ HEAP_FREE_STACK(THREAD(thridx).name);
+ /* THREAD(thridx).name = (rchar *) rnull; */
+ }
+ }
+
+ /* This may result in a @e large garbage collection */
+ GC_RUN(rfalse);
+
+ /* Declare this module uninitialized */
+ jvm_thread_initialized = rfalse;
+
+ return;
+
+} /* END of thread_shutdown() */
+
+
+/*!
+ * @brief Set up JVM thread-relative exception handler-- implements
+ * @c @b setjmp(3)/longjmp(3).
+ *
+ *
+ * @param thridx Thread table index of thread for which to set up
+ * this exception handler.
+ *
+ *
+ * @returns From normal setup, integer @link
+ #THREAD_STATUS_EMPTY THREAD_STATUS_EMPTY@endlink.
+ * Otherwise, return error code passed in to
+ * @link #thread_throw_exception()
+ thread_throw_exception()@endlink as shown below.
+ *
+ *
+ * @internal
+ * @c @b setjmp(3) and @c @b struct[idx].member do _not_ get
+ * along at all:
+ *
+ * @verbatim
+
+ int nonlocal_rc =
+ setjmp(*THREAD(thridx).nonlocal_ThrowableEvent);
+
+ @endverbatim
+ *
+ * To get this working, the @link rthread#pnonlocal_ThrowableEvent
+ * nonlocal_ThrowableEvent@endlink had to be changed to a pointer
+ * and a buffer allocated from heap. This probably is due to the
+ * @c @b typedef syntax of @c @b jmp_buf and a
+ * long array, which pointers like. However, instead of playing
+ * games with addressing &element[0], a pointer works better because
+ * not all @c @b jmp_buf implementations wil be a long array.
+ *
+ */
+
+int thread_exception_setup(jvm_thread_index thridx)
+{
+ THREAD(thridx).pnonlocal_ThrowableEvent =
+ HEAP_GET_DATA(sizeof(jmp_buf), rfalse);
+
+ return(setjmp(*THREAD(thridx).pnonlocal_ThrowableEvent));
+
+} /* END of thread_exception_setup() */
+
+
+/*!
+ * @brief Global handler setup for JVM thread errors and
+ * exceptions-- implements @c @b setjmp(3).
+ *
+ *
+ * @param thridx Thread index of thread where exception occurred.
+ *
+ * @param thread_status_bits Type of exception being generated,
+ * typically using one of the following exit codes from
+ * the status bits in
+ * @link jvm/src/thread.h thread.h@endlink
+ * per the definition there of each code:
+ *
+ * <ul><li> @link #THREAD_STATUS_THREW_EXCEPTION
+ THREAD_STATUS_THREW_EXCEPTION@endlink
+ * </li>
+ * <li> @link #THREAD_STATUS_THREW_ERROR
+ THREAD_STATUS_THREW_ERROR@endlink
+ * </li>
+ * <li> @link #THREAD_STATUS_THREW_THROWABLE
+ THREAD_STATUS_THREW_THROWABLE@endlink
+ * </li>
+ * <li> @link #THREAD_STATUS_THREW_UNCAUGHT
+ THREAD_STATUS_THREW_UNCAUGHT@endlink
+ * </li></ul>
+ *
+ * @param exception_name Null-terminated string name of error or
+ * exception class to be invoked as a result
+ * of this situation.
+ *
+ *
+ * @returns non-local state restoration from setup via @c @b setjmp(3)
+ * as stored in @link
+ #exit_LinkageError exit_LinkageError@endlink
+ * buffer by @link #exit_init() exit_init()@endlink
+ * in @link #jvm_init() jvm_init()@endlink before any of
+ * these errors could occur. All code invoking this
+ * function should use the standard @c @b lint(1) comment for
+ * "code not reached" as shown after the @c @b longjmp(3)
+ * function call in the source code of this function:
+ * <b>/</b><b>*NOTREACHED*</b><b>/</b>
+ *
+ */
+rvoid thread_throw_exception(jvm_thread_index thridx,
+ rushort thread_status_bits,
+ rchar *exception_name)
+{
+ /* Disallow invalid status from being reported */
+ switch (thread_status_bits)
+ {
+ case THREAD_STATUS_THREW_EXCEPTION:
+ case THREAD_STATUS_THREW_ERROR:
+ case THREAD_STATUS_THREW_THROWABLE:
+ case THREAD_STATUS_THREW_UNCAUGHT:
+ break;
+ default:
+ exit_throw_exception(EXIT_JVM_INTERNAL,
+ JVMCLASS_JAVA_LANG_INTERNALERROR);
+/*NOTREACHED*/
+ }
+
+ THREAD(thridx).status |= thread_status_bits;
+
+ THREAD(thridx).pThrowableEvent = exception_name;
+
+
+ int rc = (int) thread_status_bits;
+
+ longjmp(*THREAD(thridx).pnonlocal_ThrowableEvent, rc);
+/*NOTREACHED*/
+
+} /* END of thread_throw_exception() */
+
+
+/* EOF */