src/share/vm/oops/constMethodOop.cpp

changeset 3917
8150fa46d2ed
parent 3826
2fe087c3e814
     1.1 --- a/src/share/vm/oops/constMethodOop.cpp	Mon Jun 25 15:34:06 2012 -0400
     1.2 +++ b/src/share/vm/oops/constMethodOop.cpp	Tue Jun 26 19:08:44 2012 -0400
     1.3 @@ -35,6 +35,7 @@
     1.4  int constMethodOopDesc::object_size(int code_size,
     1.5                                      int compressed_line_number_size,
     1.6                                      int local_variable_table_length,
     1.7 +                                    int exception_table_length,
     1.8                                      int checked_exceptions_length) {
     1.9    int extra_bytes = code_size;
    1.10    if (compressed_line_number_size > 0) {
    1.11 @@ -49,6 +50,10 @@
    1.12      extra_bytes +=
    1.13                local_variable_table_length * sizeof(LocalVariableTableElement);
    1.14    }
    1.15 +  if (exception_table_length > 0) {
    1.16 +    extra_bytes += sizeof(u2);
    1.17 +    extra_bytes += exception_table_length * sizeof(ExceptionTableElement);
    1.18 +  }
    1.19    int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord;
    1.20    return align_object_size(header_size() + extra_words);
    1.21  }
    1.22 @@ -73,23 +78,40 @@
    1.23    return last_u2_element();
    1.24  }
    1.25  
    1.26 -u2* constMethodOopDesc::localvariable_table_length_addr() const {
    1.27 -  assert(has_localvariable_table(), "called only if table is present");
    1.28 +u2* constMethodOopDesc::exception_table_length_addr() const {
    1.29 +  assert(has_exception_handler(), "called only if table is present");
    1.30    if (has_checked_exceptions()) {
    1.31      // If checked_exception present, locate immediately before them.
    1.32      return (u2*) checked_exceptions_start() - 1;
    1.33    } else {
    1.34 -    // Else, the linenumber table is at the end of the constMethod.
    1.35 +    // Else, the exception table is at the end of the constMethod.
    1.36      return last_u2_element();
    1.37    }
    1.38  }
    1.39  
    1.40 +u2* constMethodOopDesc::localvariable_table_length_addr() const {
    1.41 +  assert(has_localvariable_table(), "called only if table is present");
    1.42 +  if (has_exception_handler()) {
    1.43 +    // If exception_table present, locate immediately before them.
    1.44 +    return (u2*) exception_table_start() - 1;
    1.45 +  } else {
    1.46 +    if (has_checked_exceptions()) {
    1.47 +      // If checked_exception present, locate immediately before them.
    1.48 +      return (u2*) checked_exceptions_start() - 1;
    1.49 +    } else {
    1.50 +      // Else, the linenumber table is at the end of the constMethod.
    1.51 +      return last_u2_element();
    1.52 +    }
    1.53 +  }
    1.54 +}
    1.55 +
    1.56  
    1.57  // Update the flags to indicate the presence of these optional fields.
    1.58  void constMethodOopDesc::set_inlined_tables_length(
    1.59                                                int checked_exceptions_len,
    1.60                                                int compressed_line_number_size,
    1.61 -                                              int localvariable_table_len) {
    1.62 +                                              int localvariable_table_len,
    1.63 +                                              int exception_table_len) {
    1.64    // Must be done in the order below, otherwise length_addr accessors
    1.65    // will not work. Only set bit in header if length is positive.
    1.66    assert(_flags == 0, "Error");
    1.67 @@ -100,6 +122,10 @@
    1.68      _flags |= _has_checked_exceptions;
    1.69      *(checked_exceptions_length_addr()) = checked_exceptions_len;
    1.70    }
    1.71 +  if (exception_table_len > 0) {
    1.72 +    _flags |= _has_exception_table;
    1.73 +    *(exception_table_length_addr()) = exception_table_len;
    1.74 +  }
    1.75    if (localvariable_table_len > 0) {
    1.76      _flags |= _has_localvariable_table;
    1.77      *(localvariable_table_length_addr()) = localvariable_table_len;
    1.78 @@ -133,3 +159,15 @@
    1.79    addr -= length * sizeof(LocalVariableTableElement) / sizeof(u2);
    1.80    return (LocalVariableTableElement*) addr;
    1.81  }
    1.82 +
    1.83 +int constMethodOopDesc::exception_table_length() const {
    1.84 +  return has_exception_handler() ? *(exception_table_length_addr()) : 0;
    1.85 +}
    1.86 +
    1.87 +ExceptionTableElement* constMethodOopDesc::exception_table_start() const {
    1.88 +  u2* addr = exception_table_length_addr();
    1.89 +  u2 length = *addr;
    1.90 +  assert(length > 0, "should only be called if table is present");
    1.91 +  addr -= length * sizeof(ExceptionTableElement) / sizeof(u2);
    1.92 +  return (ExceptionTableElement*)addr;
    1.93 +}

mercurial