comparison 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
comparison
equal deleted inserted replaced
2176:27e4ea99855d 2177:3582bf76420e
25 #include "precompiled.hpp" 25 #include "precompiled.hpp"
26 #include "classfile/stackMapFrame.hpp" 26 #include "classfile/stackMapFrame.hpp"
27 #include "classfile/verifier.hpp" 27 #include "classfile/verifier.hpp"
28 #include "memory/resourceArea.hpp" 28 #include "memory/resourceArea.hpp"
29 #include "oops/oop.inline.hpp" 29 #include "oops/oop.inline.hpp"
30 #include "oops/symbolOop.hpp" 30 #include "oops/symbol.hpp"
31 #include "runtime/handles.inline.hpp" 31 #include "runtime/handles.inline.hpp"
32 #include "utilities/globalDefinitions.hpp" 32 #include "utilities/globalDefinitions.hpp"
33 33
34 StackMapFrame::StackMapFrame(u2 max_locals, u2 max_stack, ClassVerifier* v) : 34 StackMapFrame::StackMapFrame(u2 max_locals, u2 max_stack, ClassVerifier* v) :
35 _offset(0), _locals_size(0), _stack_size(0), _flags(0), 35 _offset(0), _locals_size(0), _stack_size(0), _flags(0),
88 } 88 }
89 } 89 }
90 90
91 VerificationType StackMapFrame::set_locals_from_arg( 91 VerificationType StackMapFrame::set_locals_from_arg(
92 const methodHandle m, VerificationType thisKlass, TRAPS) { 92 const methodHandle m, VerificationType thisKlass, TRAPS) {
93 symbolHandle signature(THREAD, m->signature()); 93 SignatureStream ss(m->signature());
94 SignatureStream ss(signature);
95 int init_local_num = 0; 94 int init_local_num = 0;
96 if (!m->is_static()) { 95 if (!m->is_static()) {
97 init_local_num++; 96 init_local_num++;
98 // add one extra argument for instance method 97 // add one extra argument for instance method
99 if (m->name() == vmSymbols::object_initializer_name() && 98 if (m->name() == vmSymbols::object_initializer_name() &&
116 115
117 switch (ss.type()) { 116 switch (ss.type()) {
118 case T_OBJECT: 117 case T_OBJECT:
119 case T_ARRAY: 118 case T_ARRAY:
120 { 119 {
121 symbolOop sig = ss.as_symbol(CHECK_(VerificationType::bogus_type())); 120 Symbol* sig = ss.as_symbol(CHECK_(VerificationType::bogus_type()));
122 return VerificationType::reference_type(symbolHandle(THREAD, sig)); 121 // Create another symbol to save as signature stream unreferences
122 // this symbol.
123 Symbol* sig_copy =
124 verifier()->create_temporary_symbol(sig, 0, sig->utf8_length(),
125 CHECK_(VerificationType::bogus_type()));
126 assert(sig_copy == sig, "symbols don't match");
127 return VerificationType::reference_type(sig_copy);
123 } 128 }
124 case T_INT: return VerificationType::integer_type(); 129 case T_INT: return VerificationType::integer_type();
125 case T_BYTE: return VerificationType::byte_type(); 130 case T_BYTE: return VerificationType::byte_type();
126 case T_CHAR: return VerificationType::char_type(); 131 case T_CHAR: return VerificationType::char_type();
127 case T_SHORT: return VerificationType::short_type(); 132 case T_SHORT: return VerificationType::short_type();
155 160
156 bool StackMapFrame::is_assignable_to( 161 bool StackMapFrame::is_assignable_to(
157 VerificationType* from, VerificationType* to, int32_t len, TRAPS) const { 162 VerificationType* from, VerificationType* to, int32_t len, TRAPS) const {
158 for (int32_t i = 0; i < len; i++) { 163 for (int32_t i = 0; i < len; i++) {
159 bool subtype = to[i].is_assignable_from( 164 bool subtype = to[i].is_assignable_from(
160 from[i], verifier()->current_class(), THREAD); 165 from[i], verifier(), THREAD);
161 if (!subtype) { 166 if (!subtype) {
162 return false; 167 return false;
163 } 168 }
164 } 169 }
165 return true; 170 return true;
185 verifier()->verify_error(_offset, "Operand stack underflow"); 190 verifier()->verify_error(_offset, "Operand stack underflow");
186 return VerificationType::bogus_type(); 191 return VerificationType::bogus_type();
187 } 192 }
188 VerificationType top = _stack[--_stack_size]; 193 VerificationType top = _stack[--_stack_size];
189 bool subtype = type.is_assignable_from( 194 bool subtype = type.is_assignable_from(
190 top, verifier()->current_class(), CHECK_(VerificationType::bogus_type())); 195 top, verifier(), CHECK_(VerificationType::bogus_type()));
191 if (!subtype) { 196 if (!subtype) {
192 verifier()->verify_error(_offset, "Bad type on operand stack"); 197 verifier()->verify_error(_offset, "Bad type on operand stack");
193 return VerificationType::bogus_type(); 198 return VerificationType::bogus_type();
194 } 199 }
195 NOT_PRODUCT( _stack[_stack_size] = VerificationType::bogus_type(); ) 200 NOT_PRODUCT( _stack[_stack_size] = VerificationType::bogus_type(); )
201 if (index >= _max_locals) { 206 if (index >= _max_locals) {
202 verifier()->verify_error(_offset, "Local variable table overflow"); 207 verifier()->verify_error(_offset, "Local variable table overflow");
203 return VerificationType::bogus_type(); 208 return VerificationType::bogus_type();
204 } 209 }
205 bool subtype = type.is_assignable_from(_locals[index], 210 bool subtype = type.is_assignable_from(_locals[index],
206 verifier()->current_class(), CHECK_(VerificationType::bogus_type())); 211 verifier(), CHECK_(VerificationType::bogus_type()));
207 if (!subtype) { 212 if (!subtype) {
208 verifier()->verify_error(_offset, "Bad local variable type"); 213 verifier()->verify_error(_offset, "Bad local variable type");
209 return VerificationType::bogus_type(); 214 return VerificationType::bogus_type();
210 } 215 }
211 if(index >= _locals_size) { _locals_size = index + 1; } 216 if(index >= _locals_size) { _locals_size = index + 1; }
219 if (index >= _locals_size - 1) { 224 if (index >= _locals_size - 1) {
220 verifier()->verify_error(_offset, "get long/double overflows locals"); 225 verifier()->verify_error(_offset, "get long/double overflows locals");
221 return; 226 return;
222 } 227 }
223 bool subtype1 = type1.is_assignable_from( 228 bool subtype1 = type1.is_assignable_from(
224 _locals[index], verifier()->current_class(), CHECK); 229 _locals[index], verifier(), CHECK);
225 bool subtype2 = type2.is_assignable_from( 230 bool subtype2 = type2.is_assignable_from(
226 _locals[index+1], verifier()->current_class(), CHECK); 231 _locals[index+1], verifier(), CHECK);
227 if (!subtype1 || !subtype2) { 232 if (!subtype1 || !subtype2) {
228 verifier()->verify_error(_offset, "Bad local variable type"); 233 verifier()->verify_error(_offset, "Bad local variable type");
229 return; 234 return;
230 } 235 }
231 } 236 }