src/share/vm/oops/constMethod.cpp

Print this page




  99   int extra_bytes = code_size;
 100   if (sizes->compressed_linenumber_size() > 0) {
 101     extra_bytes += sizes->compressed_linenumber_size();
 102   }
 103   if (sizes->checked_exceptions_length() > 0) {
 104     extra_bytes += sizeof(u2);
 105     extra_bytes += sizes->checked_exceptions_length() * sizeof(CheckedExceptionElement);
 106   }
 107   if (sizes->localvariable_table_length() > 0) {
 108     extra_bytes += sizeof(u2);
 109     extra_bytes +=
 110               sizes->localvariable_table_length() * sizeof(LocalVariableTableElement);
 111   }
 112   if (sizes->exception_table_length() > 0) {
 113     extra_bytes += sizeof(u2);
 114     extra_bytes += sizes->exception_table_length() * sizeof(ExceptionTableElement);
 115   }
 116   if (sizes->generic_signature_index() != 0) {
 117     extra_bytes += sizeof(u2);
 118   }
 119   if (sizes->method_parameters_length() > 0) {
 120     extra_bytes += sizeof(u2);
 121     extra_bytes += sizes->method_parameters_length() * sizeof(MethodParametersElement);
 122   }
 123 
 124   // Align sizes up to a word.
 125   extra_bytes = align_size_up(extra_bytes, BytesPerWord);
 126 
 127   // One pointer per annotation array
 128   if (sizes->method_annotations_length() > 0) {
 129     extra_bytes += sizeof(AnnotationArray*);
 130   }
 131   if (sizes->parameter_annotations_length() > 0) {
 132     extra_bytes += sizeof(AnnotationArray*);
 133   }
 134   if (sizes->type_annotations_length() > 0) {
 135     extra_bytes += sizeof(AnnotationArray*);
 136   }
 137   if (sizes->default_annotations_length() > 0) {
 138     extra_bytes += sizeof(AnnotationArray*);
 139   }


 220     } else {
 221       if(has_method_parameters()) {
 222         // If method parameters present, locate immediately before them.
 223         return (u2*)method_parameters_start() - 1;
 224       } else {
 225         // Else, the exception table is at the end of the constMethod.
 226       return has_generic_signature() ? (last_u2_element() - 1) :
 227                                         last_u2_element();
 228       }
 229     }
 230   }
 231 }
 232 
 233 // Update the flags to indicate the presence of these optional fields.
 234 void ConstMethod::set_inlined_tables_length(InlineTableSizes* sizes) {
 235   _flags = 0;
 236   if (sizes->compressed_linenumber_size() > 0)
 237     _flags |= _has_linenumber_table;
 238   if (sizes->generic_signature_index() != 0)
 239     _flags |= _has_generic_signature;
 240   if (sizes->method_parameters_length() > 0)
 241     _flags |= _has_method_parameters;
 242   if (sizes->checked_exceptions_length() > 0)
 243     _flags |= _has_checked_exceptions;
 244   if (sizes->exception_table_length() > 0)
 245     _flags |= _has_exception_table;
 246   if (sizes->localvariable_table_length() > 0)
 247     _flags |= _has_localvariable_table;
 248 
 249   // annotations, they are all pointer sized embedded objects so don't have
 250   // a length embedded also.
 251   if (sizes->method_annotations_length() > 0)
 252     _flags |= _has_method_annotations;
 253   if (sizes->parameter_annotations_length() > 0)
 254     _flags |= _has_parameter_annotations;
 255   if (sizes->type_annotations_length() > 0)
 256     _flags |= _has_type_annotations;
 257   if (sizes->default_annotations_length() > 0)
 258     _flags |= _has_default_annotations;
 259 
 260   // This code is extremely brittle and should possibly be revised.
 261   // The *_length_addr functions walk backwards through the
 262   // constMethod data, using each of the length indexes ahead of them,
 263   // as well as the flags variable.  Therefore, the indexes must be
 264   // initialized in reverse order, or else they will compute the wrong
 265   // offsets.  Moving the initialization of _flags into a separate
 266   // block solves *half* of the problem, but the following part will
 267   // still break if the order is not exactly right.
 268   //
 269   // Also, the servicability agent needs to be informed anytime
 270   // anything is added here.  It might be advisable to have some sort
 271   // of indication of this inline.
 272   if (sizes->generic_signature_index() != 0)
 273     *(generic_signature_index_addr()) = sizes->generic_signature_index();
 274   // New data should probably go here.
 275   if (sizes->method_parameters_length() > 0)
 276     *(method_parameters_length_addr()) = sizes->method_parameters_length();
 277   if (sizes->checked_exceptions_length() > 0)
 278     *(checked_exceptions_length_addr()) = sizes->checked_exceptions_length();
 279   if (sizes->exception_table_length() > 0)
 280     *(exception_table_length_addr()) = sizes->exception_table_length();
 281   if (sizes->localvariable_table_length() > 0)
 282     *(localvariable_table_length_addr()) = sizes->localvariable_table_length();
 283 }
 284 
 285 int ConstMethod::method_parameters_length() const {
 286   return has_method_parameters() ? *(method_parameters_length_addr()) : 0;
 287 }
 288 
 289 MethodParametersElement* ConstMethod::method_parameters_start() const {
 290   u2* addr = method_parameters_length_addr();
 291   u2 length = *addr;
 292   assert(length > 0, "should only be called if table is present");
 293   addr -= length * sizeof(MethodParametersElement) / sizeof(u2);
 294   return (MethodParametersElement*) addr;
 295 }
 296 
 297 
 298 int ConstMethod::checked_exceptions_length() const {
 299   return has_checked_exceptions() ? *(checked_exceptions_length_addr()) : 0;
 300 }
 301 
 302 
 303 CheckedExceptionElement* ConstMethod::checked_exceptions_start() const {
 304   u2* addr = checked_exceptions_length_addr();
 305   u2 length = *addr;
 306   assert(length > 0, "should only be called if table is present");




  99   int extra_bytes = code_size;
 100   if (sizes->compressed_linenumber_size() > 0) {
 101     extra_bytes += sizes->compressed_linenumber_size();
 102   }
 103   if (sizes->checked_exceptions_length() > 0) {
 104     extra_bytes += sizeof(u2);
 105     extra_bytes += sizes->checked_exceptions_length() * sizeof(CheckedExceptionElement);
 106   }
 107   if (sizes->localvariable_table_length() > 0) {
 108     extra_bytes += sizeof(u2);
 109     extra_bytes +=
 110               sizes->localvariable_table_length() * sizeof(LocalVariableTableElement);
 111   }
 112   if (sizes->exception_table_length() > 0) {
 113     extra_bytes += sizeof(u2);
 114     extra_bytes += sizes->exception_table_length() * sizeof(ExceptionTableElement);
 115   }
 116   if (sizes->generic_signature_index() != 0) {
 117     extra_bytes += sizeof(u2);
 118   }
 119   if (sizes->method_parameters_length() >= 0) {
 120     extra_bytes += sizeof(u2);
 121     extra_bytes += sizes->method_parameters_length() * sizeof(MethodParametersElement);
 122   }
 123 
 124   // Align sizes up to a word.
 125   extra_bytes = align_size_up(extra_bytes, BytesPerWord);
 126 
 127   // One pointer per annotation array
 128   if (sizes->method_annotations_length() > 0) {
 129     extra_bytes += sizeof(AnnotationArray*);
 130   }
 131   if (sizes->parameter_annotations_length() > 0) {
 132     extra_bytes += sizeof(AnnotationArray*);
 133   }
 134   if (sizes->type_annotations_length() > 0) {
 135     extra_bytes += sizeof(AnnotationArray*);
 136   }
 137   if (sizes->default_annotations_length() > 0) {
 138     extra_bytes += sizeof(AnnotationArray*);
 139   }


 220     } else {
 221       if(has_method_parameters()) {
 222         // If method parameters present, locate immediately before them.
 223         return (u2*)method_parameters_start() - 1;
 224       } else {
 225         // Else, the exception table is at the end of the constMethod.
 226       return has_generic_signature() ? (last_u2_element() - 1) :
 227                                         last_u2_element();
 228       }
 229     }
 230   }
 231 }
 232 
 233 // Update the flags to indicate the presence of these optional fields.
 234 void ConstMethod::set_inlined_tables_length(InlineTableSizes* sizes) {
 235   _flags = 0;
 236   if (sizes->compressed_linenumber_size() > 0)
 237     _flags |= _has_linenumber_table;
 238   if (sizes->generic_signature_index() != 0)
 239     _flags |= _has_generic_signature;
 240   if (sizes->method_parameters_length() >= 0)
 241     _flags |= _has_method_parameters;
 242   if (sizes->checked_exceptions_length() > 0)
 243     _flags |= _has_checked_exceptions;
 244   if (sizes->exception_table_length() > 0)
 245     _flags |= _has_exception_table;
 246   if (sizes->localvariable_table_length() > 0)
 247     _flags |= _has_localvariable_table;
 248 
 249   // annotations, they are all pointer sized embedded objects so don't have
 250   // a length embedded also.
 251   if (sizes->method_annotations_length() > 0)
 252     _flags |= _has_method_annotations;
 253   if (sizes->parameter_annotations_length() > 0)
 254     _flags |= _has_parameter_annotations;
 255   if (sizes->type_annotations_length() > 0)
 256     _flags |= _has_type_annotations;
 257   if (sizes->default_annotations_length() > 0)
 258     _flags |= _has_default_annotations;
 259 
 260   // This code is extremely brittle and should possibly be revised.
 261   // The *_length_addr functions walk backwards through the
 262   // constMethod data, using each of the length indexes ahead of them,
 263   // as well as the flags variable.  Therefore, the indexes must be
 264   // initialized in reverse order, or else they will compute the wrong
 265   // offsets.  Moving the initialization of _flags into a separate
 266   // block solves *half* of the problem, but the following part will
 267   // still break if the order is not exactly right.
 268   //
 269   // Also, the servicability agent needs to be informed anytime
 270   // anything is added here.  It might be advisable to have some sort
 271   // of indication of this inline.
 272   if (sizes->generic_signature_index() != 0)
 273     *(generic_signature_index_addr()) = sizes->generic_signature_index();
 274   // New data should probably go here.
 275   if (sizes->method_parameters_length() >= 0)
 276     *(method_parameters_length_addr()) = sizes->method_parameters_length();
 277   if (sizes->checked_exceptions_length() > 0)
 278     *(checked_exceptions_length_addr()) = sizes->checked_exceptions_length();
 279   if (sizes->exception_table_length() > 0)
 280     *(exception_table_length_addr()) = sizes->exception_table_length();
 281   if (sizes->localvariable_table_length() > 0)
 282     *(localvariable_table_length_addr()) = sizes->localvariable_table_length();
 283 }
 284 
 285 int ConstMethod::method_parameters_length() const {
 286   return has_method_parameters() ? *(method_parameters_length_addr()) : -1;
 287 }
 288 
 289 MethodParametersElement* ConstMethod::method_parameters_start() const {
 290   u2* addr = method_parameters_length_addr();
 291   u2 length = *addr;
 292   assert(length > 0, "should only be called if table is present");
 293   addr -= length * sizeof(MethodParametersElement) / sizeof(u2);
 294   return (MethodParametersElement*) addr;
 295 }
 296 
 297 
 298 int ConstMethod::checked_exceptions_length() const {
 299   return has_checked_exceptions() ? *(checked_exceptions_length_addr()) : 0;
 300 }
 301 
 302 
 303 CheckedExceptionElement* ConstMethod::checked_exceptions_start() const {
 304   u2* addr = checked_exceptions_length_addr();
 305   u2 length = *addr;
 306   assert(length > 0, "should only be called if table is present");