src/share/vm/interpreter/bytecodes.cpp

changeset 0
f90c822e73f8
child 1
2d8a650513c2
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/interpreter/bytecodes.cpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,575 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "precompiled.hpp"
    1.29 +#include "interpreter/bytecodes.hpp"
    1.30 +#include "memory/resourceArea.hpp"
    1.31 +#include "oops/method.hpp"
    1.32 +#ifdef TARGET_ARCH_x86
    1.33 +# include "bytes_x86.hpp"
    1.34 +#endif
    1.35 +#ifdef TARGET_ARCH_sparc
    1.36 +# include "bytes_sparc.hpp"
    1.37 +#endif
    1.38 +#ifdef TARGET_ARCH_zero
    1.39 +# include "bytes_zero.hpp"
    1.40 +#endif
    1.41 +#ifdef TARGET_ARCH_arm
    1.42 +# include "bytes_arm.hpp"
    1.43 +#endif
    1.44 +#ifdef TARGET_ARCH_ppc
    1.45 +# include "bytes_ppc.hpp"
    1.46 +#endif
    1.47 +
    1.48 +
    1.49 +#if defined(WIN32) && (defined(_MSC_VER) && (_MSC_VER < 1600))
    1.50 +// Windows AMD64 Compiler Hangs compiling this file
    1.51 +// unless optimization is off
    1.52 +#ifdef _M_AMD64
    1.53 +#pragma optimize ("", off)
    1.54 +#endif
    1.55 +#endif
    1.56 +
    1.57 +
    1.58 +bool            Bytecodes::_is_initialized = false;
    1.59 +const char*     Bytecodes::_name          [Bytecodes::number_of_codes];
    1.60 +BasicType       Bytecodes::_result_type   [Bytecodes::number_of_codes];
    1.61 +s_char          Bytecodes::_depth         [Bytecodes::number_of_codes];
    1.62 +u_char          Bytecodes::_lengths       [Bytecodes::number_of_codes];
    1.63 +Bytecodes::Code Bytecodes::_java_code     [Bytecodes::number_of_codes];
    1.64 +u_short         Bytecodes::_flags         [(1<<BitsPerByte)*2];
    1.65 +
    1.66 +#ifdef ASSERT
    1.67 +bool Bytecodes::check_method(const Method* method, address bcp) {
    1.68 +  return method->contains(bcp);
    1.69 +}
    1.70 +#endif
    1.71 +
    1.72 +bool Bytecodes::check_must_rewrite(Bytecodes::Code code) {
    1.73 +  assert(can_rewrite(code), "post-check only");
    1.74 +
    1.75 +  // Some codes are conditionally rewriting.  Look closely at them.
    1.76 +  switch (code) {
    1.77 +  case Bytecodes::_aload_0:
    1.78 +    // Even if RewriteFrequentPairs is turned on,
    1.79 +    // the _aload_0 code might delay its rewrite until
    1.80 +    // a following _getfield rewrites itself.
    1.81 +    return false;
    1.82 +
    1.83 +  case Bytecodes::_lookupswitch:
    1.84 +    return false;  // the rewrite is not done by the interpreter
    1.85 +
    1.86 +  case Bytecodes::_new:
    1.87 +    // (Could actually look at the class here, but the profit would be small.)
    1.88 +    return false;  // the rewrite is not always done
    1.89 +  }
    1.90 +
    1.91 +  // No other special cases.
    1.92 +  return true;
    1.93 +}
    1.94 +
    1.95 +Bytecodes::Code Bytecodes::code_at(Method* method, int bci) {
    1.96 +  return code_at(method, method->bcp_from(bci));
    1.97 +}
    1.98 +
    1.99 +Bytecodes::Code Bytecodes::non_breakpoint_code_at(const Method* method, address bcp) {
   1.100 +  assert(method != NULL, "must have the method for breakpoint conversion");
   1.101 +  assert(method->contains(bcp), "must be valid bcp in method");
   1.102 +  return method->orig_bytecode_at(method->bci_from(bcp));
   1.103 +}
   1.104 +
   1.105 +int Bytecodes::special_length_at(Bytecodes::Code code, address bcp, address end) {
   1.106 +  switch (code) {
   1.107 +  case _wide:
   1.108 +    if (end != NULL && bcp + 1 >= end) {
   1.109 +      return -1; // don't read past end of code buffer
   1.110 +    }
   1.111 +    return wide_length_for(cast(*(bcp + 1)));
   1.112 +  case _tableswitch:
   1.113 +    { address aligned_bcp = (address)round_to((intptr_t)bcp + 1, jintSize);
   1.114 +      if (end != NULL && aligned_bcp + 3*jintSize >= end) {
   1.115 +        return -1; // don't read past end of code buffer
   1.116 +      }
   1.117 +      jlong lo = (jint)Bytes::get_Java_u4(aligned_bcp + 1*jintSize);
   1.118 +      jlong hi = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize);
   1.119 +      jlong len = (aligned_bcp - bcp) + (3 + hi - lo + 1)*jintSize;
   1.120 +      // only return len if it can be represented as a positive int;
   1.121 +      // return -1 otherwise
   1.122 +      return (len > 0 && len == (int)len) ? len : -1;
   1.123 +    }
   1.124 +
   1.125 +  case _lookupswitch:      // fall through
   1.126 +  case _fast_binaryswitch: // fall through
   1.127 +  case _fast_linearswitch:
   1.128 +    { address aligned_bcp = (address)round_to((intptr_t)bcp + 1, jintSize);
   1.129 +      if (end != NULL && aligned_bcp + 2*jintSize >= end) {
   1.130 +        return -1; // don't read past end of code buffer
   1.131 +      }
   1.132 +      jlong npairs = (jint)Bytes::get_Java_u4(aligned_bcp + jintSize);
   1.133 +      jlong len = (aligned_bcp - bcp) + (2 + 2*npairs)*jintSize;
   1.134 +      // only return len if it can be represented as a positive int;
   1.135 +      // return -1 otherwise
   1.136 +      return (len > 0 && len == (int)len) ? len : -1;
   1.137 +    }
   1.138 +  }
   1.139 +  // Note: Length functions must return <=0 for invalid bytecodes.
   1.140 +  return 0;
   1.141 +}
   1.142 +
   1.143 +// At a breakpoint instruction, this returns the breakpoint's length,
   1.144 +// otherwise, it's the same as special_length_at().  This is used by
   1.145 +// the RawByteCodeStream, which wants to see the actual bytecode
   1.146 +// values (including breakpoint).  RawByteCodeStream is used by the
   1.147 +// verifier when reading in bytecode to verify.  Other mechanisms that
   1.148 +// run at runtime (such as generateOopMaps) need to iterate over the code
   1.149 +// and don't expect to see breakpoints: they want to see the instruction
   1.150 +// which was replaced so that they can get the correct length and find
   1.151 +// the next bytecode.
   1.152 +//
   1.153 +// 'end' indicates the end of the code buffer, which we should not try to read
   1.154 +// past.
   1.155 +int Bytecodes::raw_special_length_at(address bcp, address end) {
   1.156 +  Code code = code_or_bp_at(bcp);
   1.157 +  if (code == _breakpoint) {
   1.158 +    return 1;
   1.159 +  } else {
   1.160 +    return special_length_at(code, bcp, end);
   1.161 +  }
   1.162 +}
   1.163 +
   1.164 +
   1.165 +
   1.166 +void Bytecodes::def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap) {
   1.167 +  def(code, name, format, wide_format, result_type, depth, can_trap, code);
   1.168 +}
   1.169 +
   1.170 +
   1.171 +void 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) {
   1.172 +  assert(wide_format == NULL || format != NULL, "short form must exist if there's a wide form");
   1.173 +  int len  = (format      != NULL ? (int) strlen(format)      : 0);
   1.174 +  int wlen = (wide_format != NULL ? (int) strlen(wide_format) : 0);
   1.175 +  _name          [code] = name;
   1.176 +  _result_type   [code] = result_type;
   1.177 +  _depth         [code] = depth;
   1.178 +  _lengths       [code] = (wlen << 4) | (len & 0xF);
   1.179 +  _java_code     [code] = java_code;
   1.180 +  int bc_flags = 0;
   1.181 +  if (can_trap)           bc_flags |= _bc_can_trap;
   1.182 +  if (java_code != code)  bc_flags |= _bc_can_rewrite;
   1.183 +  _flags[(u1)code+0*(1<<BitsPerByte)] = compute_flags(format,      bc_flags);
   1.184 +  _flags[(u1)code+1*(1<<BitsPerByte)] = compute_flags(wide_format, bc_flags);
   1.185 +  assert(is_defined(code)      == (format != NULL),      "");
   1.186 +  assert(wide_is_defined(code) == (wide_format != NULL), "");
   1.187 +  assert(length_for(code)      == len, "");
   1.188 +  assert(wide_length_for(code) == wlen, "");
   1.189 +}
   1.190 +
   1.191 +
   1.192 +// Format strings interpretation:
   1.193 +//
   1.194 +// b: bytecode
   1.195 +// c: signed constant, Java byte-ordering
   1.196 +// i: unsigned local index, Java byte-ordering (I = native byte ordering)
   1.197 +// j: unsigned CP cache index, Java byte-ordering (J = native byte ordering)
   1.198 +// k: unsigned CP index, Java byte-ordering
   1.199 +// o: branch offset, Java byte-ordering
   1.200 +// _: unused/ignored
   1.201 +// w: wide bytecode
   1.202 +//
   1.203 +// Note: The format strings are used for 2 purposes:
   1.204 +//       1. to specify the length of the bytecode
   1.205 +//          (= number of characters in format string)
   1.206 +//       2. to derive bytecode format flags (_fmt_has_k, etc.)
   1.207 +//
   1.208 +// Note: For bytecodes with variable length, the format string is the empty string.
   1.209 +
   1.210 +int Bytecodes::compute_flags(const char* format, int more_flags) {
   1.211 +  if (format == NULL)  return 0;  // not even more_flags
   1.212 +  int flags = more_flags;
   1.213 +  const char* fp = format;
   1.214 +  switch (*fp) {
   1.215 +  case '\0':
   1.216 +    flags |= _fmt_not_simple; // but variable
   1.217 +    break;
   1.218 +  case 'b':
   1.219 +    flags |= _fmt_not_variable;  // but simple
   1.220 +    ++fp;  // skip 'b'
   1.221 +    break;
   1.222 +  case 'w':
   1.223 +    flags |= _fmt_not_variable | _fmt_not_simple;
   1.224 +    ++fp;  // skip 'w'
   1.225 +    guarantee(*fp == 'b', "wide format must start with 'wb'");
   1.226 +    ++fp;  // skip 'b'
   1.227 +    break;
   1.228 +  }
   1.229 +
   1.230 +  int has_nbo = 0, has_jbo = 0, has_size = 0;
   1.231 +  for (;;) {
   1.232 +    int this_flag = 0;
   1.233 +    char fc = *fp++;
   1.234 +    switch (fc) {
   1.235 +    case '\0':  // end of string
   1.236 +      assert(flags == (jchar)flags, "change _format_flags");
   1.237 +      return flags;
   1.238 +
   1.239 +    case '_': continue;         // ignore these
   1.240 +
   1.241 +    case 'j': this_flag = _fmt_has_j; has_jbo = 1; break;
   1.242 +    case 'k': this_flag = _fmt_has_k; has_jbo = 1; break;
   1.243 +    case 'i': this_flag = _fmt_has_i; has_jbo = 1; break;
   1.244 +    case 'c': this_flag = _fmt_has_c; has_jbo = 1; break;
   1.245 +    case 'o': this_flag = _fmt_has_o; has_jbo = 1; break;
   1.246 +
   1.247 +    // uppercase versions mark native byte order (from Rewriter)
   1.248 +    // actually, only the 'J' case happens currently
   1.249 +    case 'J': this_flag = _fmt_has_j; has_nbo = 1; break;
   1.250 +    case 'K': this_flag = _fmt_has_k; has_nbo = 1; break;
   1.251 +    case 'I': this_flag = _fmt_has_i; has_nbo = 1; break;
   1.252 +    case 'C': this_flag = _fmt_has_c; has_nbo = 1; break;
   1.253 +    case 'O': this_flag = _fmt_has_o; has_nbo = 1; break;
   1.254 +    default:  guarantee(false, "bad char in format");
   1.255 +    }
   1.256 +
   1.257 +    flags |= this_flag;
   1.258 +
   1.259 +    guarantee(!(has_jbo && has_nbo), "mixed byte orders in format");
   1.260 +    if (has_nbo)
   1.261 +      flags |= _fmt_has_nbo;
   1.262 +
   1.263 +    int this_size = 1;
   1.264 +    if (*fp == fc) {
   1.265 +      // advance beyond run of the same characters
   1.266 +      this_size = 2;
   1.267 +      while (*++fp == fc)  this_size++;
   1.268 +      switch (this_size) {
   1.269 +      case 2: flags |= _fmt_has_u2; break;
   1.270 +      case 4: flags |= _fmt_has_u4; break;
   1.271 +      default: guarantee(false, "bad rep count in format");
   1.272 +      }
   1.273 +    }
   1.274 +    guarantee(has_size == 0 ||                     // no field yet
   1.275 +              this_size == has_size ||             // same size
   1.276 +              this_size < has_size && *fp == '\0', // last field can be short
   1.277 +              "mixed field sizes in format");
   1.278 +    has_size = this_size;
   1.279 +  }
   1.280 +}
   1.281 +
   1.282 +void Bytecodes::initialize() {
   1.283 +  if (_is_initialized) return;
   1.284 +  assert(number_of_codes <= 256, "too many bytecodes");
   1.285 +
   1.286 +  // initialize bytecode tables - didn't use static array initializers
   1.287 +  // (such as {}) so we can do additional consistency checks and init-
   1.288 +  // code is independent of actual bytecode numbering.
   1.289 +  //
   1.290 +  // Note 1: NULL for the format string means the bytecode doesn't exist
   1.291 +  //         in that form.
   1.292 +  //
   1.293 +  // Note 2: The result type is T_ILLEGAL for bytecodes where the top of stack
   1.294 +  //         type after execution is not only determined by the bytecode itself.
   1.295 +
   1.296 +  //  Java bytecodes
   1.297 +  //  bytecode               bytecode name           format   wide f.   result tp  stk traps
   1.298 +  def(_nop                 , "nop"                 , "b"    , NULL    , T_VOID   ,  0, false);
   1.299 +  def(_aconst_null         , "aconst_null"         , "b"    , NULL    , T_OBJECT ,  1, false);
   1.300 +  def(_iconst_m1           , "iconst_m1"           , "b"    , NULL    , T_INT    ,  1, false);
   1.301 +  def(_iconst_0            , "iconst_0"            , "b"    , NULL    , T_INT    ,  1, false);
   1.302 +  def(_iconst_1            , "iconst_1"            , "b"    , NULL    , T_INT    ,  1, false);
   1.303 +  def(_iconst_2            , "iconst_2"            , "b"    , NULL    , T_INT    ,  1, false);
   1.304 +  def(_iconst_3            , "iconst_3"            , "b"    , NULL    , T_INT    ,  1, false);
   1.305 +  def(_iconst_4            , "iconst_4"            , "b"    , NULL    , T_INT    ,  1, false);
   1.306 +  def(_iconst_5            , "iconst_5"            , "b"    , NULL    , T_INT    ,  1, false);
   1.307 +  def(_lconst_0            , "lconst_0"            , "b"    , NULL    , T_LONG   ,  2, false);
   1.308 +  def(_lconst_1            , "lconst_1"            , "b"    , NULL    , T_LONG   ,  2, false);
   1.309 +  def(_fconst_0            , "fconst_0"            , "b"    , NULL    , T_FLOAT  ,  1, false);
   1.310 +  def(_fconst_1            , "fconst_1"            , "b"    , NULL    , T_FLOAT  ,  1, false);
   1.311 +  def(_fconst_2            , "fconst_2"            , "b"    , NULL    , T_FLOAT  ,  1, false);
   1.312 +  def(_dconst_0            , "dconst_0"            , "b"    , NULL    , T_DOUBLE ,  2, false);
   1.313 +  def(_dconst_1            , "dconst_1"            , "b"    , NULL    , T_DOUBLE ,  2, false);
   1.314 +  def(_bipush              , "bipush"              , "bc"   , NULL    , T_INT    ,  1, false);
   1.315 +  def(_sipush              , "sipush"              , "bcc"  , NULL    , T_INT    ,  1, false);
   1.316 +  def(_ldc                 , "ldc"                 , "bk"   , NULL    , T_ILLEGAL,  1, true );
   1.317 +  def(_ldc_w               , "ldc_w"               , "bkk"  , NULL    , T_ILLEGAL,  1, true );
   1.318 +  def(_ldc2_w              , "ldc2_w"              , "bkk"  , NULL    , T_ILLEGAL,  2, true );
   1.319 +  def(_iload               , "iload"               , "bi"   , "wbii"  , T_INT    ,  1, false);
   1.320 +  def(_lload               , "lload"               , "bi"   , "wbii"  , T_LONG   ,  2, false);
   1.321 +  def(_fload               , "fload"               , "bi"   , "wbii"  , T_FLOAT  ,  1, false);
   1.322 +  def(_dload               , "dload"               , "bi"   , "wbii"  , T_DOUBLE ,  2, false);
   1.323 +  def(_aload               , "aload"               , "bi"   , "wbii"  , T_OBJECT ,  1, false);
   1.324 +  def(_iload_0             , "iload_0"             , "b"    , NULL    , T_INT    ,  1, false);
   1.325 +  def(_iload_1             , "iload_1"             , "b"    , NULL    , T_INT    ,  1, false);
   1.326 +  def(_iload_2             , "iload_2"             , "b"    , NULL    , T_INT    ,  1, false);
   1.327 +  def(_iload_3             , "iload_3"             , "b"    , NULL    , T_INT    ,  1, false);
   1.328 +  def(_lload_0             , "lload_0"             , "b"    , NULL    , T_LONG   ,  2, false);
   1.329 +  def(_lload_1             , "lload_1"             , "b"    , NULL    , T_LONG   ,  2, false);
   1.330 +  def(_lload_2             , "lload_2"             , "b"    , NULL    , T_LONG   ,  2, false);
   1.331 +  def(_lload_3             , "lload_3"             , "b"    , NULL    , T_LONG   ,  2, false);
   1.332 +  def(_fload_0             , "fload_0"             , "b"    , NULL    , T_FLOAT  ,  1, false);
   1.333 +  def(_fload_1             , "fload_1"             , "b"    , NULL    , T_FLOAT  ,  1, false);
   1.334 +  def(_fload_2             , "fload_2"             , "b"    , NULL    , T_FLOAT  ,  1, false);
   1.335 +  def(_fload_3             , "fload_3"             , "b"    , NULL    , T_FLOAT  ,  1, false);
   1.336 +  def(_dload_0             , "dload_0"             , "b"    , NULL    , T_DOUBLE ,  2, false);
   1.337 +  def(_dload_1             , "dload_1"             , "b"    , NULL    , T_DOUBLE ,  2, false);
   1.338 +  def(_dload_2             , "dload_2"             , "b"    , NULL    , T_DOUBLE ,  2, false);
   1.339 +  def(_dload_3             , "dload_3"             , "b"    , NULL    , T_DOUBLE ,  2, false);
   1.340 +  def(_aload_0             , "aload_0"             , "b"    , NULL    , T_OBJECT ,  1, true ); // rewriting in interpreter
   1.341 +  def(_aload_1             , "aload_1"             , "b"    , NULL    , T_OBJECT ,  1, false);
   1.342 +  def(_aload_2             , "aload_2"             , "b"    , NULL    , T_OBJECT ,  1, false);
   1.343 +  def(_aload_3             , "aload_3"             , "b"    , NULL    , T_OBJECT ,  1, false);
   1.344 +  def(_iaload              , "iaload"              , "b"    , NULL    , T_INT    , -1, true );
   1.345 +  def(_laload              , "laload"              , "b"    , NULL    , T_LONG   ,  0, true );
   1.346 +  def(_faload              , "faload"              , "b"    , NULL    , T_FLOAT  , -1, true );
   1.347 +  def(_daload              , "daload"              , "b"    , NULL    , T_DOUBLE ,  0, true );
   1.348 +  def(_aaload              , "aaload"              , "b"    , NULL    , T_OBJECT , -1, true );
   1.349 +  def(_baload              , "baload"              , "b"    , NULL    , T_INT    , -1, true );
   1.350 +  def(_caload              , "caload"              , "b"    , NULL    , T_INT    , -1, true );
   1.351 +  def(_saload              , "saload"              , "b"    , NULL    , T_INT    , -1, true );
   1.352 +  def(_istore              , "istore"              , "bi"   , "wbii"  , T_VOID   , -1, false);
   1.353 +  def(_lstore              , "lstore"              , "bi"   , "wbii"  , T_VOID   , -2, false);
   1.354 +  def(_fstore              , "fstore"              , "bi"   , "wbii"  , T_VOID   , -1, false);
   1.355 +  def(_dstore              , "dstore"              , "bi"   , "wbii"  , T_VOID   , -2, false);
   1.356 +  def(_astore              , "astore"              , "bi"   , "wbii"  , T_VOID   , -1, false);
   1.357 +  def(_istore_0            , "istore_0"            , "b"    , NULL    , T_VOID   , -1, false);
   1.358 +  def(_istore_1            , "istore_1"            , "b"    , NULL    , T_VOID   , -1, false);
   1.359 +  def(_istore_2            , "istore_2"            , "b"    , NULL    , T_VOID   , -1, false);
   1.360 +  def(_istore_3            , "istore_3"            , "b"    , NULL    , T_VOID   , -1, false);
   1.361 +  def(_lstore_0            , "lstore_0"            , "b"    , NULL    , T_VOID   , -2, false);
   1.362 +  def(_lstore_1            , "lstore_1"            , "b"    , NULL    , T_VOID   , -2, false);
   1.363 +  def(_lstore_2            , "lstore_2"            , "b"    , NULL    , T_VOID   , -2, false);
   1.364 +  def(_lstore_3            , "lstore_3"            , "b"    , NULL    , T_VOID   , -2, false);
   1.365 +  def(_fstore_0            , "fstore_0"            , "b"    , NULL    , T_VOID   , -1, false);
   1.366 +  def(_fstore_1            , "fstore_1"            , "b"    , NULL    , T_VOID   , -1, false);
   1.367 +  def(_fstore_2            , "fstore_2"            , "b"    , NULL    , T_VOID   , -1, false);
   1.368 +  def(_fstore_3            , "fstore_3"            , "b"    , NULL    , T_VOID   , -1, false);
   1.369 +  def(_dstore_0            , "dstore_0"            , "b"    , NULL    , T_VOID   , -2, false);
   1.370 +  def(_dstore_1            , "dstore_1"            , "b"    , NULL    , T_VOID   , -2, false);
   1.371 +  def(_dstore_2            , "dstore_2"            , "b"    , NULL    , T_VOID   , -2, false);
   1.372 +  def(_dstore_3            , "dstore_3"            , "b"    , NULL    , T_VOID   , -2, false);
   1.373 +  def(_astore_0            , "astore_0"            , "b"    , NULL    , T_VOID   , -1, false);
   1.374 +  def(_astore_1            , "astore_1"            , "b"    , NULL    , T_VOID   , -1, false);
   1.375 +  def(_astore_2            , "astore_2"            , "b"    , NULL    , T_VOID   , -1, false);
   1.376 +  def(_astore_3            , "astore_3"            , "b"    , NULL    , T_VOID   , -1, false);
   1.377 +  def(_iastore             , "iastore"             , "b"    , NULL    , T_VOID   , -3, true );
   1.378 +  def(_lastore             , "lastore"             , "b"    , NULL    , T_VOID   , -4, true );
   1.379 +  def(_fastore             , "fastore"             , "b"    , NULL    , T_VOID   , -3, true );
   1.380 +  def(_dastore             , "dastore"             , "b"    , NULL    , T_VOID   , -4, true );
   1.381 +  def(_aastore             , "aastore"             , "b"    , NULL    , T_VOID   , -3, true );
   1.382 +  def(_bastore             , "bastore"             , "b"    , NULL    , T_VOID   , -3, true );
   1.383 +  def(_castore             , "castore"             , "b"    , NULL    , T_VOID   , -3, true );
   1.384 +  def(_sastore             , "sastore"             , "b"    , NULL    , T_VOID   , -3, true );
   1.385 +  def(_pop                 , "pop"                 , "b"    , NULL    , T_VOID   , -1, false);
   1.386 +  def(_pop2                , "pop2"                , "b"    , NULL    , T_VOID   , -2, false);
   1.387 +  def(_dup                 , "dup"                 , "b"    , NULL    , T_VOID   ,  1, false);
   1.388 +  def(_dup_x1              , "dup_x1"              , "b"    , NULL    , T_VOID   ,  1, false);
   1.389 +  def(_dup_x2              , "dup_x2"              , "b"    , NULL    , T_VOID   ,  1, false);
   1.390 +  def(_dup2                , "dup2"                , "b"    , NULL    , T_VOID   ,  2, false);
   1.391 +  def(_dup2_x1             , "dup2_x1"             , "b"    , NULL    , T_VOID   ,  2, false);
   1.392 +  def(_dup2_x2             , "dup2_x2"             , "b"    , NULL    , T_VOID   ,  2, false);
   1.393 +  def(_swap                , "swap"                , "b"    , NULL    , T_VOID   ,  0, false);
   1.394 +  def(_iadd                , "iadd"                , "b"    , NULL    , T_INT    , -1, false);
   1.395 +  def(_ladd                , "ladd"                , "b"    , NULL    , T_LONG   , -2, false);
   1.396 +  def(_fadd                , "fadd"                , "b"    , NULL    , T_FLOAT  , -1, false);
   1.397 +  def(_dadd                , "dadd"                , "b"    , NULL    , T_DOUBLE , -2, false);
   1.398 +  def(_isub                , "isub"                , "b"    , NULL    , T_INT    , -1, false);
   1.399 +  def(_lsub                , "lsub"                , "b"    , NULL    , T_LONG   , -2, false);
   1.400 +  def(_fsub                , "fsub"                , "b"    , NULL    , T_FLOAT  , -1, false);
   1.401 +  def(_dsub                , "dsub"                , "b"    , NULL    , T_DOUBLE , -2, false);
   1.402 +  def(_imul                , "imul"                , "b"    , NULL    , T_INT    , -1, false);
   1.403 +  def(_lmul                , "lmul"                , "b"    , NULL    , T_LONG   , -2, false);
   1.404 +  def(_fmul                , "fmul"                , "b"    , NULL    , T_FLOAT  , -1, false);
   1.405 +  def(_dmul                , "dmul"                , "b"    , NULL    , T_DOUBLE , -2, false);
   1.406 +  def(_idiv                , "idiv"                , "b"    , NULL    , T_INT    , -1, true );
   1.407 +  def(_ldiv                , "ldiv"                , "b"    , NULL    , T_LONG   , -2, true );
   1.408 +  def(_fdiv                , "fdiv"                , "b"    , NULL    , T_FLOAT  , -1, false);
   1.409 +  def(_ddiv                , "ddiv"                , "b"    , NULL    , T_DOUBLE , -2, false);
   1.410 +  def(_irem                , "irem"                , "b"    , NULL    , T_INT    , -1, true );
   1.411 +  def(_lrem                , "lrem"                , "b"    , NULL    , T_LONG   , -2, true );
   1.412 +  def(_frem                , "frem"                , "b"    , NULL    , T_FLOAT  , -1, false);
   1.413 +  def(_drem                , "drem"                , "b"    , NULL    , T_DOUBLE , -2, false);
   1.414 +  def(_ineg                , "ineg"                , "b"    , NULL    , T_INT    ,  0, false);
   1.415 +  def(_lneg                , "lneg"                , "b"    , NULL    , T_LONG   ,  0, false);
   1.416 +  def(_fneg                , "fneg"                , "b"    , NULL    , T_FLOAT  ,  0, false);
   1.417 +  def(_dneg                , "dneg"                , "b"    , NULL    , T_DOUBLE ,  0, false);
   1.418 +  def(_ishl                , "ishl"                , "b"    , NULL    , T_INT    , -1, false);
   1.419 +  def(_lshl                , "lshl"                , "b"    , NULL    , T_LONG   , -1, false);
   1.420 +  def(_ishr                , "ishr"                , "b"    , NULL    , T_INT    , -1, false);
   1.421 +  def(_lshr                , "lshr"                , "b"    , NULL    , T_LONG   , -1, false);
   1.422 +  def(_iushr               , "iushr"               , "b"    , NULL    , T_INT    , -1, false);
   1.423 +  def(_lushr               , "lushr"               , "b"    , NULL    , T_LONG   , -1, false);
   1.424 +  def(_iand                , "iand"                , "b"    , NULL    , T_INT    , -1, false);
   1.425 +  def(_land                , "land"                , "b"    , NULL    , T_LONG   , -2, false);
   1.426 +  def(_ior                 , "ior"                 , "b"    , NULL    , T_INT    , -1, false);
   1.427 +  def(_lor                 , "lor"                 , "b"    , NULL    , T_LONG   , -2, false);
   1.428 +  def(_ixor                , "ixor"                , "b"    , NULL    , T_INT    , -1, false);
   1.429 +  def(_lxor                , "lxor"                , "b"    , NULL    , T_LONG   , -2, false);
   1.430 +  def(_iinc                , "iinc"                , "bic"  , "wbiicc", T_VOID   ,  0, false);
   1.431 +  def(_i2l                 , "i2l"                 , "b"    , NULL    , T_LONG   ,  1, false);
   1.432 +  def(_i2f                 , "i2f"                 , "b"    , NULL    , T_FLOAT  ,  0, false);
   1.433 +  def(_i2d                 , "i2d"                 , "b"    , NULL    , T_DOUBLE ,  1, false);
   1.434 +  def(_l2i                 , "l2i"                 , "b"    , NULL    , T_INT    , -1, false);
   1.435 +  def(_l2f                 , "l2f"                 , "b"    , NULL    , T_FLOAT  , -1, false);
   1.436 +  def(_l2d                 , "l2d"                 , "b"    , NULL    , T_DOUBLE ,  0, false);
   1.437 +  def(_f2i                 , "f2i"                 , "b"    , NULL    , T_INT    ,  0, false);
   1.438 +  def(_f2l                 , "f2l"                 , "b"    , NULL    , T_LONG   ,  1, false);
   1.439 +  def(_f2d                 , "f2d"                 , "b"    , NULL    , T_DOUBLE ,  1, false);
   1.440 +  def(_d2i                 , "d2i"                 , "b"    , NULL    , T_INT    , -1, false);
   1.441 +  def(_d2l                 , "d2l"                 , "b"    , NULL    , T_LONG   ,  0, false);
   1.442 +  def(_d2f                 , "d2f"                 , "b"    , NULL    , T_FLOAT  , -1, false);
   1.443 +  def(_i2b                 , "i2b"                 , "b"    , NULL    , T_BYTE   ,  0, false);
   1.444 +  def(_i2c                 , "i2c"                 , "b"    , NULL    , T_CHAR   ,  0, false);
   1.445 +  def(_i2s                 , "i2s"                 , "b"    , NULL    , T_SHORT  ,  0, false);
   1.446 +  def(_lcmp                , "lcmp"                , "b"    , NULL    , T_VOID   , -3, false);
   1.447 +  def(_fcmpl               , "fcmpl"               , "b"    , NULL    , T_VOID   , -1, false);
   1.448 +  def(_fcmpg               , "fcmpg"               , "b"    , NULL    , T_VOID   , -1, false);
   1.449 +  def(_dcmpl               , "dcmpl"               , "b"    , NULL    , T_VOID   , -3, false);
   1.450 +  def(_dcmpg               , "dcmpg"               , "b"    , NULL    , T_VOID   , -3, false);
   1.451 +  def(_ifeq                , "ifeq"                , "boo"  , NULL    , T_VOID   , -1, false);
   1.452 +  def(_ifne                , "ifne"                , "boo"  , NULL    , T_VOID   , -1, false);
   1.453 +  def(_iflt                , "iflt"                , "boo"  , NULL    , T_VOID   , -1, false);
   1.454 +  def(_ifge                , "ifge"                , "boo"  , NULL    , T_VOID   , -1, false);
   1.455 +  def(_ifgt                , "ifgt"                , "boo"  , NULL    , T_VOID   , -1, false);
   1.456 +  def(_ifle                , "ifle"                , "boo"  , NULL    , T_VOID   , -1, false);
   1.457 +  def(_if_icmpeq           , "if_icmpeq"           , "boo"  , NULL    , T_VOID   , -2, false);
   1.458 +  def(_if_icmpne           , "if_icmpne"           , "boo"  , NULL    , T_VOID   , -2, false);
   1.459 +  def(_if_icmplt           , "if_icmplt"           , "boo"  , NULL    , T_VOID   , -2, false);
   1.460 +  def(_if_icmpge           , "if_icmpge"           , "boo"  , NULL    , T_VOID   , -2, false);
   1.461 +  def(_if_icmpgt           , "if_icmpgt"           , "boo"  , NULL    , T_VOID   , -2, false);
   1.462 +  def(_if_icmple           , "if_icmple"           , "boo"  , NULL    , T_VOID   , -2, false);
   1.463 +  def(_if_acmpeq           , "if_acmpeq"           , "boo"  , NULL    , T_VOID   , -2, false);
   1.464 +  def(_if_acmpne           , "if_acmpne"           , "boo"  , NULL    , T_VOID   , -2, false);
   1.465 +  def(_goto                , "goto"                , "boo"  , NULL    , T_VOID   ,  0, false);
   1.466 +  def(_jsr                 , "jsr"                 , "boo"  , NULL    , T_INT    ,  0, false);
   1.467 +  def(_ret                 , "ret"                 , "bi"   , "wbii"  , T_VOID   ,  0, false);
   1.468 +  def(_tableswitch         , "tableswitch"         , ""     , NULL    , T_VOID   , -1, false); // may have backward branches
   1.469 +  def(_lookupswitch        , "lookupswitch"        , ""     , NULL    , T_VOID   , -1, false); // rewriting in interpreter
   1.470 +  def(_ireturn             , "ireturn"             , "b"    , NULL    , T_INT    , -1, true);
   1.471 +  def(_lreturn             , "lreturn"             , "b"    , NULL    , T_LONG   , -2, true);
   1.472 +  def(_freturn             , "freturn"             , "b"    , NULL    , T_FLOAT  , -1, true);
   1.473 +  def(_dreturn             , "dreturn"             , "b"    , NULL    , T_DOUBLE , -2, true);
   1.474 +  def(_areturn             , "areturn"             , "b"    , NULL    , T_OBJECT , -1, true);
   1.475 +  def(_return              , "return"              , "b"    , NULL    , T_VOID   ,  0, true);
   1.476 +  def(_getstatic           , "getstatic"           , "bJJ"  , NULL    , T_ILLEGAL,  1, true );
   1.477 +  def(_putstatic           , "putstatic"           , "bJJ"  , NULL    , T_ILLEGAL, -1, true );
   1.478 +  def(_getfield            , "getfield"            , "bJJ"  , NULL    , T_ILLEGAL,  0, true );
   1.479 +  def(_putfield            , "putfield"            , "bJJ"  , NULL    , T_ILLEGAL, -2, true );
   1.480 +  def(_invokevirtual       , "invokevirtual"       , "bJJ"  , NULL    , T_ILLEGAL, -1, true);
   1.481 +  def(_invokespecial       , "invokespecial"       , "bJJ"  , NULL    , T_ILLEGAL, -1, true);
   1.482 +  def(_invokestatic        , "invokestatic"        , "bJJ"  , NULL    , T_ILLEGAL,  0, true);
   1.483 +  def(_invokeinterface     , "invokeinterface"     , "bJJ__", NULL    , T_ILLEGAL, -1, true);
   1.484 +  def(_invokedynamic       , "invokedynamic"       , "bJJJJ", NULL    , T_ILLEGAL,  0, true );
   1.485 +  def(_new                 , "new"                 , "bkk"  , NULL    , T_OBJECT ,  1, true );
   1.486 +  def(_newarray            , "newarray"            , "bc"   , NULL    , T_OBJECT ,  0, true );
   1.487 +  def(_anewarray           , "anewarray"           , "bkk"  , NULL    , T_OBJECT ,  0, true );
   1.488 +  def(_arraylength         , "arraylength"         , "b"    , NULL    , T_VOID   ,  0, true );
   1.489 +  def(_athrow              , "athrow"              , "b"    , NULL    , T_VOID   , -1, true );
   1.490 +  def(_checkcast           , "checkcast"           , "bkk"  , NULL    , T_OBJECT ,  0, true );
   1.491 +  def(_instanceof          , "instanceof"          , "bkk"  , NULL    , T_INT    ,  0, true );
   1.492 +  def(_monitorenter        , "monitorenter"        , "b"    , NULL    , T_VOID   , -1, true );
   1.493 +  def(_monitorexit         , "monitorexit"         , "b"    , NULL    , T_VOID   , -1, true );
   1.494 +  def(_wide                , "wide"                , ""     , NULL    , T_VOID   ,  0, false);
   1.495 +  def(_multianewarray      , "multianewarray"      , "bkkc" , NULL    , T_OBJECT ,  1, true );
   1.496 +  def(_ifnull              , "ifnull"              , "boo"  , NULL    , T_VOID   , -1, false);
   1.497 +  def(_ifnonnull           , "ifnonnull"           , "boo"  , NULL    , T_VOID   , -1, false);
   1.498 +  def(_goto_w              , "goto_w"              , "boooo", NULL    , T_VOID   ,  0, false);
   1.499 +  def(_jsr_w               , "jsr_w"               , "boooo", NULL    , T_INT    ,  0, false);
   1.500 +  def(_breakpoint          , "breakpoint"          , ""     , NULL    , T_VOID   ,  0, true);
   1.501 +
   1.502 +  //  JVM bytecodes
   1.503 +  //  bytecode               bytecode name           format   wide f.   result tp  stk traps  std code
   1.504 +
   1.505 +  def(_fast_agetfield      , "fast_agetfield"      , "bJJ"  , NULL    , T_OBJECT ,  0, true , _getfield       );
   1.506 +  def(_fast_bgetfield      , "fast_bgetfield"      , "bJJ"  , NULL    , T_INT    ,  0, true , _getfield       );
   1.507 +  def(_fast_cgetfield      , "fast_cgetfield"      , "bJJ"  , NULL    , T_CHAR   ,  0, true , _getfield       );
   1.508 +  def(_fast_dgetfield      , "fast_dgetfield"      , "bJJ"  , NULL    , T_DOUBLE ,  0, true , _getfield       );
   1.509 +  def(_fast_fgetfield      , "fast_fgetfield"      , "bJJ"  , NULL    , T_FLOAT  ,  0, true , _getfield       );
   1.510 +  def(_fast_igetfield      , "fast_igetfield"      , "bJJ"  , NULL    , T_INT    ,  0, true , _getfield       );
   1.511 +  def(_fast_lgetfield      , "fast_lgetfield"      , "bJJ"  , NULL    , T_LONG   ,  0, true , _getfield       );
   1.512 +  def(_fast_sgetfield      , "fast_sgetfield"      , "bJJ"  , NULL    , T_SHORT  ,  0, true , _getfield       );
   1.513 +
   1.514 +  def(_fast_aputfield      , "fast_aputfield"      , "bJJ"  , NULL    , T_OBJECT ,  0, true , _putfield       );
   1.515 +  def(_fast_bputfield      , "fast_bputfield"      , "bJJ"  , NULL    , T_INT    ,  0, true , _putfield       );
   1.516 +  def(_fast_cputfield      , "fast_cputfield"      , "bJJ"  , NULL    , T_CHAR   ,  0, true , _putfield       );
   1.517 +  def(_fast_dputfield      , "fast_dputfield"      , "bJJ"  , NULL    , T_DOUBLE ,  0, true , _putfield       );
   1.518 +  def(_fast_fputfield      , "fast_fputfield"      , "bJJ"  , NULL    , T_FLOAT  ,  0, true , _putfield       );
   1.519 +  def(_fast_iputfield      , "fast_iputfield"      , "bJJ"  , NULL    , T_INT    ,  0, true , _putfield       );
   1.520 +  def(_fast_lputfield      , "fast_lputfield"      , "bJJ"  , NULL    , T_LONG   ,  0, true , _putfield       );
   1.521 +  def(_fast_sputfield      , "fast_sputfield"      , "bJJ"  , NULL    , T_SHORT  ,  0, true , _putfield       );
   1.522 +
   1.523 +  def(_fast_aload_0        , "fast_aload_0"        , "b"    , NULL    , T_OBJECT ,  1, true , _aload_0        );
   1.524 +  def(_fast_iaccess_0      , "fast_iaccess_0"      , "b_JJ" , NULL    , T_INT    ,  1, true , _aload_0        );
   1.525 +  def(_fast_aaccess_0      , "fast_aaccess_0"      , "b_JJ" , NULL    , T_OBJECT ,  1, true , _aload_0        );
   1.526 +  def(_fast_faccess_0      , "fast_faccess_0"      , "b_JJ" , NULL    , T_OBJECT ,  1, true , _aload_0        );
   1.527 +
   1.528 +  def(_fast_iload          , "fast_iload"          , "bi"   , NULL    , T_INT    ,  1, false, _iload);
   1.529 +  def(_fast_iload2         , "fast_iload2"         , "bi_i" , NULL    , T_INT    ,  2, false, _iload);
   1.530 +  def(_fast_icaload        , "fast_icaload"        , "bi_"  , NULL    , T_INT    ,  0, false, _iload);
   1.531 +
   1.532 +  // Faster method invocation.
   1.533 +  def(_fast_invokevfinal   , "fast_invokevfinal"   , "bJJ"  , NULL    , T_ILLEGAL, -1, true, _invokevirtual   );
   1.534 +
   1.535 +  def(_fast_linearswitch   , "fast_linearswitch"   , ""     , NULL    , T_VOID   , -1, false, _lookupswitch   );
   1.536 +  def(_fast_binaryswitch   , "fast_binaryswitch"   , ""     , NULL    , T_VOID   , -1, false, _lookupswitch   );
   1.537 +
   1.538 +  def(_return_register_finalizer , "return_register_finalizer" , "b"    , NULL    , T_VOID   ,  0, true, _return);
   1.539 +
   1.540 +  def(_invokehandle        , "invokehandle"        , "bJJ"  , NULL    , T_ILLEGAL, -1, true, _invokevirtual   );
   1.541 +
   1.542 +  def(_fast_aldc           , "fast_aldc"           , "bj"   , NULL    , T_OBJECT,   1, true,  _ldc   );
   1.543 +  def(_fast_aldc_w         , "fast_aldc_w"         , "bJJ"  , NULL    , T_OBJECT,   1, true,  _ldc_w );
   1.544 +
   1.545 +  def(_shouldnotreachhere  , "_shouldnotreachhere" , "b"    , NULL    , T_VOID   ,  0, false);
   1.546 +
   1.547 +  // platform specific JVM bytecodes
   1.548 +  pd_initialize();
   1.549 +
   1.550 +  // compare can_trap information for each bytecode with the
   1.551 +  // can_trap information for the corresponding base bytecode
   1.552 +  // (if a rewritten bytecode can trap, so must the base bytecode)
   1.553 +  #ifdef ASSERT
   1.554 +    { for (int i = 0; i < number_of_codes; i++) {
   1.555 +        if (is_defined(i)) {
   1.556 +          Code code = cast(i);
   1.557 +          Code java = java_code(code);
   1.558 +          if (can_trap(code) && !can_trap(java))
   1.559 +            fatal(err_msg("%s can trap => %s can trap, too", name(code),
   1.560 +                          name(java)));
   1.561 +        }
   1.562 +      }
   1.563 +    }
   1.564 +  #endif
   1.565 +
   1.566 +  // initialization successful
   1.567 +  _is_initialized = true;
   1.568 +}
   1.569 +
   1.570 +
   1.571 +void bytecodes_init() {
   1.572 +  Bytecodes::initialize();
   1.573 +}
   1.574 +
   1.575 +// Restore optimization
   1.576 +#ifdef _M_AMD64
   1.577 +#pragma optimize ("", on)
   1.578 +#endif

mercurial