diff --git a/src/hotspot/share/interpreter/bytecodes.cpp b/src/hotspot/share/interpreter/bytecodes.cpp index c5204e63ce281..5db3ab5fe6b0d 100644 --- a/src/hotspot/share/interpreter/bytecodes.cpp +++ b/src/hotspot/share/interpreter/bytecodes.cpp @@ -29,13 +29,309 @@ #include "utilities/align.hpp" #include "utilities/bytes.hpp" -bool Bytecodes::_is_initialized = false; -const char* Bytecodes::_name [Bytecodes::number_of_codes]; -BasicType Bytecodes::_result_type [Bytecodes::number_of_codes]; -s_char Bytecodes::_depth [Bytecodes::number_of_codes]; -u_char Bytecodes::_lengths [Bytecodes::number_of_codes]; -Bytecodes::Code Bytecodes::_java_code [Bytecodes::number_of_codes]; -unsigned short Bytecodes::_flags [(1< + static constexpr size_t invoke(const char (&)[N]) { + static_assert(N > 0, "N must be greater than 0"); + // The size is N - 1, as C strings have an implicit NUL at the end. So "foo" will result in N + // being 4, but we actually want 3. + return N - 1; + } + + static constexpr size_t invoke(std::nullptr_t) { + return 0; + } +}; + +#define STRING_SIZE(string) StringLiteralSize::invoke(string) + +const u_char Bytecodes::_lengths[Bytecodes::number_of_codes] = { +#define BYTECODE_LENGTHS(code, name, format, wide_format, result_type, depth, can_trap, java_code) static_cast((STRING_SIZE(wide_format) << 4) | (STRING_SIZE(format) & 0xf)), + BYTECODES_DO(BYTECODE_LENGTHS) +#undef BYTECODE_LENGTHS +}; + +const Bytecodes::Code Bytecodes::_java_code[Bytecodes::number_of_codes] = { +#define BYTECODE_JAVA_CODE(code, name, format, wide_format, result_type, depth, can_trap, java_code) Bytecodes::java_code, + BYTECODES_DO(BYTECODE_JAVA_CODE) +#undef BYTECODE_JAVA_CODE +}; + +jchar Bytecodes::_flags[(1<