annotate src/share/vm/classfile/stackMapFrame.cpp @ 2177:3582bf76420e

6990754: Use native memory and reference counting to implement SymbolTable Summary: move symbols from permgen into C heap and reference count them Reviewed-by: never, acorn, jmasa, stefank
author coleenp
date Thu, 27 Jan 2011 16:11:27 -0800
parents f95d63e2154a
children c1a6154012c8
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 "classfile/stackMapFrame.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "classfile/verifier.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/resourceArea.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "oops/oop.inline.hpp"
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
30 #include "oops/symbol.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "runtime/handles.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "utilities/globalDefinitions.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 StackMapFrame::StackMapFrame(u2 max_locals, u2 max_stack, ClassVerifier* v) :
a61af66fc99e Initial load
duke
parents:
diff changeset
35 _offset(0), _locals_size(0), _stack_size(0), _flags(0),
a61af66fc99e Initial load
duke
parents:
diff changeset
36 _max_locals(max_locals), _max_stack(max_stack),
a61af66fc99e Initial load
duke
parents:
diff changeset
37 _verifier(v) {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 Thread* thr = v->thread();
a61af66fc99e Initial load
duke
parents:
diff changeset
39 _locals = NEW_RESOURCE_ARRAY_IN_THREAD(thr, VerificationType, max_locals);
a61af66fc99e Initial load
duke
parents:
diff changeset
40 _stack = NEW_RESOURCE_ARRAY_IN_THREAD(thr, VerificationType, max_stack);
a61af66fc99e Initial load
duke
parents:
diff changeset
41 int32_t i;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 for(i = 0; i < max_locals; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 _locals[i] = VerificationType::bogus_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
44 }
a61af66fc99e Initial load
duke
parents:
diff changeset
45 for(i = 0; i < max_stack; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 _stack[i] = VerificationType::bogus_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
47 }
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 StackMapFrame* StackMapFrame::frame_in_exception_handler(u1 flags) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 Thread* thr = _verifier->thread();
a61af66fc99e Initial load
duke
parents:
diff changeset
52 VerificationType* stack = NEW_RESOURCE_ARRAY_IN_THREAD(thr, VerificationType, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
53 StackMapFrame* frame = new StackMapFrame(_offset, flags, _locals_size, 0, _max_locals, _max_stack, _locals, stack, _verifier);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 return frame;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 bool StackMapFrame::has_new_object() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 int32_t i;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 for (i = 0; i < _max_locals; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 if (_locals[i].is_uninitialized()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 for (i = 0; i < _stack_size; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 if (_stack[i].is_uninitialized()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 void StackMapFrame::initialize_object(
a61af66fc99e Initial load
duke
parents:
diff changeset
73 VerificationType old_object, VerificationType new_object) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 int32_t i;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 for (i = 0; i < _max_locals; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 if (_locals[i].equals(old_object)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 _locals[i] = new_object;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 for (i = 0; i < _stack_size; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 if (_stack[i].equals(old_object)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 _stack[i] = new_object;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 }
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85 if (old_object == VerificationType::uninitialized_this_type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // "this" has been initialized - reset flags
a61af66fc99e Initial load
duke
parents:
diff changeset
87 _flags = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 VerificationType StackMapFrame::set_locals_from_arg(
a61af66fc99e Initial load
duke
parents:
diff changeset
92 const methodHandle m, VerificationType thisKlass, TRAPS) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
93 SignatureStream ss(m->signature());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
94 int init_local_num = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 if (!m->is_static()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 init_local_num++;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // add one extra argument for instance method
a61af66fc99e Initial load
duke
parents:
diff changeset
98 if (m->name() == vmSymbols::object_initializer_name() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
99 thisKlass.name() != vmSymbols::java_lang_Object()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 _locals[0] = VerificationType::uninitialized_this_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
101 _flags |= FLAG_THIS_UNINIT;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 _locals[0] = thisKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // local num may be greater than size of parameters because long/double occupies two slots
a61af66fc99e Initial load
duke
parents:
diff changeset
108 while(!ss.at_return_type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 init_local_num += _verifier->change_sig_to_verificationType(
a61af66fc99e Initial load
duke
parents:
diff changeset
110 &ss, &_locals[init_local_num],
a61af66fc99e Initial load
duke
parents:
diff changeset
111 CHECK_VERIFY_(verifier(), VerificationType::bogus_type()));
a61af66fc99e Initial load
duke
parents:
diff changeset
112 ss.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 _locals_size = init_local_num;
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 switch (ss.type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 case T_OBJECT:
a61af66fc99e Initial load
duke
parents:
diff changeset
118 case T_ARRAY:
a61af66fc99e Initial load
duke
parents:
diff changeset
119 {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
120 Symbol* sig = ss.as_symbol(CHECK_(VerificationType::bogus_type()));
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
121 // Create another symbol to save as signature stream unreferences
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
122 // this symbol.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
123 Symbol* sig_copy =
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
124 verifier()->create_temporary_symbol(sig, 0, sig->utf8_length(),
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
125 CHECK_(VerificationType::bogus_type()));
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
126 assert(sig_copy == sig, "symbols don't match");
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
127 return VerificationType::reference_type(sig_copy);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129 case T_INT: return VerificationType::integer_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
130 case T_BYTE: return VerificationType::byte_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
131 case T_CHAR: return VerificationType::char_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
132 case T_SHORT: return VerificationType::short_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
133 case T_BOOLEAN: return VerificationType::boolean_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
134 case T_FLOAT: return VerificationType::float_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
135 case T_DOUBLE: return VerificationType::double_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
136 case T_LONG: return VerificationType::long_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
137 case T_VOID: return VerificationType::bogus_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
138 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
139 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 return VerificationType::bogus_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 void StackMapFrame::copy_locals(const StackMapFrame* src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 int32_t len = src->locals_size() < _locals_size ?
a61af66fc99e Initial load
duke
parents:
diff changeset
146 src->locals_size() : _locals_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 for (int32_t i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 _locals[i] = src->locals()[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 void StackMapFrame::copy_stack(const StackMapFrame* src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 int32_t len = src->stack_size() < _stack_size ?
a61af66fc99e Initial load
duke
parents:
diff changeset
154 src->stack_size() : _stack_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 for (int32_t i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 _stack[i] = src->stack()[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 bool StackMapFrame::is_assignable_to(
a61af66fc99e Initial load
duke
parents:
diff changeset
162 VerificationType* from, VerificationType* to, int32_t len, TRAPS) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 for (int32_t i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 bool subtype = to[i].is_assignable_from(
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
165 from[i], verifier(), THREAD);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
166 if (!subtype) {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 bool StackMapFrame::is_assignable_to(const StackMapFrame* target, TRAPS) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 if (_max_locals != target->max_locals() || _stack_size != target->stack_size()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // Only need to compare type elements up to target->locals() or target->stack().
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // The remaining type elements in this state can be ignored because they are
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // assignable to bogus type.
a61af66fc99e Initial load
duke
parents:
diff changeset
180 bool match_locals = is_assignable_to(
a61af66fc99e Initial load
duke
parents:
diff changeset
181 _locals, target->locals(), target->locals_size(), CHECK_false);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 bool match_stack = is_assignable_to(
a61af66fc99e Initial load
duke
parents:
diff changeset
183 _stack, target->stack(), _stack_size, CHECK_false);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 bool match_flags = (_flags | target->flags()) == target->flags();
a61af66fc99e Initial load
duke
parents:
diff changeset
185 return (match_locals && match_stack && match_flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 VerificationType StackMapFrame::pop_stack_ex(VerificationType type, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 if (_stack_size <= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 verifier()->verify_error(_offset, "Operand stack underflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
191 return VerificationType::bogus_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193 VerificationType top = _stack[--_stack_size];
a61af66fc99e Initial load
duke
parents:
diff changeset
194 bool subtype = type.is_assignable_from(
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
195 top, verifier(), CHECK_(VerificationType::bogus_type()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
196 if (!subtype) {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 verifier()->verify_error(_offset, "Bad type on operand stack");
a61af66fc99e Initial load
duke
parents:
diff changeset
198 return VerificationType::bogus_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200 NOT_PRODUCT( _stack[_stack_size] = VerificationType::bogus_type(); )
a61af66fc99e Initial load
duke
parents:
diff changeset
201 return top;
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 VerificationType StackMapFrame::get_local(
a61af66fc99e Initial load
duke
parents:
diff changeset
205 int32_t index, VerificationType type, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 if (index >= _max_locals) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 verifier()->verify_error(_offset, "Local variable table overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
208 return VerificationType::bogus_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210 bool subtype = type.is_assignable_from(_locals[index],
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
211 verifier(), CHECK_(VerificationType::bogus_type()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
212 if (!subtype) {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 verifier()->verify_error(_offset, "Bad local variable type");
a61af66fc99e Initial load
duke
parents:
diff changeset
214 return VerificationType::bogus_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
216 if(index >= _locals_size) { _locals_size = index + 1; }
a61af66fc99e Initial load
duke
parents:
diff changeset
217 return _locals[index];
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 void StackMapFrame::get_local_2(
a61af66fc99e Initial load
duke
parents:
diff changeset
221 int32_t index, VerificationType type1, VerificationType type2, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 assert(type1.is_long() || type1.is_double(), "must be long/double");
a61af66fc99e Initial load
duke
parents:
diff changeset
223 assert(type2.is_long2() || type2.is_double2(), "must be long/double_2");
a61af66fc99e Initial load
duke
parents:
diff changeset
224 if (index >= _locals_size - 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 verifier()->verify_error(_offset, "get long/double overflows locals");
a61af66fc99e Initial load
duke
parents:
diff changeset
226 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228 bool subtype1 = type1.is_assignable_from(
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
229 _locals[index], verifier(), CHECK);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
230 bool subtype2 = type2.is_assignable_from(
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
231 _locals[index+1], verifier(), CHECK);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
232 if (!subtype1 || !subtype2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 verifier()->verify_error(_offset, "Bad local variable type");
a61af66fc99e Initial load
duke
parents:
diff changeset
234 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 void StackMapFrame::set_local(int32_t index, VerificationType type, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 assert(!type.is_check(), "Must be a real type");
a61af66fc99e Initial load
duke
parents:
diff changeset
240 if (index >= _max_locals) {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 verifier()->verify_error("Local variable table overflow", _offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // If type at index is double or long, set the next location to be unusable
a61af66fc99e Initial load
duke
parents:
diff changeset
245 if (_locals[index].is_double() || _locals[index].is_long()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 assert((index + 1) < _locals_size, "Local variable table overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
247 _locals[index + 1] = VerificationType::bogus_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // If type at index is double_2 or long_2, set the previous location to be unusable
a61af66fc99e Initial load
duke
parents:
diff changeset
250 if (_locals[index].is_double2() || _locals[index].is_long2()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 assert(index >= 1, "Local variable table underflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
252 _locals[index - 1] = VerificationType::bogus_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254 _locals[index] = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 if (index >= _locals_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
257 for (int i=_locals_size; i<index; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 assert(_locals[i] == VerificationType::bogus_type(),
a61af66fc99e Initial load
duke
parents:
diff changeset
259 "holes must be bogus type");
a61af66fc99e Initial load
duke
parents:
diff changeset
260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
261 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
262 _locals_size = index + 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264 }
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 void StackMapFrame::set_local_2(
a61af66fc99e Initial load
duke
parents:
diff changeset
267 int32_t index, VerificationType type1, VerificationType type2, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
268 assert(type1.is_long() || type1.is_double(), "must be long/double");
a61af66fc99e Initial load
duke
parents:
diff changeset
269 assert(type2.is_long2() || type2.is_double2(), "must be long/double_2");
a61af66fc99e Initial load
duke
parents:
diff changeset
270 if (index >= _max_locals - 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 verifier()->verify_error("Local variable table overflow", _offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
272 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // If type at index+1 is double or long, set the next location to be unusable
a61af66fc99e Initial load
duke
parents:
diff changeset
275 if (_locals[index+1].is_double() || _locals[index+1].is_long()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 assert((index + 2) < _locals_size, "Local variable table overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
277 _locals[index + 2] = VerificationType::bogus_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // If type at index is double_2 or long_2, set the previous location to be unusable
a61af66fc99e Initial load
duke
parents:
diff changeset
280 if (_locals[index].is_double2() || _locals[index].is_long2()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
281 assert(index >= 1, "Local variable table underflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
282 _locals[index - 1] = VerificationType::bogus_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284 _locals[index] = type1;
a61af66fc99e Initial load
duke
parents:
diff changeset
285 _locals[index+1] = type2;
a61af66fc99e Initial load
duke
parents:
diff changeset
286 if (index >= _locals_size - 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
287 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
288 for (int i=_locals_size; i<index; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 assert(_locals[i] == VerificationType::bogus_type(),
a61af66fc99e Initial load
duke
parents:
diff changeset
290 "holes must be bogus type");
a61af66fc99e Initial load
duke
parents:
diff changeset
291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
292 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
293 _locals_size = index + 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
295 }
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 void StackMapFrame::print() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
300 tty->print_cr("stackmap_frame[%d]:", _offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
301 tty->print_cr("flags = 0x%x", _flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
302 tty->print("locals[%d] = { ", _locals_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
303 for (int32_t i = 0; i < _locals_size; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 _locals[i].print_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
305 }
a61af66fc99e Initial load
duke
parents:
diff changeset
306 tty->print_cr(" }");
a61af66fc99e Initial load
duke
parents:
diff changeset
307 tty->print("stack[%d] = { ", _stack_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
308 for (int32_t j = 0; j < _stack_size; j++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 _stack[j].print_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311 tty->print_cr(" }");
a61af66fc99e Initial load
duke
parents:
diff changeset
312 }
a61af66fc99e Initial load
duke
parents:
diff changeset
313
a61af66fc99e Initial load
duke
parents:
diff changeset
314 #endif