src/share/vm/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7017732_incremental Sdiff src/share/vm/classfile

src/share/vm/classfile/classFileParser.cpp

Print this page




2696     fields_with_fix->ushort_at_put(i + instanceKlass::access_flags_offset,
2697       flags);
2698 
2699     assert(fields_with_fix->ushort_at(i + instanceKlass::name_index_offset)
2700       == reference_name_index, "The fake reference name is incorrect");
2701     assert(fields_with_fix->ushort_at(i + instanceKlass::signature_index_offset)
2702       == reference_sig_index, "The fake reference signature is incorrect");
2703     // The type of the field is stored in the low_offset entry during
2704     // parsing.
2705     assert(fields_with_fix->ushort_at(i + instanceKlass::low_offset) ==
2706       NONSTATIC_OOP, "The fake reference type is incorrect");
2707 
2708     // "fields" is allocated in the permanent generation.  Disgard
2709     // it and let it be collected.
2710     (*fields_ptr) = fields_with_fix;
2711   }
2712   return;
2713 }
2714 
2715 
2716 void ClassFileParser::java_lang_Class_fix_pre(objArrayHandle* methods_ptr,
2717   FieldAllocationCount *fac_ptr, TRAPS) {
2718   // Add fake fields for java.lang.Class instances
2719   //
2720   // This is not particularly nice. We should consider adding a
2721   // private transient object field at the Java level to
2722   // java.lang.Class. Alternatively we could add a subclass of
2723   // instanceKlass which provides an accessor and size computer for
2724   // this field, but that appears to be more code than this hack.
2725   //
2726   // NOTE that we wedge these in at the beginning rather than the
2727   // end of the object because the Class layout changed between JDK
2728   // 1.3 and JDK 1.4 with the new reflection implementation; some
2729   // nonstatic oop fields were added at the Java level. The offsets
2730   // of these fake fields can't change between these two JDK
2731   // versions because when the offsets are computed at bootstrap
2732   // time we don't know yet which version of the JDK we're running in.
2733 
2734   // The values below are fake but will force two non-static oop fields and
2735   // a corresponding non-static oop map block to be allocated.
2736   const int extra = java_lang_Class::number_of_fake_oop_fields;
2737   fac_ptr->nonstatic_oop_count += extra;
2738   fac_ptr->nonstatic_word_count += java_lang_Class::hc_number_of_fake_int_fields;


2739 }
2740 
2741 
2742 void ClassFileParser::java_lang_Class_fix_post(int* next_nonstatic_oop_offset_ptr) {
2743   // Cause the extra fake fields in java.lang.Class to show up before
2744   // the Java fields for layout compatibility between 1.3 and 1.4
2745   // Incrementing next_nonstatic_oop_offset here advances the
2746   // location where the real java fields are placed.
2747   const int extra = java_lang_Class::number_of_fake_oop_fields;
2748   (*next_nonstatic_oop_offset_ptr) += (extra * heapOopSize);
2749 }
2750 
2751 
2752 // Force MethodHandle.vmentry to be an unmanaged pointer.
2753 // There is no way for a classfile to express this, so we must help it.
2754 void ClassFileParser::java_dyn_MethodHandle_fix_pre(constantPoolHandle cp,
2755                                                     typeArrayHandle fields,
2756                                                     FieldAllocationCount *fac_ptr,
2757                                                     TRAPS) {
2758   // Add fake fields for java.dyn.MethodHandle instances


3150     // Calculate the starting byte offsets
3151     next_static_oop_offset      = instanceMirrorKlass::offset_of_static_fields();
3152     next_static_double_offset   = next_static_oop_offset +
3153                                   (fac.static_oop_count * heapOopSize);
3154     if ( fac.static_double_count &&
3155          (Universe::field_type_should_be_aligned(T_DOUBLE) ||
3156           Universe::field_type_should_be_aligned(T_LONG)) ) {
3157       next_static_double_offset = align_size_up(next_static_double_offset, BytesPerLong);
3158     }
3159 
3160     next_static_word_offset     = next_static_double_offset +
3161                                   (fac.static_double_count * BytesPerLong);
3162     next_static_short_offset    = next_static_word_offset +
3163                                   (fac.static_word_count * BytesPerInt);
3164     next_static_byte_offset     = next_static_short_offset +
3165                                   (fac.static_short_count * BytesPerShort);
3166     next_static_type_offset     = align_size_up((next_static_byte_offset +
3167                                   fac.static_byte_count ), wordSize );
3168     static_field_size           = (next_static_type_offset -
3169                                   next_static_oop_offset) / wordSize;
3170     first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() +
3171                                    nonstatic_field_size * heapOopSize;
3172     next_nonstatic_field_offset = first_nonstatic_field_offset;
3173 
3174     // Add fake fields for java.lang.Class instances (also see below)
3175     if (class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
3176       java_lang_Class_fix_pre(&methods, &fac, CHECK_(nullHandle));
3177     }
3178 




3179     // adjust the vmentry field declaration in java.dyn.MethodHandle
3180     if (EnableMethodHandles && class_name == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) {
3181       java_dyn_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
3182     }
3183 
3184     // Add a fake "discovered" field if it is not present
3185     // for compatibility with earlier jdk's.
3186     if (class_name == vmSymbols::java_lang_ref_Reference()
3187       && class_loader.is_null()) {
3188       java_lang_ref_Reference_fix_pre(&fields, cp, &fac, CHECK_(nullHandle));
3189     }
3190     // end of "discovered" field compactibility fix
3191 
3192     unsigned int nonstatic_double_count = fac.nonstatic_double_count;
3193     unsigned int nonstatic_word_count   = fac.nonstatic_word_count;
3194     unsigned int nonstatic_short_count  = fac.nonstatic_short_count;
3195     unsigned int nonstatic_byte_count   = fac.nonstatic_byte_count;
3196     unsigned int nonstatic_oop_count    = fac.nonstatic_oop_count;
3197 
3198     bool super_has_nonstatic_fields =


3467         case NONSTATIC_ALIGNED_DOUBLE:
3468         case NONSTATIC_DOUBLE:
3469           real_offset = next_nonstatic_double_offset;
3470           next_nonstatic_double_offset += BytesPerLong;
3471           break;
3472         default:
3473           ShouldNotReachHere();
3474       }
3475       fields->short_at_put(i + instanceKlass::low_offset,  extract_low_short_from_int(real_offset));
3476       fields->short_at_put(i + instanceKlass::high_offset, extract_high_short_from_int(real_offset));
3477     }
3478 
3479     // Size of instances
3480     int instance_size;
3481 
3482     next_nonstatic_type_offset = align_size_up(notaligned_offset, wordSize );
3483     instance_size = align_object_size(next_nonstatic_type_offset / wordSize);
3484 
3485     assert(instance_size == align_object_size(align_size_up((instanceOopDesc::base_offset_in_bytes() + nonstatic_field_size*heapOopSize), wordSize) / wordSize), "consistent layout helper value");
3486 
3487     if (class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
3488       // record location of extra ints
3489       java_lang_Class::oop_size_offset = next_nonstatic_word_offset;
3490       next_nonstatic_word_offset += BytesPerInt;
3491       java_lang_Class::static_oop_field_size_offset = next_nonstatic_word_offset;
3492       next_nonstatic_word_offset += BytesPerInt;
3493     }
3494 
3495     // Number of non-static oop map blocks allocated at end of klass.
3496     const unsigned int total_oop_map_count =
3497       compute_oop_map_count(super_klass, nonstatic_oop_map_count,
3498                             first_nonstatic_oop_offset);
3499 
3500     // Compute reference type
3501     ReferenceType rt;
3502     if (super_klass() == NULL) {
3503       rt = REF_NONE;
3504     } else if (class_name == vmSymbols::java_lang_Class()) {
3505       rt = REF_MIRROR;
3506     } else {
3507       rt = super_klass->reference_type();
3508     }
3509 
3510     // We can now create the basic klassOop for this klass
3511     klassOop ik = oopFactory::new_instanceKlass(vtable_size, itable_size,
3512                                                 static_field_size,
3513                                                 total_oop_map_count,
3514                                                 rt, CHECK_(nullHandle));




2696     fields_with_fix->ushort_at_put(i + instanceKlass::access_flags_offset,
2697       flags);
2698 
2699     assert(fields_with_fix->ushort_at(i + instanceKlass::name_index_offset)
2700       == reference_name_index, "The fake reference name is incorrect");
2701     assert(fields_with_fix->ushort_at(i + instanceKlass::signature_index_offset)
2702       == reference_sig_index, "The fake reference signature is incorrect");
2703     // The type of the field is stored in the low_offset entry during
2704     // parsing.
2705     assert(fields_with_fix->ushort_at(i + instanceKlass::low_offset) ==
2706       NONSTATIC_OOP, "The fake reference type is incorrect");
2707 
2708     // "fields" is allocated in the permanent generation.  Disgard
2709     // it and let it be collected.
2710     (*fields_ptr) = fields_with_fix;
2711   }
2712   return;
2713 }
2714 
2715 
2716 void ClassFileParser::java_lang_Class_fix_pre(int* nonstatic_field_size,
2717                                               FieldAllocationCount *fac_ptr) {
2718   // Add fake fields for java.lang.Class instances
2719   //
2720   // This is not particularly nice. We should consider adding a
2721   // private transient object field at the Java level to
2722   // java.lang.Class. Alternatively we could add a subclass of
2723   // instanceKlass which provides an accessor and size computer for
2724   // this field, but that appears to be more code than this hack.
2725   //
2726   // NOTE that we wedge these in at the beginning rather than the
2727   // end of the object because the Class layout changed between JDK
2728   // 1.3 and JDK 1.4 with the new reflection implementation; some
2729   // nonstatic oop fields were added at the Java level. The offsets
2730   // of these fake fields can't change between these two JDK
2731   // versions because when the offsets are computed at bootstrap
2732   // time we don't know yet which version of the JDK we're running in.
2733 
2734   // The values below are fake but will force three non-static oop fields and
2735   // a corresponding non-static oop map block to be allocated.
2736   const int extra = java_lang_Class::number_of_fake_oop_fields;
2737   fac_ptr->nonstatic_oop_count += extra;
2738 
2739   // Reserve some leading space for fake ints
2740   *nonstatic_field_size += align_size_up(java_lang_Class::hc_number_of_fake_int_fields * BytesPerInt, heapOopSize) / heapOopSize;
2741 }
2742 
2743 
2744 void ClassFileParser::java_lang_Class_fix_post(int* next_nonstatic_oop_offset_ptr) {
2745   // Cause the extra fake fields in java.lang.Class to show up before
2746   // the Java fields for layout compatibility between 1.3 and 1.4
2747   // Incrementing next_nonstatic_oop_offset here advances the
2748   // location where the real java fields are placed.
2749   const int extra = java_lang_Class::number_of_fake_oop_fields;
2750   (*next_nonstatic_oop_offset_ptr) += (extra * heapOopSize);
2751 }
2752 
2753 
2754 // Force MethodHandle.vmentry to be an unmanaged pointer.
2755 // There is no way for a classfile to express this, so we must help it.
2756 void ClassFileParser::java_dyn_MethodHandle_fix_pre(constantPoolHandle cp,
2757                                                     typeArrayHandle fields,
2758                                                     FieldAllocationCount *fac_ptr,
2759                                                     TRAPS) {
2760   // Add fake fields for java.dyn.MethodHandle instances


3152     // Calculate the starting byte offsets
3153     next_static_oop_offset      = instanceMirrorKlass::offset_of_static_fields();
3154     next_static_double_offset   = next_static_oop_offset +
3155                                   (fac.static_oop_count * heapOopSize);
3156     if ( fac.static_double_count &&
3157          (Universe::field_type_should_be_aligned(T_DOUBLE) ||
3158           Universe::field_type_should_be_aligned(T_LONG)) ) {
3159       next_static_double_offset = align_size_up(next_static_double_offset, BytesPerLong);
3160     }
3161 
3162     next_static_word_offset     = next_static_double_offset +
3163                                   (fac.static_double_count * BytesPerLong);
3164     next_static_short_offset    = next_static_word_offset +
3165                                   (fac.static_word_count * BytesPerInt);
3166     next_static_byte_offset     = next_static_short_offset +
3167                                   (fac.static_short_count * BytesPerShort);
3168     next_static_type_offset     = align_size_up((next_static_byte_offset +
3169                                   fac.static_byte_count ), wordSize );
3170     static_field_size           = (next_static_type_offset -
3171                                   next_static_oop_offset) / wordSize;



3172 
3173     // Add fake fields for java.lang.Class instances (also see below)
3174     if (class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
3175       java_lang_Class_fix_pre(&nonstatic_field_size, &fac);
3176     }
3177 
3178     first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() +
3179                                    nonstatic_field_size * heapOopSize;
3180     next_nonstatic_field_offset = first_nonstatic_field_offset;
3181 
3182     // adjust the vmentry field declaration in java.dyn.MethodHandle
3183     if (EnableMethodHandles && class_name == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) {
3184       java_dyn_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
3185     }
3186 
3187     // Add a fake "discovered" field if it is not present
3188     // for compatibility with earlier jdk's.
3189     if (class_name == vmSymbols::java_lang_ref_Reference()
3190       && class_loader.is_null()) {
3191       java_lang_ref_Reference_fix_pre(&fields, cp, &fac, CHECK_(nullHandle));
3192     }
3193     // end of "discovered" field compactibility fix
3194 
3195     unsigned int nonstatic_double_count = fac.nonstatic_double_count;
3196     unsigned int nonstatic_word_count   = fac.nonstatic_word_count;
3197     unsigned int nonstatic_short_count  = fac.nonstatic_short_count;
3198     unsigned int nonstatic_byte_count   = fac.nonstatic_byte_count;
3199     unsigned int nonstatic_oop_count    = fac.nonstatic_oop_count;
3200 
3201     bool super_has_nonstatic_fields =


3470         case NONSTATIC_ALIGNED_DOUBLE:
3471         case NONSTATIC_DOUBLE:
3472           real_offset = next_nonstatic_double_offset;
3473           next_nonstatic_double_offset += BytesPerLong;
3474           break;
3475         default:
3476           ShouldNotReachHere();
3477       }
3478       fields->short_at_put(i + instanceKlass::low_offset,  extract_low_short_from_int(real_offset));
3479       fields->short_at_put(i + instanceKlass::high_offset, extract_high_short_from_int(real_offset));
3480     }
3481 
3482     // Size of instances
3483     int instance_size;
3484 
3485     next_nonstatic_type_offset = align_size_up(notaligned_offset, wordSize );
3486     instance_size = align_object_size(next_nonstatic_type_offset / wordSize);
3487 
3488     assert(instance_size == align_object_size(align_size_up((instanceOopDesc::base_offset_in_bytes() + nonstatic_field_size*heapOopSize), wordSize) / wordSize), "consistent layout helper value");
3489 








3490     // Number of non-static oop map blocks allocated at end of klass.
3491     const unsigned int total_oop_map_count =
3492       compute_oop_map_count(super_klass, nonstatic_oop_map_count,
3493                             first_nonstatic_oop_offset);
3494 
3495     // Compute reference type
3496     ReferenceType rt;
3497     if (super_klass() == NULL) {
3498       rt = REF_NONE;
3499     } else if (class_name == vmSymbols::java_lang_Class()) {
3500       rt = REF_MIRROR;
3501     } else {
3502       rt = super_klass->reference_type();
3503     }
3504 
3505     // We can now create the basic klassOop for this klass
3506     klassOop ik = oopFactory::new_instanceKlass(vtable_size, itable_size,
3507                                                 static_field_size,
3508                                                 total_oop_map_count,
3509                                                 rt, CHECK_(nullHandle));


src/share/vm/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File