src/share/vm/oops/constMethodOop.cpp

Wed, 02 Feb 2011 11:35:26 -0500

author
bobv
date
Wed, 02 Feb 2011 11:35:26 -0500
changeset 2508
b92c45f2bc75
parent 2314
f95d63e2154a
child 3826
2fe087c3e814
permissions
-rw-r--r--

7016023: Enable building ARM and PPC from src/closed repository
Reviewed-by: dholmes, bdelsart

duke@435 1 /*
stefank@2314 2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "oops/constMethodOop.hpp"
stefank@2314 27 #include "oops/methodOop.hpp"
duke@435 28
duke@435 29 // Static initialization
duke@435 30 const u2 constMethodOopDesc::MAX_IDNUM = 0xFFFE;
duke@435 31 const u2 constMethodOopDesc::UNSET_IDNUM = 0xFFFF;
duke@435 32
duke@435 33 // How big must this constMethodObject be?
duke@435 34
duke@435 35 int constMethodOopDesc::object_size(int code_size,
duke@435 36 int compressed_line_number_size,
duke@435 37 int local_variable_table_length,
duke@435 38 int checked_exceptions_length) {
duke@435 39 int extra_bytes = code_size;
duke@435 40 if (compressed_line_number_size > 0) {
duke@435 41 extra_bytes += compressed_line_number_size;
duke@435 42 }
duke@435 43 if (checked_exceptions_length > 0) {
duke@435 44 extra_bytes += sizeof(u2);
duke@435 45 extra_bytes += checked_exceptions_length * sizeof(CheckedExceptionElement);
duke@435 46 }
duke@435 47 if (local_variable_table_length > 0) {
duke@435 48 extra_bytes += sizeof(u2);
duke@435 49 extra_bytes +=
duke@435 50 local_variable_table_length * sizeof(LocalVariableTableElement);
duke@435 51 }
duke@435 52 int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord;
duke@435 53 return align_object_size(header_size() + extra_words);
duke@435 54 }
duke@435 55
duke@435 56
duke@435 57 // linenumber table - note that length is unknown until decompression,
duke@435 58 // see class CompressedLineNumberReadStream.
duke@435 59
duke@435 60 u_char* constMethodOopDesc::compressed_linenumber_table() const {
duke@435 61 // Located immediately following the bytecodes.
duke@435 62 assert(has_linenumber_table(), "called only if table is present");
duke@435 63 return code_end();
duke@435 64 }
duke@435 65
duke@435 66 u2* constMethodOopDesc::checked_exceptions_length_addr() const {
duke@435 67 // Located at the end of the constMethod.
duke@435 68 assert(has_checked_exceptions(), "called only if table is present");
duke@435 69 return last_u2_element();
duke@435 70 }
duke@435 71
duke@435 72 u2* constMethodOopDesc::localvariable_table_length_addr() const {
duke@435 73 assert(has_localvariable_table(), "called only if table is present");
duke@435 74 if (has_checked_exceptions()) {
duke@435 75 // If checked_exception present, locate immediately before them.
duke@435 76 return (u2*) checked_exceptions_start() - 1;
duke@435 77 } else {
duke@435 78 // Else, the linenumber table is at the end of the constMethod.
duke@435 79 return last_u2_element();
duke@435 80 }
duke@435 81 }
duke@435 82
duke@435 83
duke@435 84 // Update the flags to indicate the presence of these optional fields.
duke@435 85 void constMethodOopDesc::set_inlined_tables_length(
duke@435 86 int checked_exceptions_len,
duke@435 87 int compressed_line_number_size,
duke@435 88 int localvariable_table_len) {
duke@435 89 // Must be done in the order below, otherwise length_addr accessors
duke@435 90 // will not work. Only set bit in header if length is positive.
duke@435 91 assert(_flags == 0, "Error");
duke@435 92 if (compressed_line_number_size > 0) {
duke@435 93 _flags |= _has_linenumber_table;
duke@435 94 }
duke@435 95 if (checked_exceptions_len > 0) {
duke@435 96 _flags |= _has_checked_exceptions;
duke@435 97 *(checked_exceptions_length_addr()) = checked_exceptions_len;
duke@435 98 }
duke@435 99 if (localvariable_table_len > 0) {
duke@435 100 _flags |= _has_localvariable_table;
duke@435 101 *(localvariable_table_length_addr()) = localvariable_table_len;
duke@435 102 }
duke@435 103 }
duke@435 104
duke@435 105
duke@435 106 int constMethodOopDesc::checked_exceptions_length() const {
duke@435 107 return has_checked_exceptions() ? *(checked_exceptions_length_addr()) : 0;
duke@435 108 }
duke@435 109
duke@435 110
duke@435 111 CheckedExceptionElement* constMethodOopDesc::checked_exceptions_start() const {
duke@435 112 u2* addr = checked_exceptions_length_addr();
duke@435 113 u2 length = *addr;
duke@435 114 assert(length > 0, "should only be called if table is present");
duke@435 115 addr -= length * sizeof(CheckedExceptionElement) / sizeof(u2);
duke@435 116 return (CheckedExceptionElement*) addr;
duke@435 117 }
duke@435 118
duke@435 119
duke@435 120 int constMethodOopDesc::localvariable_table_length() const {
duke@435 121 return has_localvariable_table() ? *(localvariable_table_length_addr()) : 0;
duke@435 122 }
duke@435 123
duke@435 124
duke@435 125 LocalVariableTableElement* constMethodOopDesc::localvariable_table_start() const {
duke@435 126 u2* addr = localvariable_table_length_addr();
duke@435 127 u2 length = *addr;
duke@435 128 assert(length > 0, "should only be called if table is present");
duke@435 129 addr -= length * sizeof(LocalVariableTableElement) / sizeof(u2);
duke@435 130 return (LocalVariableTableElement*) addr;
duke@435 131 }

mercurial