src/share/vm/interpreter/bytecodes.hpp

Print this page




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 






  25 // Bytecodes specifies all bytecodes used in the VM and
  26 // provides utility functions to get bytecode attributes.
  27 
  28 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/interpreter/Bytecodes.java
  29 class Bytecodes: AllStatic {
  30  public:
  31   enum Code {
  32     _illegal              =  -1,
  33 
  34     // Java bytecodes
  35     _nop                  =   0, // 0x00
  36     _aconst_null          =   1, // 0x01
  37     _iconst_m1            =   2, // 0x02
  38     _iconst_0             =   3, // 0x03
  39     _iconst_1             =   4, // 0x04
  40     _iconst_2             =   5, // 0x05
  41     _iconst_3             =   6, // 0x06
  42     _iconst_4             =   7, // 0x07
  43     _iconst_5             =   8, // 0x08
  44     _lconst_0             =   9, // 0x09


 262     _fast_aaccess_0       ,
 263     _fast_faccess_0       ,
 264 
 265     _fast_iload           ,
 266     _fast_iload2          ,
 267     _fast_icaload         ,
 268 
 269     _fast_invokevfinal    ,
 270     _fast_linearswitch    ,
 271     _fast_binaryswitch    ,
 272 
 273     // special handling of oop constants:
 274     _fast_aldc            ,
 275     _fast_aldc_w          ,
 276 
 277     _return_register_finalizer    ,
 278 
 279     _shouldnotreachhere,      // For debugging
 280 
 281     // Platform specific JVM bytecodes
 282     #include "incls/_bytecodes_pd.hpp.incl"









 283 
 284     number_of_codes
 285   };
 286 
 287   // Flag bits derived from format strings, can_trap, can_rewrite, etc.:
 288   enum Flags {
 289     // semantic flags:
 290     _bc_can_trap      = 1<<0,     // bytecode execution can trap or block
 291     _bc_can_rewrite   = 1<<1,     // bytecode execution has an alternate form
 292 
 293     // format bits (determined only by the format string):
 294     _fmt_has_c        = 1<<2,     // constant, such as sipush "bcc"
 295     _fmt_has_j        = 1<<3,     // constant pool cache index, such as getfield "bjj"
 296     _fmt_has_k        = 1<<4,     // constant pool index, such as ldc "bk"
 297     _fmt_has_i        = 1<<5,     // local index, such as iload
 298     _fmt_has_o        = 1<<6,     // offset, such as ifeq
 299     _fmt_has_nbo      = 1<<7,     // contains native-order field(s)
 300     _fmt_has_u2       = 1<<8,     // contains double-byte field(s)
 301     _fmt_has_u4       = 1<<9,     // contains quad-byte field
 302     _fmt_not_variable = 1<<10,    // not of variable length (simple or wide)


 377   static bool        is_aload       (Code code)    { return (code == _aload  || code == _aload_0  || code == _aload_1
 378                                                                              || code == _aload_2  || code == _aload_3); }
 379   static bool        is_astore      (Code code)    { return (code == _astore || code == _astore_0 || code == _astore_1
 380                                                                              || code == _astore_2 || code == _astore_3); }
 381 
 382   static bool        is_zero_const  (Code code)    { return (code == _aconst_null || code == _iconst_0
 383                                                            || code == _fconst_0 || code == _dconst_0); }
 384   static int         compute_flags  (const char* format, int more_flags = 0);  // compute the flags
 385   static int         flags          (int code, bool is_wide) {
 386     assert(code == (u_char)code, "must be a byte");
 387     return _flags[code + (is_wide ? (1<<BitsPerByte) : 0)];
 388   }
 389   static int         format_bits    (Code code, bool is_wide) { return flags(code, is_wide) & _all_fmt_bits; }
 390   static bool        has_all_flags  (Code code, int test_flags, bool is_wide) {
 391     return (flags(code, is_wide) & test_flags) == test_flags;
 392   }
 393 
 394   // Initialization
 395   static void        initialize     ();
 396 };




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_INTERPRETER_BYTECODES_HPP
  26 #define SHARE_VM_INTERPRETER_BYTECODES_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "utilities/top.hpp"
  30 
  31 // Bytecodes specifies all bytecodes used in the VM and
  32 // provides utility functions to get bytecode attributes.
  33 
  34 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/interpreter/Bytecodes.java
  35 class Bytecodes: AllStatic {
  36  public:
  37   enum Code {
  38     _illegal              =  -1,
  39 
  40     // Java bytecodes
  41     _nop                  =   0, // 0x00
  42     _aconst_null          =   1, // 0x01
  43     _iconst_m1            =   2, // 0x02
  44     _iconst_0             =   3, // 0x03
  45     _iconst_1             =   4, // 0x04
  46     _iconst_2             =   5, // 0x05
  47     _iconst_3             =   6, // 0x06
  48     _iconst_4             =   7, // 0x07
  49     _iconst_5             =   8, // 0x08
  50     _lconst_0             =   9, // 0x09


 268     _fast_aaccess_0       ,
 269     _fast_faccess_0       ,
 270 
 271     _fast_iload           ,
 272     _fast_iload2          ,
 273     _fast_icaload         ,
 274 
 275     _fast_invokevfinal    ,
 276     _fast_linearswitch    ,
 277     _fast_binaryswitch    ,
 278 
 279     // special handling of oop constants:
 280     _fast_aldc            ,
 281     _fast_aldc_w          ,
 282 
 283     _return_register_finalizer    ,
 284 
 285     _shouldnotreachhere,      // For debugging
 286 
 287     // Platform specific JVM bytecodes
 288 #ifdef TARGET_ARCH_x86
 289 # include "bytecodes_x86.hpp"
 290 #endif
 291 #ifdef TARGET_ARCH_sparc
 292 # include "bytecodes_sparc.hpp"
 293 #endif
 294 #ifdef TARGET_ARCH_zero
 295 # include "bytecodes_zero.hpp"
 296 #endif
 297 
 298 
 299     number_of_codes
 300   };
 301 
 302   // Flag bits derived from format strings, can_trap, can_rewrite, etc.:
 303   enum Flags {
 304     // semantic flags:
 305     _bc_can_trap      = 1<<0,     // bytecode execution can trap or block
 306     _bc_can_rewrite   = 1<<1,     // bytecode execution has an alternate form
 307 
 308     // format bits (determined only by the format string):
 309     _fmt_has_c        = 1<<2,     // constant, such as sipush "bcc"
 310     _fmt_has_j        = 1<<3,     // constant pool cache index, such as getfield "bjj"
 311     _fmt_has_k        = 1<<4,     // constant pool index, such as ldc "bk"
 312     _fmt_has_i        = 1<<5,     // local index, such as iload
 313     _fmt_has_o        = 1<<6,     // offset, such as ifeq
 314     _fmt_has_nbo      = 1<<7,     // contains native-order field(s)
 315     _fmt_has_u2       = 1<<8,     // contains double-byte field(s)
 316     _fmt_has_u4       = 1<<9,     // contains quad-byte field
 317     _fmt_not_variable = 1<<10,    // not of variable length (simple or wide)


 392   static bool        is_aload       (Code code)    { return (code == _aload  || code == _aload_0  || code == _aload_1
 393                                                                              || code == _aload_2  || code == _aload_3); }
 394   static bool        is_astore      (Code code)    { return (code == _astore || code == _astore_0 || code == _astore_1
 395                                                                              || code == _astore_2 || code == _astore_3); }
 396 
 397   static bool        is_zero_const  (Code code)    { return (code == _aconst_null || code == _iconst_0
 398                                                            || code == _fconst_0 || code == _dconst_0); }
 399   static int         compute_flags  (const char* format, int more_flags = 0);  // compute the flags
 400   static int         flags          (int code, bool is_wide) {
 401     assert(code == (u_char)code, "must be a byte");
 402     return _flags[code + (is_wide ? (1<<BitsPerByte) : 0)];
 403   }
 404   static int         format_bits    (Code code, bool is_wide) { return flags(code, is_wide) & _all_fmt_bits; }
 405   static bool        has_all_flags  (Code code, int test_flags, bool is_wide) {
 406     return (flags(code, is_wide) & test_flags) == test_flags;
 407   }
 408 
 409   // Initialization
 410   static void        initialize     ();
 411 };
 412 
 413 #endif // SHARE_VM_INTERPRETER_BYTECODES_HPP