bytecodes.cpp revision 0:a61af66fc99e
17984SN/A/*
27984SN/A * Copyright 1997-2005 Sun Microsystems, Inc.  All Rights Reserved.
37984SN/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
47984SN/A *
57984SN/A * This code is free software; you can redistribute it and/or modify it
67984SN/A * under the terms of the GNU General Public License version 2 only, as
77984SN/A * published by the Free Software Foundation.
87984SN/A *
97984SN/A * This code is distributed in the hope that it will be useful, but WITHOUT
107984SN/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
117984SN/A * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
127984SN/A * version 2 for more details (a copy is included in the LICENSE file that
137984SN/A * accompanied this code).
147984SN/A *
157984SN/A * You should have received a copy of the GNU General Public License version
167984SN/A * 2 along with this work; if not, write to the Free Software Foundation,
177984SN/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
187984SN/A *
197984SN/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
207984SN/A * CA 95054 USA or visit www.sun.com if you need additional information or
217984SN/A * have any questions.
227984SN/A *
237984SN/A */
247984SN/A
257984SN/A#include "incls/_precompiled.incl"
267984SN/A#include "incls/_bytecodes.cpp.incl"
277984SN/A
287984SN/A
297984SN/A// Windows AMD64 Compiler Hangs compiling this file
307984SN/A// unless optimization is off
317984SN/A#ifdef _M_AMD64
327984SN/A#pragma optimize ("", off)
337984SN/A#endif
347984SN/A
357984SN/A
367984SN/Abool            Bytecodes::_is_initialized = false;
377984SN/Aconst char*     Bytecodes::_name          [Bytecodes::number_of_codes];
387984SN/Aconst char*     Bytecodes::_format        [Bytecodes::number_of_codes];
397984SN/Aconst char*     Bytecodes::_wide_format   [Bytecodes::number_of_codes];
407984SN/ABasicType       Bytecodes::_result_type   [Bytecodes::number_of_codes];
417984SN/As_char          Bytecodes::_depth         [Bytecodes::number_of_codes];
427984SN/Au_char          Bytecodes::_length        [Bytecodes::number_of_codes];
437984SN/Abool            Bytecodes::_can_trap      [Bytecodes::number_of_codes];
447984SN/ABytecodes::Code Bytecodes::_java_code     [Bytecodes::number_of_codes];
457984SN/Abool            Bytecodes::_can_rewrite   [Bytecodes::number_of_codes];
4610484SN/A
477984SN/A
487984SN/ABytecodes::Code Bytecodes::code_at(methodOop method, int bci) {
497984SN/A  return code_at(method->bcp_from(bci), method);
507984SN/A}
517984SN/A
527984SN/ABytecodes::Code Bytecodes::non_breakpoint_code_at(address bcp, methodOop method) {
537984SN/A  if (method == NULL)  method = methodOopDesc::method_from_bcp(bcp);
547984SN/A  return method->orig_bytecode_at(method->bci_from(bcp));
557984SN/A}
567984SN/A
577984SN/Aint Bytecodes::special_length_at(address bcp) {
587984SN/A  Code code = code_at(bcp);
597984SN/A  switch (code) {
607984SN/A  case _wide:
617984SN/A    return wide_length_for(cast(*(bcp + 1)));
627984SN/A  case _tableswitch:
637984SN/A    { address aligned_bcp = (address)round_to((intptr_t)bcp + 1, jintSize);
647984SN/A      jlong lo = (jint)Bytes::get_Java_u4(aligned_bcp + 1*jintSize);
657984SN/A      jlong hi = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize);
667984SN/A      jlong len = (aligned_bcp - bcp) + (3 + hi - lo + 1)*jintSize;
677984SN/A      // only return len if it can be represented as a positive int;
687984SN/A      // return -1 otherwise
697984SN/A      return (len > 0 && len == (int)len) ? len : -1;
707984SN/A    }
717984SN/A
727984SN/A  case _lookupswitch:      // fall through
737984SN/A  case _fast_binaryswitch: // fall through
747984SN/A  case _fast_linearswitch:
757984SN/A    { address aligned_bcp = (address)round_to((intptr_t)bcp + 1, jintSize);
767984SN/A      jlong npairs = (jint)Bytes::get_Java_u4(aligned_bcp + jintSize);
777984SN/A      jlong len = (aligned_bcp - bcp) + (2 + 2*npairs)*jintSize;
787984SN/A      // only return len if it can be represented as a positive int;
797984SN/A      // return -1 otherwise
807984SN/A      return (len > 0 && len == (int)len) ? len : -1;
817984SN/A    }
827984SN/A  }
837984SN/A  return 0;
847984SN/A}
857984SN/A
867984SN/A// At a breakpoint instruction, this returns the breakpoint's length,
877984SN/A// otherwise, it's the same as special_length_at().  This is used by
887984SN/A// the RawByteCodeStream, which wants to see the actual bytecode
897984SN/A// values (including breakpoint).  RawByteCodeStream is used by the
907984SN/A// verifier when reading in bytecode to verify.  Other mechanisms that
917984SN/A// run at runtime (such as generateOopMaps) need to iterate over the code
927984SN/A// and don't expect to see breakpoints: they want to see the instruction
937984SN/A// which was replaces so that they can get the correct length and find
947984SN/A// the next bytecode.
957984SN/Aint Bytecodes::raw_special_length_at(address bcp) {
967984SN/A  Code code = code_or_bp_at(bcp);
977984SN/A  if (code == _breakpoint) {
987984SN/A    return 1;
997984SN/A  } else {
1007984SN/A    return special_length_at(bcp);
1017984SN/A  }
1027984SN/A}
1037984SN/A
1047984SN/A
1057984SN/A
1067984SN/Avoid Bytecodes::def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap) {
1077984SN/A  def(code, name, format, wide_format, result_type, depth, can_trap, code);
1087984SN/A}
1097984SN/A
110
111void Bytecodes::def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap, Code java_code) {
112  assert(wide_format == NULL || format != NULL, "short form must exist if there's a wide form");
113  _name          [code] = name;
114  _format        [code] = format;
115  _wide_format   [code] = wide_format;
116  _result_type   [code] = result_type;
117  _depth         [code] = depth;
118  _can_trap      [code] = can_trap;
119  _length        [code] = format != NULL ? (u_char)strlen(format) : 0;
120  _java_code     [code] = java_code;
121  if (java_code != code)  _can_rewrite[java_code] = true;
122}
123
124
125// Format strings interpretation:
126//
127// b: bytecode
128// c: signed constant, Java byte-ordering
129// i: unsigned index , Java byte-ordering
130// j: unsigned index , native byte-ordering
131// o: branch offset  , Java byte-ordering
132// _: unused/ignored
133// w: wide bytecode
134//
135// Note: Right now the format strings are used for 2 purposes:
136//       1. to specify the length of the bytecode
137//          (= number of characters in format string)
138//       2. to specify the bytecode attributes
139//
140//       The bytecode attributes are currently used only for bytecode tracing
141//       (see BytecodeTracer); thus if more specific format information is
142//       used, one would also have to adjust the bytecode tracer.
143//
144// Note: For bytecodes with variable length, the format string is the empty string.
145
146void Bytecodes::initialize() {
147  if (_is_initialized) return;
148  assert(number_of_codes <= 256, "too many bytecodes");
149
150  // initialize bytecode tables - didn't use static array initializers
151  // (such as {}) so we can do additional consistency checks and init-
152  // code is independent of actual bytecode numbering.
153  //
154  // Note 1: NULL for the format string means the bytecode doesn't exist
155  //         in that form.
156  //
157  // Note 2: The result type is T_ILLEGAL for bytecodes where the top of stack
158  //         type after execution is not only determined by the bytecode itself.
159
160  //  Java bytecodes
161  //  bytecode               bytecode name           format   wide f.   result tp  stk traps
162  def(_nop                 , "nop"                 , "b"    , NULL    , T_VOID   ,  0, false);
163  def(_aconst_null         , "aconst_null"         , "b"    , NULL    , T_OBJECT ,  1, false);
164  def(_iconst_m1           , "iconst_m1"           , "b"    , NULL    , T_INT    ,  1, false);
165  def(_iconst_0            , "iconst_0"            , "b"    , NULL    , T_INT    ,  1, false);
166  def(_iconst_1            , "iconst_1"            , "b"    , NULL    , T_INT    ,  1, false);
167  def(_iconst_2            , "iconst_2"            , "b"    , NULL    , T_INT    ,  1, false);
168  def(_iconst_3            , "iconst_3"            , "b"    , NULL    , T_INT    ,  1, false);
169  def(_iconst_4            , "iconst_4"            , "b"    , NULL    , T_INT    ,  1, false);
170  def(_iconst_5            , "iconst_5"            , "b"    , NULL    , T_INT    ,  1, false);
171  def(_lconst_0            , "lconst_0"            , "b"    , NULL    , T_LONG   ,  2, false);
172  def(_lconst_1            , "lconst_1"            , "b"    , NULL    , T_LONG   ,  2, false);
173  def(_fconst_0            , "fconst_0"            , "b"    , NULL    , T_FLOAT  ,  1, false);
174  def(_fconst_1            , "fconst_1"            , "b"    , NULL    , T_FLOAT  ,  1, false);
175  def(_fconst_2            , "fconst_2"            , "b"    , NULL    , T_FLOAT  ,  1, false);
176  def(_dconst_0            , "dconst_0"            , "b"    , NULL    , T_DOUBLE ,  2, false);
177  def(_dconst_1            , "dconst_1"            , "b"    , NULL    , T_DOUBLE ,  2, false);
178  def(_bipush              , "bipush"              , "bc"   , NULL    , T_INT    ,  1, false);
179  def(_sipush              , "sipush"              , "bcc"  , NULL    , T_INT    ,  1, false);
180  def(_ldc                 , "ldc"                 , "bi"   , NULL    , T_ILLEGAL,  1, true );
181  def(_ldc_w               , "ldc_w"               , "bii"  , NULL    , T_ILLEGAL,  1, true );
182  def(_ldc2_w              , "ldc2_w"              , "bii"  , NULL    , T_ILLEGAL,  2, true );
183  def(_iload               , "iload"               , "bi"   , "wbii"  , T_INT    ,  1, false);
184  def(_lload               , "lload"               , "bi"   , "wbii"  , T_LONG   ,  2, false);
185  def(_fload               , "fload"               , "bi"   , "wbii"  , T_FLOAT  ,  1, false);
186  def(_dload               , "dload"               , "bi"   , "wbii"  , T_DOUBLE ,  2, false);
187  def(_aload               , "aload"               , "bi"   , "wbii"  , T_OBJECT ,  1, false);
188  def(_iload_0             , "iload_0"             , "b"    , NULL    , T_INT    ,  1, false);
189  def(_iload_1             , "iload_1"             , "b"    , NULL    , T_INT    ,  1, false);
190  def(_iload_2             , "iload_2"             , "b"    , NULL    , T_INT    ,  1, false);
191  def(_iload_3             , "iload_3"             , "b"    , NULL    , T_INT    ,  1, false);
192  def(_lload_0             , "lload_0"             , "b"    , NULL    , T_LONG   ,  2, false);
193  def(_lload_1             , "lload_1"             , "b"    , NULL    , T_LONG   ,  2, false);
194  def(_lload_2             , "lload_2"             , "b"    , NULL    , T_LONG   ,  2, false);
195  def(_lload_3             , "lload_3"             , "b"    , NULL    , T_LONG   ,  2, false);
196  def(_fload_0             , "fload_0"             , "b"    , NULL    , T_FLOAT  ,  1, false);
197  def(_fload_1             , "fload_1"             , "b"    , NULL    , T_FLOAT  ,  1, false);
198  def(_fload_2             , "fload_2"             , "b"    , NULL    , T_FLOAT  ,  1, false);
199  def(_fload_3             , "fload_3"             , "b"    , NULL    , T_FLOAT  ,  1, false);
200  def(_dload_0             , "dload_0"             , "b"    , NULL    , T_DOUBLE ,  2, false);
201  def(_dload_1             , "dload_1"             , "b"    , NULL    , T_DOUBLE ,  2, false);
202  def(_dload_2             , "dload_2"             , "b"    , NULL    , T_DOUBLE ,  2, false);
203  def(_dload_3             , "dload_3"             , "b"    , NULL    , T_DOUBLE ,  2, false);
204  def(_aload_0             , "aload_0"             , "b"    , NULL    , T_OBJECT ,  1, true ); // rewriting in interpreter
205  def(_aload_1             , "aload_1"             , "b"    , NULL    , T_OBJECT ,  1, false);
206  def(_aload_2             , "aload_2"             , "b"    , NULL    , T_OBJECT ,  1, false);
207  def(_aload_3             , "aload_3"             , "b"    , NULL    , T_OBJECT ,  1, false);
208  def(_iaload              , "iaload"              , "b"    , NULL    , T_INT    , -1, true );
209  def(_laload              , "laload"              , "b"    , NULL    , T_LONG   ,  0, true );
210  def(_faload              , "faload"              , "b"    , NULL    , T_FLOAT  , -1, true );
211  def(_daload              , "daload"              , "b"    , NULL    , T_DOUBLE ,  0, true );
212  def(_aaload              , "aaload"              , "b"    , NULL    , T_OBJECT , -1, true );
213  def(_baload              , "baload"              , "b"    , NULL    , T_INT    , -1, true );
214  def(_caload              , "caload"              , "b"    , NULL    , T_INT    , -1, true );
215  def(_saload              , "saload"              , "b"    , NULL    , T_INT    , -1, true );
216  def(_istore              , "istore"              , "bi"   , "wbii"  , T_VOID   , -1, false);
217  def(_lstore              , "lstore"              , "bi"   , "wbii"  , T_VOID   , -2, false);
218  def(_fstore              , "fstore"              , "bi"   , "wbii"  , T_VOID   , -1, false);
219  def(_dstore              , "dstore"              , "bi"   , "wbii"  , T_VOID   , -2, false);
220  def(_astore              , "astore"              , "bi"   , "wbii"  , T_VOID   , -1, false);
221  def(_istore_0            , "istore_0"            , "b"    , NULL    , T_VOID   , -1, false);
222  def(_istore_1            , "istore_1"            , "b"    , NULL    , T_VOID   , -1, false);
223  def(_istore_2            , "istore_2"            , "b"    , NULL    , T_VOID   , -1, false);
224  def(_istore_3            , "istore_3"            , "b"    , NULL    , T_VOID   , -1, false);
225  def(_lstore_0            , "lstore_0"            , "b"    , NULL    , T_VOID   , -2, false);
226  def(_lstore_1            , "lstore_1"            , "b"    , NULL    , T_VOID   , -2, false);
227  def(_lstore_2            , "lstore_2"            , "b"    , NULL    , T_VOID   , -2, false);
228  def(_lstore_3            , "lstore_3"            , "b"    , NULL    , T_VOID   , -2, false);
229  def(_fstore_0            , "fstore_0"            , "b"    , NULL    , T_VOID   , -1, false);
230  def(_fstore_1            , "fstore_1"            , "b"    , NULL    , T_VOID   , -1, false);
231  def(_fstore_2            , "fstore_2"            , "b"    , NULL    , T_VOID   , -1, false);
232  def(_fstore_3            , "fstore_3"            , "b"    , NULL    , T_VOID   , -1, false);
233  def(_dstore_0            , "dstore_0"            , "b"    , NULL    , T_VOID   , -2, false);
234  def(_dstore_1            , "dstore_1"            , "b"    , NULL    , T_VOID   , -2, false);
235  def(_dstore_2            , "dstore_2"            , "b"    , NULL    , T_VOID   , -2, false);
236  def(_dstore_3            , "dstore_3"            , "b"    , NULL    , T_VOID   , -2, false);
237  def(_astore_0            , "astore_0"            , "b"    , NULL    , T_VOID   , -1, false);
238  def(_astore_1            , "astore_1"            , "b"    , NULL    , T_VOID   , -1, false);
239  def(_astore_2            , "astore_2"            , "b"    , NULL    , T_VOID   , -1, false);
240  def(_astore_3            , "astore_3"            , "b"    , NULL    , T_VOID   , -1, false);
241  def(_iastore             , "iastore"             , "b"    , NULL    , T_VOID   , -3, true );
242  def(_lastore             , "lastore"             , "b"    , NULL    , T_VOID   , -4, true );
243  def(_fastore             , "fastore"             , "b"    , NULL    , T_VOID   , -3, true );
244  def(_dastore             , "dastore"             , "b"    , NULL    , T_VOID   , -4, true );
245  def(_aastore             , "aastore"             , "b"    , NULL    , T_VOID   , -3, true );
246  def(_bastore             , "bastore"             , "b"    , NULL    , T_VOID   , -3, true );
247  def(_castore             , "castore"             , "b"    , NULL    , T_VOID   , -3, true );
248  def(_sastore             , "sastore"             , "b"    , NULL    , T_VOID   , -3, true );
249  def(_pop                 , "pop"                 , "b"    , NULL    , T_VOID   , -1, false);
250  def(_pop2                , "pop2"                , "b"    , NULL    , T_VOID   , -2, false);
251  def(_dup                 , "dup"                 , "b"    , NULL    , T_VOID   ,  1, false);
252  def(_dup_x1              , "dup_x1"              , "b"    , NULL    , T_VOID   ,  1, false);
253  def(_dup_x2              , "dup_x2"              , "b"    , NULL    , T_VOID   ,  1, false);
254  def(_dup2                , "dup2"                , "b"    , NULL    , T_VOID   ,  2, false);
255  def(_dup2_x1             , "dup2_x1"             , "b"    , NULL    , T_VOID   ,  2, false);
256  def(_dup2_x2             , "dup2_x2"             , "b"    , NULL    , T_VOID   ,  2, false);
257  def(_swap                , "swap"                , "b"    , NULL    , T_VOID   ,  0, false);
258  def(_iadd                , "iadd"                , "b"    , NULL    , T_INT    , -1, false);
259  def(_ladd                , "ladd"                , "b"    , NULL    , T_LONG   , -2, false);
260  def(_fadd                , "fadd"                , "b"    , NULL    , T_FLOAT  , -1, false);
261  def(_dadd                , "dadd"                , "b"    , NULL    , T_DOUBLE , -2, false);
262  def(_isub                , "isub"                , "b"    , NULL    , T_INT    , -1, false);
263  def(_lsub                , "lsub"                , "b"    , NULL    , T_LONG   , -2, false);
264  def(_fsub                , "fsub"                , "b"    , NULL    , T_FLOAT  , -1, false);
265  def(_dsub                , "dsub"                , "b"    , NULL    , T_DOUBLE , -2, false);
266  def(_imul                , "imul"                , "b"    , NULL    , T_INT    , -1, false);
267  def(_lmul                , "lmul"                , "b"    , NULL    , T_LONG   , -2, false);
268  def(_fmul                , "fmul"                , "b"    , NULL    , T_FLOAT  , -1, false);
269  def(_dmul                , "dmul"                , "b"    , NULL    , T_DOUBLE , -2, false);
270  def(_idiv                , "idiv"                , "b"    , NULL    , T_INT    , -1, true );
271  def(_ldiv                , "ldiv"                , "b"    , NULL    , T_LONG   , -2, true );
272  def(_fdiv                , "fdiv"                , "b"    , NULL    , T_FLOAT  , -1, false);
273  def(_ddiv                , "ddiv"                , "b"    , NULL    , T_DOUBLE , -2, false);
274  def(_irem                , "irem"                , "b"    , NULL    , T_INT    , -1, true );
275  def(_lrem                , "lrem"                , "b"    , NULL    , T_LONG   , -2, true );
276  def(_frem                , "frem"                , "b"    , NULL    , T_FLOAT  , -1, false);
277  def(_drem                , "drem"                , "b"    , NULL    , T_DOUBLE , -2, false);
278  def(_ineg                , "ineg"                , "b"    , NULL    , T_INT    ,  0, false);
279  def(_lneg                , "lneg"                , "b"    , NULL    , T_LONG   ,  0, false);
280  def(_fneg                , "fneg"                , "b"    , NULL    , T_FLOAT  ,  0, false);
281  def(_dneg                , "dneg"                , "b"    , NULL    , T_DOUBLE ,  0, false);
282  def(_ishl                , "ishl"                , "b"    , NULL    , T_INT    , -1, false);
283  def(_lshl                , "lshl"                , "b"    , NULL    , T_LONG   , -1, false);
284  def(_ishr                , "ishr"                , "b"    , NULL    , T_INT    , -1, false);
285  def(_lshr                , "lshr"                , "b"    , NULL    , T_LONG   , -1, false);
286  def(_iushr               , "iushr"               , "b"    , NULL    , T_INT    , -1, false);
287  def(_lushr               , "lushr"               , "b"    , NULL    , T_LONG   , -1, false);
288  def(_iand                , "iand"                , "b"    , NULL    , T_INT    , -1, false);
289  def(_land                , "land"                , "b"    , NULL    , T_LONG   , -2, false);
290  def(_ior                 , "ior"                 , "b"    , NULL    , T_INT    , -1, false);
291  def(_lor                 , "lor"                 , "b"    , NULL    , T_LONG   , -2, false);
292  def(_ixor                , "ixor"                , "b"    , NULL    , T_INT    , -1, false);
293  def(_lxor                , "lxor"                , "b"    , NULL    , T_LONG   , -2, false);
294  def(_iinc                , "iinc"                , "bic"  , "wbiicc", T_VOID   ,  0, false);
295  def(_i2l                 , "i2l"                 , "b"    , NULL    , T_LONG   ,  1, false);
296  def(_i2f                 , "i2f"                 , "b"    , NULL    , T_FLOAT  ,  0, false);
297  def(_i2d                 , "i2d"                 , "b"    , NULL    , T_DOUBLE ,  1, false);
298  def(_l2i                 , "l2i"                 , "b"    , NULL    , T_INT    , -1, false);
299  def(_l2f                 , "l2f"                 , "b"    , NULL    , T_FLOAT  , -1, false);
300  def(_l2d                 , "l2d"                 , "b"    , NULL    , T_DOUBLE ,  0, false);
301  def(_f2i                 , "f2i"                 , "b"    , NULL    , T_INT    ,  0, false);
302  def(_f2l                 , "f2l"                 , "b"    , NULL    , T_LONG   ,  1, false);
303  def(_f2d                 , "f2d"                 , "b"    , NULL    , T_DOUBLE ,  1, false);
304  def(_d2i                 , "d2i"                 , "b"    , NULL    , T_INT    , -1, false);
305  def(_d2l                 , "d2l"                 , "b"    , NULL    , T_LONG   ,  0, false);
306  def(_d2f                 , "d2f"                 , "b"    , NULL    , T_FLOAT  , -1, false);
307  def(_i2b                 , "i2b"                 , "b"    , NULL    , T_BYTE   ,  0, false);
308  def(_i2c                 , "i2c"                 , "b"    , NULL    , T_CHAR   ,  0, false);
309  def(_i2s                 , "i2s"                 , "b"    , NULL    , T_SHORT  ,  0, false);
310  def(_lcmp                , "lcmp"                , "b"    , NULL    , T_VOID   , -3, false);
311  def(_fcmpl               , "fcmpl"               , "b"    , NULL    , T_VOID   , -1, false);
312  def(_fcmpg               , "fcmpg"               , "b"    , NULL    , T_VOID   , -1, false);
313  def(_dcmpl               , "dcmpl"               , "b"    , NULL    , T_VOID   , -3, false);
314  def(_dcmpg               , "dcmpg"               , "b"    , NULL    , T_VOID   , -3, false);
315  def(_ifeq                , "ifeq"                , "boo"  , NULL    , T_VOID   , -1, false);
316  def(_ifne                , "ifne"                , "boo"  , NULL    , T_VOID   , -1, false);
317  def(_iflt                , "iflt"                , "boo"  , NULL    , T_VOID   , -1, false);
318  def(_ifge                , "ifge"                , "boo"  , NULL    , T_VOID   , -1, false);
319  def(_ifgt                , "ifgt"                , "boo"  , NULL    , T_VOID   , -1, false);
320  def(_ifle                , "ifle"                , "boo"  , NULL    , T_VOID   , -1, false);
321  def(_if_icmpeq           , "if_icmpeq"           , "boo"  , NULL    , T_VOID   , -2, false);
322  def(_if_icmpne           , "if_icmpne"           , "boo"  , NULL    , T_VOID   , -2, false);
323  def(_if_icmplt           , "if_icmplt"           , "boo"  , NULL    , T_VOID   , -2, false);
324  def(_if_icmpge           , "if_icmpge"           , "boo"  , NULL    , T_VOID   , -2, false);
325  def(_if_icmpgt           , "if_icmpgt"           , "boo"  , NULL    , T_VOID   , -2, false);
326  def(_if_icmple           , "if_icmple"           , "boo"  , NULL    , T_VOID   , -2, false);
327  def(_if_acmpeq           , "if_acmpeq"           , "boo"  , NULL    , T_VOID   , -2, false);
328  def(_if_acmpne           , "if_acmpne"           , "boo"  , NULL    , T_VOID   , -2, false);
329  def(_goto                , "goto"                , "boo"  , NULL    , T_VOID   ,  0, false);
330  def(_jsr                 , "jsr"                 , "boo"  , NULL    , T_INT    ,  0, false);
331  def(_ret                 , "ret"                 , "bi"   , "wbii"  , T_VOID   ,  0, false);
332  def(_tableswitch         , "tableswitch"         , ""     , NULL    , T_VOID   , -1, false); // may have backward branches
333  def(_lookupswitch        , "lookupswitch"        , ""     , NULL    , T_VOID   , -1, false); // rewriting in interpreter
334  def(_ireturn             , "ireturn"             , "b"    , NULL    , T_INT    , -1, true);
335  def(_lreturn             , "lreturn"             , "b"    , NULL    , T_LONG   , -2, true);
336  def(_freturn             , "freturn"             , "b"    , NULL    , T_FLOAT  , -1, true);
337  def(_dreturn             , "dreturn"             , "b"    , NULL    , T_DOUBLE , -2, true);
338  def(_areturn             , "areturn"             , "b"    , NULL    , T_OBJECT , -1, true);
339  def(_return              , "return"              , "b"    , NULL    , T_VOID   ,  0, true);
340  def(_getstatic           , "getstatic"           , "bjj"  , NULL    , T_ILLEGAL,  1, true );
341  def(_putstatic           , "putstatic"           , "bjj"  , NULL    , T_ILLEGAL, -1, true );
342  def(_getfield            , "getfield"            , "bjj"  , NULL    , T_ILLEGAL,  0, true );
343  def(_putfield            , "putfield"            , "bjj"  , NULL    , T_ILLEGAL, -2, true );
344  def(_invokevirtual       , "invokevirtual"       , "bjj"  , NULL    , T_ILLEGAL, -1, true);
345  def(_invokespecial       , "invokespecial"       , "bjj"  , NULL    , T_ILLEGAL, -1, true);
346  def(_invokestatic        , "invokestatic"        , "bjj"  , NULL    , T_ILLEGAL,  0, true);
347  def(_invokeinterface     , "invokeinterface"     , "bjj__", NULL    , T_ILLEGAL, -1, true);
348  def(_xxxunusedxxx        , "xxxunusedxxx"        , NULL   , NULL    , T_VOID   ,  0, false);
349  def(_new                 , "new"                 , "bii"  , NULL    , T_OBJECT ,  1, true );
350  def(_newarray            , "newarray"            , "bc"   , NULL    , T_OBJECT ,  0, true );
351  def(_anewarray           , "anewarray"           , "bii"  , NULL    , T_OBJECT ,  0, true );
352  def(_arraylength         , "arraylength"         , "b"    , NULL    , T_VOID   ,  0, true );
353  def(_athrow              , "athrow"              , "b"    , NULL    , T_VOID   , -1, true );
354  def(_checkcast           , "checkcast"           , "bii"  , NULL    , T_OBJECT ,  0, true );
355  def(_instanceof          , "instanceof"          , "bii"  , NULL    , T_INT    ,  0, true );
356  def(_monitorenter        , "monitorenter"        , "b"    , NULL    , T_VOID   , -1, true );
357  def(_monitorexit         , "monitorexit"         , "b"    , NULL    , T_VOID   , -1, true );
358  def(_wide                , "wide"                , ""     , NULL    , T_VOID   ,  0, false);
359  def(_multianewarray      , "multianewarray"      , "biic" , NULL    , T_OBJECT ,  1, true );
360  def(_ifnull              , "ifnull"              , "boo"  , NULL    , T_VOID   , -1, false);
361  def(_ifnonnull           , "ifnonnull"           , "boo"  , NULL    , T_VOID   , -1, false);
362  def(_goto_w              , "goto_w"              , "boooo", NULL    , T_VOID   ,  0, false);
363  def(_jsr_w               , "jsr_w"               , "boooo", NULL    , T_INT    ,  0, false);
364  def(_breakpoint          , "breakpoint"          , ""     , NULL    , T_VOID   ,  0, true);
365
366  //  JVM bytecodes
367  //  bytecode               bytecode name           format   wide f.   result tp  stk traps  std code
368
369  def(_fast_agetfield      , "fast_agetfield"      , "bjj"  , NULL    , T_OBJECT ,  0, true , _getfield       );
370  def(_fast_bgetfield      , "fast_bgetfield"      , "bjj"  , NULL    , T_INT    ,  0, true , _getfield       );
371  def(_fast_cgetfield      , "fast_cgetfield"      , "bjj"  , NULL    , T_CHAR   ,  0, true , _getfield       );
372  def(_fast_dgetfield      , "fast_dgetfield"      , "bjj"  , NULL    , T_DOUBLE ,  0, true , _getfield       );
373  def(_fast_fgetfield      , "fast_fgetfield"      , "bjj"  , NULL    , T_FLOAT  ,  0, true , _getfield       );
374  def(_fast_igetfield      , "fast_igetfield"      , "bjj"  , NULL    , T_INT    ,  0, true , _getfield       );
375  def(_fast_lgetfield      , "fast_lgetfield"      , "bjj"  , NULL    , T_LONG   ,  0, true , _getfield       );
376  def(_fast_sgetfield      , "fast_sgetfield"      , "bjj"  , NULL    , T_SHORT  ,  0, true , _getfield       );
377
378  def(_fast_aputfield      , "fast_aputfield"      , "bjj"  , NULL    , T_OBJECT ,  0, true , _putfield       );
379  def(_fast_bputfield      , "fast_bputfield"      , "bjj"  , NULL    , T_INT    ,  0, true , _putfield       );
380  def(_fast_cputfield      , "fast_cputfield"      , "bjj"  , NULL    , T_CHAR   ,  0, true , _putfield       );
381  def(_fast_dputfield      , "fast_dputfield"      , "bjj"  , NULL    , T_DOUBLE ,  0, true , _putfield       );
382  def(_fast_fputfield      , "fast_fputfield"      , "bjj"  , NULL    , T_FLOAT  ,  0, true , _putfield       );
383  def(_fast_iputfield      , "fast_iputfield"      , "bjj"  , NULL    , T_INT    ,  0, true , _putfield       );
384  def(_fast_lputfield      , "fast_lputfield"      , "bjj"  , NULL    , T_LONG   ,  0, true , _putfield       );
385  def(_fast_sputfield      , "fast_sputfield"      , "bjj"  , NULL    , T_SHORT  ,  0, true , _putfield       );
386
387  def(_fast_aload_0        , "fast_aload_0"        , "b"    , NULL    , T_OBJECT ,  1, true , _aload_0        );
388  def(_fast_iaccess_0      , "fast_iaccess_0"      , "b_jj" , NULL    , T_INT    ,  1, true , _aload_0        );
389  def(_fast_aaccess_0      , "fast_aaccess_0"      , "b_jj" , NULL    , T_OBJECT ,  1, true , _aload_0        );
390  def(_fast_faccess_0      , "fast_faccess_0"      , "b_jj" , NULL    , T_OBJECT ,  1, true , _aload_0        );
391
392  def(_fast_iload          , "fast_iload"          , "bi"   , NULL    , T_INT    ,  1, false, _iload);
393  def(_fast_iload2         , "fast_iload2"         , "bi_i" , NULL    , T_INT    ,  2, false, _iload);
394  def(_fast_icaload        , "fast_icaload"        , "bi_"  , NULL    , T_INT    ,  0, false, _iload);
395
396  // Faster method invocation.
397  def(_fast_invokevfinal   , "fast_invokevfinal"   , "bjj"  , NULL    , T_ILLEGAL, -1, true, _invokevirtual   );
398
399  def(_fast_linearswitch   , "fast_linearswitch"   , ""     , NULL    , T_VOID   , -1, false, _lookupswitch   );
400  def(_fast_binaryswitch   , "fast_binaryswitch"   , ""     , NULL    , T_VOID   , -1, false, _lookupswitch   );
401
402  def(_return_register_finalizer , "return_register_finalizer" , "b"    , NULL    , T_VOID   ,  0, true, _return);
403
404  def(_shouldnotreachhere  , "_shouldnotreachhere" , "b"    , NULL    , T_VOID   ,  0, false);
405
406  // platform specific JVM bytecodes
407  pd_initialize();
408
409  // compare can_trap information for each bytecode with the
410  // can_trap information for the corresponding base bytecode
411  // (if a rewritten bytecode can trap, so must the base bytecode)
412  #ifdef ASSERT
413    { for (int i = 0; i < number_of_codes; i++) {
414        if (is_defined(i)) {
415          Code code = cast(i);
416          Code java = java_code(code);
417          if (can_trap(code) && !can_trap(java)) fatal2("%s can trap => %s can trap, too", name(code), name(java));
418        }
419      }
420    }
421  #endif
422
423  // initialization successful
424  _is_initialized = true;
425}
426
427
428void bytecodes_init() {
429  Bytecodes::initialize();
430}
431
432// Restore optimization
433#ifdef _M_AMD64
434#pragma optimize ("", on)
435#endif
436