bytecodes.cpp revision 0:a61af66fc99e
1104476Ssam/*
2104476Ssam * Copyright 1997-2005 Sun Microsystems, Inc.  All Rights Reserved.
3104476Ssam * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4139825Simp *
5104476Ssam * This code is free software; you can redistribute it and/or modify it
6167755Ssam * under the terms of the GNU General Public License version 2 only, as
7104476Ssam * published by the Free Software Foundation.
8104476Ssam *
9104476Ssam * This code is distributed in the hope that it will be useful, but WITHOUT
10104476Ssam * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11104476Ssam * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12104476Ssam * version 2 for more details (a copy is included in the LICENSE file that
13104476Ssam * accompanied this code).
14104476Ssam *
15104476Ssam * You should have received a copy of the GNU General Public License version
16104476Ssam * 2 along with this work; if not, write to the Free Software Foundation,
17104476Ssam * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18104476Ssam *
19104476Ssam * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20104476Ssam * CA 95054 USA or visit www.sun.com if you need additional information or
21104476Ssam * have any questions.
22104476Ssam *
23104476Ssam */
24104476Ssam
25104476Ssam#include "incls/_precompiled.incl"
26104476Ssam#include "incls/_bytecodes.cpp.incl"
27104476Ssam
28104476Ssam
29104476Ssam// Windows AMD64 Compiler Hangs compiling this file
30104476Ssam// unless optimization is off
31104476Ssam#ifdef _M_AMD64
32104476Ssam#pragma optimize ("", off)
33104476Ssam#endif
34104476Ssam
35104476Ssam
36104476Ssambool            Bytecodes::_is_initialized = false;
37104476Ssamconst char*     Bytecodes::_name          [Bytecodes::number_of_codes];
38104476Ssamconst char*     Bytecodes::_format        [Bytecodes::number_of_codes];
39104476Ssamconst char*     Bytecodes::_wide_format   [Bytecodes::number_of_codes];
40104476SsamBasicType       Bytecodes::_result_type   [Bytecodes::number_of_codes];
41104476Ssams_char          Bytecodes::_depth         [Bytecodes::number_of_codes];
42104476Ssamu_char          Bytecodes::_length        [Bytecodes::number_of_codes];
43104476Ssambool            Bytecodes::_can_trap      [Bytecodes::number_of_codes];
44104476SsamBytecodes::Code Bytecodes::_java_code     [Bytecodes::number_of_codes];
45104476Ssambool            Bytecodes::_can_rewrite   [Bytecodes::number_of_codes];
46104476Ssam
47104476Ssam
48104476SsamBytecodes::Code Bytecodes::code_at(methodOop method, int bci) {
49104476Ssam  return code_at(method->bcp_from(bci), method);
50104476Ssam}
51104476Ssam
52104476SsamBytecodes::Code Bytecodes::non_breakpoint_code_at(address bcp, methodOop method) {
53104476Ssam  if (method == NULL)  method = methodOopDesc::method_from_bcp(bcp);
54104476Ssam  return method->orig_bytecode_at(method->bci_from(bcp));
55104476Ssam}
56104476Ssam
57104476Ssamint Bytecodes::special_length_at(address bcp) {
58104476Ssam  Code code = code_at(bcp);
59104476Ssam  switch (code) {
60104476Ssam  case _wide:
61104476Ssam    return wide_length_for(cast(*(bcp + 1)));
62104476Ssam  case _tableswitch:
63104476Ssam    { address aligned_bcp = (address)round_to((intptr_t)bcp + 1, jintSize);
64104476Ssam      jlong lo = (jint)Bytes::get_Java_u4(aligned_bcp + 1*jintSize);
65159227Spjd      jlong hi = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize);
66159227Spjd      jlong len = (aligned_bcp - bcp) + (3 + hi - lo + 1)*jintSize;
67159227Spjd      // only return len if it can be represented as a positive int;
68159227Spjd      // return -1 otherwise
69159227Spjd      return (len > 0 && len == (int)len) ? len : -1;
70159227Spjd    }
71159227Spjd
72159227Spjd  case _lookupswitch:      // fall through
73159227Spjd  case _fast_binaryswitch: // fall through
74159227Spjd  case _fast_linearswitch:
75159228Spjd    { address aligned_bcp = (address)round_to((intptr_t)bcp + 1, jintSize);
76159228Spjd      jlong npairs = (jint)Bytes::get_Java_u4(aligned_bcp + jintSize);
77159228Spjd      jlong len = (aligned_bcp - bcp) + (2 + 2*npairs)*jintSize;
78104476Ssam      // only return len if it can be represented as a positive int;
79159227Spjd      // return -1 otherwise
80159227Spjd      return (len > 0 && len == (int)len) ? len : -1;
81159227Spjd    }
82159227Spjd  }
83159227Spjd  return 0;
84159227Spjd}
85159227Spjd
86159229Spjd// At a breakpoint instruction, this returns the breakpoint's length,
87159229Spjd// otherwise, it's the same as special_length_at().  This is used by
88159227Spjd// the RawByteCodeStream, which wants to see the actual bytecode
89159227Spjd// values (including breakpoint).  RawByteCodeStream is used by the
90104476Ssam// verifier when reading in bytecode to verify.  Other mechanisms that
91104476Ssam// run at runtime (such as generateOopMaps) need to iterate over the code
92159227Spjd// and don't expect to see breakpoints: they want to see the instruction
93104476Ssam// which was replaces so that they can get the correct length and find
94104476Ssam// the next bytecode.
95104476Ssamint Bytecodes::raw_special_length_at(address bcp) {
96104476Ssam  Code code = code_or_bp_at(bcp);
97104476Ssam  if (code == _breakpoint) {
98104476Ssam    return 1;
99159227Spjd  } else {
100169425Sgnn    return special_length_at(bcp);
101159230Spjd  }
102104476Ssam}
103104476Ssam
104104476Ssam
105104476Ssam
106104476Ssamvoid Bytecodes::def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap) {
107104476Ssam  def(code, name, format, wide_format, result_type, depth, can_trap, code);
108104476Ssam}
109104476Ssam
110104476Ssam
111104476Ssamvoid 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) {
112104476Ssam  assert(wide_format == NULL || format != NULL, "short form must exist if there's a wide form");
113104476Ssam  _name          [code] = name;
114104476Ssam  _format        [code] = format;
115104476Ssam  _wide_format   [code] = wide_format;
116104476Ssam  _result_type   [code] = result_type;
117104476Ssam  _depth         [code] = depth;
118104476Ssam  _can_trap      [code] = can_trap;
119158703Spjd  _length        [code] = format != NULL ? (u_char)strlen(format) : 0;
120158703Spjd  _java_code     [code] = java_code;
121158703Spjd  if (java_code != code)  _can_rewrite[java_code] = true;
122158703Spjd}
123158703Spjd
124158703Spjd
125169425Sgnn// Format strings interpretation:
126213068Spjd//
127213068Spjd// b: bytecode
128104476Ssam// c: signed constant, Java byte-ordering
129104476Ssam// i: unsigned index , Java byte-ordering
130104476Ssam// j: unsigned index , native byte-ordering
131104476Ssam// o: branch offset  , Java byte-ordering
132104476Ssam// _: unused/ignored
133104476Ssam// w: wide bytecode
134167755Ssam//
135167755Ssam// Note: Right now the format strings are used for 2 purposes:
136167755Ssam//       1. to specify the length of the bytecode
137167755Ssam//          (= number of characters in format string)
138167755Ssam//       2. to specify the bytecode attributes
139167755Ssam//
140167755Ssam//       The bytecode attributes are currently used only for bytecode tracing
141167755Ssam//       (see BytecodeTracer); thus if more specific format information is
142167755Ssam//       used, one would also have to adjust the bytecode tracer.
143167755Ssam//
144167755Ssam// Note: For bytecodes with variable length, the format string is the empty string.
145167755Ssam
146104476Ssamvoid Bytecodes::initialize() {
147104476Ssam  if (_is_initialized) return;
148104476Ssam  assert(number_of_codes <= 256, "too many bytecodes");
149104476Ssam
150104476Ssam  // initialize bytecode tables - didn't use static array initializers
151104476Ssam  // (such as {}) so we can do additional consistency checks and init-
152104476Ssam  // code is independent of actual bytecode numbering.
153104476Ssam  //
154104476Ssam  // Note 1: NULL for the format string means the bytecode doesn't exist
155104476Ssam  //         in that form.
156104476Ssam  //
157104476Ssam  // Note 2: The result type is T_ILLEGAL for bytecodes where the top of stack
158167755Ssam  //         type after execution is not only determined by the bytecode itself.
159167755Ssam
160167755Ssam  //  Java bytecodes
161167755Ssam  //  bytecode               bytecode name           format   wide f.   result tp  stk traps
162167755Ssam  def(_nop                 , "nop"                 , "b"    , NULL    , T_VOID   ,  0, false);
163167755Ssam  def(_aconst_null         , "aconst_null"         , "b"    , NULL    , T_OBJECT ,  1, false);
164167755Ssam  def(_iconst_m1           , "iconst_m1"           , "b"    , NULL    , T_INT    ,  1, false);
165167755Ssam  def(_iconst_0            , "iconst_0"            , "b"    , NULL    , T_INT    ,  1, false);
166167755Ssam  def(_iconst_1            , "iconst_1"            , "b"    , NULL    , T_INT    ,  1, false);
167167755Ssam  def(_iconst_2            , "iconst_2"            , "b"    , NULL    , T_INT    ,  1, false);
168167755Ssam  def(_iconst_3            , "iconst_3"            , "b"    , NULL    , T_INT    ,  1, false);
169167755Ssam  def(_iconst_4            , "iconst_4"            , "b"    , NULL    , T_INT    ,  1, false);
170167755Ssam  def(_iconst_5            , "iconst_5"            , "b"    , NULL    , T_INT    ,  1, false);
171167755Ssam  def(_lconst_0            , "lconst_0"            , "b"    , NULL    , T_LONG   ,  2, false);
172104476Ssam  def(_lconst_1            , "lconst_1"            , "b"    , NULL    , T_LONG   ,  2, false);
173104476Ssam  def(_fconst_0            , "fconst_0"            , "b"    , NULL    , T_FLOAT  ,  1, false);
174104476Ssam  def(_fconst_1            , "fconst_1"            , "b"    , NULL    , T_FLOAT  ,  1, false);
175104476Ssam  def(_fconst_2            , "fconst_2"            , "b"    , NULL    , T_FLOAT  ,  1, false);
176104476Ssam  def(_dconst_0            , "dconst_0"            , "b"    , NULL    , T_DOUBLE ,  2, false);
177111297Ssam  def(_dconst_1            , "dconst_1"            , "b"    , NULL    , T_DOUBLE ,  2, false);
178111297Ssam  def(_bipush              , "bipush"              , "bc"   , NULL    , T_INT    ,  1, false);
179104476Ssam  def(_sipush              , "sipush"              , "bcc"  , NULL    , T_INT    ,  1, false);
180104476Ssam  def(_ldc                 , "ldc"                 , "bi"   , NULL    , T_ILLEGAL,  1, true );
181104476Ssam  def(_ldc_w               , "ldc_w"               , "bii"  , NULL    , T_ILLEGAL,  1, true );
182104476Ssam  def(_ldc2_w              , "ldc2_w"              , "bii"  , NULL    , T_ILLEGAL,  2, true );
183104476Ssam  def(_iload               , "iload"               , "bi"   , "wbii"  , T_INT    ,  1, false);
184104476Ssam  def(_lload               , "lload"               , "bi"   , "wbii"  , T_LONG   ,  2, false);
185167755Ssam  def(_fload               , "fload"               , "bi"   , "wbii"  , T_FLOAT  ,  1, false);
186167755Ssam  def(_dload               , "dload"               , "bi"   , "wbii"  , T_DOUBLE ,  2, false);
187167755Ssam  def(_aload               , "aload"               , "bi"   , "wbii"  , T_OBJECT ,  1, false);
188167755Ssam  def(_iload_0             , "iload_0"             , "b"    , NULL    , T_INT    ,  1, false);
189167755Ssam  def(_iload_1             , "iload_1"             , "b"    , NULL    , T_INT    ,  1, false);
190167755Ssam  def(_iload_2             , "iload_2"             , "b"    , NULL    , T_INT    ,  1, false);
191167755Ssam  def(_iload_3             , "iload_3"             , "b"    , NULL    , T_INT    ,  1, false);
192167755Ssam  def(_lload_0             , "lload_0"             , "b"    , NULL    , T_LONG   ,  2, false);
193167755Ssam  def(_lload_1             , "lload_1"             , "b"    , NULL    , T_LONG   ,  2, false);
194167755Ssam  def(_lload_2             , "lload_2"             , "b"    , NULL    , T_LONG   ,  2, false);
195104476Ssam  def(_lload_3             , "lload_3"             , "b"    , NULL    , T_LONG   ,  2, false);
196104476Ssam  def(_fload_0             , "fload_0"             , "b"    , NULL    , T_FLOAT  ,  1, false);
197104476Ssam  def(_fload_1             , "fload_1"             , "b"    , NULL    , T_FLOAT  ,  1, false);
198104476Ssam  def(_fload_2             , "fload_2"             , "b"    , NULL    , T_FLOAT  ,  1, false);
199104476Ssam  def(_fload_3             , "fload_3"             , "b"    , NULL    , T_FLOAT  ,  1, false);
200104476Ssam  def(_dload_0             , "dload_0"             , "b"    , NULL    , T_DOUBLE ,  2, false);
201104476Ssam  def(_dload_1             , "dload_1"             , "b"    , NULL    , T_DOUBLE ,  2, false);
202104476Ssam  def(_dload_2             , "dload_2"             , "b"    , NULL    , T_DOUBLE ,  2, false);
203104476Ssam  def(_dload_3             , "dload_3"             , "b"    , NULL    , T_DOUBLE ,  2, false);
204104476Ssam  def(_aload_0             , "aload_0"             , "b"    , NULL    , T_OBJECT ,  1, true ); // rewriting in interpreter
205104476Ssam  def(_aload_1             , "aload_1"             , "b"    , NULL    , T_OBJECT ,  1, false);
206104476Ssam  def(_aload_2             , "aload_2"             , "b"    , NULL    , T_OBJECT ,  1, false);
207104476Ssam  def(_aload_3             , "aload_3"             , "b"    , NULL    , T_OBJECT ,  1, false);
208167755Ssam  def(_iaload              , "iaload"              , "b"    , NULL    , T_INT    , -1, true );
209104476Ssam  def(_laload              , "laload"              , "b"    , NULL    , T_LONG   ,  0, true );
210104476Ssam  def(_faload              , "faload"              , "b"    , NULL    , T_FLOAT  , -1, true );
211104476Ssam  def(_daload              , "daload"              , "b"    , NULL    , T_DOUBLE ,  0, true );
212104476Ssam  def(_aaload              , "aaload"              , "b"    , NULL    , T_OBJECT , -1, true );
213104476Ssam  def(_baload              , "baload"              , "b"    , NULL    , T_INT    , -1, true );
214104476Ssam  def(_caload              , "caload"              , "b"    , NULL    , T_INT    , -1, true );
215104476Ssam  def(_saload              , "saload"              , "b"    , NULL    , T_INT    , -1, true );
216104476Ssam  def(_istore              , "istore"              , "bi"   , "wbii"  , T_VOID   , -1, false);
217104476Ssam  def(_lstore              , "lstore"              , "bi"   , "wbii"  , T_VOID   , -2, false);
218104476Ssam  def(_fstore              , "fstore"              , "bi"   , "wbii"  , T_VOID   , -1, false);
219104476Ssam  def(_dstore              , "dstore"              , "bi"   , "wbii"  , T_VOID   , -2, false);
220104476Ssam  def(_astore              , "astore"              , "bi"   , "wbii"  , T_VOID   , -1, false);
221104476Ssam  def(_istore_0            , "istore_0"            , "b"    , NULL    , T_VOID   , -1, false);
222104476Ssam  def(_istore_1            , "istore_1"            , "b"    , NULL    , T_VOID   , -1, false);
223104476Ssam  def(_istore_2            , "istore_2"            , "b"    , NULL    , T_VOID   , -1, false);
224104476Ssam  def(_istore_3            , "istore_3"            , "b"    , NULL    , T_VOID   , -1, false);
225104476Ssam  def(_lstore_0            , "lstore_0"            , "b"    , NULL    , T_VOID   , -2, false);
226104476Ssam  def(_lstore_1            , "lstore_1"            , "b"    , NULL    , T_VOID   , -2, false);
227104476Ssam  def(_lstore_2            , "lstore_2"            , "b"    , NULL    , T_VOID   , -2, false);
228104476Ssam  def(_lstore_3            , "lstore_3"            , "b"    , NULL    , T_VOID   , -2, false);
229104476Ssam  def(_fstore_0            , "fstore_0"            , "b"    , NULL    , T_VOID   , -1, false);
230167755Ssam  def(_fstore_1            , "fstore_1"            , "b"    , NULL    , T_VOID   , -1, false);
231167755Ssam  def(_fstore_2            , "fstore_2"            , "b"    , NULL    , T_VOID   , -1, false);
232104476Ssam  def(_fstore_3            , "fstore_3"            , "b"    , NULL    , T_VOID   , -1, false);
233104476Ssam  def(_dstore_0            , "dstore_0"            , "b"    , NULL    , T_VOID   , -2, false);
234104476Ssam  def(_dstore_1            , "dstore_1"            , "b"    , NULL    , T_VOID   , -2, false);
235104476Ssam  def(_dstore_2            , "dstore_2"            , "b"    , NULL    , T_VOID   , -2, false);
236104476Ssam  def(_dstore_3            , "dstore_3"            , "b"    , NULL    , T_VOID   , -2, false);
237104476Ssam  def(_astore_0            , "astore_0"            , "b"    , NULL    , T_VOID   , -1, false);
238104476Ssam  def(_astore_1            , "astore_1"            , "b"    , NULL    , T_VOID   , -1, false);
239167755Ssam  def(_astore_2            , "astore_2"            , "b"    , NULL    , T_VOID   , -1, false);
240167755Ssam  def(_astore_3            , "astore_3"            , "b"    , NULL    , T_VOID   , -1, false);
241167755Ssam  def(_iastore             , "iastore"             , "b"    , NULL    , T_VOID   , -3, true );
242104476Ssam  def(_lastore             , "lastore"             , "b"    , NULL    , T_VOID   , -4, true );
243108587Ssam  def(_fastore             , "fastore"             , "b"    , NULL    , T_VOID   , -3, true );
244108587Ssam  def(_dastore             , "dastore"             , "b"    , NULL    , T_VOID   , -4, true );
245108587Ssam  def(_aastore             , "aastore"             , "b"    , NULL    , T_VOID   , -3, true );
246108587Ssam  def(_bastore             , "bastore"             , "b"    , NULL    , T_VOID   , -3, true );
247108587Ssam  def(_castore             , "castore"             , "b"    , NULL    , T_VOID   , -3, true );
248108587Ssam  def(_sastore             , "sastore"             , "b"    , NULL    , T_VOID   , -3, true );
249108587Ssam  def(_pop                 , "pop"                 , "b"    , NULL    , T_VOID   , -1, false);
250108587Ssam  def(_pop2                , "pop2"                , "b"    , NULL    , T_VOID   , -2, false);
251108587Ssam  def(_dup                 , "dup"                 , "b"    , NULL    , T_VOID   ,  1, false);
252108587Ssam  def(_dup_x1              , "dup_x1"              , "b"    , NULL    , T_VOID   ,  1, false);
253108587Ssam  def(_dup_x2              , "dup_x2"              , "b"    , NULL    , T_VOID   ,  1, false);
254108587Ssam  def(_dup2                , "dup2"                , "b"    , NULL    , T_VOID   ,  2, false);
255108587Ssam  def(_dup2_x1             , "dup2_x1"             , "b"    , NULL    , T_VOID   ,  2, false);
256108587Ssam  def(_dup2_x2             , "dup2_x2"             , "b"    , NULL    , T_VOID   ,  2, false);
257108587Ssam  def(_swap                , "swap"                , "b"    , NULL    , T_VOID   ,  0, false);
258108587Ssam  def(_iadd                , "iadd"                , "b"    , NULL    , T_INT    , -1, false);
259108587Ssam  def(_ladd                , "ladd"                , "b"    , NULL    , T_LONG   , -2, false);
260108587Ssam  def(_fadd                , "fadd"                , "b"    , NULL    , T_FLOAT  , -1, false);
261108587Ssam  def(_dadd                , "dadd"                , "b"    , NULL    , T_DOUBLE , -2, false);
262108587Ssam  def(_isub                , "isub"                , "b"    , NULL    , T_INT    , -1, false);
263108587Ssam  def(_lsub                , "lsub"                , "b"    , NULL    , T_LONG   , -2, false);
264108587Ssam  def(_fsub                , "fsub"                , "b"    , NULL    , T_FLOAT  , -1, false);
265108587Ssam  def(_dsub                , "dsub"                , "b"    , NULL    , T_DOUBLE , -2, false);
266108587Ssam  def(_imul                , "imul"                , "b"    , NULL    , T_INT    , -1, false);
267108587Ssam  def(_lmul                , "lmul"                , "b"    , NULL    , T_LONG   , -2, false);
268108587Ssam  def(_fmul                , "fmul"                , "b"    , NULL    , T_FLOAT  , -1, false);
269108587Ssam  def(_dmul                , "dmul"                , "b"    , NULL    , T_DOUBLE , -2, false);
270108587Ssam  def(_idiv                , "idiv"                , "b"    , NULL    , T_INT    , -1, true );
271104476Ssam  def(_ldiv                , "ldiv"                , "b"    , NULL    , T_LONG   , -2, true );
272104476Ssam  def(_fdiv                , "fdiv"                , "b"    , NULL    , T_FLOAT  , -1, false);
273104476Ssam  def(_ddiv                , "ddiv"                , "b"    , NULL    , T_DOUBLE , -2, false);
274104476Ssam  def(_irem                , "irem"                , "b"    , NULL    , T_INT    , -1, true );
275104476Ssam  def(_lrem                , "lrem"                , "b"    , NULL    , T_LONG   , -2, true );
276158703Spjd  def(_frem                , "frem"                , "b"    , NULL    , T_FLOAT  , -1, false);
277158703Spjd  def(_drem                , "drem"                , "b"    , NULL    , T_DOUBLE , -2, false);
278104476Ssam  def(_ineg                , "ineg"                , "b"    , NULL    , T_INT    ,  0, false);
279104476Ssam  def(_lneg                , "lneg"                , "b"    , NULL    , T_LONG   ,  0, false);
280104476Ssam  def(_fneg                , "fneg"                , "b"    , NULL    , T_FLOAT  ,  0, false);
281104476Ssam  def(_dneg                , "dneg"                , "b"    , NULL    , T_DOUBLE ,  0, false);
282104476Ssam  def(_ishl                , "ishl"                , "b"    , NULL    , T_INT    , -1, false);
283104476Ssam  def(_lshl                , "lshl"                , "b"    , NULL    , T_LONG   , -1, false);
284104476Ssam  def(_ishr                , "ishr"                , "b"    , NULL    , T_INT    , -1, false);
285104476Ssam  def(_lshr                , "lshr"                , "b"    , NULL    , T_LONG   , -1, false);
286104476Ssam  def(_iushr               , "iushr"               , "b"    , NULL    , T_INT    , -1, false);
287104476Ssam  def(_lushr               , "lushr"               , "b"    , NULL    , T_LONG   , -1, false);
288104476Ssam  def(_iand                , "iand"                , "b"    , NULL    , T_INT    , -1, false);
289104476Ssam  def(_land                , "land"                , "b"    , NULL    , T_LONG   , -2, false);
290104476Ssam  def(_ior                 , "ior"                 , "b"    , NULL    , T_INT    , -1, false);
291104476Ssam  def(_lor                 , "lor"                 , "b"    , NULL    , T_LONG   , -2, false);
292104476Ssam  def(_ixor                , "ixor"                , "b"    , NULL    , T_INT    , -1, false);
293104476Ssam  def(_lxor                , "lxor"                , "b"    , NULL    , T_LONG   , -2, false);
294104476Ssam  def(_iinc                , "iinc"                , "bic"  , "wbiicc", T_VOID   ,  0, false);
295125330Sphk  def(_i2l                 , "i2l"                 , "b"    , NULL    , T_LONG   ,  1, false);
296104476Ssam  def(_i2f                 , "i2f"                 , "b"    , NULL    , T_FLOAT  ,  0, false);
297104476Ssam  def(_i2d                 , "i2d"                 , "b"    , NULL    , T_DOUBLE ,  1, false);
298104476Ssam  def(_l2i                 , "l2i"                 , "b"    , NULL    , T_INT    , -1, false);
299104476Ssam  def(_l2f                 , "l2f"                 , "b"    , NULL    , T_FLOAT  , -1, false);
300104476Ssam  def(_l2d                 , "l2d"                 , "b"    , NULL    , T_DOUBLE ,  0, false);
301104476Ssam  def(_f2i                 , "f2i"                 , "b"    , NULL    , T_INT    ,  0, false);
302104476Ssam  def(_f2l                 , "f2l"                 , "b"    , NULL    , T_LONG   ,  1, false);
303104476Ssam  def(_f2d                 , "f2d"                 , "b"    , NULL    , T_DOUBLE ,  1, false);
304104476Ssam  def(_d2i                 , "d2i"                 , "b"    , NULL    , T_INT    , -1, false);
305104476Ssam  def(_d2l                 , "d2l"                 , "b"    , NULL    , T_LONG   ,  0, false);
306104476Ssam  def(_d2f                 , "d2f"                 , "b"    , NULL    , T_FLOAT  , -1, false);
307104476Ssam  def(_i2b                 , "i2b"                 , "b"    , NULL    , T_BYTE   ,  0, false);
308104476Ssam  def(_i2c                 , "i2c"                 , "b"    , NULL    , T_CHAR   ,  0, false);
309104476Ssam  def(_i2s                 , "i2s"                 , "b"    , NULL    , T_SHORT  ,  0, false);
310104476Ssam  def(_lcmp                , "lcmp"                , "b"    , NULL    , T_VOID   , -3, false);
311104476Ssam  def(_fcmpl               , "fcmpl"               , "b"    , NULL    , T_VOID   , -1, false);
312104476Ssam  def(_fcmpg               , "fcmpg"               , "b"    , NULL    , T_VOID   , -1, false);
313104476Ssam  def(_dcmpl               , "dcmpl"               , "b"    , NULL    , T_VOID   , -3, false);
314104476Ssam  def(_dcmpg               , "dcmpg"               , "b"    , NULL    , T_VOID   , -3, false);
315104476Ssam  def(_ifeq                , "ifeq"                , "boo"  , NULL    , T_VOID   , -1, false);
316104476Ssam  def(_ifne                , "ifne"                , "boo"  , NULL    , T_VOID   , -1, false);
317104476Ssam  def(_iflt                , "iflt"                , "boo"  , NULL    , T_VOID   , -1, false);
318104476Ssam  def(_ifge                , "ifge"                , "boo"  , NULL    , T_VOID   , -1, false);
319104476Ssam  def(_ifgt                , "ifgt"                , "boo"  , NULL    , T_VOID   , -1, false);
320104476Ssam  def(_ifle                , "ifle"                , "boo"  , NULL    , T_VOID   , -1, false);
321104476Ssam  def(_if_icmpeq           , "if_icmpeq"           , "boo"  , NULL    , T_VOID   , -2, false);
322104476Ssam  def(_if_icmpne           , "if_icmpne"           , "boo"  , NULL    , T_VOID   , -2, false);
323104476Ssam  def(_if_icmplt           , "if_icmplt"           , "boo"  , NULL    , T_VOID   , -2, false);
324104476Ssam  def(_if_icmpge           , "if_icmpge"           , "boo"  , NULL    , T_VOID   , -2, false);
325104476Ssam  def(_if_icmpgt           , "if_icmpgt"           , "boo"  , NULL    , T_VOID   , -2, false);
326104476Ssam  def(_if_icmple           , "if_icmple"           , "boo"  , NULL    , T_VOID   , -2, false);
327117058Ssam  def(_if_acmpeq           , "if_acmpeq"           , "boo"  , NULL    , T_VOID   , -2, false);
328117058Ssam  def(_if_acmpne           , "if_acmpne"           , "boo"  , NULL    , T_VOID   , -2, false);
329117058Ssam  def(_goto                , "goto"                , "boo"  , NULL    , T_VOID   ,  0, false);
330117058Ssam  def(_jsr                 , "jsr"                 , "boo"  , NULL    , T_INT    ,  0, false);
331117058Ssam  def(_ret                 , "ret"                 , "bi"   , "wbii"  , T_VOID   ,  0, false);
332117058Ssam  def(_tableswitch         , "tableswitch"         , ""     , NULL    , T_VOID   , -1, false); // may have backward branches
333117058Ssam  def(_lookupswitch        , "lookupswitch"        , ""     , NULL    , T_VOID   , -1, false); // rewriting in interpreter
334104476Ssam  def(_ireturn             , "ireturn"             , "b"    , NULL    , T_INT    , -1, true);
335104476Ssam  def(_lreturn             , "lreturn"             , "b"    , NULL    , T_LONG   , -2, true);
336104476Ssam  def(_freturn             , "freturn"             , "b"    , NULL    , T_FLOAT  , -1, true);
337104476Ssam  def(_dreturn             , "dreturn"             , "b"    , NULL    , T_DOUBLE , -2, true);
338104476Ssam  def(_areturn             , "areturn"             , "b"    , NULL    , T_OBJECT , -1, true);
339104476Ssam  def(_return              , "return"              , "b"    , NULL    , T_VOID   ,  0, true);
340104476Ssam  def(_getstatic           , "getstatic"           , "bjj"  , NULL    , T_ILLEGAL,  1, true );
341108587Ssam  def(_putstatic           , "putstatic"           , "bjj"  , NULL    , T_ILLEGAL, -1, true );
342104476Ssam  def(_getfield            , "getfield"            , "bjj"  , NULL    , T_ILLEGAL,  0, true );
343104476Ssam  def(_putfield            , "putfield"            , "bjj"  , NULL    , T_ILLEGAL, -2, true );
344104476Ssam  def(_invokevirtual       , "invokevirtual"       , "bjj"  , NULL    , T_ILLEGAL, -1, true);
345104476Ssam  def(_invokespecial       , "invokespecial"       , "bjj"  , NULL    , T_ILLEGAL, -1, true);
346104476Ssam  def(_invokestatic        , "invokestatic"        , "bjj"  , NULL    , T_ILLEGAL,  0, true);
347104476Ssam  def(_invokeinterface     , "invokeinterface"     , "bjj__", NULL    , T_ILLEGAL, -1, true);
348104476Ssam  def(_xxxunusedxxx        , "xxxunusedxxx"        , NULL   , NULL    , T_VOID   ,  0, false);
349104476Ssam  def(_new                 , "new"                 , "bii"  , NULL    , T_OBJECT ,  1, true );
350104476Ssam  def(_newarray            , "newarray"            , "bc"   , NULL    , T_OBJECT ,  0, true );
351104476Ssam  def(_anewarray           , "anewarray"           , "bii"  , NULL    , T_OBJECT ,  0, true );
352104476Ssam  def(_arraylength         , "arraylength"         , "b"    , NULL    , T_VOID   ,  0, true );
353104476Ssam  def(_athrow              , "athrow"              , "b"    , NULL    , T_VOID   , -1, true );
354104476Ssam  def(_checkcast           , "checkcast"           , "bii"  , NULL    , T_OBJECT ,  0, true );
355104476Ssam  def(_instanceof          , "instanceof"          , "bii"  , NULL    , T_INT    ,  0, true );
356104476Ssam  def(_monitorenter        , "monitorenter"        , "b"    , NULL    , T_VOID   , -1, true );
357104476Ssam  def(_monitorexit         , "monitorexit"         , "b"    , NULL    , T_VOID   , -1, true );
358104476Ssam  def(_wide                , "wide"                , ""     , NULL    , T_VOID   ,  0, false);
359104476Ssam  def(_multianewarray      , "multianewarray"      , "biic" , NULL    , T_OBJECT ,  1, true );
360104476Ssam  def(_ifnull              , "ifnull"              , "boo"  , NULL    , T_VOID   , -1, false);
361104476Ssam  def(_ifnonnull           , "ifnonnull"           , "boo"  , NULL    , T_VOID   , -1, false);
362104476Ssam  def(_goto_w              , "goto_w"              , "boooo", NULL    , T_VOID   ,  0, false);
363167755Ssam  def(_jsr_w               , "jsr_w"               , "boooo", NULL    , T_INT    ,  0, false);
364104476Ssam  def(_breakpoint          , "breakpoint"          , ""     , NULL    , T_VOID   ,  0, true);
365104476Ssam
366104476Ssam  //  JVM bytecodes
367104476Ssam  //  bytecode               bytecode name           format   wide f.   result tp  stk traps  std code
368104476Ssam
369158824Spjd  def(_fast_agetfield      , "fast_agetfield"      , "bjj"  , NULL    , T_OBJECT ,  0, true , _getfield       );
370116924Ssam  def(_fast_bgetfield      , "fast_bgetfield"      , "bjj"  , NULL    , T_INT    ,  0, true , _getfield       );
371116924Ssam  def(_fast_cgetfield      , "fast_cgetfield"      , "bjj"  , NULL    , T_CHAR   ,  0, true , _getfield       );
372116924Ssam  def(_fast_dgetfield      , "fast_dgetfield"      , "bjj"  , NULL    , T_DOUBLE ,  0, true , _getfield       );
373116924Ssam  def(_fast_fgetfield      , "fast_fgetfield"      , "bjj"  , NULL    , T_FLOAT  ,  0, true , _getfield       );
374116924Ssam  def(_fast_igetfield      , "fast_igetfield"      , "bjj"  , NULL    , T_INT    ,  0, true , _getfield       );
375116924Ssam  def(_fast_lgetfield      , "fast_lgetfield"      , "bjj"  , NULL    , T_LONG   ,  0, true , _getfield       );
376167755Ssam  def(_fast_sgetfield      , "fast_sgetfield"      , "bjj"  , NULL    , T_SHORT  ,  0, true , _getfield       );
377167755Ssam
378116924Ssam  def(_fast_aputfield      , "fast_aputfield"      , "bjj"  , NULL    , T_OBJECT ,  0, true , _putfield       );
379116924Ssam  def(_fast_bputfield      , "fast_bputfield"      , "bjj"  , NULL    , T_INT    ,  0, true , _putfield       );
380104476Ssam  def(_fast_cputfield      , "fast_cputfield"      , "bjj"  , NULL    , T_CHAR   ,  0, true , _putfield       );
381104476Ssam  def(_fast_dputfield      , "fast_dputfield"      , "bjj"  , NULL    , T_DOUBLE ,  0, true , _putfield       );
382104476Ssam  def(_fast_fputfield      , "fast_fputfield"      , "bjj"  , NULL    , T_FLOAT  ,  0, true , _putfield       );
383104476Ssam  def(_fast_iputfield      , "fast_iputfield"      , "bjj"  , NULL    , T_INT    ,  0, true , _putfield       );
384167755Ssam  def(_fast_lputfield      , "fast_lputfield"      , "bjj"  , NULL    , T_LONG   ,  0, true , _putfield       );
385167755Ssam  def(_fast_sputfield      , "fast_sputfield"      , "bjj"  , NULL    , T_SHORT  ,  0, true , _putfield       );
386167755Ssam
387167755Ssam  def(_fast_aload_0        , "fast_aload_0"        , "b"    , NULL    , T_OBJECT ,  1, true , _aload_0        );
388167755Ssam  def(_fast_iaccess_0      , "fast_iaccess_0"      , "b_jj" , NULL    , T_INT    ,  1, true , _aload_0        );
389167755Ssam  def(_fast_aaccess_0      , "fast_aaccess_0"      , "b_jj" , NULL    , T_OBJECT ,  1, true , _aload_0        );
390167755Ssam  def(_fast_faccess_0      , "fast_faccess_0"      , "b_jj" , NULL    , T_OBJECT ,  1, true , _aload_0        );
391104476Ssam
392167755Ssam  def(_fast_iload          , "fast_iload"          , "bi"   , NULL    , T_INT    ,  1, false, _iload);
393167755Ssam  def(_fast_iload2         , "fast_iload2"         , "bi_i" , NULL    , T_INT    ,  2, false, _iload);
394104476Ssam  def(_fast_icaload        , "fast_icaload"        , "bi_"  , NULL    , T_INT    ,  0, false, _iload);
395104476Ssam
396104476Ssam  // Faster method invocation.
397104476Ssam  def(_fast_invokevfinal   , "fast_invokevfinal"   , "bjj"  , NULL    , T_ILLEGAL, -1, true, _invokevirtual   );
398104476Ssam
399104476Ssam  def(_fast_linearswitch   , "fast_linearswitch"   , ""     , NULL    , T_VOID   , -1, false, _lookupswitch   );
400104476Ssam  def(_fast_binaryswitch   , "fast_binaryswitch"   , ""     , NULL    , T_VOID   , -1, false, _lookupswitch   );
401104476Ssam
402104476Ssam  def(_return_register_finalizer , "return_register_finalizer" , "b"    , NULL    , T_VOID   ,  0, true, _return);
403104476Ssam
404104476Ssam  def(_shouldnotreachhere  , "_shouldnotreachhere" , "b"    , NULL    , T_VOID   ,  0, false);
405104476Ssam
406104476Ssam  // platform specific JVM bytecodes
407104476Ssam  pd_initialize();
408104476Ssam
409104476Ssam  // compare can_trap information for each bytecode with the
410104476Ssam  // can_trap information for the corresponding base bytecode
411104476Ssam  // (if a rewritten bytecode can trap, so must the base bytecode)
412104476Ssam  #ifdef ASSERT
413104476Ssam    { for (int i = 0; i < number_of_codes; i++) {
414104476Ssam        if (is_defined(i)) {
415104476Ssam          Code code = cast(i);
416104476Ssam          Code java = java_code(code);
417104476Ssam          if (can_trap(code) && !can_trap(java)) fatal2("%s can trap => %s can trap, too", name(code), name(java));
418104476Ssam        }
419104476Ssam      }
420104476Ssam    }
421104476Ssam  #endif
422158699Spjd
423158703Spjd  // initialization successful
424159241Spjd  _is_initialized = true;
425159241Spjd}
426159241Spjd
427159241Spjd
428159241Spjdvoid bytecodes_init() {
429159241Spjd  Bytecodes::initialize();
430159241Spjd}
431104476Ssam
432104476Ssam// Restore optimization
433#ifdef _M_AMD64
434#pragma optimize ("", on)
435#endif
436