< prev index next >

src/hotspot/share/ci/ciEnv.cpp

roman_version

523   if (cpool->tag_at(index).is_symbol()) {                                                                                            
524     klass_name = cpool->symbol_at(index);                                                                                            
525   } else {                                                                                                                           
526     // Check if it's resolved if it's not a symbol constant pool entry.                                                              
527     klass =  ConstantPool::klass_at_if_loaded(cpool, index);                                                                         
528     // Try to look it up by name.                                                                                                    
529     if (klass == NULL) {                                                                                                             
530       klass_name = cpool->klass_name_at(index);                                                                                      
531     }                                                                                                                                
532   }                                                                                                                                  
533 
534   if (klass == NULL) {                                                                                                               
535     // Not found in constant pool.  Use the name to do the lookup.                                                                   
536     ciKlass* k = get_klass_by_name_impl(accessor,                                                                                    
537                                         cpool,                                                                                       
538                                         get_symbol(klass_name),                                                                      
539                                         false);                                                                                      
540     // Calculate accessibility the hard way.                                                                                         
541     if (!k->is_loaded()) {                                                                                                           
542       is_accessible = false;                                                                                                         
543     } else if (k->loader() != accessor->loader() &&                                                                                  
544                get_klass_by_name_impl(accessor, cpool, k->name(), true) == NULL) {                                                   
545       // Loaded only remotely.  Not linked yet.                                                                                      
546       is_accessible = false;                                                                                                         
547     } else {                                                                                                                         
548       // Linked locally, and we must also check public/private, etc.                                                                 
549       is_accessible = check_klass_accessibility(accessor, k->get_Klass());                                                           
550     }                                                                                                                                
551     return k;                                                                                                                        
552   }                                                                                                                                  
553 
554   // Check for prior unloaded klass.  The SystemDictionary's answers                                                                 
555   // can vary over time but the compiler needs consistency.                                                                          
556   ciSymbol* name = get_symbol(klass->name());                                                                                        
557   ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name);                                                                
558   if (unloaded_klass != NULL) {                                                                                                      
559     is_accessible = false;                                                                                                           
560     return unloaded_klass;                                                                                                           
561   }                                                                                                                                  
562 

523   if (cpool->tag_at(index).is_symbol()) {
524     klass_name = cpool->symbol_at(index);
525   } else {
526     // Check if it's resolved if it's not a symbol constant pool entry.
527     klass =  ConstantPool::klass_at_if_loaded(cpool, index);
528     // Try to look it up by name.
529     if (klass == NULL) {
530       klass_name = cpool->klass_name_at(index);
531     }
532   }
533 
534   if (klass == NULL) {
535     // Not found in constant pool.  Use the name to do the lookup.
536     ciKlass* k = get_klass_by_name_impl(accessor,
537                                         cpool,
538                                         get_symbol(klass_name),
539                                         false);
540     // Calculate accessibility the hard way.
541     if (!k->is_loaded()) {
542       is_accessible = false;
543     } else if (!oopDesc::equals(k->loader(), accessor->loader()) &&
544                get_klass_by_name_impl(accessor, cpool, k->name(), true) == NULL) {
545       // Loaded only remotely.  Not linked yet.
546       is_accessible = false;
547     } else {
548       // Linked locally, and we must also check public/private, etc.
549       is_accessible = check_klass_accessibility(accessor, k->get_Klass());
550     }
551     return k;
552   }
553 
554   // Check for prior unloaded klass.  The SystemDictionary's answers
555   // can vary over time but the compiler needs consistency.
556   ciSymbol* name = get_symbol(klass->name());
557   ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name);
558   if (unloaded_klass != NULL) {
559     is_accessible = false;
560     return unloaded_klass;
561   }
562 

574                                    bool& is_accessible,                                                                              
575                                    ciInstanceKlass* accessor) {                                                                      
576   GUARDED_VM_ENTRY(return get_klass_by_index_impl(cpool, index, is_accessible, accessor);)                                           
577 }                                                                                                                                    
578 
579 // ------------------------------------------------------------------                                                                
580 // ciEnv::get_constant_by_index_impl                                                                                                 
581 //                                                                                                                                   
582 // Implementation of get_constant_by_index().                                                                                        
583 ciConstant ciEnv::get_constant_by_index_impl(const constantPoolHandle& cpool,                                                        
584                                              int pool_index, int cache_index,                                                        
585                                              ciInstanceKlass* accessor) {                                                            
586   bool ignore_will_link;                                                                                                             
587   EXCEPTION_CONTEXT;                                                                                                                 
588   int index = pool_index;                                                                                                            
589   if (cache_index >= 0) {                                                                                                            
590     assert(index < 0, "only one kind of index at a time");                                                                           
591     index = cpool->object_to_cp_index(cache_index);                                                                                  
592     oop obj = cpool->resolved_references()->obj_at(cache_index);                                                                     
593     if (obj != NULL) {                                                                                                               
594       if (obj == Universe::the_null_sentinel()) {                                                                                    
595         return ciConstant(T_OBJECT, get_object(NULL));                                                                               
596       }                                                                                                                              
597       BasicType bt = T_OBJECT;                                                                                                       
598       if (cpool->tag_at(index).is_dynamic_constant())                                                                                
599         bt = FieldType::basic_type(cpool->uncached_signature_ref_at(index));                                                         
600       if (is_reference_type(bt)) {                                                                                                   
601       } else {                                                                                                                       
602         // we have to unbox the primitive value                                                                                      
603         if (!is_java_primitive(bt))  return ciConstant();                                                                            
604         jvalue value;                                                                                                                
605         BasicType bt2 = java_lang_boxing_object::get_value(obj, &value);                                                             
606         assert(bt2 == bt, "");                                                                                                       
607         switch (bt2) {                                                                                                               
608         case T_DOUBLE:  return ciConstant(value.d);                                                                                  
609         case T_FLOAT:   return ciConstant(value.f);                                                                                  
610         case T_LONG:    return ciConstant(value.j);                                                                                  
611         case T_INT:     return ciConstant(bt2, value.i);                                                                             
612         case T_SHORT:   return ciConstant(bt2, value.s);                                                                             
613         case T_BYTE:    return ciConstant(bt2, value.b);                                                                             

574                                    bool& is_accessible,
575                                    ciInstanceKlass* accessor) {
576   GUARDED_VM_ENTRY(return get_klass_by_index_impl(cpool, index, is_accessible, accessor);)
577 }
578 
579 // ------------------------------------------------------------------
580 // ciEnv::get_constant_by_index_impl
581 //
582 // Implementation of get_constant_by_index().
583 ciConstant ciEnv::get_constant_by_index_impl(const constantPoolHandle& cpool,
584                                              int pool_index, int cache_index,
585                                              ciInstanceKlass* accessor) {
586   bool ignore_will_link;
587   EXCEPTION_CONTEXT;
588   int index = pool_index;
589   if (cache_index >= 0) {
590     assert(index < 0, "only one kind of index at a time");
591     index = cpool->object_to_cp_index(cache_index);
592     oop obj = cpool->resolved_references()->obj_at(cache_index);
593     if (obj != NULL) {
594       if (oopDesc::equals(obj, Universe::the_null_sentinel())) {
595         return ciConstant(T_OBJECT, get_object(NULL));
596       }
597       BasicType bt = T_OBJECT;
598       if (cpool->tag_at(index).is_dynamic_constant())
599         bt = FieldType::basic_type(cpool->uncached_signature_ref_at(index));
600       if (is_reference_type(bt)) {
601       } else {
602         // we have to unbox the primitive value
603         if (!is_java_primitive(bt))  return ciConstant();
604         jvalue value;
605         BasicType bt2 = java_lang_boxing_object::get_value(obj, &value);
606         assert(bt2 == bt, "");
607         switch (bt2) {
608         case T_DOUBLE:  return ciConstant(value.d);
609         case T_FLOAT:   return ciConstant(value.f);
610         case T_LONG:    return ciConstant(value.j);
611         case T_INT:     return ciConstant(bt2, value.i);
612         case T_SHORT:   return ciConstant(bt2, value.s);
613         case T_BYTE:    return ciConstant(bt2, value.b);
< prev index next >