1 /*
2 * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
110 // information about the class and method
111 constantPoolHandle _cp;
112 ClassVerifier* _verifier;
113 StackMapStream* _stream;
114 char* _code_data;
115 int32_t _code_length;
116
117 // information from the attribute
118 int32_t _frame_count;
119
120 // Number of frames parsed
121 int32_t _parsed_frame_count;
122
123 // Previous frame buffer
124 StackMapFrame* _prev_frame;
125
126 // information from method
127 u2 _max_locals;
128 u2 _max_stack;
129
130 // Check if reading first entry
131 bool _first;
132
133 StackMapFrame* next_helper(TRAPS);
134 void check_offset(StackMapFrame* frame);
135 void check_size(TRAPS);
136 int32_t chop(VerificationType* locals, int32_t length, int32_t chops);
137 VerificationType parse_verification_type(u1* flags, TRAPS);
138 void check_verification_type_array_size(
139 int32_t size, int32_t max_size, TRAPS) {
140 if (size < 0 || size > max_size) {
141 // Since this error could be caused someone rewriting the method
142 // but not knowing to update the stackmap data, we call the
143 // verifier's error method, which may not throw an exception and
144 // failover to the old verifier instead.
145 _verifier->class_format_error(
146 "StackMapTable format error: bad type array size");
147 }
148 }
149
150 enum {
151 SAME_LOCALS_1_STACK_ITEM_EXTENDED = 247,
152 SAME_EXTENDED = 251,
153 FULL = 255
154 };
155
156 public:
157 // Constructor
158 StackMapReader(ClassVerifier* v, StackMapStream* stream,
159 char* code_data, int32_t code_len,
160 StackMapFrame* init_frame,
161 u2 max_locals, u2 max_stack, TRAPS);
162
163 inline int32_t get_frame_count() const { return _frame_count; }
164 inline StackMapFrame* prev_frame() const { return _prev_frame; }
165 inline char* code_data() const { return _code_data; }
166 inline int32_t code_length() const { return _code_length; }
167 inline bool at_end() const { return _stream->at_end(); }
168
169 StackMapFrame* next(TRAPS);
170 void check_end(TRAPS);
171 };
172
173 #endif // SHARE_CLASSFILE_STACKMAPTABLE_HPP
|
1 /*
2 * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
110 // information about the class and method
111 constantPoolHandle _cp;
112 ClassVerifier* _verifier;
113 StackMapStream* _stream;
114 char* _code_data;
115 int32_t _code_length;
116
117 // information from the attribute
118 int32_t _frame_count;
119
120 // Number of frames parsed
121 int32_t _parsed_frame_count;
122
123 // Previous frame buffer
124 StackMapFrame* _prev_frame;
125
126 // information from method
127 u2 _max_locals;
128 u2 _max_stack;
129
130 // Contains assert_unset_fields generated from classfile
131 StackMapFrame::AssertUnsetFieldTable* _assert_unset_fields_buffer;
132
133 // Check if reading first entry
134 bool _first;
135
136 StackMapFrame* next_helper(TRAPS);
137 void check_offset(StackMapFrame* frame);
138 void check_size(TRAPS);
139 int32_t chop(VerificationType* locals, int32_t length, int32_t chops);
140 VerificationType parse_verification_type(u1* flags, TRAPS);
141 void check_verification_type_array_size(
142 int32_t size, int32_t max_size, TRAPS) {
143 if (size < 0 || size > max_size) {
144 // Since this error could be caused someone rewriting the method
145 // but not knowing to update the stackmap data, we call the
146 // verifier's error method, which may not throw an exception and
147 // failover to the old verifier instead.
148 _verifier->class_format_error(
149 "StackMapTable format error: bad type array size");
150 }
151 }
152
153 enum {
154 ASSERT_UNSET_FIELDS = 246,
155 SAME_LOCALS_1_STACK_ITEM_EXTENDED = 247,
156 SAME_EXTENDED = 251,
157 FULL = 255
158 };
159
160 public:
161 // Constructor
162 StackMapReader(ClassVerifier* v, StackMapStream* stream,
163 char* code_data, int32_t code_len,
164 StackMapFrame* init_frame,
165 u2 max_locals, u2 max_stack,
166 StackMapFrame::AssertUnsetFieldTable* initial_strict_fields, TRAPS);
167
168 inline int32_t get_frame_count() const { return _frame_count; }
169 inline StackMapFrame* prev_frame() const { return _prev_frame; }
170 inline char* code_data() const { return _code_data; }
171 inline int32_t code_length() const { return _code_length; }
172 inline bool at_end() const { return _stream->at_end(); }
173
174 StackMapFrame* next(TRAPS);
175 void check_end(TRAPS);
176 };
177
178 #endif // SHARE_CLASSFILE_STACKMAPTABLE_HPP
|