/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "memory/allocation.hpp"
// Bytecodes specifies all bytecodes used in the VM and
// provides utility functions to get bytecode attributes.
// NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/interpreter/Bytecodes.java
public:
enum Code {
// Java bytecodes
// JVM bytecodes
// special handling of oop constants:
// special handling of signature-polymorphic methods:
// Platform specific JVM bytecodes
#ifdef TARGET_ARCH_x86
# include "bytecodes_x86.hpp"
#endif
#ifdef TARGET_ARCH_sparc
# include "bytecodes_sparc.hpp"
#endif
#ifdef TARGET_ARCH_zero
# include "bytecodes_zero.hpp"
#endif
#ifdef TARGET_ARCH_arm
# include "bytecodes_arm.hpp"
#endif
#ifdef TARGET_ARCH_ppc
# include "bytecodes_ppc.hpp"
#endif
};
// Flag bits derived from format strings, can_trap, can_rewrite, etc.:
enum Flags {
// semantic flags:
// format bits (determined only by the format string):
// Example derived format syndromes:
};
private:
static bool _is_initialized;
static void def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap);
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);
static void pd_initialize(); // platform specific initialization
// Verify that bcp points into method
#ifdef ASSERT
#endif
public:
// Conversion
static void wide_check (Code code) { assert(wide_is_defined(code), err_msg("illegal code: %d", (int)code)); }
// Fetch a bytecode, hiding breakpoints as necessary. The method
// argument is used for conversion of breakpoints into the original
// bytecode. The CI uses these methods but guarantees that
// breakpoints are hidden so the method argument should be passed as
// NULL since in that case the bcp and methodOop are unrelated
// memory.
}
}
// Fetch a bytecode or a breakpoint:
// find a bytecode, behind a breakpoint if necessary:
// Bytecode attributes
static bool is_defined (int code) { return 0 <= code && code < number_of_codes && flags(code, false) != 0; }
// Note: Length functions must return <=0 for invalid bytecodes.
// Calling check(code) in length functions would throw an unwanted assert.
static bool can_rewrite (Code code) { check(code); return has_all_flags(code, _bc_can_rewrite, false); }
static bool must_rewrite(Bytecodes::Code code) { return can_rewrite(code) && check_must_rewrite(code); }
static bool native_byte_order(Code code) { check(code); return has_all_flags(code, _fmt_has_nbo, false); }
static bool uses_cp_cache (Code code) { check(code); return has_all_flags(code, _fmt_has_j, false); }
// if 'end' is provided, it indicates the end of the code buffer which
// should not be read past when parsing.
static int special_length_at(methodOop method, address bcp, address end = NULL) { return special_length_at(code_at(method, bcp), bcp, end); }
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); }
static int length_at (methodOop method, address bcp) { return length_for_code_at(code_at(method, bcp), bcp); }
static int java_length_at (methodOop method, address bcp) { return length_for_code_at(java_code_at(method, bcp), bcp); }
static bool is_astore (Code code) { return (code == _astore || code == _astore_0 || code == _astore_1
static bool has_receiver (Code code) { assert(is_invoke(code), ""); return code == _invokevirtual ||
code == _invokespecial ||
code == _invokeinterface; }
static bool has_optional_appendix(Code code) { return code == _invokedynamic || code == _invokehandle; }
}
}
// Initialization
static void initialize ();
};
#endif // SHARE_VM_INTERPRETER_BYTECODES_HPP