src/share/vm/interpreter/bytecodes.hpp

changeset 435
a61af66fc99e
child 848
c7ec737733a6
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/interpreter/bytecodes.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,358 @@
     1.4 +/*
     1.5 + * Copyright 1997-2005 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +// Bytecodes specifies all bytecodes used in the VM and
    1.29 +// provides utility functions to get bytecode attributes.
    1.30 +
    1.31 +// NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/interpreter/Bytecodes.java
    1.32 +class Bytecodes: AllStatic {
    1.33 + public:
    1.34 +  enum Code {
    1.35 +    _illegal              =  -1,
    1.36 +
    1.37 +    // Java bytecodes
    1.38 +    _nop                  =   0, // 0x00
    1.39 +    _aconst_null          =   1, // 0x01
    1.40 +    _iconst_m1            =   2, // 0x02
    1.41 +    _iconst_0             =   3, // 0x03
    1.42 +    _iconst_1             =   4, // 0x04
    1.43 +    _iconst_2             =   5, // 0x05
    1.44 +    _iconst_3             =   6, // 0x06
    1.45 +    _iconst_4             =   7, // 0x07
    1.46 +    _iconst_5             =   8, // 0x08
    1.47 +    _lconst_0             =   9, // 0x09
    1.48 +    _lconst_1             =  10, // 0x0a
    1.49 +    _fconst_0             =  11, // 0x0b
    1.50 +    _fconst_1             =  12, // 0x0c
    1.51 +    _fconst_2             =  13, // 0x0d
    1.52 +    _dconst_0             =  14, // 0x0e
    1.53 +    _dconst_1             =  15, // 0x0f
    1.54 +    _bipush               =  16, // 0x10
    1.55 +    _sipush               =  17, // 0x11
    1.56 +    _ldc                  =  18, // 0x12
    1.57 +    _ldc_w                =  19, // 0x13
    1.58 +    _ldc2_w               =  20, // 0x14
    1.59 +    _iload                =  21, // 0x15
    1.60 +    _lload                =  22, // 0x16
    1.61 +    _fload                =  23, // 0x17
    1.62 +    _dload                =  24, // 0x18
    1.63 +    _aload                =  25, // 0x19
    1.64 +    _iload_0              =  26, // 0x1a
    1.65 +    _iload_1              =  27, // 0x1b
    1.66 +    _iload_2              =  28, // 0x1c
    1.67 +    _iload_3              =  29, // 0x1d
    1.68 +    _lload_0              =  30, // 0x1e
    1.69 +    _lload_1              =  31, // 0x1f
    1.70 +    _lload_2              =  32, // 0x20
    1.71 +    _lload_3              =  33, // 0x21
    1.72 +    _fload_0              =  34, // 0x22
    1.73 +    _fload_1              =  35, // 0x23
    1.74 +    _fload_2              =  36, // 0x24
    1.75 +    _fload_3              =  37, // 0x25
    1.76 +    _dload_0              =  38, // 0x26
    1.77 +    _dload_1              =  39, // 0x27
    1.78 +    _dload_2              =  40, // 0x28
    1.79 +    _dload_3              =  41, // 0x29
    1.80 +    _aload_0              =  42, // 0x2a
    1.81 +    _aload_1              =  43, // 0x2b
    1.82 +    _aload_2              =  44, // 0x2c
    1.83 +    _aload_3              =  45, // 0x2d
    1.84 +    _iaload               =  46, // 0x2e
    1.85 +    _laload               =  47, // 0x2f
    1.86 +    _faload               =  48, // 0x30
    1.87 +    _daload               =  49, // 0x31
    1.88 +    _aaload               =  50, // 0x32
    1.89 +    _baload               =  51, // 0x33
    1.90 +    _caload               =  52, // 0x34
    1.91 +    _saload               =  53, // 0x35
    1.92 +    _istore               =  54, // 0x36
    1.93 +    _lstore               =  55, // 0x37
    1.94 +    _fstore               =  56, // 0x38
    1.95 +    _dstore               =  57, // 0x39
    1.96 +    _astore               =  58, // 0x3a
    1.97 +    _istore_0             =  59, // 0x3b
    1.98 +    _istore_1             =  60, // 0x3c
    1.99 +    _istore_2             =  61, // 0x3d
   1.100 +    _istore_3             =  62, // 0x3e
   1.101 +    _lstore_0             =  63, // 0x3f
   1.102 +    _lstore_1             =  64, // 0x40
   1.103 +    _lstore_2             =  65, // 0x41
   1.104 +    _lstore_3             =  66, // 0x42
   1.105 +    _fstore_0             =  67, // 0x43
   1.106 +    _fstore_1             =  68, // 0x44
   1.107 +    _fstore_2             =  69, // 0x45
   1.108 +    _fstore_3             =  70, // 0x46
   1.109 +    _dstore_0             =  71, // 0x47
   1.110 +    _dstore_1             =  72, // 0x48
   1.111 +    _dstore_2             =  73, // 0x49
   1.112 +    _dstore_3             =  74, // 0x4a
   1.113 +    _astore_0             =  75, // 0x4b
   1.114 +    _astore_1             =  76, // 0x4c
   1.115 +    _astore_2             =  77, // 0x4d
   1.116 +    _astore_3             =  78, // 0x4e
   1.117 +    _iastore              =  79, // 0x4f
   1.118 +    _lastore              =  80, // 0x50
   1.119 +    _fastore              =  81, // 0x51
   1.120 +    _dastore              =  82, // 0x52
   1.121 +    _aastore              =  83, // 0x53
   1.122 +    _bastore              =  84, // 0x54
   1.123 +    _castore              =  85, // 0x55
   1.124 +    _sastore              =  86, // 0x56
   1.125 +    _pop                  =  87, // 0x57
   1.126 +    _pop2                 =  88, // 0x58
   1.127 +    _dup                  =  89, // 0x59
   1.128 +    _dup_x1               =  90, // 0x5a
   1.129 +    _dup_x2               =  91, // 0x5b
   1.130 +    _dup2                 =  92, // 0x5c
   1.131 +    _dup2_x1              =  93, // 0x5d
   1.132 +    _dup2_x2              =  94, // 0x5e
   1.133 +    _swap                 =  95, // 0x5f
   1.134 +    _iadd                 =  96, // 0x60
   1.135 +    _ladd                 =  97, // 0x61
   1.136 +    _fadd                 =  98, // 0x62
   1.137 +    _dadd                 =  99, // 0x63
   1.138 +    _isub                 = 100, // 0x64
   1.139 +    _lsub                 = 101, // 0x65
   1.140 +    _fsub                 = 102, // 0x66
   1.141 +    _dsub                 = 103, // 0x67
   1.142 +    _imul                 = 104, // 0x68
   1.143 +    _lmul                 = 105, // 0x69
   1.144 +    _fmul                 = 106, // 0x6a
   1.145 +    _dmul                 = 107, // 0x6b
   1.146 +    _idiv                 = 108, // 0x6c
   1.147 +    _ldiv                 = 109, // 0x6d
   1.148 +    _fdiv                 = 110, // 0x6e
   1.149 +    _ddiv                 = 111, // 0x6f
   1.150 +    _irem                 = 112, // 0x70
   1.151 +    _lrem                 = 113, // 0x71
   1.152 +    _frem                 = 114, // 0x72
   1.153 +    _drem                 = 115, // 0x73
   1.154 +    _ineg                 = 116, // 0x74
   1.155 +    _lneg                 = 117, // 0x75
   1.156 +    _fneg                 = 118, // 0x76
   1.157 +    _dneg                 = 119, // 0x77
   1.158 +    _ishl                 = 120, // 0x78
   1.159 +    _lshl                 = 121, // 0x79
   1.160 +    _ishr                 = 122, // 0x7a
   1.161 +    _lshr                 = 123, // 0x7b
   1.162 +    _iushr                = 124, // 0x7c
   1.163 +    _lushr                = 125, // 0x7d
   1.164 +    _iand                 = 126, // 0x7e
   1.165 +    _land                 = 127, // 0x7f
   1.166 +    _ior                  = 128, // 0x80
   1.167 +    _lor                  = 129, // 0x81
   1.168 +    _ixor                 = 130, // 0x82
   1.169 +    _lxor                 = 131, // 0x83
   1.170 +    _iinc                 = 132, // 0x84
   1.171 +    _i2l                  = 133, // 0x85
   1.172 +    _i2f                  = 134, // 0x86
   1.173 +    _i2d                  = 135, // 0x87
   1.174 +    _l2i                  = 136, // 0x88
   1.175 +    _l2f                  = 137, // 0x89
   1.176 +    _l2d                  = 138, // 0x8a
   1.177 +    _f2i                  = 139, // 0x8b
   1.178 +    _f2l                  = 140, // 0x8c
   1.179 +    _f2d                  = 141, // 0x8d
   1.180 +    _d2i                  = 142, // 0x8e
   1.181 +    _d2l                  = 143, // 0x8f
   1.182 +    _d2f                  = 144, // 0x90
   1.183 +    _i2b                  = 145, // 0x91
   1.184 +    _i2c                  = 146, // 0x92
   1.185 +    _i2s                  = 147, // 0x93
   1.186 +    _lcmp                 = 148, // 0x94
   1.187 +    _fcmpl                = 149, // 0x95
   1.188 +    _fcmpg                = 150, // 0x96
   1.189 +    _dcmpl                = 151, // 0x97
   1.190 +    _dcmpg                = 152, // 0x98
   1.191 +    _ifeq                 = 153, // 0x99
   1.192 +    _ifne                 = 154, // 0x9a
   1.193 +    _iflt                 = 155, // 0x9b
   1.194 +    _ifge                 = 156, // 0x9c
   1.195 +    _ifgt                 = 157, // 0x9d
   1.196 +    _ifle                 = 158, // 0x9e
   1.197 +    _if_icmpeq            = 159, // 0x9f
   1.198 +    _if_icmpne            = 160, // 0xa0
   1.199 +    _if_icmplt            = 161, // 0xa1
   1.200 +    _if_icmpge            = 162, // 0xa2
   1.201 +    _if_icmpgt            = 163, // 0xa3
   1.202 +    _if_icmple            = 164, // 0xa4
   1.203 +    _if_acmpeq            = 165, // 0xa5
   1.204 +    _if_acmpne            = 166, // 0xa6
   1.205 +    _goto                 = 167, // 0xa7
   1.206 +    _jsr                  = 168, // 0xa8
   1.207 +    _ret                  = 169, // 0xa9
   1.208 +    _tableswitch          = 170, // 0xaa
   1.209 +    _lookupswitch         = 171, // 0xab
   1.210 +    _ireturn              = 172, // 0xac
   1.211 +    _lreturn              = 173, // 0xad
   1.212 +    _freturn              = 174, // 0xae
   1.213 +    _dreturn              = 175, // 0xaf
   1.214 +    _areturn              = 176, // 0xb0
   1.215 +    _return               = 177, // 0xb1
   1.216 +    _getstatic            = 178, // 0xb2
   1.217 +    _putstatic            = 179, // 0xb3
   1.218 +    _getfield             = 180, // 0xb4
   1.219 +    _putfield             = 181, // 0xb5
   1.220 +    _invokevirtual        = 182, // 0xb6
   1.221 +    _invokespecial        = 183, // 0xb7
   1.222 +    _invokestatic         = 184, // 0xb8
   1.223 +    _invokeinterface      = 185, // 0xb9
   1.224 +    _xxxunusedxxx         = 186, // 0xba
   1.225 +    _new                  = 187, // 0xbb
   1.226 +    _newarray             = 188, // 0xbc
   1.227 +    _anewarray            = 189, // 0xbd
   1.228 +    _arraylength          = 190, // 0xbe
   1.229 +    _athrow               = 191, // 0xbf
   1.230 +    _checkcast            = 192, // 0xc0
   1.231 +    _instanceof           = 193, // 0xc1
   1.232 +    _monitorenter         = 194, // 0xc2
   1.233 +    _monitorexit          = 195, // 0xc3
   1.234 +    _wide                 = 196, // 0xc4
   1.235 +    _multianewarray       = 197, // 0xc5
   1.236 +    _ifnull               = 198, // 0xc6
   1.237 +    _ifnonnull            = 199, // 0xc7
   1.238 +    _goto_w               = 200, // 0xc8
   1.239 +    _jsr_w                = 201, // 0xc9
   1.240 +    _breakpoint           = 202, // 0xca
   1.241 +
   1.242 +    number_of_java_codes,
   1.243 +
   1.244 +    // JVM bytecodes
   1.245 +    _fast_agetfield       = number_of_java_codes,
   1.246 +    _fast_bgetfield       ,
   1.247 +    _fast_cgetfield       ,
   1.248 +    _fast_dgetfield       ,
   1.249 +    _fast_fgetfield       ,
   1.250 +    _fast_igetfield       ,
   1.251 +    _fast_lgetfield       ,
   1.252 +    _fast_sgetfield       ,
   1.253 +
   1.254 +    _fast_aputfield       ,
   1.255 +    _fast_bputfield       ,
   1.256 +    _fast_cputfield       ,
   1.257 +    _fast_dputfield       ,
   1.258 +    _fast_fputfield       ,
   1.259 +    _fast_iputfield       ,
   1.260 +    _fast_lputfield       ,
   1.261 +    _fast_sputfield       ,
   1.262 +
   1.263 +    _fast_aload_0         ,
   1.264 +    _fast_iaccess_0       ,
   1.265 +    _fast_aaccess_0       ,
   1.266 +    _fast_faccess_0       ,
   1.267 +
   1.268 +    _fast_iload           ,
   1.269 +    _fast_iload2          ,
   1.270 +    _fast_icaload         ,
   1.271 +
   1.272 +    _fast_invokevfinal    ,
   1.273 +    _fast_linearswitch    ,
   1.274 +    _fast_binaryswitch    ,
   1.275 +
   1.276 +    _return_register_finalizer    ,
   1.277 +
   1.278 +    _shouldnotreachhere,      // For debugging
   1.279 +
   1.280 +    // Platform specific JVM bytecodes
   1.281 +    #include "incls/_bytecodes_pd.hpp.incl"
   1.282 +
   1.283 +    number_of_codes
   1.284 +  };
   1.285 +
   1.286 + private:
   1.287 +  static bool        _is_initialized;
   1.288 +  static const char* _name          [number_of_codes];
   1.289 +  static const char* _format        [number_of_codes];
   1.290 +  static const char* _wide_format   [number_of_codes];
   1.291 +  static BasicType   _result_type   [number_of_codes];
   1.292 +  static s_char      _depth         [number_of_codes];
   1.293 +  static u_char      _length        [number_of_codes];
   1.294 +  static bool        _can_trap      [number_of_codes];
   1.295 +  static Code        _java_code     [number_of_codes];
   1.296 +  static bool        _can_rewrite   [number_of_codes];
   1.297 +
   1.298 +  static void        def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap);
   1.299 +  static void        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.300 +  static void        pd_initialize();              // platform specific initialization
   1.301 +  static Code        pd_base_code_for(Code code);  // platform specific base_code_for implementation
   1.302 +
   1.303 + public:
   1.304 +  // Conversion
   1.305 +  static void        check          (Code code)    { assert(is_defined(code), "illegal code"); }
   1.306 +  static void        wide_check     (Code code)    { assert(wide_is_defined(code), "illegal code"); }
   1.307 +  static Code        cast           (int  code)    { return (Code)code; }
   1.308 +
   1.309 +
   1.310 +   // Fetch a bytecode, hiding breakpoints as necessary:
   1.311 +   static Code       code_at(address bcp, methodOop method = NULL) {
   1.312 +          Code code = cast(*bcp); return (code != _breakpoint) ? code : non_breakpoint_code_at(bcp, method);
   1.313 +   }
   1.314 +   static Code       java_code_at(address bcp, methodOop method = NULL) {
   1.315 +          return java_code(code_at(bcp, method));
   1.316 +   }
   1.317 +
   1.318 +   // Fetch a bytecode or a breakpoint:
   1.319 +   static Code       code_or_bp_at(address bcp)    { return (Code)cast(*bcp); }
   1.320 +
   1.321 +   static Code       code_at(methodOop method, int bci);
   1.322 +   static bool       is_active_breakpoint_at(address bcp) { return (Code)*bcp == _breakpoint; }
   1.323 +
   1.324 +   // find a bytecode, behind a breakpoint if necessary:
   1.325 +   static Code       non_breakpoint_code_at(address bcp, methodOop method = NULL);
   1.326 +
   1.327 +  // Bytecode attributes
   1.328 +  static bool        is_defined     (int  code)    { return 0 <= code && code < number_of_codes && _format[code] != NULL; }
   1.329 +  static bool        wide_is_defined(int  code)    { return is_defined(code) && _wide_format[code] != NULL; }
   1.330 +  static const char* name           (Code code)    { check(code);      return _name          [code]; }
   1.331 +  static const char* format         (Code code)    { check(code);      return _format        [code]; }
   1.332 +  static const char* wide_format    (Code code)    { return _wide_format[code]; }
   1.333 +  static BasicType   result_type    (Code code)    { check(code);      return _result_type   [code]; }
   1.334 +  static int         depth          (Code code)    { check(code);      return _depth         [code]; }
   1.335 +  static int         length_for     (Code code)    { return _length[code]; }
   1.336 +  static bool        can_trap       (Code code)    { check(code);      return _can_trap      [code]; }
   1.337 +  static Code        java_code      (Code code)    { check(code);      return _java_code     [code]; }
   1.338 +  static bool        can_rewrite    (Code code)    { check(code);      return _can_rewrite   [code]; }
   1.339 +  static int         wide_length_for(Code code)    {
   1.340 +    if (!is_defined(code)) {
   1.341 +      return 0;
   1.342 +    }
   1.343 +    const char* wf = wide_format(code);
   1.344 +    return (wf == NULL) ? 0 : (int)strlen(wf);
   1.345 +  }
   1.346 +  static int         special_length_at(address bcp);
   1.347 +  static int         raw_special_length_at(address bcp);
   1.348 +  static int         length_at      (address bcp)  { int l = length_for(code_at(bcp)); return l > 0 ? l : special_length_at(bcp); }
   1.349 +  static int         java_length_at (address bcp)  { int l = length_for(java_code_at(bcp)); return l > 0 ? l : special_length_at(bcp); }
   1.350 +  static bool        is_java_code   (Code code)    { return 0 <= code && code < number_of_java_codes; }
   1.351 +
   1.352 +  static bool        is_aload       (Code code)    { return (code == _aload  || code == _aload_0  || code == _aload_1
   1.353 +                                                                             || code == _aload_2  || code == _aload_3); }
   1.354 +  static bool        is_astore      (Code code)    { return (code == _astore || code == _astore_0 || code == _astore_1
   1.355 +                                                                             || code == _astore_2 || code == _astore_3); }
   1.356 +
   1.357 +  static bool        is_zero_const  (Code code)    { return (code == _aconst_null || code == _iconst_0
   1.358 +                                                           || code == _fconst_0 || code == _dconst_0); }
   1.359 +  // Initialization
   1.360 +  static void        initialize     ();
   1.361 +};

mercurial