annotate src/share/vm/oops/constMethodOop.cpp @ 196:d1605aabd0a1 jdk7-b30

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