hotspot/src/share/vm/interpreter/bytecodes.hpp
changeset 7913 dd096a83bdbb
parent 7397 5b173b4ca846
child 8107 78e5bd944384
equal deleted inserted replaced
7901:ea3d83447861 7913:dd096a83bdbb
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   340   static void        def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap);
   340   static void        def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap);
   341   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);
   341   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);
   342   static void        pd_initialize();              // platform specific initialization
   342   static void        pd_initialize();              // platform specific initialization
   343   static Code        pd_base_code_for(Code code);  // platform specific base_code_for implementation
   343   static Code        pd_base_code_for(Code code);  // platform specific base_code_for implementation
   344 
   344 
       
   345   // Verify that bcp points into method
       
   346 #ifdef ASSERT
       
   347   static bool        check_method(const methodOopDesc* method, address bcp);
       
   348 #endif
       
   349   static bool check_must_rewrite(Bytecodes::Code bc);
       
   350 
   345  public:
   351  public:
   346   // Conversion
   352   // Conversion
   347   static void        check          (Code code)    { assert(is_defined(code), "illegal code"); }
   353   static void        check          (Code code)    { assert(is_defined(code), "illegal code"); }
   348   static void        wide_check     (Code code)    { assert(wide_is_defined(code), "illegal code"); }
   354   static void        wide_check     (Code code)    { assert(wide_is_defined(code), "illegal code"); }
   349   static Code        cast           (int  code)    { return (Code)code; }
   355   static Code        cast           (int  code)    { return (Code)code; }
   350 
   356 
   351 
   357 
   352    // Fetch a bytecode, hiding breakpoints as necessary:
   358   // Fetch a bytecode, hiding breakpoints as necessary.  The method
   353    static Code       code_at(address bcp, methodOop method = NULL) {
   359   // argument is used for conversion of breakpoints into the original
   354           Code code = cast(*bcp); return (code != _breakpoint) ? code : non_breakpoint_code_at(bcp, method);
   360   // bytecode.  The CI uses these methods but guarantees that
   355    }
   361   // breakpoints are hidden so the method argument should be passed as
   356    static Code       java_code_at(address bcp, methodOop method = NULL) {
   362   // NULL since in that case the bcp and methodOop are unrelated
   357           return java_code(code_at(bcp, method));
   363   // memory.
   358    }
   364   static Code       code_at(const methodOopDesc* method, address bcp) {
   359 
   365     assert(method == NULL || check_method(method, bcp), "bcp must point into method");
   360    // Fetch a bytecode or a breakpoint:
   366     Code code = cast(*bcp);
   361    static Code       code_or_bp_at(address bcp)    { return (Code)cast(*bcp); }
   367     assert(code != _breakpoint || method != NULL, "need methodOop to decode breakpoint");
   362 
   368     return (code != _breakpoint) ? code : non_breakpoint_code_at(method, bcp);
   363    static Code       code_at(methodOop method, int bci);
   369   }
   364    static bool       is_active_breakpoint_at(address bcp) { return (Code)*bcp == _breakpoint; }
   370   static Code       java_code_at(const methodOopDesc* method, address bcp) {
   365 
   371     return java_code(code_at(method, bcp));
   366    // find a bytecode, behind a breakpoint if necessary:
   372   }
   367    static Code       non_breakpoint_code_at(address bcp, methodOop method = NULL);
   373 
       
   374   // Fetch a bytecode or a breakpoint:
       
   375   static Code       code_or_bp_at(address bcp)    { return (Code)cast(*bcp); }
       
   376 
       
   377   static Code       code_at(methodOop method, int bci);
       
   378   static bool       is_active_breakpoint_at(address bcp) { return (Code)*bcp == _breakpoint; }
       
   379 
       
   380   // find a bytecode, behind a breakpoint if necessary:
       
   381   static Code       non_breakpoint_code_at(const methodOopDesc* method, address bcp);
   368 
   382 
   369   // Bytecode attributes
   383   // Bytecode attributes
   370   static bool        is_defined     (int  code)    { return 0 <= code && code < number_of_codes && flags(code, false) != 0; }
   384   static bool        is_defined     (int  code)    { return 0 <= code && code < number_of_codes && flags(code, false) != 0; }
   371   static bool        wide_is_defined(int  code)    { return is_defined(code) && flags(code, true) != 0; }
   385   static bool        wide_is_defined(int  code)    { return is_defined(code) && flags(code, true) != 0; }
   372   static const char* name           (Code code)    { check(code);      return _name          [code]; }
   386   static const char* name           (Code code)    { check(code);      return _name          [code]; }
   377   static int         length_for     (Code code)    { /*no check*/      return _lengths       [code] & 0xF; }
   391   static int         length_for     (Code code)    { /*no check*/      return _lengths       [code] & 0xF; }
   378   static int         wide_length_for(Code code)    { /*no check*/      return _lengths       [code] >> 4; }
   392   static int         wide_length_for(Code code)    { /*no check*/      return _lengths       [code] >> 4; }
   379   static bool        can_trap       (Code code)    { check(code);      return has_all_flags(code, _bc_can_trap, false); }
   393   static bool        can_trap       (Code code)    { check(code);      return has_all_flags(code, _bc_can_trap, false); }
   380   static Code        java_code      (Code code)    { check(code);      return _java_code     [code]; }
   394   static Code        java_code      (Code code)    { check(code);      return _java_code     [code]; }
   381   static bool        can_rewrite    (Code code)    { check(code);      return has_all_flags(code, _bc_can_rewrite, false); }
   395   static bool        can_rewrite    (Code code)    { check(code);      return has_all_flags(code, _bc_can_rewrite, false); }
       
   396   static bool        must_rewrite(Bytecodes::Code code) { return can_rewrite(code) && check_must_rewrite(code); }
   382   static bool        native_byte_order(Code code)  { check(code);      return has_all_flags(code, _fmt_has_nbo, false); }
   397   static bool        native_byte_order(Code code)  { check(code);      return has_all_flags(code, _fmt_has_nbo, false); }
   383   static bool        uses_cp_cache  (Code code)    { check(code);      return has_all_flags(code, _fmt_has_j, false); }
   398   static bool        uses_cp_cache  (Code code)    { check(code);      return has_all_flags(code, _fmt_has_j, false); }
   384   // if 'end' is provided, it indicates the end of the code buffer which
   399   // if 'end' is provided, it indicates the end of the code buffer which
   385   // should not be read past when parsing.
   400   // should not be read past when parsing.
   386   static int         special_length_at(address bcp, address end = NULL);
   401   static int         special_length_at(Bytecodes::Code code, address bcp, address end = NULL);
       
   402   static int         special_length_at(methodOop method, address bcp, address end = NULL) { return special_length_at(code_at(method, bcp), bcp, end); }
   387   static int         raw_special_length_at(address bcp, address end = NULL);
   403   static int         raw_special_length_at(address bcp, address end = NULL);
   388   static int         length_at      (address bcp)  { int l = length_for(code_at(bcp)); return l > 0 ? l : special_length_at(bcp); }
   404   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); }
   389   static int         java_length_at (address bcp)  { int l = length_for(java_code_at(bcp)); return l > 0 ? l : special_length_at(bcp); }
   405   static int         length_at      (methodOop method, address bcp)  { return length_for_code_at(code_at(method, bcp), bcp); }
       
   406   static int         java_length_at (methodOop method, address bcp)  { return length_for_code_at(java_code_at(method, bcp), bcp); }
   390   static bool        is_java_code   (Code code)    { return 0 <= code && code < number_of_java_codes; }
   407   static bool        is_java_code   (Code code)    { return 0 <= code && code < number_of_java_codes; }
   391 
   408 
   392   static bool        is_aload       (Code code)    { return (code == _aload  || code == _aload_0  || code == _aload_1
   409   static bool        is_aload       (Code code)    { return (code == _aload  || code == _aload_0  || code == _aload_1
   393                                                                              || code == _aload_2  || code == _aload_3); }
   410                                                                              || code == _aload_2  || code == _aload_3); }
   394   static bool        is_astore      (Code code)    { return (code == _astore || code == _astore_0 || code == _astore_1
   411   static bool        is_astore      (Code code)    { return (code == _astore || code == _astore_0 || code == _astore_1