duke@435: /* acorn@4497: * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #include "precompiled.hpp" coleenp@4037: #include "interpreter/interpreter.hpp" coleenp@4037: #include "memory/gcLocker.hpp" acorn@4497: #include "memory/heapInspection.hpp" coleenp@4037: #include "memory/metadataFactory.hpp" coleenp@4037: #include "oops/constMethod.hpp" coleenp@4037: #include "oops/method.hpp" duke@435: duke@435: // Static initialization coleenp@4037: const u2 ConstMethod::MAX_IDNUM = 0xFFFE; coleenp@4037: const u2 ConstMethod::UNSET_IDNUM = 0xFFFF; coleenp@4037: coleenp@4037: ConstMethod* ConstMethod::allocate(ClassLoaderData* loader_data, kamg@4245: int byte_code_size, coleenp@4572: InlineTableSizes* sizes, kamg@4245: MethodType method_type, kamg@4245: TRAPS) { coleenp@4572: int size = ConstMethod::size(byte_code_size, sizes); iklam@5208: return new (loader_data, size, true, MetaspaceObj::ConstMethodType, THREAD) ConstMethod( coleenp@4572: byte_code_size, sizes, method_type, size); coleenp@4037: } coleenp@4037: coleenp@4037: ConstMethod::ConstMethod(int byte_code_size, coleenp@4572: InlineTableSizes* sizes, kamg@4245: MethodType method_type, kamg@4245: int size) { coleenp@4037: coleenp@4037: No_Safepoint_Verifier no_safepoint; coleenp@4037: init_fingerprint(); coleenp@4037: set_constants(NULL); coleenp@4037: set_stackmap_data(NULL); coleenp@4037: set_code_size(byte_code_size); coleenp@4037: set_constMethod_size(size); coleenp@4715: set_inlined_tables_length(sizes); // sets _flags kamg@4245: set_method_type(method_type); coleenp@4037: assert(this->size() == size, "wrong size for object"); coleenp@4712: set_name_index(0); coleenp@4712: set_signature_index(0); coleenp@4712: set_constants(NULL); coleenp@4712: set_max_stack(0); coleenp@4712: set_max_locals(0); coleenp@4712: set_method_idnum(0); coleenp@4715: set_size_of_parameters(0); coleenp@4037: } coleenp@4037: coleenp@4719: // Accessor that copies to metadata. coleenp@4719: void ConstMethod::copy_stackmap_data(ClassLoaderData* loader_data, coleenp@4719: u1* sd, int length, TRAPS) { coleenp@4719: _stackmap_data = MetadataFactory::new_array(loader_data, length, CHECK); coleenp@4719: memcpy((void*)_stackmap_data->adr_at(0), (void*)sd, length); coleenp@4719: } coleenp@4037: coleenp@4037: // Deallocate metadata fields associated with ConstMethod* coleenp@4037: void ConstMethod::deallocate_contents(ClassLoaderData* loader_data) { coleenp@4037: if (stackmap_data() != NULL) { coleenp@4037: MetadataFactory::free_array(loader_data, stackmap_data()); coleenp@4037: } coleenp@4037: set_stackmap_data(NULL); coleenp@4572: coleenp@4572: // deallocate annotation arrays coleenp@4572: if (has_method_annotations()) coleenp@4572: MetadataFactory::free_array(loader_data, method_annotations()); coleenp@4572: if (has_parameter_annotations()) coleenp@4572: MetadataFactory::free_array(loader_data, parameter_annotations()); coleenp@4572: if (has_type_annotations()) coleenp@4572: MetadataFactory::free_array(loader_data, type_annotations()); coleenp@4572: if (has_default_annotations()) coleenp@4572: MetadataFactory::free_array(loader_data, default_annotations()); coleenp@4037: } duke@435: duke@435: // How big must this constMethodObject be? duke@435: coleenp@4037: int ConstMethod::size(int code_size, coleenp@4572: InlineTableSizes* sizes) { duke@435: int extra_bytes = code_size; coleenp@4572: if (sizes->compressed_linenumber_size() > 0) { coleenp@4572: extra_bytes += sizes->compressed_linenumber_size(); duke@435: } coleenp@4572: if (sizes->checked_exceptions_length() > 0) { duke@435: extra_bytes += sizeof(u2); coleenp@4572: extra_bytes += sizes->checked_exceptions_length() * sizeof(CheckedExceptionElement); duke@435: } coleenp@4572: if (sizes->localvariable_table_length() > 0) { duke@435: extra_bytes += sizeof(u2); duke@435: extra_bytes += coleenp@4572: sizes->localvariable_table_length() * sizeof(LocalVariableTableElement); duke@435: } coleenp@4572: if (sizes->exception_table_length() > 0) { jiangli@3917: extra_bytes += sizeof(u2); coleenp@4572: extra_bytes += sizes->exception_table_length() * sizeof(ExceptionTableElement); jiangli@3917: } coleenp@4572: if (sizes->generic_signature_index() != 0) { jiangli@4302: extra_bytes += sizeof(u2); jiangli@4302: } coleenp@4572: if (sizes->method_parameters_length() > 0) { coleenp@4398: extra_bytes += sizeof(u2); coleenp@4572: extra_bytes += sizes->method_parameters_length() * sizeof(MethodParametersElement); coleenp@4398: } coleenp@4572: coleenp@4572: // Align sizes up to a word. coleenp@4572: extra_bytes = align_size_up(extra_bytes, BytesPerWord); coleenp@4572: coleenp@4572: // One pointer per annotation array coleenp@4572: if (sizes->method_annotations_length() > 0) { coleenp@4572: extra_bytes += sizeof(AnnotationArray*); coleenp@4572: } coleenp@4572: if (sizes->parameter_annotations_length() > 0) { coleenp@4572: extra_bytes += sizeof(AnnotationArray*); coleenp@4572: } coleenp@4572: if (sizes->type_annotations_length() > 0) { coleenp@4572: extra_bytes += sizeof(AnnotationArray*); coleenp@4572: } coleenp@4572: if (sizes->default_annotations_length() > 0) { coleenp@4572: extra_bytes += sizeof(AnnotationArray*); coleenp@4572: } coleenp@4572: duke@435: int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord; coleenp@4572: assert(extra_words == extra_bytes/BytesPerWord, "should already be aligned"); duke@435: return align_object_size(header_size() + extra_words); duke@435: } duke@435: coleenp@4037: Method* ConstMethod::method() const { coleenp@4251: return _constants->pool_holder()->method_with_idnum(_method_idnum); jiangli@3826: } duke@435: duke@435: // linenumber table - note that length is unknown until decompression, duke@435: // see class CompressedLineNumberReadStream. duke@435: coleenp@4037: u_char* ConstMethod::compressed_linenumber_table() const { duke@435: // Located immediately following the bytecodes. duke@435: assert(has_linenumber_table(), "called only if table is present"); duke@435: return code_end(); duke@435: } duke@435: coleenp@4572: // Last short in ConstMethod* before annotations coleenp@4572: u2* ConstMethod::last_u2_element() const { coleenp@4572: int offset = 0; coleenp@4572: if (has_method_annotations()) offset++; coleenp@4572: if (has_parameter_annotations()) offset++; coleenp@4572: if (has_type_annotations()) offset++; coleenp@4572: if (has_default_annotations()) offset++; coleenp@4572: return (u2*)((AnnotationArray**)constMethod_end() - offset) - 1; coleenp@4572: } coleenp@4572: jiangli@4302: u2* ConstMethod::generic_signature_index_addr() const { jiangli@4302: // Located at the end of the constMethod. jiangli@4302: assert(has_generic_signature(), "called only if generic signature exists"); jiangli@4302: return last_u2_element(); jiangli@4302: } jiangli@4302: coleenp@4572: u2* ConstMethod::method_parameters_length_addr() const { coleenp@4572: assert(has_method_parameters(), "called only if table is present"); coleenp@4572: return has_generic_signature() ? (last_u2_element() - 1) : coleenp@4572: last_u2_element(); coleenp@4572: } coleenp@4572: coleenp@4037: u2* ConstMethod::checked_exceptions_length_addr() const { jiangli@4302: // Located immediately before the generic signature index. duke@435: assert(has_checked_exceptions(), "called only if table is present"); coleenp@4398: if(has_method_parameters()) { coleenp@4398: // If method parameters present, locate immediately before them. coleenp@4398: return (u2*)method_parameters_start() - 1; coleenp@4398: } else { coleenp@4398: // Else, the exception table is at the end of the constMethod. coleenp@4398: return has_generic_signature() ? (last_u2_element() - 1) : coleenp@4398: last_u2_element(); coleenp@4398: } coleenp@4398: } coleenp@4398: coleenp@4037: u2* ConstMethod::exception_table_length_addr() const { jiangli@3917: assert(has_exception_handler(), "called only if table is present"); duke@435: if (has_checked_exceptions()) { duke@435: // If checked_exception present, locate immediately before them. duke@435: return (u2*) checked_exceptions_start() - 1; duke@435: } else { coleenp@4398: if(has_method_parameters()) { coleenp@4398: // If method parameters present, locate immediately before them. coleenp@4398: return (u2*)method_parameters_start() - 1; coleenp@4398: } else { coleenp@4398: // Else, the exception table is at the end of the constMethod. coleenp@4572: return has_generic_signature() ? (last_u2_element() - 1) : coleenp@4572: last_u2_element(); coleenp@4572: } coleenp@4398: } duke@435: } duke@435: coleenp@4037: u2* ConstMethod::localvariable_table_length_addr() const { jiangli@3917: assert(has_localvariable_table(), "called only if table is present"); jiangli@3917: if (has_exception_handler()) { jiangli@3917: // If exception_table present, locate immediately before them. jiangli@3917: return (u2*) exception_table_start() - 1; jiangli@3917: } else { jiangli@3917: if (has_checked_exceptions()) { jiangli@3917: // If checked_exception present, locate immediately before them. jiangli@3917: return (u2*) checked_exceptions_start() - 1; jiangli@3917: } else { coleenp@4398: if(has_method_parameters()) { coleenp@4398: // If method parameters present, locate immediately before them. coleenp@4398: return (u2*)method_parameters_start() - 1; coleenp@4398: } else { coleenp@4398: // Else, the exception table is at the end of the constMethod. jiangli@4302: return has_generic_signature() ? (last_u2_element() - 1) : jiangli@4302: last_u2_element(); coleenp@4572: } jiangli@3917: } jiangli@3917: } jiangli@3917: } jiangli@3917: duke@435: // Update the flags to indicate the presence of these optional fields. coleenp@4572: void ConstMethod::set_inlined_tables_length(InlineTableSizes* sizes) { coleenp@4572: _flags = 0; coleenp@4572: if (sizes->compressed_linenumber_size() > 0) duke@435: _flags |= _has_linenumber_table; coleenp@4572: if (sizes->generic_signature_index() != 0) jiangli@4302: _flags |= _has_generic_signature; coleenp@4572: if (sizes->method_parameters_length() > 0) coleenp@4398: _flags |= _has_method_parameters; coleenp@4572: if (sizes->checked_exceptions_length() > 0) coleenp@4398: _flags |= _has_checked_exceptions; coleenp@4572: if (sizes->exception_table_length() > 0) coleenp@4398: _flags |= _has_exception_table; coleenp@4572: if (sizes->localvariable_table_length() > 0) coleenp@4398: _flags |= _has_localvariable_table; coleenp@4398: coleenp@4572: // annotations, they are all pointer sized embedded objects so don't have coleenp@4572: // a length embedded also. coleenp@4572: if (sizes->method_annotations_length() > 0) coleenp@4572: _flags |= _has_method_annotations; coleenp@4572: if (sizes->parameter_annotations_length() > 0) coleenp@4572: _flags |= _has_parameter_annotations; coleenp@4572: if (sizes->type_annotations_length() > 0) coleenp@4572: _flags |= _has_type_annotations; coleenp@4572: if (sizes->default_annotations_length() > 0) coleenp@4572: _flags |= _has_default_annotations; coleenp@4572: coleenp@4398: // This code is extremely brittle and should possibly be revised. coleenp@4398: // The *_length_addr functions walk backwards through the coleenp@4398: // constMethod data, using each of the length indexes ahead of them, coleenp@4398: // as well as the flags variable. Therefore, the indexes must be coleenp@4398: // initialized in reverse order, or else they will compute the wrong coleenp@4398: // offsets. Moving the initialization of _flags into a separate coleenp@4398: // block solves *half* of the problem, but the following part will coleenp@4398: // still break if the order is not exactly right. coleenp@4398: // coleenp@4398: // Also, the servicability agent needs to be informed anytime coleenp@4398: // anything is added here. It might be advisable to have some sort coleenp@4398: // of indication of this inline. coleenp@4572: if (sizes->generic_signature_index() != 0) coleenp@4572: *(generic_signature_index_addr()) = sizes->generic_signature_index(); coleenp@4398: // New data should probably go here. coleenp@4572: if (sizes->method_parameters_length() > 0) coleenp@4572: *(method_parameters_length_addr()) = sizes->method_parameters_length(); coleenp@4572: if (sizes->checked_exceptions_length() > 0) coleenp@4572: *(checked_exceptions_length_addr()) = sizes->checked_exceptions_length(); coleenp@4572: if (sizes->exception_table_length() > 0) coleenp@4572: *(exception_table_length_addr()) = sizes->exception_table_length(); coleenp@4572: if (sizes->localvariable_table_length() > 0) coleenp@4572: *(localvariable_table_length_addr()) = sizes->localvariable_table_length(); coleenp@4398: } coleenp@4398: coleenp@4398: int ConstMethod::method_parameters_length() const { coleenp@4398: return has_method_parameters() ? *(method_parameters_length_addr()) : 0; coleenp@4398: } coleenp@4398: coleenp@4398: MethodParametersElement* ConstMethod::method_parameters_start() const { coleenp@4398: u2* addr = method_parameters_length_addr(); coleenp@4398: u2 length = *addr; coleenp@4398: assert(length > 0, "should only be called if table is present"); coleenp@4398: addr -= length * sizeof(MethodParametersElement) / sizeof(u2); coleenp@4398: return (MethodParametersElement*) addr; duke@435: } duke@435: duke@435: coleenp@4037: int ConstMethod::checked_exceptions_length() const { duke@435: return has_checked_exceptions() ? *(checked_exceptions_length_addr()) : 0; duke@435: } duke@435: duke@435: coleenp@4037: CheckedExceptionElement* ConstMethod::checked_exceptions_start() const { duke@435: u2* addr = checked_exceptions_length_addr(); duke@435: u2 length = *addr; duke@435: assert(length > 0, "should only be called if table is present"); duke@435: addr -= length * sizeof(CheckedExceptionElement) / sizeof(u2); duke@435: return (CheckedExceptionElement*) addr; duke@435: } duke@435: duke@435: coleenp@4037: int ConstMethod::localvariable_table_length() const { duke@435: return has_localvariable_table() ? *(localvariable_table_length_addr()) : 0; duke@435: } duke@435: duke@435: coleenp@4037: LocalVariableTableElement* ConstMethod::localvariable_table_start() const { duke@435: u2* addr = localvariable_table_length_addr(); duke@435: u2 length = *addr; duke@435: assert(length > 0, "should only be called if table is present"); duke@435: addr -= length * sizeof(LocalVariableTableElement) / sizeof(u2); duke@435: return (LocalVariableTableElement*) addr; duke@435: } jiangli@3917: coleenp@4037: int ConstMethod::exception_table_length() const { jiangli@3917: return has_exception_handler() ? *(exception_table_length_addr()) : 0; jiangli@3917: } jiangli@3917: coleenp@4037: ExceptionTableElement* ConstMethod::exception_table_start() const { jiangli@3917: u2* addr = exception_table_length_addr(); jiangli@3917: u2 length = *addr; jiangli@3917: assert(length > 0, "should only be called if table is present"); jiangli@3917: addr -= length * sizeof(ExceptionTableElement) / sizeof(u2); jiangli@3917: return (ExceptionTableElement*)addr; jiangli@3917: } coleenp@4037: coleenp@4572: AnnotationArray** ConstMethod::method_annotations_addr() const { coleenp@4572: assert(has_method_annotations(), "should only be called if method annotations are present"); coleenp@4572: return (AnnotationArray**)constMethod_end() - 1; coleenp@4572: } coleenp@4572: coleenp@4572: AnnotationArray** ConstMethod::parameter_annotations_addr() const { coleenp@4572: assert(has_parameter_annotations(), "should only be called if method parameter annotations are present"); coleenp@4572: int offset = 1; coleenp@4572: if (has_method_annotations()) offset++; coleenp@4572: return (AnnotationArray**)constMethod_end() - offset; coleenp@4572: } coleenp@4572: coleenp@4572: AnnotationArray** ConstMethod::type_annotations_addr() const { coleenp@4572: assert(has_type_annotations(), "should only be called if method type annotations are present"); coleenp@4572: int offset = 1; coleenp@4572: if (has_method_annotations()) offset++; coleenp@4572: if (has_parameter_annotations()) offset++; coleenp@4572: return (AnnotationArray**)constMethod_end() - offset; coleenp@4572: } coleenp@4572: coleenp@4572: AnnotationArray** ConstMethod::default_annotations_addr() const { coleenp@4572: assert(has_default_annotations(), "should only be called if method default annotations are present"); coleenp@4572: int offset = 1; coleenp@4572: if (has_method_annotations()) offset++; coleenp@4572: if (has_parameter_annotations()) offset++; coleenp@4572: if (has_type_annotations()) offset++; coleenp@4572: return (AnnotationArray**)constMethod_end() - offset; coleenp@4572: } coleenp@4037: coleenp@4837: // copy annotations from 'cm' to 'this' coleenp@4837: void ConstMethod::copy_annotations_from(ConstMethod* cm) { coleenp@4837: if (cm->has_method_annotations()) { coleenp@4837: assert(has_method_annotations(), "should be allocated already"); coleenp@4837: set_method_annotations(cm->method_annotations()); coleenp@4837: } coleenp@4837: if (cm->has_parameter_annotations()) { coleenp@4837: assert(has_parameter_annotations(), "should be allocated already"); coleenp@4837: set_parameter_annotations(cm->parameter_annotations()); coleenp@4837: } coleenp@4837: if (cm->has_type_annotations()) { coleenp@4837: assert(has_type_annotations(), "should be allocated already"); coleenp@4837: set_type_annotations(cm->type_annotations()); coleenp@4837: } coleenp@4837: if (cm->has_default_annotations()) { coleenp@4837: assert(has_default_annotations(), "should be allocated already"); coleenp@4837: set_default_annotations(cm->default_annotations()); coleenp@4837: } coleenp@4837: } coleenp@4837: coleenp@4037: // Printing coleenp@4037: coleenp@4037: void ConstMethod::print_on(outputStream* st) const { coleenp@4037: ResourceMark rm; coleenp@4037: assert(is_constMethod(), "must be constMethod"); coleenp@4037: st->print_cr(internal_name()); coleenp@4037: st->print(" - method: " INTPTR_FORMAT " ", (address)method()); coleenp@4037: method()->print_value_on(st); st->cr(); coleenp@4037: if (has_stackmap_table()) { coleenp@4037: st->print(" - stackmap data: "); coleenp@4037: stackmap_data()->print_value_on(st); coleenp@4037: st->cr(); coleenp@4037: } coleenp@4037: } coleenp@4037: coleenp@4037: // Short version of printing ConstMethod* - just print the name of the coleenp@4037: // method it belongs to. coleenp@4037: void ConstMethod::print_value_on(outputStream* st) const { coleenp@4037: assert(is_constMethod(), "must be constMethod"); coleenp@4037: st->print(" const part of method " ); coleenp@4037: method()->print_value_on(st); coleenp@4037: } coleenp@4037: acorn@4497: #if INCLUDE_SERVICES acorn@4497: // Size Statistics acorn@4497: void ConstMethod::collect_statistics(KlassSizeStats *sz) const { acorn@4497: int n1, n2, n3; acorn@4497: sz->_const_method_bytes += (n1 = sz->count(this)); acorn@4497: sz->_bytecode_bytes += (n2 = code_size()); acorn@4497: sz->_stackmap_bytes += (n3 = sz->count_array(stackmap_data())); acorn@4497: coleenp@4572: // Count method annotations coleenp@4572: int a1 = 0, a2 = 0, a3 = 0, a4 = 0; coleenp@4572: if (has_method_annotations()) { coleenp@4572: sz->_methods_annotations_bytes += (a1 = sz->count_array(method_annotations())); coleenp@4572: } coleenp@4572: if (has_parameter_annotations()) { coleenp@4572: sz->_methods_parameter_annotations_bytes += (a2 = sz->count_array(parameter_annotations())); coleenp@4572: } coleenp@4572: if (has_type_annotations()) { coleenp@4572: sz->_methods_type_annotations_bytes += (a3 = sz->count_array(type_annotations())); coleenp@4572: } coleenp@4572: if (has_default_annotations()) { coleenp@4572: sz->_methods_default_annotations_bytes += (a4 = sz->count_array(default_annotations())); coleenp@4572: } coleenp@4572: coleenp@4572: int size_annotations = a1 + a2 + a3 + a4; coleenp@4572: coleenp@4572: sz->_method_all_bytes += n1 + n3 + size_annotations; // note: n2 is part of n3 coleenp@4572: sz->_ro_bytes += n1 + n3 + size_annotations; acorn@4497: } acorn@4497: #endif // INCLUDE_SERVICES coleenp@4037: coleenp@4037: // Verification coleenp@4037: coleenp@4037: void ConstMethod::verify_on(outputStream* st) { coleenp@4037: guarantee(is_constMethod(), "object must be constMethod"); coleenp@4037: coleenp@4037: // Verification can occur during oop construction before the method or coleenp@4037: // other fields have been initialized. coleenp@4037: guarantee(method()->is_method(), "should be method"); coleenp@4037: coleenp@4572: address m_end = (address)((intptr_t) this + size()); coleenp@4037: address compressed_table_start = code_end(); coleenp@4037: guarantee(compressed_table_start <= m_end, "invalid method layout"); coleenp@4037: address compressed_table_end = compressed_table_start; coleenp@4037: // Verify line number table coleenp@4037: if (has_linenumber_table()) { coleenp@4037: CompressedLineNumberReadStream stream(compressed_linenumber_table()); coleenp@4037: while (stream.read_pair()) { coleenp@4037: guarantee(stream.bci() >= 0 && stream.bci() <= code_size(), "invalid bci in line number table"); coleenp@4037: } coleenp@4037: compressed_table_end += stream.position(); coleenp@4037: } coleenp@4037: guarantee(compressed_table_end <= m_end, "invalid method layout"); coleenp@4037: // Verify checked exceptions, exception table and local variable tables coleenp@4398: if (has_method_parameters()) { coleenp@4398: u2* addr = method_parameters_length_addr(); coleenp@4398: guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout"); coleenp@4398: } coleenp@4037: if (has_checked_exceptions()) { coleenp@4037: u2* addr = checked_exceptions_length_addr(); coleenp@4037: guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout"); coleenp@4037: } coleenp@4037: if (has_exception_handler()) { coleenp@4037: u2* addr = exception_table_length_addr(); coleenp@4037: guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout"); coleenp@4037: } coleenp@4037: if (has_localvariable_table()) { coleenp@4037: u2* addr = localvariable_table_length_addr(); coleenp@4037: guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout"); coleenp@4037: } coleenp@4037: // Check compressed_table_end relative to uncompressed_table_start coleenp@4037: u2* uncompressed_table_start; coleenp@4037: if (has_localvariable_table()) { coleenp@4037: uncompressed_table_start = (u2*) localvariable_table_start(); coleenp@4037: } else if (has_exception_handler()) { coleenp@4037: uncompressed_table_start = (u2*) exception_table_start(); coleenp@4037: } else if (has_checked_exceptions()) { coleenp@4037: uncompressed_table_start = (u2*) checked_exceptions_start(); coleenp@4398: } else if (has_method_parameters()) { coleenp@4398: uncompressed_table_start = (u2*) method_parameters_start(); coleenp@4037: } else { coleenp@4037: uncompressed_table_start = (u2*) m_end; coleenp@4037: } coleenp@4037: int gap = (intptr_t) uncompressed_table_start - (intptr_t) compressed_table_end; coleenp@4037: int max_gap = align_object_size(1)*BytesPerWord; coleenp@4037: guarantee(gap >= 0 && gap < max_gap, "invalid method layout"); coleenp@4037: }