comparison src/share/vm/graal/graalEnv.cpp @ 3670:f198b24093f3

put back in thread transitions.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 18 Nov 2011 16:23:26 +0100
parents 6e1abd79e7c8
children 5e331d5f760e
comparison
equal deleted inserted replaced
3669:53636e2c9d03 3670:f198b24093f3
47 // ------------------------------------------------------------------ 47 // ------------------------------------------------------------------
48 // ciEnv::check_klass_accessiblity 48 // ciEnv::check_klass_accessiblity
49 // 49 //
50 // Note: the logic of this method should mirror the logic of 50 // Note: the logic of this method should mirror the logic of
51 // constantPoolOopDesc::verify_constant_pool_resolve. 51 // constantPoolOopDesc::verify_constant_pool_resolve.
52 bool GraalEnv::check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass) { 52 bool GraalEnv::check_klass_accessibility(KlassHandle& accessing_klass, KlassHandle& resolved_klass) {
53 if (accessing_klass->oop_is_objArray()) { 53 if (accessing_klass->oop_is_objArray()) {
54 accessing_klass = objArrayKlass::cast(accessing_klass())->bottom_klass(); 54 accessing_klass = objArrayKlass::cast(accessing_klass())->bottom_klass();
55 } 55 }
56 if (!accessing_klass->oop_is_instance()) { 56 if (!accessing_klass->oop_is_instance()) {
57 return true; 57 return true;
67 return true; 67 return true;
68 } 68 }
69 69
70 // ------------------------------------------------------------------ 70 // ------------------------------------------------------------------
71 // ciEnv::get_klass_by_name_impl 71 // ciEnv::get_klass_by_name_impl
72 KlassHandle GraalEnv::get_klass_by_name_impl(KlassHandle accessing_klass, 72 KlassHandle GraalEnv::get_klass_by_name_impl(KlassHandle& accessing_klass,
73 constantPoolHandle cpool, 73 constantPoolHandle& cpool,
74 Symbol* sym, 74 Symbol* sym,
75 bool require_local) { 75 bool require_local) {
76 EXCEPTION_CONTEXT; 76 EXCEPTION_CONTEXT;
77 77
78 // Now we need to check the SystemDictionary 78 // Now we need to check the SystemDictionary
147 return found_klass(); 147 return found_klass();
148 } 148 }
149 149
150 // ------------------------------------------------------------------ 150 // ------------------------------------------------------------------
151 // ciEnv::get_klass_by_name 151 // ciEnv::get_klass_by_name
152 KlassHandle GraalEnv::get_klass_by_name(KlassHandle accessing_klass, 152 KlassHandle GraalEnv::get_klass_by_name(KlassHandle& accessing_klass,
153 Symbol* klass_name, 153 Symbol* klass_name,
154 bool require_local) { 154 bool require_local) {
155 ResourceMark rm; 155 ResourceMark rm;
156 return get_klass_by_name_impl(accessing_klass, 156 return get_klass_by_name_impl(accessing_klass,
157 constantPoolHandle(), 157 constantPoolHandle(),
161 161
162 // ------------------------------------------------------------------ 162 // ------------------------------------------------------------------
163 // ciEnv::get_klass_by_index_impl 163 // ciEnv::get_klass_by_index_impl
164 // 164 //
165 // Implementation of get_klass_by_index. 165 // Implementation of get_klass_by_index.
166 KlassHandle GraalEnv::get_klass_by_index_impl(constantPoolHandle cpool, 166 KlassHandle GraalEnv::get_klass_by_index_impl(constantPoolHandle& cpool,
167 int index, 167 int index,
168 bool& is_accessible, 168 bool& is_accessible,
169 KlassHandle accessor) { 169 KlassHandle& accessor) {
170 EXCEPTION_CONTEXT; 170 EXCEPTION_CONTEXT;
171 KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index)); 171 KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index));
172 Symbol* klass_name = NULL; 172 Symbol* klass_name = NULL;
173 if (klass.is_null()) { 173 if (klass.is_null()) {
174 // The klass has not been inserted into the constant pool. 174 // The klass has not been inserted into the constant pool.
205 get_klass_by_name_impl(accessor, cpool, k->name(), true) == NULL) { 205 get_klass_by_name_impl(accessor, cpool, k->name(), true) == NULL) {
206 // Loaded only remotely. Not linked yet. 206 // Loaded only remotely. Not linked yet.
207 is_accessible = false; 207 is_accessible = false;
208 } else { 208 } else {
209 // Linked locally, and we must also check public/private, etc. 209 // Linked locally, and we must also check public/private, etc.
210 is_accessible = check_klass_accessibility(accessor(), k()); 210 is_accessible = check_klass_accessibility(accessor, k);
211 } 211 }
212 return k; 212 return k;
213 } 213 }
214 214
215 // It is known to be accessible, since it was found in the constant pool. 215 // It is known to be accessible, since it was found in the constant pool.
219 219
220 // ------------------------------------------------------------------ 220 // ------------------------------------------------------------------
221 // ciEnv::get_klass_by_index 221 // ciEnv::get_klass_by_index
222 // 222 //
223 // Get a klass from the constant pool. 223 // Get a klass from the constant pool.
224 KlassHandle GraalEnv::get_klass_by_index(constantPoolHandle cpool, 224 KlassHandle GraalEnv::get_klass_by_index(constantPoolHandle& cpool,
225 int index, 225 int index,
226 bool& is_accessible, 226 bool& is_accessible,
227 KlassHandle accessor) { 227 KlassHandle& accessor) {
228 ResourceMark rm; 228 ResourceMark rm;
229 return get_klass_by_index_impl(cpool, index, is_accessible, accessor); 229 return get_klass_by_index_impl(cpool, index, is_accessible, accessor);
230 } 230 }
231 231
232 // ------------------------------------------------------------------ 232 // ------------------------------------------------------------------
234 // 234 //
235 // Implementation of get_field_by_index. 235 // Implementation of get_field_by_index.
236 // 236 //
237 // Implementation note: the results of field lookups are cached 237 // Implementation note: the results of field lookups are cached
238 // in the accessor klass. 238 // in the accessor klass.
239 void GraalEnv::get_field_by_index_impl(instanceKlassHandle klass, fieldDescriptor& field_desc, 239 void GraalEnv::get_field_by_index_impl(instanceKlassHandle& klass, fieldDescriptor& field_desc,
240 int index) { 240 int index) {
241 EXCEPTION_CONTEXT; 241 EXCEPTION_CONTEXT;
242 242
243 assert(klass->is_linked(), "must be linked before using its constan-pool"); 243 assert(klass->is_linked(), "must be linked before using its constan-pool");
244 244
280 280
281 // ------------------------------------------------------------------ 281 // ------------------------------------------------------------------
282 // ciEnv::get_field_by_index 282 // ciEnv::get_field_by_index
283 // 283 //
284 // Get a field by index from a klass's constant pool. 284 // Get a field by index from a klass's constant pool.
285 void GraalEnv::get_field_by_index(instanceKlassHandle accessor, fieldDescriptor& fd, 285 void GraalEnv::get_field_by_index(instanceKlassHandle& accessor, fieldDescriptor& fd,
286 int index) { 286 int index) {
287 ResourceMark rm; 287 ResourceMark rm;
288 return get_field_by_index_impl(accessor, fd, index); 288 return get_field_by_index_impl(accessor, fd, index);
289 } 289 }
290 290
291 // ------------------------------------------------------------------ 291 // ------------------------------------------------------------------
292 // ciEnv::lookup_method 292 // ciEnv::lookup_method
293 // 293 //
294 // Perform an appropriate method lookup based on accessor, holder, 294 // Perform an appropriate method lookup based on accessor, holder,
295 // name, signature, and bytecode. 295 // name, signature, and bytecode.
296 methodHandle GraalEnv::lookup_method(instanceKlassHandle h_accessor, 296 methodHandle GraalEnv::lookup_method(instanceKlassHandle& h_accessor,
297 instanceKlassHandle h_holder, 297 instanceKlassHandle& h_holder,
298 Symbol* name, 298 Symbol* name,
299 Symbol* sig, 299 Symbol* sig,
300 Bytecodes::Code bc) { 300 Bytecodes::Code bc) {
301 EXCEPTION_CONTEXT; 301 EXCEPTION_CONTEXT;
302 LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL)); 302 LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL));
327 } 327 }
328 328
329 329
330 // ------------------------------------------------------------------ 330 // ------------------------------------------------------------------
331 // ciEnv::get_method_by_index_impl 331 // ciEnv::get_method_by_index_impl
332 methodHandle GraalEnv::get_method_by_index_impl(constantPoolHandle cpool, 332 methodHandle GraalEnv::get_method_by_index_impl(constantPoolHandle& cpool,
333 int index, Bytecodes::Code bc, 333 int index, Bytecodes::Code bc,
334 instanceKlassHandle accessor) { 334 instanceKlassHandle& accessor) {
335 int holder_index = cpool->klass_ref_index_at(index); 335 int holder_index = cpool->klass_ref_index_at(index);
336 bool holder_is_accessible; 336 bool holder_is_accessible;
337 KlassHandle holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor); 337 KlassHandle holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor);
338 338
339 // Get the method's name and signature. 339 // Get the method's name and signature.
362 return NULL; 362 return NULL;
363 } 363 }
364 364
365 // ------------------------------------------------------------------ 365 // ------------------------------------------------------------------
366 // ciEnv::get_instance_klass_for_declared_method_holder 366 // ciEnv::get_instance_klass_for_declared_method_holder
367 instanceKlassHandle GraalEnv::get_instance_klass_for_declared_method_holder(KlassHandle method_holder) { 367 instanceKlassHandle GraalEnv::get_instance_klass_for_declared_method_holder(KlassHandle& method_holder) {
368 // For the case of <array>.clone(), the method holder can be a ciArrayKlass 368 // For the case of <array>.clone(), the method holder can be a ciArrayKlass
369 // instead of a ciInstanceKlass. For that case simply pretend that the 369 // instead of a ciInstanceKlass. For that case simply pretend that the
370 // declared holder is Object.clone since that's where the call will bottom out. 370 // declared holder is Object.clone since that's where the call will bottom out.
371 // A more correct fix would trickle out through many interfaces in CI, 371 // A more correct fix would trickle out through many interfaces in CI,
372 // requiring ciInstanceKlass* to become ciKlass* and many more places would 372 // requiring ciInstanceKlass* to become ciKlass* and many more places would
384 } 384 }
385 385
386 386
387 // ------------------------------------------------------------------ 387 // ------------------------------------------------------------------
388 // ciEnv::get_method_by_index 388 // ciEnv::get_method_by_index
389 methodHandle GraalEnv::get_method_by_index(constantPoolHandle cpool, 389 methodHandle GraalEnv::get_method_by_index(constantPoolHandle& cpool,
390 int index, Bytecodes::Code bc, 390 int index, Bytecodes::Code bc,
391 instanceKlassHandle accessor) { 391 instanceKlassHandle& accessor) {
392 ResourceMark rm; 392 ResourceMark rm;
393 assert(bc != Bytecodes::_invokedynamic, "invokedynamic not yet supported"); 393 assert(bc != Bytecodes::_invokedynamic, "invokedynamic not yet supported");
394 return get_method_by_index_impl(cpool, index, bc, accessor); 394 return get_method_by_index_impl(cpool, index, bc, accessor);
395 } 395 }
396 396