src/share/vm/interpreter/bytecodes.cpp

Thu, 13 Jan 2011 22:15:41 -0800

author
never
date
Thu, 13 Jan 2011 22:15:41 -0800
changeset 2462
8012aa3ccede
parent 2314
f95d63e2154a
child 2508
b92c45f2bc75
permissions
-rw-r--r--

4926272: methodOopDesc::method_from_bcp is unsafe
Reviewed-by: coleenp, jrose, kvn, dcubed

duke@435 1 /*
never@2462 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "interpreter/bytecodes.hpp"
stefank@2314 27 #include "memory/resourceArea.hpp"
stefank@2314 28 #include "oops/methodOop.hpp"
stefank@2314 29 #ifdef TARGET_ARCH_x86
stefank@2314 30 # include "bytes_x86.hpp"
stefank@2314 31 #endif
stefank@2314 32 #ifdef TARGET_ARCH_sparc
stefank@2314 33 # include "bytes_sparc.hpp"
stefank@2314 34 #endif
stefank@2314 35 #ifdef TARGET_ARCH_zero
stefank@2314 36 # include "bytes_zero.hpp"
stefank@2314 37 #endif
duke@435 38
duke@435 39
prr@1881 40 #if defined(WIN32) && (defined(_MSC_VER) && (_MSC_VER < 1600))
duke@435 41 // Windows AMD64 Compiler Hangs compiling this file
duke@435 42 // unless optimization is off
duke@435 43 #ifdef _M_AMD64
duke@435 44 #pragma optimize ("", off)
duke@435 45 #endif
prr@1881 46 #endif
duke@435 47
duke@435 48
duke@435 49 bool Bytecodes::_is_initialized = false;
duke@435 50 const char* Bytecodes::_name [Bytecodes::number_of_codes];
duke@435 51 BasicType Bytecodes::_result_type [Bytecodes::number_of_codes];
duke@435 52 s_char Bytecodes::_depth [Bytecodes::number_of_codes];
jrose@1920 53 u_char Bytecodes::_lengths [Bytecodes::number_of_codes];
duke@435 54 Bytecodes::Code Bytecodes::_java_code [Bytecodes::number_of_codes];
jrose@1920 55 u_short Bytecodes::_flags [(1<<BitsPerByte)*2];
duke@435 56
never@2462 57 #ifdef ASSERT
never@2462 58 bool Bytecodes::check_method(const methodOopDesc* method, address bcp) {
never@2462 59 return method->contains(bcp);
never@2462 60 }
never@2462 61 #endif
never@2462 62
never@2462 63 bool Bytecodes::check_must_rewrite(Bytecodes::Code code) {
never@2462 64 assert(can_rewrite(code), "post-check only");
never@2462 65
never@2462 66 // Some codes are conditionally rewriting. Look closely at them.
never@2462 67 switch (code) {
never@2462 68 case Bytecodes::_aload_0:
never@2462 69 // Even if RewriteFrequentPairs is turned on,
never@2462 70 // the _aload_0 code might delay its rewrite until
never@2462 71 // a following _getfield rewrites itself.
never@2462 72 return false;
never@2462 73
never@2462 74 case Bytecodes::_lookupswitch:
never@2462 75 return false; // the rewrite is not done by the interpreter
never@2462 76
never@2462 77 case Bytecodes::_new:
never@2462 78 // (Could actually look at the class here, but the profit would be small.)
never@2462 79 return false; // the rewrite is not always done
never@2462 80 }
never@2462 81
never@2462 82 // No other special cases.
never@2462 83 return true;
never@2462 84 }
duke@435 85
duke@435 86 Bytecodes::Code Bytecodes::code_at(methodOop method, int bci) {
never@2462 87 return code_at(method, method->bcp_from(bci));
duke@435 88 }
duke@435 89
never@2462 90 Bytecodes::Code Bytecodes::non_breakpoint_code_at(const methodOopDesc* method, address bcp) {
never@2462 91 assert(method != NULL, "must have the method for breakpoint conversion");
never@2462 92 assert(method->contains(bcp), "must be valid bcp in method");
duke@435 93 return method->orig_bytecode_at(method->bci_from(bcp));
duke@435 94 }
duke@435 95
never@2462 96 int Bytecodes::special_length_at(Bytecodes::Code code, address bcp, address end) {
duke@435 97 switch (code) {
duke@435 98 case _wide:
kamg@848 99 if (end != NULL && bcp + 1 >= end) {
kamg@848 100 return -1; // don't read past end of code buffer
kamg@848 101 }
duke@435 102 return wide_length_for(cast(*(bcp + 1)));
duke@435 103 case _tableswitch:
duke@435 104 { address aligned_bcp = (address)round_to((intptr_t)bcp + 1, jintSize);
kamg@848 105 if (end != NULL && aligned_bcp + 3*jintSize >= end) {
kamg@848 106 return -1; // don't read past end of code buffer
kamg@848 107 }
duke@435 108 jlong lo = (jint)Bytes::get_Java_u4(aligned_bcp + 1*jintSize);
duke@435 109 jlong hi = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize);
duke@435 110 jlong len = (aligned_bcp - bcp) + (3 + hi - lo + 1)*jintSize;
duke@435 111 // only return len if it can be represented as a positive int;
duke@435 112 // return -1 otherwise
duke@435 113 return (len > 0 && len == (int)len) ? len : -1;
duke@435 114 }
duke@435 115
duke@435 116 case _lookupswitch: // fall through
duke@435 117 case _fast_binaryswitch: // fall through
duke@435 118 case _fast_linearswitch:
duke@435 119 { address aligned_bcp = (address)round_to((intptr_t)bcp + 1, jintSize);
kamg@848 120 if (end != NULL && aligned_bcp + 2*jintSize >= end) {
kamg@848 121 return -1; // don't read past end of code buffer
kamg@848 122 }
duke@435 123 jlong npairs = (jint)Bytes::get_Java_u4(aligned_bcp + jintSize);
duke@435 124 jlong len = (aligned_bcp - bcp) + (2 + 2*npairs)*jintSize;
duke@435 125 // only return len if it can be represented as a positive int;
duke@435 126 // return -1 otherwise
duke@435 127 return (len > 0 && len == (int)len) ? len : -1;
duke@435 128 }
duke@435 129 }
jrose@1925 130 // Note: Length functions must return <=0 for invalid bytecodes.
duke@435 131 return 0;
duke@435 132 }
duke@435 133
duke@435 134 // At a breakpoint instruction, this returns the breakpoint's length,
duke@435 135 // otherwise, it's the same as special_length_at(). This is used by
duke@435 136 // the RawByteCodeStream, which wants to see the actual bytecode
duke@435 137 // values (including breakpoint). RawByteCodeStream is used by the
duke@435 138 // verifier when reading in bytecode to verify. Other mechanisms that
duke@435 139 // run at runtime (such as generateOopMaps) need to iterate over the code
duke@435 140 // and don't expect to see breakpoints: they want to see the instruction
kamg@848 141 // which was replaced so that they can get the correct length and find
duke@435 142 // the next bytecode.
kamg@848 143 //
kamg@848 144 // 'end' indicates the end of the code buffer, which we should not try to read
kamg@848 145 // past.
kamg@848 146 int Bytecodes::raw_special_length_at(address bcp, address end) {
duke@435 147 Code code = code_or_bp_at(bcp);
duke@435 148 if (code == _breakpoint) {
duke@435 149 return 1;
duke@435 150 } else {
never@2462 151 return special_length_at(code, bcp, end);
duke@435 152 }
duke@435 153 }
duke@435 154
duke@435 155
duke@435 156
duke@435 157 void Bytecodes::def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap) {
duke@435 158 def(code, name, format, wide_format, result_type, depth, can_trap, code);
duke@435 159 }
duke@435 160
duke@435 161
duke@435 162 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) {
duke@435 163 assert(wide_format == NULL || format != NULL, "short form must exist if there's a wide form");
jrose@1920 164 int len = (format != NULL ? (int) strlen(format) : 0);
jrose@1920 165 int wlen = (wide_format != NULL ? (int) strlen(wide_format) : 0);
duke@435 166 _name [code] = name;
duke@435 167 _result_type [code] = result_type;
duke@435 168 _depth [code] = depth;
jrose@1920 169 _lengths [code] = (wlen << 4) | (len & 0xF);
duke@435 170 _java_code [code] = java_code;
jrose@1920 171 int bc_flags = 0;
jrose@1920 172 if (can_trap) bc_flags |= _bc_can_trap;
jrose@1920 173 if (java_code != code) bc_flags |= _bc_can_rewrite;
jrose@1920 174 _flags[(u1)code+0*(1<<BitsPerByte)] = compute_flags(format, bc_flags);
jrose@1920 175 _flags[(u1)code+1*(1<<BitsPerByte)] = compute_flags(wide_format, bc_flags);
jrose@1920 176 assert(is_defined(code) == (format != NULL), "");
jrose@1920 177 assert(wide_is_defined(code) == (wide_format != NULL), "");
jrose@1920 178 assert(length_for(code) == len, "");
jrose@1920 179 assert(wide_length_for(code) == wlen, "");
duke@435 180 }
duke@435 181
duke@435 182
duke@435 183 // Format strings interpretation:
duke@435 184 //
duke@435 185 // b: bytecode
duke@435 186 // c: signed constant, Java byte-ordering
jrose@1920 187 // i: unsigned local index, Java byte-ordering (I = native byte ordering)
jrose@1920 188 // j: unsigned CP cache index, Java byte-ordering (J = native byte ordering)
jrose@1920 189 // k: unsigned CP index, Java byte-ordering
jrose@1920 190 // o: branch offset, Java byte-ordering
duke@435 191 // _: unused/ignored
duke@435 192 // w: wide bytecode
duke@435 193 //
jrose@1920 194 // Note: The format strings are used for 2 purposes:
duke@435 195 // 1. to specify the length of the bytecode
duke@435 196 // (= number of characters in format string)
jrose@1920 197 // 2. to derive bytecode format flags (_fmt_has_k, etc.)
duke@435 198 //
duke@435 199 // Note: For bytecodes with variable length, the format string is the empty string.
duke@435 200
jrose@1920 201 int Bytecodes::compute_flags(const char* format, int more_flags) {
jrose@1920 202 if (format == NULL) return 0; // not even more_flags
jrose@1920 203 int flags = more_flags;
jrose@1920 204 const char* fp = format;
jrose@1920 205 switch (*fp) {
jrose@1920 206 case '\0':
jrose@1920 207 flags |= _fmt_not_simple; // but variable
jrose@1920 208 break;
jrose@1920 209 case 'b':
jrose@1920 210 flags |= _fmt_not_variable; // but simple
jrose@1920 211 ++fp; // skip 'b'
jrose@1920 212 break;
jrose@1920 213 case 'w':
jrose@1920 214 flags |= _fmt_not_variable | _fmt_not_simple;
jrose@1920 215 ++fp; // skip 'w'
jrose@1920 216 guarantee(*fp == 'b', "wide format must start with 'wb'");
jrose@1920 217 ++fp; // skip 'b'
jrose@1920 218 break;
jrose@1920 219 }
jrose@1920 220
jrose@1920 221 int has_nbo = 0, has_jbo = 0, has_size = 0;
jrose@1920 222 for (;;) {
jrose@1920 223 int this_flag = 0;
jrose@1920 224 char fc = *fp++;
jrose@1920 225 switch (fc) {
jrose@1920 226 case '\0': // end of string
jrose@1920 227 assert(flags == (jchar)flags, "change _format_flags");
jrose@1920 228 return flags;
jrose@1920 229
jrose@1920 230 case '_': continue; // ignore these
jrose@1920 231
jrose@1920 232 case 'j': this_flag = _fmt_has_j; has_jbo = 1; break;
jrose@1920 233 case 'k': this_flag = _fmt_has_k; has_jbo = 1; break;
jrose@1920 234 case 'i': this_flag = _fmt_has_i; has_jbo = 1; break;
jrose@1920 235 case 'c': this_flag = _fmt_has_c; has_jbo = 1; break;
jrose@1920 236 case 'o': this_flag = _fmt_has_o; has_jbo = 1; break;
jrose@1920 237
jrose@1920 238 // uppercase versions mark native byte order (from Rewriter)
jrose@1920 239 // actually, only the 'J' case happens currently
jrose@1920 240 case 'J': this_flag = _fmt_has_j; has_nbo = 1; break;
jrose@1920 241 case 'K': this_flag = _fmt_has_k; has_nbo = 1; break;
jrose@1920 242 case 'I': this_flag = _fmt_has_i; has_nbo = 1; break;
jrose@1920 243 case 'C': this_flag = _fmt_has_c; has_nbo = 1; break;
jrose@1920 244 case 'O': this_flag = _fmt_has_o; has_nbo = 1; break;
jrose@1920 245 default: guarantee(false, "bad char in format");
jrose@1920 246 }
jrose@1920 247
jrose@1920 248 flags |= this_flag;
jrose@1920 249
jrose@1920 250 guarantee(!(has_jbo && has_nbo), "mixed byte orders in format");
jrose@1920 251 if (has_nbo)
jrose@1920 252 flags |= _fmt_has_nbo;
jrose@1920 253
jrose@1920 254 int this_size = 1;
jrose@1920 255 if (*fp == fc) {
jrose@1920 256 // advance beyond run of the same characters
jrose@1920 257 this_size = 2;
jrose@1920 258 while (*++fp == fc) this_size++;
jrose@1920 259 switch (this_size) {
jrose@1920 260 case 2: flags |= _fmt_has_u2; break;
jrose@1920 261 case 4: flags |= _fmt_has_u4; break;
jrose@1920 262 default: guarantee(false, "bad rep count in format");
jrose@1920 263 }
jrose@1920 264 }
jrose@1920 265 guarantee(has_size == 0 || // no field yet
jrose@1920 266 this_size == has_size || // same size
jrose@1920 267 this_size < has_size && *fp == '\0', // last field can be short
jrose@1920 268 "mixed field sizes in format");
jrose@1920 269 has_size = this_size;
jrose@1920 270 }
jrose@1920 271 }
jrose@1920 272
duke@435 273 void Bytecodes::initialize() {
duke@435 274 if (_is_initialized) return;
duke@435 275 assert(number_of_codes <= 256, "too many bytecodes");
duke@435 276
duke@435 277 // initialize bytecode tables - didn't use static array initializers
duke@435 278 // (such as {}) so we can do additional consistency checks and init-
duke@435 279 // code is independent of actual bytecode numbering.
duke@435 280 //
duke@435 281 // Note 1: NULL for the format string means the bytecode doesn't exist
duke@435 282 // in that form.
duke@435 283 //
duke@435 284 // Note 2: The result type is T_ILLEGAL for bytecodes where the top of stack
duke@435 285 // type after execution is not only determined by the bytecode itself.
duke@435 286
duke@435 287 // Java bytecodes
duke@435 288 // bytecode bytecode name format wide f. result tp stk traps
duke@435 289 def(_nop , "nop" , "b" , NULL , T_VOID , 0, false);
duke@435 290 def(_aconst_null , "aconst_null" , "b" , NULL , T_OBJECT , 1, false);
duke@435 291 def(_iconst_m1 , "iconst_m1" , "b" , NULL , T_INT , 1, false);
duke@435 292 def(_iconst_0 , "iconst_0" , "b" , NULL , T_INT , 1, false);
duke@435 293 def(_iconst_1 , "iconst_1" , "b" , NULL , T_INT , 1, false);
duke@435 294 def(_iconst_2 , "iconst_2" , "b" , NULL , T_INT , 1, false);
duke@435 295 def(_iconst_3 , "iconst_3" , "b" , NULL , T_INT , 1, false);
duke@435 296 def(_iconst_4 , "iconst_4" , "b" , NULL , T_INT , 1, false);
duke@435 297 def(_iconst_5 , "iconst_5" , "b" , NULL , T_INT , 1, false);
duke@435 298 def(_lconst_0 , "lconst_0" , "b" , NULL , T_LONG , 2, false);
duke@435 299 def(_lconst_1 , "lconst_1" , "b" , NULL , T_LONG , 2, false);
duke@435 300 def(_fconst_0 , "fconst_0" , "b" , NULL , T_FLOAT , 1, false);
duke@435 301 def(_fconst_1 , "fconst_1" , "b" , NULL , T_FLOAT , 1, false);
duke@435 302 def(_fconst_2 , "fconst_2" , "b" , NULL , T_FLOAT , 1, false);
duke@435 303 def(_dconst_0 , "dconst_0" , "b" , NULL , T_DOUBLE , 2, false);
duke@435 304 def(_dconst_1 , "dconst_1" , "b" , NULL , T_DOUBLE , 2, false);
duke@435 305 def(_bipush , "bipush" , "bc" , NULL , T_INT , 1, false);
duke@435 306 def(_sipush , "sipush" , "bcc" , NULL , T_INT , 1, false);
jrose@1920 307 def(_ldc , "ldc" , "bk" , NULL , T_ILLEGAL, 1, true );
jrose@1920 308 def(_ldc_w , "ldc_w" , "bkk" , NULL , T_ILLEGAL, 1, true );
jrose@1920 309 def(_ldc2_w , "ldc2_w" , "bkk" , NULL , T_ILLEGAL, 2, true );
duke@435 310 def(_iload , "iload" , "bi" , "wbii" , T_INT , 1, false);
duke@435 311 def(_lload , "lload" , "bi" , "wbii" , T_LONG , 2, false);
duke@435 312 def(_fload , "fload" , "bi" , "wbii" , T_FLOAT , 1, false);
duke@435 313 def(_dload , "dload" , "bi" , "wbii" , T_DOUBLE , 2, false);
duke@435 314 def(_aload , "aload" , "bi" , "wbii" , T_OBJECT , 1, false);
duke@435 315 def(_iload_0 , "iload_0" , "b" , NULL , T_INT , 1, false);
duke@435 316 def(_iload_1 , "iload_1" , "b" , NULL , T_INT , 1, false);
duke@435 317 def(_iload_2 , "iload_2" , "b" , NULL , T_INT , 1, false);
duke@435 318 def(_iload_3 , "iload_3" , "b" , NULL , T_INT , 1, false);
duke@435 319 def(_lload_0 , "lload_0" , "b" , NULL , T_LONG , 2, false);
duke@435 320 def(_lload_1 , "lload_1" , "b" , NULL , T_LONG , 2, false);
duke@435 321 def(_lload_2 , "lload_2" , "b" , NULL , T_LONG , 2, false);
duke@435 322 def(_lload_3 , "lload_3" , "b" , NULL , T_LONG , 2, false);
duke@435 323 def(_fload_0 , "fload_0" , "b" , NULL , T_FLOAT , 1, false);
duke@435 324 def(_fload_1 , "fload_1" , "b" , NULL , T_FLOAT , 1, false);
duke@435 325 def(_fload_2 , "fload_2" , "b" , NULL , T_FLOAT , 1, false);
duke@435 326 def(_fload_3 , "fload_3" , "b" , NULL , T_FLOAT , 1, false);
duke@435 327 def(_dload_0 , "dload_0" , "b" , NULL , T_DOUBLE , 2, false);
duke@435 328 def(_dload_1 , "dload_1" , "b" , NULL , T_DOUBLE , 2, false);
duke@435 329 def(_dload_2 , "dload_2" , "b" , NULL , T_DOUBLE , 2, false);
duke@435 330 def(_dload_3 , "dload_3" , "b" , NULL , T_DOUBLE , 2, false);
duke@435 331 def(_aload_0 , "aload_0" , "b" , NULL , T_OBJECT , 1, true ); // rewriting in interpreter
duke@435 332 def(_aload_1 , "aload_1" , "b" , NULL , T_OBJECT , 1, false);
duke@435 333 def(_aload_2 , "aload_2" , "b" , NULL , T_OBJECT , 1, false);
duke@435 334 def(_aload_3 , "aload_3" , "b" , NULL , T_OBJECT , 1, false);
duke@435 335 def(_iaload , "iaload" , "b" , NULL , T_INT , -1, true );
duke@435 336 def(_laload , "laload" , "b" , NULL , T_LONG , 0, true );
duke@435 337 def(_faload , "faload" , "b" , NULL , T_FLOAT , -1, true );
duke@435 338 def(_daload , "daload" , "b" , NULL , T_DOUBLE , 0, true );
duke@435 339 def(_aaload , "aaload" , "b" , NULL , T_OBJECT , -1, true );
duke@435 340 def(_baload , "baload" , "b" , NULL , T_INT , -1, true );
duke@435 341 def(_caload , "caload" , "b" , NULL , T_INT , -1, true );
duke@435 342 def(_saload , "saload" , "b" , NULL , T_INT , -1, true );
duke@435 343 def(_istore , "istore" , "bi" , "wbii" , T_VOID , -1, false);
duke@435 344 def(_lstore , "lstore" , "bi" , "wbii" , T_VOID , -2, false);
duke@435 345 def(_fstore , "fstore" , "bi" , "wbii" , T_VOID , -1, false);
duke@435 346 def(_dstore , "dstore" , "bi" , "wbii" , T_VOID , -2, false);
duke@435 347 def(_astore , "astore" , "bi" , "wbii" , T_VOID , -1, false);
duke@435 348 def(_istore_0 , "istore_0" , "b" , NULL , T_VOID , -1, false);
duke@435 349 def(_istore_1 , "istore_1" , "b" , NULL , T_VOID , -1, false);
duke@435 350 def(_istore_2 , "istore_2" , "b" , NULL , T_VOID , -1, false);
duke@435 351 def(_istore_3 , "istore_3" , "b" , NULL , T_VOID , -1, false);
duke@435 352 def(_lstore_0 , "lstore_0" , "b" , NULL , T_VOID , -2, false);
duke@435 353 def(_lstore_1 , "lstore_1" , "b" , NULL , T_VOID , -2, false);
duke@435 354 def(_lstore_2 , "lstore_2" , "b" , NULL , T_VOID , -2, false);
duke@435 355 def(_lstore_3 , "lstore_3" , "b" , NULL , T_VOID , -2, false);
duke@435 356 def(_fstore_0 , "fstore_0" , "b" , NULL , T_VOID , -1, false);
duke@435 357 def(_fstore_1 , "fstore_1" , "b" , NULL , T_VOID , -1, false);
duke@435 358 def(_fstore_2 , "fstore_2" , "b" , NULL , T_VOID , -1, false);
duke@435 359 def(_fstore_3 , "fstore_3" , "b" , NULL , T_VOID , -1, false);
duke@435 360 def(_dstore_0 , "dstore_0" , "b" , NULL , T_VOID , -2, false);
duke@435 361 def(_dstore_1 , "dstore_1" , "b" , NULL , T_VOID , -2, false);
duke@435 362 def(_dstore_2 , "dstore_2" , "b" , NULL , T_VOID , -2, false);
duke@435 363 def(_dstore_3 , "dstore_3" , "b" , NULL , T_VOID , -2, false);
duke@435 364 def(_astore_0 , "astore_0" , "b" , NULL , T_VOID , -1, false);
duke@435 365 def(_astore_1 , "astore_1" , "b" , NULL , T_VOID , -1, false);
duke@435 366 def(_astore_2 , "astore_2" , "b" , NULL , T_VOID , -1, false);
duke@435 367 def(_astore_3 , "astore_3" , "b" , NULL , T_VOID , -1, false);
duke@435 368 def(_iastore , "iastore" , "b" , NULL , T_VOID , -3, true );
duke@435 369 def(_lastore , "lastore" , "b" , NULL , T_VOID , -4, true );
duke@435 370 def(_fastore , "fastore" , "b" , NULL , T_VOID , -3, true );
duke@435 371 def(_dastore , "dastore" , "b" , NULL , T_VOID , -4, true );
duke@435 372 def(_aastore , "aastore" , "b" , NULL , T_VOID , -3, true );
duke@435 373 def(_bastore , "bastore" , "b" , NULL , T_VOID , -3, true );
duke@435 374 def(_castore , "castore" , "b" , NULL , T_VOID , -3, true );
duke@435 375 def(_sastore , "sastore" , "b" , NULL , T_VOID , -3, true );
duke@435 376 def(_pop , "pop" , "b" , NULL , T_VOID , -1, false);
duke@435 377 def(_pop2 , "pop2" , "b" , NULL , T_VOID , -2, false);
duke@435 378 def(_dup , "dup" , "b" , NULL , T_VOID , 1, false);
duke@435 379 def(_dup_x1 , "dup_x1" , "b" , NULL , T_VOID , 1, false);
duke@435 380 def(_dup_x2 , "dup_x2" , "b" , NULL , T_VOID , 1, false);
duke@435 381 def(_dup2 , "dup2" , "b" , NULL , T_VOID , 2, false);
duke@435 382 def(_dup2_x1 , "dup2_x1" , "b" , NULL , T_VOID , 2, false);
duke@435 383 def(_dup2_x2 , "dup2_x2" , "b" , NULL , T_VOID , 2, false);
duke@435 384 def(_swap , "swap" , "b" , NULL , T_VOID , 0, false);
duke@435 385 def(_iadd , "iadd" , "b" , NULL , T_INT , -1, false);
duke@435 386 def(_ladd , "ladd" , "b" , NULL , T_LONG , -2, false);
duke@435 387 def(_fadd , "fadd" , "b" , NULL , T_FLOAT , -1, false);
duke@435 388 def(_dadd , "dadd" , "b" , NULL , T_DOUBLE , -2, false);
duke@435 389 def(_isub , "isub" , "b" , NULL , T_INT , -1, false);
duke@435 390 def(_lsub , "lsub" , "b" , NULL , T_LONG , -2, false);
duke@435 391 def(_fsub , "fsub" , "b" , NULL , T_FLOAT , -1, false);
duke@435 392 def(_dsub , "dsub" , "b" , NULL , T_DOUBLE , -2, false);
duke@435 393 def(_imul , "imul" , "b" , NULL , T_INT , -1, false);
duke@435 394 def(_lmul , "lmul" , "b" , NULL , T_LONG , -2, false);
duke@435 395 def(_fmul , "fmul" , "b" , NULL , T_FLOAT , -1, false);
duke@435 396 def(_dmul , "dmul" , "b" , NULL , T_DOUBLE , -2, false);
duke@435 397 def(_idiv , "idiv" , "b" , NULL , T_INT , -1, true );
duke@435 398 def(_ldiv , "ldiv" , "b" , NULL , T_LONG , -2, true );
duke@435 399 def(_fdiv , "fdiv" , "b" , NULL , T_FLOAT , -1, false);
duke@435 400 def(_ddiv , "ddiv" , "b" , NULL , T_DOUBLE , -2, false);
duke@435 401 def(_irem , "irem" , "b" , NULL , T_INT , -1, true );
duke@435 402 def(_lrem , "lrem" , "b" , NULL , T_LONG , -2, true );
duke@435 403 def(_frem , "frem" , "b" , NULL , T_FLOAT , -1, false);
duke@435 404 def(_drem , "drem" , "b" , NULL , T_DOUBLE , -2, false);
duke@435 405 def(_ineg , "ineg" , "b" , NULL , T_INT , 0, false);
duke@435 406 def(_lneg , "lneg" , "b" , NULL , T_LONG , 0, false);
duke@435 407 def(_fneg , "fneg" , "b" , NULL , T_FLOAT , 0, false);
duke@435 408 def(_dneg , "dneg" , "b" , NULL , T_DOUBLE , 0, false);
duke@435 409 def(_ishl , "ishl" , "b" , NULL , T_INT , -1, false);
duke@435 410 def(_lshl , "lshl" , "b" , NULL , T_LONG , -1, false);
duke@435 411 def(_ishr , "ishr" , "b" , NULL , T_INT , -1, false);
duke@435 412 def(_lshr , "lshr" , "b" , NULL , T_LONG , -1, false);
duke@435 413 def(_iushr , "iushr" , "b" , NULL , T_INT , -1, false);
duke@435 414 def(_lushr , "lushr" , "b" , NULL , T_LONG , -1, false);
duke@435 415 def(_iand , "iand" , "b" , NULL , T_INT , -1, false);
duke@435 416 def(_land , "land" , "b" , NULL , T_LONG , -2, false);
duke@435 417 def(_ior , "ior" , "b" , NULL , T_INT , -1, false);
duke@435 418 def(_lor , "lor" , "b" , NULL , T_LONG , -2, false);
duke@435 419 def(_ixor , "ixor" , "b" , NULL , T_INT , -1, false);
duke@435 420 def(_lxor , "lxor" , "b" , NULL , T_LONG , -2, false);
duke@435 421 def(_iinc , "iinc" , "bic" , "wbiicc", T_VOID , 0, false);
duke@435 422 def(_i2l , "i2l" , "b" , NULL , T_LONG , 1, false);
duke@435 423 def(_i2f , "i2f" , "b" , NULL , T_FLOAT , 0, false);
duke@435 424 def(_i2d , "i2d" , "b" , NULL , T_DOUBLE , 1, false);
duke@435 425 def(_l2i , "l2i" , "b" , NULL , T_INT , -1, false);
duke@435 426 def(_l2f , "l2f" , "b" , NULL , T_FLOAT , -1, false);
duke@435 427 def(_l2d , "l2d" , "b" , NULL , T_DOUBLE , 0, false);
duke@435 428 def(_f2i , "f2i" , "b" , NULL , T_INT , 0, false);
duke@435 429 def(_f2l , "f2l" , "b" , NULL , T_LONG , 1, false);
duke@435 430 def(_f2d , "f2d" , "b" , NULL , T_DOUBLE , 1, false);
duke@435 431 def(_d2i , "d2i" , "b" , NULL , T_INT , -1, false);
duke@435 432 def(_d2l , "d2l" , "b" , NULL , T_LONG , 0, false);
duke@435 433 def(_d2f , "d2f" , "b" , NULL , T_FLOAT , -1, false);
duke@435 434 def(_i2b , "i2b" , "b" , NULL , T_BYTE , 0, false);
duke@435 435 def(_i2c , "i2c" , "b" , NULL , T_CHAR , 0, false);
duke@435 436 def(_i2s , "i2s" , "b" , NULL , T_SHORT , 0, false);
duke@435 437 def(_lcmp , "lcmp" , "b" , NULL , T_VOID , -3, false);
duke@435 438 def(_fcmpl , "fcmpl" , "b" , NULL , T_VOID , -1, false);
duke@435 439 def(_fcmpg , "fcmpg" , "b" , NULL , T_VOID , -1, false);
duke@435 440 def(_dcmpl , "dcmpl" , "b" , NULL , T_VOID , -3, false);
duke@435 441 def(_dcmpg , "dcmpg" , "b" , NULL , T_VOID , -3, false);
duke@435 442 def(_ifeq , "ifeq" , "boo" , NULL , T_VOID , -1, false);
duke@435 443 def(_ifne , "ifne" , "boo" , NULL , T_VOID , -1, false);
duke@435 444 def(_iflt , "iflt" , "boo" , NULL , T_VOID , -1, false);
duke@435 445 def(_ifge , "ifge" , "boo" , NULL , T_VOID , -1, false);
duke@435 446 def(_ifgt , "ifgt" , "boo" , NULL , T_VOID , -1, false);
duke@435 447 def(_ifle , "ifle" , "boo" , NULL , T_VOID , -1, false);
duke@435 448 def(_if_icmpeq , "if_icmpeq" , "boo" , NULL , T_VOID , -2, false);
duke@435 449 def(_if_icmpne , "if_icmpne" , "boo" , NULL , T_VOID , -2, false);
duke@435 450 def(_if_icmplt , "if_icmplt" , "boo" , NULL , T_VOID , -2, false);
duke@435 451 def(_if_icmpge , "if_icmpge" , "boo" , NULL , T_VOID , -2, false);
duke@435 452 def(_if_icmpgt , "if_icmpgt" , "boo" , NULL , T_VOID , -2, false);
duke@435 453 def(_if_icmple , "if_icmple" , "boo" , NULL , T_VOID , -2, false);
duke@435 454 def(_if_acmpeq , "if_acmpeq" , "boo" , NULL , T_VOID , -2, false);
duke@435 455 def(_if_acmpne , "if_acmpne" , "boo" , NULL , T_VOID , -2, false);
duke@435 456 def(_goto , "goto" , "boo" , NULL , T_VOID , 0, false);
duke@435 457 def(_jsr , "jsr" , "boo" , NULL , T_INT , 0, false);
duke@435 458 def(_ret , "ret" , "bi" , "wbii" , T_VOID , 0, false);
duke@435 459 def(_tableswitch , "tableswitch" , "" , NULL , T_VOID , -1, false); // may have backward branches
duke@435 460 def(_lookupswitch , "lookupswitch" , "" , NULL , T_VOID , -1, false); // rewriting in interpreter
duke@435 461 def(_ireturn , "ireturn" , "b" , NULL , T_INT , -1, true);
duke@435 462 def(_lreturn , "lreturn" , "b" , NULL , T_LONG , -2, true);
duke@435 463 def(_freturn , "freturn" , "b" , NULL , T_FLOAT , -1, true);
duke@435 464 def(_dreturn , "dreturn" , "b" , NULL , T_DOUBLE , -2, true);
duke@435 465 def(_areturn , "areturn" , "b" , NULL , T_OBJECT , -1, true);
duke@435 466 def(_return , "return" , "b" , NULL , T_VOID , 0, true);
jrose@1920 467 def(_getstatic , "getstatic" , "bJJ" , NULL , T_ILLEGAL, 1, true );
jrose@1920 468 def(_putstatic , "putstatic" , "bJJ" , NULL , T_ILLEGAL, -1, true );
jrose@1920 469 def(_getfield , "getfield" , "bJJ" , NULL , T_ILLEGAL, 0, true );
jrose@1920 470 def(_putfield , "putfield" , "bJJ" , NULL , T_ILLEGAL, -2, true );
jrose@1920 471 def(_invokevirtual , "invokevirtual" , "bJJ" , NULL , T_ILLEGAL, -1, true);
jrose@1920 472 def(_invokespecial , "invokespecial" , "bJJ" , NULL , T_ILLEGAL, -1, true);
jrose@1920 473 def(_invokestatic , "invokestatic" , "bJJ" , NULL , T_ILLEGAL, 0, true);
jrose@1920 474 def(_invokeinterface , "invokeinterface" , "bJJ__", NULL , T_ILLEGAL, -1, true);
jrose@1920 475 def(_invokedynamic , "invokedynamic" , "bJJJJ", NULL , T_ILLEGAL, 0, true );
jrose@1920 476 def(_new , "new" , "bkk" , NULL , T_OBJECT , 1, true );
duke@435 477 def(_newarray , "newarray" , "bc" , NULL , T_OBJECT , 0, true );
jrose@1920 478 def(_anewarray , "anewarray" , "bkk" , NULL , T_OBJECT , 0, true );
duke@435 479 def(_arraylength , "arraylength" , "b" , NULL , T_VOID , 0, true );
duke@435 480 def(_athrow , "athrow" , "b" , NULL , T_VOID , -1, true );
jrose@1920 481 def(_checkcast , "checkcast" , "bkk" , NULL , T_OBJECT , 0, true );
jrose@1920 482 def(_instanceof , "instanceof" , "bkk" , NULL , T_INT , 0, true );
duke@435 483 def(_monitorenter , "monitorenter" , "b" , NULL , T_VOID , -1, true );
duke@435 484 def(_monitorexit , "monitorexit" , "b" , NULL , T_VOID , -1, true );
duke@435 485 def(_wide , "wide" , "" , NULL , T_VOID , 0, false);
jrose@1920 486 def(_multianewarray , "multianewarray" , "bkkc" , NULL , T_OBJECT , 1, true );
duke@435 487 def(_ifnull , "ifnull" , "boo" , NULL , T_VOID , -1, false);
duke@435 488 def(_ifnonnull , "ifnonnull" , "boo" , NULL , T_VOID , -1, false);
duke@435 489 def(_goto_w , "goto_w" , "boooo", NULL , T_VOID , 0, false);
duke@435 490 def(_jsr_w , "jsr_w" , "boooo", NULL , T_INT , 0, false);
duke@435 491 def(_breakpoint , "breakpoint" , "" , NULL , T_VOID , 0, true);
duke@435 492
duke@435 493 // JVM bytecodes
duke@435 494 // bytecode bytecode name format wide f. result tp stk traps std code
duke@435 495
jrose@1920 496 def(_fast_agetfield , "fast_agetfield" , "bJJ" , NULL , T_OBJECT , 0, true , _getfield );
jrose@1920 497 def(_fast_bgetfield , "fast_bgetfield" , "bJJ" , NULL , T_INT , 0, true , _getfield );
jrose@1920 498 def(_fast_cgetfield , "fast_cgetfield" , "bJJ" , NULL , T_CHAR , 0, true , _getfield );
jrose@1920 499 def(_fast_dgetfield , "fast_dgetfield" , "bJJ" , NULL , T_DOUBLE , 0, true , _getfield );
jrose@1920 500 def(_fast_fgetfield , "fast_fgetfield" , "bJJ" , NULL , T_FLOAT , 0, true , _getfield );
jrose@1920 501 def(_fast_igetfield , "fast_igetfield" , "bJJ" , NULL , T_INT , 0, true , _getfield );
jrose@1920 502 def(_fast_lgetfield , "fast_lgetfield" , "bJJ" , NULL , T_LONG , 0, true , _getfield );
jrose@1920 503 def(_fast_sgetfield , "fast_sgetfield" , "bJJ" , NULL , T_SHORT , 0, true , _getfield );
duke@435 504
jrose@1920 505 def(_fast_aputfield , "fast_aputfield" , "bJJ" , NULL , T_OBJECT , 0, true , _putfield );
jrose@1920 506 def(_fast_bputfield , "fast_bputfield" , "bJJ" , NULL , T_INT , 0, true , _putfield );
jrose@1920 507 def(_fast_cputfield , "fast_cputfield" , "bJJ" , NULL , T_CHAR , 0, true , _putfield );
jrose@1920 508 def(_fast_dputfield , "fast_dputfield" , "bJJ" , NULL , T_DOUBLE , 0, true , _putfield );
jrose@1920 509 def(_fast_fputfield , "fast_fputfield" , "bJJ" , NULL , T_FLOAT , 0, true , _putfield );
jrose@1920 510 def(_fast_iputfield , "fast_iputfield" , "bJJ" , NULL , T_INT , 0, true , _putfield );
jrose@1920 511 def(_fast_lputfield , "fast_lputfield" , "bJJ" , NULL , T_LONG , 0, true , _putfield );
jrose@1920 512 def(_fast_sputfield , "fast_sputfield" , "bJJ" , NULL , T_SHORT , 0, true , _putfield );
duke@435 513
duke@435 514 def(_fast_aload_0 , "fast_aload_0" , "b" , NULL , T_OBJECT , 1, true , _aload_0 );
jrose@1920 515 def(_fast_iaccess_0 , "fast_iaccess_0" , "b_JJ" , NULL , T_INT , 1, true , _aload_0 );
jrose@1920 516 def(_fast_aaccess_0 , "fast_aaccess_0" , "b_JJ" , NULL , T_OBJECT , 1, true , _aload_0 );
jrose@1920 517 def(_fast_faccess_0 , "fast_faccess_0" , "b_JJ" , NULL , T_OBJECT , 1, true , _aload_0 );
duke@435 518
duke@435 519 def(_fast_iload , "fast_iload" , "bi" , NULL , T_INT , 1, false, _iload);
duke@435 520 def(_fast_iload2 , "fast_iload2" , "bi_i" , NULL , T_INT , 2, false, _iload);
duke@435 521 def(_fast_icaload , "fast_icaload" , "bi_" , NULL , T_INT , 0, false, _iload);
duke@435 522
duke@435 523 // Faster method invocation.
jrose@1920 524 def(_fast_invokevfinal , "fast_invokevfinal" , "bJJ" , NULL , T_ILLEGAL, -1, true, _invokevirtual );
duke@435 525
duke@435 526 def(_fast_linearswitch , "fast_linearswitch" , "" , NULL , T_VOID , -1, false, _lookupswitch );
duke@435 527 def(_fast_binaryswitch , "fast_binaryswitch" , "" , NULL , T_VOID , -1, false, _lookupswitch );
duke@435 528
duke@435 529 def(_return_register_finalizer , "return_register_finalizer" , "b" , NULL , T_VOID , 0, true, _return);
duke@435 530
jrose@1957 531 def(_fast_aldc , "fast_aldc" , "bj" , NULL , T_OBJECT, 1, true, _ldc );
jrose@1957 532 def(_fast_aldc_w , "fast_aldc_w" , "bJJ" , NULL , T_OBJECT, 1, true, _ldc_w );
jrose@1957 533
duke@435 534 def(_shouldnotreachhere , "_shouldnotreachhere" , "b" , NULL , T_VOID , 0, false);
duke@435 535
duke@435 536 // platform specific JVM bytecodes
duke@435 537 pd_initialize();
duke@435 538
duke@435 539 // compare can_trap information for each bytecode with the
duke@435 540 // can_trap information for the corresponding base bytecode
duke@435 541 // (if a rewritten bytecode can trap, so must the base bytecode)
duke@435 542 #ifdef ASSERT
duke@435 543 { for (int i = 0; i < number_of_codes; i++) {
duke@435 544 if (is_defined(i)) {
duke@435 545 Code code = cast(i);
duke@435 546 Code java = java_code(code);
jcoomes@1845 547 if (can_trap(code) && !can_trap(java))
jcoomes@1845 548 fatal(err_msg("%s can trap => %s can trap, too", name(code),
jcoomes@1845 549 name(java)));
duke@435 550 }
duke@435 551 }
duke@435 552 }
duke@435 553 #endif
duke@435 554
duke@435 555 // initialization successful
duke@435 556 _is_initialized = true;
duke@435 557 }
duke@435 558
duke@435 559
duke@435 560 void bytecodes_init() {
duke@435 561 Bytecodes::initialize();
duke@435 562 }
duke@435 563
duke@435 564 // Restore optimization
duke@435 565 #ifdef _M_AMD64
duke@435 566 #pragma optimize ("", on)
duke@435 567 #endif

mercurial