annotate src/share/vm/classfile/stackMapTable.hpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children b92c45f2bc75
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 #ifndef SHARE_VM_CLASSFILE_STACKMAPTABLE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_CLASSFILE_STACKMAPTABLE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "classfile/stackMapFrame.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "oops/constantPoolOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "oops/methodOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "utilities/globalDefinitions.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #ifdef TARGET_ARCH_x86
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 # include "bytes_x86.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #ifdef TARGET_ARCH_sparc
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 # include "bytes_sparc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
38 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
39 #ifdef TARGET_ARCH_zero
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
40 # include "bytes_zero.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
41 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
42
0
a61af66fc99e Initial load
duke
parents:
diff changeset
43 class StackMapReader;
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // StackMapTable class is the StackMap table used by type checker
a61af66fc99e Initial load
duke
parents:
diff changeset
46 class StackMapTable : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Logically, the _frame_count (as well as many fields in the StackFrame)
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // should be a u2, but if we defined the variable as that type it will
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // be difficult to detect/recover from overflow or underflow conditions.
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // Widening the type and making it signed will help detect these.
a61af66fc99e Initial load
duke
parents:
diff changeset
52 int32_t _code_length;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 int32_t _frame_count; // Stackmap frame count
a61af66fc99e Initial load
duke
parents:
diff changeset
54 StackMapFrame** _frame_array;
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
57 StackMapTable(StackMapReader* reader, StackMapFrame* init_frame,
a61af66fc99e Initial load
duke
parents:
diff changeset
58 u2 max_locals, u2 max_stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
59 char* code_data, int code_len, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 inline int32_t get_frame_count() const { return _frame_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 inline int get_offset(int index) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 return _frame_array[index]->offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Match and/or update current_frame to the frame in stackmap table with
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // specified offset. Return true if the two frames match.
a61af66fc99e Initial load
duke
parents:
diff changeset
68 bool match_stackmap(
a61af66fc99e Initial load
duke
parents:
diff changeset
69 StackMapFrame* current_frame, int32_t offset,
a61af66fc99e Initial load
duke
parents:
diff changeset
70 bool match, bool update, TRAPS) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // Match and/or update current_frame to the frame in stackmap table with
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // specified offset and frame index. Return true if the two frames match.
a61af66fc99e Initial load
duke
parents:
diff changeset
73 bool match_stackmap(
a61af66fc99e Initial load
duke
parents:
diff changeset
74 StackMapFrame* current_frame, int32_t offset, int32_t frame_index,
a61af66fc99e Initial load
duke
parents:
diff changeset
75 bool match, bool update, TRAPS) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // Check jump instructions. Make sure there are no uninitialized
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // instances on backward branch.
a61af66fc99e Initial load
duke
parents:
diff changeset
79 void check_jump_target(StackMapFrame* frame, int32_t target, TRAPS) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // The following methods are only used inside this class.
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // Returns the frame array index where the frame with offset is stored.
a61af66fc99e Initial load
duke
parents:
diff changeset
84 int get_index_from_offset(int32_t offset) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Make sure that there's no uninitialized object exist on backward branch.
a61af66fc99e Initial load
duke
parents:
diff changeset
87 void check_new_object(
a61af66fc99e Initial load
duke
parents:
diff changeset
88 const StackMapFrame* frame, int32_t target, TRAPS) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // Debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
91 void print() const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 };
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 class StackMapStream : StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
96 typeArrayHandle _data;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 int _index;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
99 StackMapStream(typeArrayHandle ah)
a61af66fc99e Initial load
duke
parents:
diff changeset
100 : _data(ah), _index(0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102 u1 get_u1(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 if (_data == NULL || _index >= _data->length()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 stackmap_format_error("access beyond the end of attribute", CHECK_0);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 return _data->byte_at(_index++);
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108 u2 get_u2(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 if (_data == NULL || _index >= _data->length() - 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 stackmap_format_error("access beyond the end of attribute", CHECK_0);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112 u2 res = Bytes::get_Java_u2((u1*)_data->byte_at_addr(_index));
a61af66fc99e Initial load
duke
parents:
diff changeset
113 _index += 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 bool at_end() {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 return (_data == NULL) || (_index == _data->length());
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 static void stackmap_format_error(const char* msg, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 };
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 class StackMapReader : StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // information about the class and method
a61af66fc99e Initial load
duke
parents:
diff changeset
125 constantPoolHandle _cp;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 ClassVerifier* _verifier;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 StackMapStream* _stream;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 char* _code_data;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 int32_t _code_length;
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // information get from the attribute
a61af66fc99e Initial load
duke
parents:
diff changeset
132 int32_t _frame_count; // frame count
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 int32_t chop(VerificationType* locals, int32_t length, int32_t chops);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 VerificationType parse_verification_type(u1* flags, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
136 void check_verification_type_array_size(
a61af66fc99e Initial load
duke
parents:
diff changeset
137 int32_t size, int32_t max_size, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 if (size < 0 || size > max_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // Since this error could be caused someone rewriting the method
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // but not knowing to update the stackmap data, we call the the
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // verifier's error method, which may not throw an exception and
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // failover to the old verifier instead.
a61af66fc99e Initial load
duke
parents:
diff changeset
143 _verifier->class_format_error(
a61af66fc99e Initial load
duke
parents:
diff changeset
144 "StackMapTable format error: bad type array size");
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 SAME_LOCALS_1_STACK_ITEM_EXTENDED = 247,
a61af66fc99e Initial load
duke
parents:
diff changeset
150 SAME_EXTENDED = 251,
a61af66fc99e Initial load
duke
parents:
diff changeset
151 FULL = 255
a61af66fc99e Initial load
duke
parents:
diff changeset
152 };
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // Constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
156 StackMapReader(ClassVerifier* v, StackMapStream* stream, char* code_data,
a61af66fc99e Initial load
duke
parents:
diff changeset
157 int32_t code_len, TRAPS) :
a61af66fc99e Initial load
duke
parents:
diff changeset
158 _verifier(v), _stream(stream),
a61af66fc99e Initial load
duke
parents:
diff changeset
159 _code_data(code_data), _code_length(code_len) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 methodHandle m = v->method();
a61af66fc99e Initial load
duke
parents:
diff changeset
161 if (m->has_stackmap_table()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 _cp = constantPoolHandle(THREAD, m->constants());
a61af66fc99e Initial load
duke
parents:
diff changeset
163 _frame_count = _stream->get_u2(CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
164 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // There's no stackmap table present. Frame count and size are 0.
a61af66fc99e Initial load
duke
parents:
diff changeset
166 _frame_count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 inline int32_t get_frame_count() const { return _frame_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
171 StackMapFrame* next(StackMapFrame* pre_frame, bool first,
a61af66fc99e Initial load
duke
parents:
diff changeset
172 u2 max_locals, u2 max_stack, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 void check_end(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 if (!_stream->at_end()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 StackMapStream::stackmap_format_error("wrong attribute size", CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
180
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
181 #endif // SHARE_VM_CLASSFILE_STACKMAPTABLE_HPP