/ src / include / bytecode.h
bytecode.h
  1  /*
  2   *  Bean Java VM
  3   *  Copyright (C) 2005-2015 Christian Lins <christian@lins.me>
  4   *
  5   *  Licensed under the Apache License, Version 2.0 (the "License");
  6   *  you may not use this file except in compliance with the License.
  7   *  You may obtain a copy of the License at
  8   *
  9   *     http://www.apache.org/licenses/LICENSE-2.0
 10   *
 11   *  Unless required by applicable law or agreed to in writing, software
 12   *  distributed under the License is distributed on an "AS IS" BASIS,
 13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14   *  See the License for the specific language governing permissions and
 15   *  limitations under the License.
 16   */
 17  
 18  #ifndef _BYTECODE_H_
 19  #define _BYTECODE_H_
 20  
 21  #include <thread.h>
 22  
 23  #define IL_NOP          0x00
 24  #define IL_ACONST_NULL  0x01
 25  #define IL_ICONST_M1    0x02
 26  #define IL_ICONST_0     0x03
 27  #define IL_ICONST_1     0x04
 28  #define IL_ICONST_2     0x05
 29  #define IL_ICONST_3     0x06
 30  #define IL_ICONST_4     0x07
 31  #define IL_ICONST_5     0x08
 32  #define IL_LCONST_0     0x09
 33  #define IL_LCONST_1     0x0A
 34  #define IL_FCONST_0     0x0B
 35  #define IL_FCONST_1     0x0C
 36  #define IL_FCONST_2     0x0D
 37  #define IL_DCONST_0     0x0E
 38  #define IL_DCONST_1     0x0F
 39  #define IL_BIPUSH       0x10
 40  #define IL_SIPUSH       0x11
 41  #define IL_LDC          0x12
 42  #define IL_LDC_W        0x13
 43  #define IL_LDC2_W       0x14
 44  #define IL_ILOAD        0x15
 45  #define IL_LLOAD        0x16
 46  #define IL_FLOAD        0x17
 47  #define IL_DLOAD        0x18
 48  #define IL_ALOAD        0x19
 49  #define IL_ILOAD_0      0x1A
 50  #define IL_ILOAD_1      0x1B
 51  #define IL_ILOAD_2      0x1C
 52  #define IL_ILOAD_3      0x1D
 53  #define IL_LLOAD_0      0x1E
 54  #define IL_LLOAD_1      0x1F
 55  #define IL_LLOAD_2      0x20
 56  #define IL_LLOAD_3      0x21
 57  #define IL_FLOAD_0      0x22
 58  #define IL_FLOAD_1      0x23
 59  #define IL_FLOAD_2      0x24
 60  #define IL_FLOAD_3      0x25
 61  #define IL_DLOAD_0      0x26
 62  #define IL_DLOAD_1      0x27
 63  #define IL_DLOAD_2      0x28
 64  #define IL_DLOAD_3      0x29
 65  #define IL_ALOAD_0      0x2A
 66  #define IL_ALOAD_1      0x2B
 67  #define IL_ALOAD_2      0x2C
 68  #define IL_ALOAD_3      0x2D
 69  #define IL_IALOAD       0x2E
 70  #define IL_LALOAD       0x2F
 71  #define IL_FALOAD       0x30
 72  #define IL_DALOAD       0x31
 73  #define IL_AALOAD       0x32
 74  #define IL_BALOAD       0x33
 75  #define IL_CALOAD       0x34
 76  #define IL_SALOAD       0x35
 77  #define IL_ISTORE       0x36
 78  #define IL_LSTORE       0x37
 79  #define IL_FSTORE       0x38
 80  #define IL_DSTORE       0x39
 81  #define IL_ASTORE       0x3A
 82  #define IL_ISTORE_0     0x3B
 83  #define IL_ISTORE_1     0x3C
 84  #define IL_ISTORE_2     0x3D
 85  #define IL_ISTORE_3     0x3E
 86  #define IL_LSTORE_0     0x3F
 87  #define IL_LSTORE_1     0x40
 88  #define IL_LSTORE_2     0x41
 89  #define IL_LSTORE_3     0x42
 90  #define IL_FSTORE_0     0x43
 91  #define IL_FSTORE_1     0x44
 92  #define IL_FSTORE_2     0x45
 93  #define IL_FSTORE_3     0x46
 94  #define IL_DSTORE_0     0x47
 95  #define IL_DSTORE_1     0x48
 96  #define IL_DSTORE_2     0x49
 97  #define IL_DSTORE_3     0x4A
 98  #define IL_ASTORE_0     0x4B
 99  #define IL_ASTORE_1     0x4C
100  #define IL_ASTORE_2     0x4D
101  #define IL_ASTORE_3     0x4E
102  #define IL_IASTORE      0x4F
103  #define IL_LASTORE      0x50
104  #define IL_FASTORE      0x51
105  #define IL_DASTORE      0x52
106  #define IL_AASTORE      0x53
107  #define IL_BASTORE      0x54
108  #define IL_CASTORE      0x55
109  #define IL_SASTORE      0x56
110  #define IL_POP          0x57
111  #define IL_POP2         0x58
112  #define IL_DUP          0x59
113  #define IL_DUP_X1       0x5A
114  #define IL_DUP_X2       0x5B
115  #define IL_DUP2         0x5C
116  #define IL_DUP2_X1      0x5D
117  #define IL_DUP2_X2      0x5E
118  #define IL_SWAP         0x5F
119  #define IL_IADD         0x60
120  #define IL_LADD         0x61
121  #define IL_FADD         0x62
122  #define IL_DADD         0x63
123  #define IL_ISUB         0x64
124  #define IL_LSUB         0x65
125  #define IL_FSUB         0x66
126  #define IL_DSUB         0x67
127  #define IL_IMUL         0x68
128  #define IL_LMUL         0x69
129  #define IL_FMUL         0x6A
130  #define IL_DMUL         0x6B
131  #define IL_IDIV         0x6C
132  #define IL_LDIV         0x6D
133  #define IL_FDIV         0x6E
134  #define IL_DDIV         0x6F
135  #define IL_IREM         0x70
136  #define IL_LREM         0x71
137  #define IL_FREM         0x72
138  #define IL_DREM         0x73
139  #define IL_INEG         0x74
140  #define IL_LNEG         0x75
141  #define IL_FNEG         0x76
142  #define IL_DNEG         0x77
143  #define IL_ISHL         0x78
144  #define IL_LSHL         0x79
145  #define IL_ISHR         0x7A
146  #define IL_LSHR         0x7B
147  #define IL_IUSHR        0x7C
148  #define IL_LUSHR        0x7D
149  #define IL_IAND         0x7E
150  #define IL_LAND         0x7F
151  #define IL_IOR          0x80
152  #define IL_LOR          0x81
153  #define IL_IXOR         0x82
154  #define IL_LXOR         0x83
155  #define IL_IINC         0x84
156  #define IL_I2L          0x85
157  #define IL_I2F          0x86
158  #define IL_I2D          0x87
159  #define IL_L2I          0x88
160  #define IL_L2F          0x89
161  #define IL_L2D          0x8A
162  #define IL_F2I          0x8B
163  #define IL_F2L          0x8C
164  #define IL_F2D          0x8D
165  #define IL_D2I          0x8E
166  #define IL_D2L          0x8F
167  #define IL_D2F          0x90
168  #define IL_I2B          0x91
169  #define IL_I2C          0x92
170  #define IL_I2S          0x93
171  #define IL_LCMP         0x94
172  #define IL_FCMPL        0x95
173  #define IL_FCMPG        0x96
174  #define IL_DCMPL        0x97
175  #define IL_DCMPG        0x98
176  #define IL_IFEQ         0x99
177  #define IL_IFNE         0x9A
178  #define IL_IFLT         0x9B
179  #define IL_IFGE         0x9C
180  #define IL_IFGT         0x9D
181  #define IL_IFLE         0x9E
182  #define IL_IF_ICMPEQ    0x9F
183  #define IL_IF_ICMPNE    0xA0
184  #define IL_IF_ICMPLT    0xA1
185  #define IL_IF_ICMPGE    0xA2
186  #define IL_IF_ICMPGT    0xA3
187  #define IL_IF_ICMPLE    0xA4
188  #define IL_IF_ACMPEQ    0xA5
189  #define IL_IF_ACMPNE    0xA6
190  #define IL_GOTO         0xA7
191  #define IL_JSR          0xA8
192  #define IL_RET          0xA9
193  #define IL_TABLESWITCH  0xAA
194  #define IL_LOOKUPSWITCH 0xAB
195  #define IL_IRETURN      0xAC
196  #define IL_LRETURN      0xAD
197  #define IL_FRETURN      0xAE
198  #define IL_DRETURN      0xAF
199  #define IL_ARETURN      0xB0
200  #define IL_RETURN       0xB1
201  #define IL_GETSTATIC    0xB2
202  #define IL_PUTSTATIC    0xB3
203  #define IL_GETFIELD     0xB4
204  #define IL_PUTFIELD     0xB5
205  #define IL_INVOKEVIRTUAL 0xB6
206  #define IL_INVOKESPECIAL 0xB7
207  #define IL_INVOKESTATIC 0xB8
208  #define IL_INVOKEINTERFACE 0xB9
209  #define IL_RESERVED1    0xBA
210  #define IL_NEW          0xBB
211  #define IL_NEWARRAY     0xBC
212  #define IL_ANEWARRAY    0xBD
213  #define IL_ARRAYLENGTH  0xBE
214  #define IL_ATHROW       0xBF
215  #define IL_CHECKCAST    0xC0
216  #define IL_INSTANCEOF   0xC1
217  #define IL_MONITORENTER 0xC2
218  #define IL_MONITOREXIT  0xC3
219  #define IL_WIDE         0xC4
220  #define IL_MULTIANEWARRAY 0xC5
221  #define IL_IFNULL       0xC6
222  #define IL_IFNONNULL    0xC7
223  #define IL_GOTO_W       0xC8
224  #define IL_JSR_W        0xC9
225  
226  /* Reserved opcodes: */
227  #define IL_BREAKPOINT   0xCA
228  #define IL_IMPDEP1      0xFE
229  #define IL_IMPDEP2      0xFF
230  
231  
232  /* Methods */
233  void do_NOP(Thread* thread);
234  void do_ACONST_NULL(Thread* thread);
235  void do_ICONSTi(Thread* thread, int32_t constant);
236  void do_LCONSTi(Thread* thread, int64_t);
237  void do_FCONSTi(Thread* thread, float);
238  void do_DCONSTi(Thread* thread, double);
239  void do_BIPUSH(Thread* thread);
240  void do_SIPUSH(Thread* thread);
241  void do_LDC(Thread* thread);
242  void do_LDC_W(Thread* thread);
243  void do_LDC2_W(Thread* thread);
244  void do_ILOAD(Thread* thread);
245  void do_ILOADi(Thread* thread, int32_t);
246  void do_LLOAD(Thread* thread);
247  void do_LLOADi(Thread* thread, int32_t);
248  void do_FLOAD(Thread* thread);
249  void do_FLOADi(Thread* thread, int32_t);
250  void do_DLOAD(Thread* thread);
251  void do_DLOADi(Thread* thread, int32_t);
252  void do_ALOAD(Thread* thread);
253  void do_ALOADi(Thread* thread, int16_t);
254  void do_IALOAD(Thread* thread);
255  void do_LALOAD(Thread* thread);
256  void do_FALOAD(Thread* thread);
257  void do_DALOAD(Thread* thread);
258  void do_AALOAD(Thread* thread);
259  void do_BALOAD(Thread* thread);
260  void do_CALOAD(Thread* thread);
261  void do_SALOAD(Thread* thread);
262  void do_ISTORE(Thread* thread);
263  void do_LSTORE(Thread* thread);
264  void do_FSTORE(Thread* thread);
265  void do_DSTORE(Thread* thread);
266  void do_ASTORE(Thread* thread);
267  void do_ISTOREi(Thread* thread, int16_t);
268  void do_LSTOREi(Thread* thread, int16_t);
269  void do_FSTOREi(Thread* thread, int16_t);
270  void do_DSTOREi(Thread* thread, int16_t);
271  void do_ASTOREi(Thread* thread, int16_t);
272  void do_IASTORE(Thread* thread);
273  void do_LASTORE(Thread* thread);
274  void do_FASTORE(Thread* thread);
275  void do_DASTORE(Thread* thread);
276  void do_AASTORE(Thread* thread);
277  void do_BASTORE(Thread* thread);
278  void do_CASTORE(Thread* thread);
279  void do_SASTORE(Thread* thread);
280  void do_POP(Thread* thread);
281  void do_POP2(Thread* thread);
282  void do_DUP(Thread* thread);
283  void do_DUP_X1(Thread* thread);
284  void do_DUP_X2(Thread* thread);
285  void do_DUP2(Thread* thread);
286  void do_DUP2_X1(Thread* thread);
287  void do_DUP2_X2(Thread* thread);
288  void do_SWAP(Thread* thread);
289  void do_IADD(Thread* thread);
290  void do_LADD(Thread* thread);
291  void do_FADD(Thread* thread);
292  void do_DADD(Thread* thread);
293  void do_ISUB(Thread* thread);
294  void do_LSUB(Thread* thread);
295  void do_FSUB(Thread* thread);
296  void do_DSUB(Thread* thread);
297  void do_IMUL(Thread* thread);
298  void do_LMUL(Thread* thread);
299  void do_FMUL(Thread* thread);
300  void do_DMUL(Thread* thread);
301  void do_IDIV(Thread* thread);
302  void do_LDIV(Thread* thread);
303  void do_FDIV(Thread* thread);
304  void do_DDIV(Thread* thread);
305  void do_IREM(Thread* thread);
306  void do_LREM(Thread* thread);
307  void do_FREM(Thread* thread);
308  void do_DREM(Thread* thread);
309  void do_INEG(Thread* thread);
310  void do_LNEG(Thread* thread);
311  void do_FNEG(Thread* thread);
312  void do_DNEG(Thread* thread);
313  void do_ISHL(Thread* thread);
314  void do_LSHL(Thread* thread);
315  void do_ISHR(Thread* thread);
316  void do_LSHR(Thread* thread);
317  void do_IUSHR(Thread* thread);
318  void do_LUSHR(Thread* thread);
319  void do_IAND(Thread* thread);
320  void do_LAND(Thread* thread);
321  void do_IOR(Thread* thread);
322  void do_LOR(Thread* thread);
323  void do_IXOR(Thread* thread);
324  void do_LXOR(Thread* thread);
325  void do_IINC(Thread* thread);
326  void do_I2L(Thread* thread);
327  void do_I2F(Thread* thread);
328  void do_I2D(Thread* thread);
329  void do_L2I(Thread* thread);
330  void do_L2F(Thread* thread);
331  void do_L2D(Thread* thread);
332  void do_F2I(Thread* thread);
333  void do_F2L(Thread* thread);
334  void do_F2D(Thread* thread);
335  void do_D2I(Thread* thread);
336  void do_D2L(Thread* thread);
337  void do_D2F(Thread* thread);
338  void do_I2B(Thread* thread);
339  void do_I2C(Thread* thread);
340  void do_I2S(Thread* thread);
341  void do_LCMP(Thread* thread);
342  void do_FCMPL(Thread* thread);
343  void do_FCMPG(Thread* thread);
344  void do_DCMPL(Thread* thread);
345  void do_DCMPG(Thread* thread);
346  void do_IFEQ(Thread* thread);
347  void do_IFNE(Thread* thread);
348  void do_IFLT(Thread* thread);
349  void do_IFGE(Thread* thread);
350  void do_IFGT(Thread* thread);
351  void do_IFLE(Thread* thread);
352  void do_IF_ICMPEQ(Thread* thread);
353  void do_IF_ICMPNE(Thread* thread);
354  void do_IF_ICMPLT(Thread* thread);
355  void do_IF_ICMPGE(Thread* thread);
356  void do_IF_ICMPGT(Thread* thread);
357  void do_IF_ICMPLE(Thread* thread);
358  void do_IF_ACMPEQ(Thread* thread);
359  void do_IF_ACMPNE(Thread* thread);
360  void do_GOTO(Thread* thread);
361  void do_JSR(Thread* thread);
362  void do_RET(Thread* thread);
363  void do_TABLESWITCH(Thread* thread);
364  void do_LOOKUPSWITCH(Thread* thread);
365  void do_IRETURN(Thread* thread);
366  void do_LRETURN(Thread* thread);
367  void do_FRETURN(Thread* thread);
368  void do_DRETURN(Thread* thread);
369  void do_ARETURN(Thread* thread);
370  void do_RETURN(Thread* thread);
371  void do_GETSTATIC(Thread* thread);
372  void do_PUTSTATIC(Thread* thread);
373  void do_GETFIELD(Thread* thread);
374  void do_PUTFIELD(Thread* thread);
375  void do_INVOKEVIRTUAL(Thread* thread);
376  void do_INVOKESPECIAL(Thread* thread);
377  void do_INVOKESTATIC(Thread* thread);
378  void do_INVOKEINTERFACE(Thread* thread);
379  void do_RESERVED1(Thread* thread);
380  void do_NEW(Thread* thread);
381  void do_NEWARRAY(Thread* thread);
382  void do_ANEWARRAY(Thread* thread);
383  void do_ARRAYLENGTH(Thread* thread);
384  void do_ATHROW(Thread* thread);
385  void do_CHECKCAST(Thread* thread);
386  void do_INSTANCEOF(Thread* thread);
387  void do_MONITORENTER(Thread* thread);
388  void do_MONITOREXIT(Thread* thread);
389  void do_WIDE(Thread* thread);
390  void do_MULTIANEWARRAY(Thread* thread);
391  void do_IFNULL(Thread* thread);
392  void do_IFNONNULL(Thread* thread);
393  void do_GOTO_W(Thread* thread);
394  void do_JSR_W(Thread* thread);
395  
396  /* Reserved opcodes(Thread* thread); */
397  void do_BREAKPOINT(Thread* thread);
398  void do_IMPDEP1(Thread* thread);
399  void do_IMPDEP2(Thread* thread);
400  
401  #endif