Mercurial > hg > truffle
diff src/share/vm/oops/constMethod.cpp @ 7482:989155e2d07a
Merge with hs25-b15.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 16 Jan 2013 01:34:24 +0100 |
parents | ade95d680b42 |
children | 16fb9f942703 |
line wrap: on
line diff
--- a/src/share/vm/oops/constMethod.cpp Tue Jan 15 18:54:02 2013 +0100 +++ b/src/share/vm/oops/constMethod.cpp Wed Jan 16 01:34:24 2013 +0100 @@ -39,18 +39,21 @@ int localvariable_table_length, int exception_table_length, int checked_exceptions_length, + int method_parameters_length, u2 generic_signature_index, MethodType method_type, TRAPS) { int size = ConstMethod::size(byte_code_size, - compressed_line_number_size, - localvariable_table_length, - exception_table_length, - checked_exceptions_length, - generic_signature_index); + compressed_line_number_size, + localvariable_table_length, + exception_table_length, + checked_exceptions_length, + method_parameters_length, + generic_signature_index); return new (loader_data, size, true, THREAD) ConstMethod( byte_code_size, compressed_line_number_size, localvariable_table_length, - exception_table_length, checked_exceptions_length, generic_signature_index, + exception_table_length, checked_exceptions_length, + method_parameters_length, generic_signature_index, method_type, size); } @@ -59,6 +62,7 @@ int localvariable_table_length, int exception_table_length, int checked_exceptions_length, + int method_parameters_length, u2 generic_signature_index, MethodType method_type, int size) { @@ -74,7 +78,8 @@ checked_exceptions_length, compressed_line_number_size, localvariable_table_length, - exception_table_length); + exception_table_length, + method_parameters_length); set_method_type(method_type); assert(this->size() == size, "wrong size for object"); } @@ -92,11 +97,12 @@ // How big must this constMethodObject be? int ConstMethod::size(int code_size, - int compressed_line_number_size, - int local_variable_table_length, - int exception_table_length, - int checked_exceptions_length, - u2 generic_signature_index) { + int compressed_line_number_size, + int local_variable_table_length, + int exception_table_length, + int checked_exceptions_length, + int method_parameters_length, + u2 generic_signature_index) { int extra_bytes = code_size; if (compressed_line_number_size > 0) { extra_bytes += compressed_line_number_size; @@ -117,6 +123,10 @@ if (generic_signature_index != 0) { extra_bytes += sizeof(u2); } + if (method_parameters_length > 0) { + extra_bytes += sizeof(u2); + extra_bytes += method_parameters_length * sizeof(MethodParametersElement); + } int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord; return align_object_size(header_size() + extra_words); } @@ -143,6 +153,18 @@ u2* ConstMethod::checked_exceptions_length_addr() const { // Located immediately before the generic signature index. assert(has_checked_exceptions(), "called only if table is present"); + if(has_method_parameters()) { + // If method parameters present, locate immediately before them. + return (u2*)method_parameters_start() - 1; + } else { + // Else, the exception table is at the end of the constMethod. + return has_generic_signature() ? (last_u2_element() - 1) : + last_u2_element(); + } +} + +u2* ConstMethod::method_parameters_length_addr() const { + assert(has_method_parameters(), "called only if table is present"); return has_generic_signature() ? (last_u2_element() - 1) : last_u2_element(); } @@ -153,11 +175,15 @@ // If checked_exception present, locate immediately before them. return (u2*) checked_exceptions_start() - 1; } else { - // Else, the exception table is at the end of the constMethod or - // immediately before the generic signature index. + if(has_method_parameters()) { + // If method parameters present, locate immediately before them. + return (u2*)method_parameters_start() - 1; + } else { + // Else, the exception table is at the end of the constMethod. return has_generic_signature() ? (last_u2_element() - 1) : last_u2_element(); } + } } u2* ConstMethod::localvariable_table_length_addr() const { @@ -170,12 +196,16 @@ // If checked_exception present, locate immediately before them. return (u2*) checked_exceptions_start() - 1; } else { - // Else, the linenumber table is at the end of the constMethod or - // immediately before the generic signature index. + if(has_method_parameters()) { + // If method parameters present, locate immediately before them. + return (u2*)method_parameters_start() - 1; + } else { + // Else, the exception table is at the end of the constMethod. return has_generic_signature() ? (last_u2_element() - 1) : last_u2_element(); } } + } } // Update the flags to indicate the presence of these optional fields. @@ -183,29 +213,57 @@ int checked_exceptions_len, int compressed_line_number_size, int localvariable_table_len, - int exception_table_len) { - // Must be done in the order below, otherwise length_addr accessors - // will not work. Only set bit in header if length is positive. + int exception_table_len, + int method_parameters_len) { assert(_flags == 0, "Error"); - if (compressed_line_number_size > 0) { + if (compressed_line_number_size > 0) _flags |= _has_linenumber_table; - } - if (generic_signature_index != 0) { + if (generic_signature_index != 0) _flags |= _has_generic_signature; + if (method_parameters_len > 0) + _flags |= _has_method_parameters; + if (checked_exceptions_len > 0) + _flags |= _has_checked_exceptions; + if (exception_table_len > 0) + _flags |= _has_exception_table; + if (localvariable_table_len > 0) + _flags |= _has_localvariable_table; + + // This code is extremely brittle and should possibly be revised. + // The *_length_addr functions walk backwards through the + // constMethod data, using each of the length indexes ahead of them, + // as well as the flags variable. Therefore, the indexes must be + // initialized in reverse order, or else they will compute the wrong + // offsets. Moving the initialization of _flags into a separate + // block solves *half* of the problem, but the following part will + // still break if the order is not exactly right. + // + // Also, the servicability agent needs to be informed anytime + // anything is added here. It might be advisable to have some sort + // of indication of this inline. + if (generic_signature_index != 0) *(generic_signature_index_addr()) = generic_signature_index; - } - if (checked_exceptions_len > 0) { - _flags |= _has_checked_exceptions; + // New data should probably go here. + if (method_parameters_len > 0) + *(method_parameters_length_addr()) = method_parameters_len; + if (checked_exceptions_len > 0) *(checked_exceptions_length_addr()) = checked_exceptions_len; - } - if (exception_table_len > 0) { - _flags |= _has_exception_table; + if (exception_table_len > 0) *(exception_table_length_addr()) = exception_table_len; - } - if (localvariable_table_len > 0) { - _flags |= _has_localvariable_table; + if (localvariable_table_len > 0) *(localvariable_table_length_addr()) = localvariable_table_len; - } +} + +int ConstMethod::method_parameters_length() const { + return has_method_parameters() ? *(method_parameters_length_addr()) : 0; +} + +MethodParametersElement* ConstMethod::method_parameters_start() const { + u2* addr = method_parameters_length_addr(); + u2 length = *addr; + assert(length > 0, "should only be called if table is present"); + addr -= length * sizeof(MethodParametersElement) / sizeof(u2); + return (MethodParametersElement*) addr; } @@ -298,6 +356,10 @@ } guarantee(compressed_table_end <= m_end, "invalid method layout"); // Verify checked exceptions, exception table and local variable tables + if (has_method_parameters()) { + u2* addr = method_parameters_length_addr(); + guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout"); + } if (has_checked_exceptions()) { u2* addr = checked_exceptions_length_addr(); guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout"); @@ -318,6 +380,8 @@ uncompressed_table_start = (u2*) exception_table_start(); } else if (has_checked_exceptions()) { uncompressed_table_start = (u2*) checked_exceptions_start(); + } else if (has_method_parameters()) { + uncompressed_table_start = (u2*) method_parameters_start(); } else { uncompressed_table_start = (u2*) m_end; }