annotate src/share/vm/oops/constMethodOop.cpp @ 4155:394404b2d9bd

Removed strict requirement for GRAAL environment variable. It only needs to be set now if the graal directory is not in the directory hierarchy of GraalVM JDK.
author Doug Simon <doug.simon@oracle.com>
date Wed, 21 Dec 2011 11:25:27 +0100
parents f95d63e2154a
children 2fe087c3e814
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0
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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "oops/constMethodOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "oops/methodOop.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // Static initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
30 const u2 constMethodOopDesc::MAX_IDNUM = 0xFFFE;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 const u2 constMethodOopDesc::UNSET_IDNUM = 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // How big must this constMethodObject be?
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 int constMethodOopDesc::object_size(int code_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
36 int compressed_line_number_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
37 int local_variable_table_length,
a61af66fc99e Initial load
duke
parents:
diff changeset
38 int checked_exceptions_length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
39 int extra_bytes = code_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 if (compressed_line_number_size > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 extra_bytes += compressed_line_number_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 }
a61af66fc99e Initial load
duke
parents:
diff changeset
43 if (checked_exceptions_length > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 extra_bytes += sizeof(u2);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 extra_bytes += checked_exceptions_length * sizeof(CheckedExceptionElement);
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47 if (local_variable_table_length > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 extra_bytes += sizeof(u2);
a61af66fc99e Initial load
duke
parents:
diff changeset
49 extra_bytes +=
a61af66fc99e Initial load
duke
parents:
diff changeset
50 local_variable_table_length * sizeof(LocalVariableTableElement);
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52 int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 return align_object_size(header_size() + extra_words);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // linenumber table - note that length is unknown until decompression,
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // see class CompressedLineNumberReadStream.
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 u_char* constMethodOopDesc::compressed_linenumber_table() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Located immediately following the bytecodes.
a61af66fc99e Initial load
duke
parents:
diff changeset
62 assert(has_linenumber_table(), "called only if table is present");
a61af66fc99e Initial load
duke
parents:
diff changeset
63 return code_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 u2* constMethodOopDesc::checked_exceptions_length_addr() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // Located at the end of the constMethod.
a61af66fc99e Initial load
duke
parents:
diff changeset
68 assert(has_checked_exceptions(), "called only if table is present");
a61af66fc99e Initial load
duke
parents:
diff changeset
69 return last_u2_element();
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 u2* constMethodOopDesc::localvariable_table_length_addr() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 assert(has_localvariable_table(), "called only if table is present");
a61af66fc99e Initial load
duke
parents:
diff changeset
74 if (has_checked_exceptions()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // If checked_exception present, locate immediately before them.
a61af66fc99e Initial load
duke
parents:
diff changeset
76 return (u2*) checked_exceptions_start() - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // Else, the linenumber table is at the end of the constMethod.
a61af66fc99e Initial load
duke
parents:
diff changeset
79 return last_u2_element();
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
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // Update the flags to indicate the presence of these optional fields.
a61af66fc99e Initial load
duke
parents:
diff changeset
85 void constMethodOopDesc::set_inlined_tables_length(
a61af66fc99e Initial load
duke
parents:
diff changeset
86 int checked_exceptions_len,
a61af66fc99e Initial load
duke
parents:
diff changeset
87 int compressed_line_number_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
88 int localvariable_table_len) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // Must be done in the order below, otherwise length_addr accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // will not work. Only set bit in header if length is positive.
a61af66fc99e Initial load
duke
parents:
diff changeset
91 assert(_flags == 0, "Error");
a61af66fc99e Initial load
duke
parents:
diff changeset
92 if (compressed_line_number_size > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 _flags |= _has_linenumber_table;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 if (checked_exceptions_len > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 _flags |= _has_checked_exceptions;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 *(checked_exceptions_length_addr()) = checked_exceptions_len;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99 if (localvariable_table_len > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 _flags |= _has_localvariable_table;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 *(localvariable_table_length_addr()) = localvariable_table_len;
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
a61af66fc99e Initial load
duke
parents:
diff changeset
106 int constMethodOopDesc::checked_exceptions_length() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 return has_checked_exceptions() ? *(checked_exceptions_length_addr()) : 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 CheckedExceptionElement* constMethodOopDesc::checked_exceptions_start() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 u2* addr = checked_exceptions_length_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
113 u2 length = *addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 assert(length > 0, "should only be called if table is present");
a61af66fc99e Initial load
duke
parents:
diff changeset
115 addr -= length * sizeof(CheckedExceptionElement) / sizeof(u2);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 return (CheckedExceptionElement*) addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 int constMethodOopDesc::localvariable_table_length() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 return has_localvariable_table() ? *(localvariable_table_length_addr()) : 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 LocalVariableTableElement* constMethodOopDesc::localvariable_table_start() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 u2* addr = localvariable_table_length_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
127 u2 length = *addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 assert(length > 0, "should only be called if table is present");
a61af66fc99e Initial load
duke
parents:
diff changeset
129 addr -= length * sizeof(LocalVariableTableElement) / sizeof(u2);
a61af66fc99e Initial load
duke
parents:
diff changeset
130 return (LocalVariableTableElement*) addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }