< prev index next >

src/hotspot/share/interpreter/bytecodes.hpp

Print this page

  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_INTERPRETER_BYTECODES_HPP
 26 #define SHARE_INTERPRETER_BYTECODES_HPP
 27 
 28 #include "memory/allStatic.hpp"

 29 #include "utilities/globalDefinitions.hpp"
 30 
 31 // Bytecodes specifies all bytecodes used in the VM and
 32 // provides utility functions to get bytecode attributes.
 33 
 34 class Method;
 35 
 36 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/interpreter/Bytecodes.java
 37 class Bytecodes: AllStatic {
 38  public:
 39   enum Code {
 40     _illegal              =  -1,
 41 
 42     // Java bytecodes
 43     _nop                  =   0, // 0x00
 44     _aconst_null          =   1, // 0x01
 45     _iconst_m1            =   2, // 0x02
 46     _iconst_0             =   3, // 0x03
 47     _iconst_1             =   4, // 0x04
 48     _iconst_2             =   5, // 0x05

231     _newarray             = 188, // 0xbc
232     _anewarray            = 189, // 0xbd
233     _arraylength          = 190, // 0xbe
234     _athrow               = 191, // 0xbf
235     _checkcast            = 192, // 0xc0
236     _instanceof           = 193, // 0xc1
237     _monitorenter         = 194, // 0xc2
238     _monitorexit          = 195, // 0xc3
239     _wide                 = 196, // 0xc4
240     _multianewarray       = 197, // 0xc5
241     _ifnull               = 198, // 0xc6
242     _ifnonnull            = 199, // 0xc7
243     _goto_w               = 200, // 0xc8
244     _jsr_w                = 201, // 0xc9
245     _breakpoint           = 202, // 0xca
246 
247     number_of_java_codes,
248 
249     // JVM bytecodes
250     _fast_agetfield       = number_of_java_codes,

251     _fast_bgetfield       ,
252     _fast_cgetfield       ,
253     _fast_dgetfield       ,
254     _fast_fgetfield       ,
255     _fast_igetfield       ,
256     _fast_lgetfield       ,
257     _fast_sgetfield       ,
258 
259     _fast_aputfield       ,

260     _fast_bputfield       ,
261     _fast_zputfield       ,
262     _fast_cputfield       ,
263     _fast_dputfield       ,
264     _fast_fputfield       ,
265     _fast_iputfield       ,
266     _fast_lputfield       ,
267     _fast_sputfield       ,
268 
269     _fast_aload_0         ,
270     _fast_iaccess_0       ,
271     _fast_aaccess_0       ,
272     _fast_faccess_0       ,
273 
274     _fast_iload           ,
275     _fast_iload2          ,
276     _fast_icaload         ,
277 
278     _fast_invokevfinal    ,
279     _fast_linearswitch    ,

402   static Code        java_code      (Code code)    { check(code);      return _java_code     [code]; }
403   static bool        can_rewrite    (Code code)    { check(code);      return has_all_flags(code, _bc_can_rewrite, false); }
404   static bool        must_rewrite(Bytecodes::Code code) { return can_rewrite(code) && check_must_rewrite(code); }
405   static bool        native_byte_order(Code code)  { check(code);      return has_all_flags(code, _fmt_has_nbo, false); }
406   static bool        uses_cp_cache  (Code code)    { check(code);      return has_all_flags(code, _fmt_has_j, false); }
407   // if 'end' is provided, it indicates the end of the code buffer which
408   // should not be read past when parsing.
409   static int         special_length_at(Bytecodes::Code code, address bcp, address end = nullptr);
410   static int         raw_special_length_at(address bcp, address end = nullptr);
411   static int         length_for_code_at(Bytecodes::Code code, address bcp)  { int l = length_for(code); return l > 0 ? l : special_length_at(code, bcp); }
412   static int         length_at      (Method* method, address bcp)  { return length_for_code_at(code_at(method, bcp), bcp); }
413   static int         java_length_at (Method* method, address bcp)  { return length_for_code_at(java_code_at(method, bcp), bcp); }
414   static bool        is_java_code   (Code code)    { return 0 <= code && code < number_of_java_codes; }
415 
416   static bool        is_store_into_local(Code code){ return (_istore <= code && code <= _astore_3); }
417   static bool        is_const       (Code code)    { return (_aconst_null <= code && code <= _ldc2_w); }
418   static bool        is_zero_const  (Code code)    { return (code == _aconst_null || code == _iconst_0
419                                                            || code == _fconst_0 || code == _dconst_0); }
420   static bool        is_return      (Code code)    { return (_ireturn <= code && code <= _return); }
421   static bool        is_invoke      (Code code)    { return (_invokevirtual <= code && code <= _invokedynamic); }
422   static bool        is_field_code  (Code code)    { return (_getstatic <= java_code(code) && java_code(code) <= _putfield); }


423   static bool        has_receiver   (Code code)    { assert(is_invoke(code), "");  return code == _invokevirtual ||
424                                                                                           code == _invokespecial ||
425                                                                                           code == _invokeinterface; }
426   static bool        has_optional_appendix(Code code) { return code == _invokedynamic || code == _invokehandle; }
427 
428   static int         flags          (int code, bool is_wide) {
429     assert(code == (u_char)code, "must be a byte");
430     return _flags[code + (is_wide ? (1<<BitsPerByte) : 0)];
431   }
432   static bool        has_all_flags  (Code code, int test_flags, bool is_wide) {
433     return (flags(code, is_wide) & test_flags) == test_flags;
434   }
435 
436   // Initialization
437   static void        initialize     ();
438 };
439 
440 #endif // SHARE_INTERPRETER_BYTECODES_HPP

  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_INTERPRETER_BYTECODES_HPP
 26 #define SHARE_INTERPRETER_BYTECODES_HPP
 27 
 28 #include "memory/allStatic.hpp"
 29 #include "runtime/globals.hpp"
 30 #include "utilities/globalDefinitions.hpp"
 31 
 32 // Bytecodes specifies all bytecodes used in the VM and
 33 // provides utility functions to get bytecode attributes.
 34 
 35 class Method;
 36 
 37 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/interpreter/Bytecodes.java
 38 class Bytecodes: AllStatic {
 39  public:
 40   enum Code {
 41     _illegal              =  -1,
 42 
 43     // Java bytecodes
 44     _nop                  =   0, // 0x00
 45     _aconst_null          =   1, // 0x01
 46     _iconst_m1            =   2, // 0x02
 47     _iconst_0             =   3, // 0x03
 48     _iconst_1             =   4, // 0x04
 49     _iconst_2             =   5, // 0x05

232     _newarray             = 188, // 0xbc
233     _anewarray            = 189, // 0xbd
234     _arraylength          = 190, // 0xbe
235     _athrow               = 191, // 0xbf
236     _checkcast            = 192, // 0xc0
237     _instanceof           = 193, // 0xc1
238     _monitorenter         = 194, // 0xc2
239     _monitorexit          = 195, // 0xc3
240     _wide                 = 196, // 0xc4
241     _multianewarray       = 197, // 0xc5
242     _ifnull               = 198, // 0xc6
243     _ifnonnull            = 199, // 0xc7
244     _goto_w               = 200, // 0xc8
245     _jsr_w                = 201, // 0xc9
246     _breakpoint           = 202, // 0xca
247 
248     number_of_java_codes,
249 
250     // JVM bytecodes
251     _fast_agetfield       = number_of_java_codes,
252     _fast_vgetfield       ,
253     _fast_bgetfield       ,
254     _fast_cgetfield       ,
255     _fast_dgetfield       ,
256     _fast_fgetfield       ,
257     _fast_igetfield       ,
258     _fast_lgetfield       ,
259     _fast_sgetfield       ,
260 
261     _fast_aputfield       ,
262     _fast_vputfield       ,
263     _fast_bputfield       ,
264     _fast_zputfield       ,
265     _fast_cputfield       ,
266     _fast_dputfield       ,
267     _fast_fputfield       ,
268     _fast_iputfield       ,
269     _fast_lputfield       ,
270     _fast_sputfield       ,
271 
272     _fast_aload_0         ,
273     _fast_iaccess_0       ,
274     _fast_aaccess_0       ,
275     _fast_faccess_0       ,
276 
277     _fast_iload           ,
278     _fast_iload2          ,
279     _fast_icaload         ,
280 
281     _fast_invokevfinal    ,
282     _fast_linearswitch    ,

405   static Code        java_code      (Code code)    { check(code);      return _java_code     [code]; }
406   static bool        can_rewrite    (Code code)    { check(code);      return has_all_flags(code, _bc_can_rewrite, false); }
407   static bool        must_rewrite(Bytecodes::Code code) { return can_rewrite(code) && check_must_rewrite(code); }
408   static bool        native_byte_order(Code code)  { check(code);      return has_all_flags(code, _fmt_has_nbo, false); }
409   static bool        uses_cp_cache  (Code code)    { check(code);      return has_all_flags(code, _fmt_has_j, false); }
410   // if 'end' is provided, it indicates the end of the code buffer which
411   // should not be read past when parsing.
412   static int         special_length_at(Bytecodes::Code code, address bcp, address end = nullptr);
413   static int         raw_special_length_at(address bcp, address end = nullptr);
414   static int         length_for_code_at(Bytecodes::Code code, address bcp)  { int l = length_for(code); return l > 0 ? l : special_length_at(code, bcp); }
415   static int         length_at      (Method* method, address bcp)  { return length_for_code_at(code_at(method, bcp), bcp); }
416   static int         java_length_at (Method* method, address bcp)  { return length_for_code_at(java_code_at(method, bcp), bcp); }
417   static bool        is_java_code   (Code code)    { return 0 <= code && code < number_of_java_codes; }
418 
419   static bool        is_store_into_local(Code code){ return (_istore <= code && code <= _astore_3); }
420   static bool        is_const       (Code code)    { return (_aconst_null <= code && code <= _ldc2_w); }
421   static bool        is_zero_const  (Code code)    { return (code == _aconst_null || code == _iconst_0
422                                                            || code == _fconst_0 || code == _dconst_0); }
423   static bool        is_return      (Code code)    { return (_ireturn <= code && code <= _return); }
424   static bool        is_invoke      (Code code)    { return (_invokevirtual <= code && code <= _invokedynamic); }
425   static bool        is_field_code  (Code code)    {
426     return (_getstatic <= java_code(code) && java_code(code) <= _putfield);
427   }
428   static bool        has_receiver   (Code code)    { assert(is_invoke(code), "");  return code == _invokevirtual ||
429                                                                                           code == _invokespecial ||
430                                                                                           code == _invokeinterface; }
431   static bool        has_optional_appendix(Code code) { return code == _invokedynamic || code == _invokehandle; }
432 
433   static int         flags          (int code, bool is_wide) {
434     assert(code == (u_char)code, "must be a byte");
435     return _flags[code + (is_wide ? (1<<BitsPerByte) : 0)];
436   }
437   static bool        has_all_flags  (Code code, int test_flags, bool is_wide) {
438     return (flags(code, is_wide) & test_flags) == test_flags;
439   }
440 
441   // Initialization
442   static void        initialize     ();
443 };
444 
445 #endif // SHARE_INTERPRETER_BYTECODES_HPP
< prev index next >