Mercurial > hg > truffle
comparison src/share/vm/classfile/classFileParser.cpp @ 165:437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
Summary: Use the gap also for a narrow oop field and a boxing object value.
Reviewed-by: coleenp, never
author | kvn |
---|---|
date | Wed, 21 May 2008 16:31:35 -0700 |
parents | 7f3a69574470 |
children | 1f809e010142 |
comparison
equal
deleted
inserted
replaced
164:c436414a719e | 165:437d03ea40b1 |
---|---|
2662 (fac.static_short_count * BytesPerShort); | 2662 (fac.static_short_count * BytesPerShort); |
2663 next_static_type_offset = align_size_up((next_static_byte_offset + | 2663 next_static_type_offset = align_size_up((next_static_byte_offset + |
2664 fac.static_byte_count ), wordSize ); | 2664 fac.static_byte_count ), wordSize ); |
2665 static_field_size = (next_static_type_offset - | 2665 static_field_size = (next_static_type_offset - |
2666 next_static_oop_offset) / wordSize; | 2666 next_static_oop_offset) / wordSize; |
2667 first_nonstatic_field_offset = (instanceOopDesc::header_size() + | 2667 first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() + |
2668 nonstatic_field_size) * wordSize; | 2668 nonstatic_field_size * heapOopSize; |
2669 next_nonstatic_field_offset = first_nonstatic_field_offset; | 2669 next_nonstatic_field_offset = first_nonstatic_field_offset; |
2670 | 2670 |
2671 // Add fake fields for java.lang.Class instances (also see below) | 2671 // Add fake fields for java.lang.Class instances (also see below) |
2672 if (class_name() == vmSymbols::java_lang_Class() && class_loader.is_null()) { | 2672 if (class_name() == vmSymbols::java_lang_Class() && class_loader.is_null()) { |
2673 java_lang_Class_fix_pre(&methods, &fac, CHECK_(nullHandle)); | 2673 java_lang_Class_fix_pre(&methods, &fac, CHECK_(nullHandle)); |
2732 next_nonstatic_short_offset = next_nonstatic_word_offset + | 2732 next_nonstatic_short_offset = next_nonstatic_word_offset + |
2733 (nonstatic_word_count * BytesPerInt); | 2733 (nonstatic_word_count * BytesPerInt); |
2734 next_nonstatic_byte_offset = next_nonstatic_short_offset + | 2734 next_nonstatic_byte_offset = next_nonstatic_short_offset + |
2735 (nonstatic_short_count * BytesPerShort); | 2735 (nonstatic_short_count * BytesPerShort); |
2736 next_nonstatic_type_offset = align_size_up((next_nonstatic_byte_offset + | 2736 next_nonstatic_type_offset = align_size_up((next_nonstatic_byte_offset + |
2737 nonstatic_byte_count ), wordSize ); | 2737 nonstatic_byte_count ), heapOopSize ); |
2738 orig_nonstatic_field_size = nonstatic_field_size + | 2738 orig_nonstatic_field_size = nonstatic_field_size + |
2739 ((next_nonstatic_type_offset - first_nonstatic_field_offset)/wordSize); | 2739 ((next_nonstatic_type_offset - first_nonstatic_field_offset)/heapOopSize); |
2740 } | 2740 } |
2741 #endif | 2741 #endif |
2742 bool compact_fields = CompactFields; | 2742 bool compact_fields = CompactFields; |
2743 int allocation_style = FieldsAllocationStyle; | 2743 int allocation_style = FieldsAllocationStyle; |
2744 if( allocation_style < 0 || allocation_style > 1 ) { // Out of range? | 2744 if( allocation_style < 0 || allocation_style > 1 ) { // Out of range? |
2789 int nonstatic_oop_space_offset; | 2789 int nonstatic_oop_space_offset; |
2790 int nonstatic_word_space_offset; | 2790 int nonstatic_word_space_offset; |
2791 int nonstatic_short_space_offset; | 2791 int nonstatic_short_space_offset; |
2792 int nonstatic_byte_space_offset; | 2792 int nonstatic_byte_space_offset; |
2793 | 2793 |
2794 bool compact_into_header = (UseCompressedOops && | 2794 if( nonstatic_double_count > 0 ) { |
2795 allocation_style == 1 && compact_fields && | 2795 int offset = next_nonstatic_double_offset; |
2796 !super_has_nonstatic_fields); | |
2797 | |
2798 if( compact_into_header || nonstatic_double_count > 0 ) { | |
2799 int offset; | |
2800 // Pack something in with the header if no super klass has done so. | |
2801 if (compact_into_header) { | |
2802 offset = oopDesc::klass_gap_offset_in_bytes(); | |
2803 } else { | |
2804 offset = next_nonstatic_double_offset; | |
2805 } | |
2806 next_nonstatic_double_offset = align_size_up(offset, BytesPerLong); | 2796 next_nonstatic_double_offset = align_size_up(offset, BytesPerLong); |
2807 if( compact_fields && offset != next_nonstatic_double_offset ) { | 2797 if( compact_fields && offset != next_nonstatic_double_offset ) { |
2808 // Allocate available fields into the gap before double field. | 2798 // Allocate available fields into the gap before double field. |
2809 int length = next_nonstatic_double_offset - offset; | 2799 int length = next_nonstatic_double_offset - offset; |
2810 assert(length == BytesPerInt, ""); | 2800 assert(length == BytesPerInt, ""); |
2828 nonstatic_byte_space_count += 1; | 2818 nonstatic_byte_space_count += 1; |
2829 length -= 1; | 2819 length -= 1; |
2830 } | 2820 } |
2831 // Allocate oop field in the gap if there are no other fields for that. | 2821 // Allocate oop field in the gap if there are no other fields for that. |
2832 nonstatic_oop_space_offset = offset; | 2822 nonstatic_oop_space_offset = offset; |
2833 if(!compact_into_header && length >= heapOopSize && | 2823 if( length >= heapOopSize && nonstatic_oop_count > 0 && |
2834 nonstatic_oop_count > 0 && | |
2835 allocation_style != 0 ) { // when oop fields not first | 2824 allocation_style != 0 ) { // when oop fields not first |
2836 nonstatic_oop_count -= 1; | 2825 nonstatic_oop_count -= 1; |
2837 nonstatic_oop_space_count = 1; // Only one will fit | 2826 nonstatic_oop_space_count = 1; // Only one will fit |
2838 length -= heapOopSize; | 2827 length -= heapOopSize; |
2839 offset += heapOopSize; | 2828 offset += heapOopSize; |
2852 if( allocation_style == 0 ) { | 2841 if( allocation_style == 0 ) { |
2853 notaligned_offset = next_nonstatic_byte_offset + nonstatic_byte_count; | 2842 notaligned_offset = next_nonstatic_byte_offset + nonstatic_byte_count; |
2854 } else { // allocation_style == 1 | 2843 } else { // allocation_style == 1 |
2855 next_nonstatic_oop_offset = next_nonstatic_byte_offset + nonstatic_byte_count; | 2844 next_nonstatic_oop_offset = next_nonstatic_byte_offset + nonstatic_byte_count; |
2856 if( nonstatic_oop_count > 0 ) { | 2845 if( nonstatic_oop_count > 0 ) { |
2857 notaligned_offset = next_nonstatic_oop_offset; | |
2858 next_nonstatic_oop_offset = align_size_up(next_nonstatic_oop_offset, heapOopSize); | 2846 next_nonstatic_oop_offset = align_size_up(next_nonstatic_oop_offset, heapOopSize); |
2859 } | 2847 } |
2860 notaligned_offset = next_nonstatic_oop_offset + (nonstatic_oop_count * heapOopSize); | 2848 notaligned_offset = next_nonstatic_oop_offset + (nonstatic_oop_count * heapOopSize); |
2861 } | 2849 } |
2862 next_nonstatic_type_offset = align_size_up(notaligned_offset, wordSize ); | 2850 next_nonstatic_type_offset = align_size_up(notaligned_offset, heapOopSize ); |
2863 nonstatic_field_size = nonstatic_field_size + ((next_nonstatic_type_offset | 2851 nonstatic_field_size = nonstatic_field_size + ((next_nonstatic_type_offset |
2864 - first_nonstatic_field_offset)/wordSize); | 2852 - first_nonstatic_field_offset)/heapOopSize); |
2865 | 2853 |
2866 // Iterate over fields again and compute correct offsets. | 2854 // Iterate over fields again and compute correct offsets. |
2867 // The field allocation type was temporarily stored in the offset slot. | 2855 // The field allocation type was temporarily stored in the offset slot. |
2868 // oop fields are located before non-oop fields (static and non-static). | 2856 // oop fields are located before non-oop fields (static and non-static). |
2869 int len = fields->length(); | 2857 int len = fields->length(); |
2960 } | 2948 } |
2961 | 2949 |
2962 // Size of instances | 2950 // Size of instances |
2963 int instance_size; | 2951 int instance_size; |
2964 | 2952 |
2953 next_nonstatic_type_offset = align_size_up(notaligned_offset, wordSize ); | |
2965 instance_size = align_object_size(next_nonstatic_type_offset / wordSize); | 2954 instance_size = align_object_size(next_nonstatic_type_offset / wordSize); |
2966 | 2955 |
2967 assert(instance_size == align_object_size(instanceOopDesc::header_size() + nonstatic_field_size), "consistent layout helper value"); | 2956 assert(instance_size == align_object_size(align_size_up((instanceOopDesc::base_offset_in_bytes() + nonstatic_field_size*heapOopSize), wordSize) / wordSize), "consistent layout helper value"); |
2968 | 2957 |
2969 // Size of non-static oop map blocks (in words) allocated at end of klass | 2958 // Size of non-static oop map blocks (in words) allocated at end of klass |
2970 int nonstatic_oop_map_size = compute_oop_map_size(super_klass, nonstatic_oop_map_count, first_nonstatic_oop_offset); | 2959 int nonstatic_oop_map_size = compute_oop_map_size(super_klass, nonstatic_oop_map_count, first_nonstatic_oop_offset); |
2971 | 2960 |
2972 // Compute reference type | 2961 // Compute reference type |
3120 } | 3109 } |
3121 | 3110 |
3122 #ifndef PRODUCT | 3111 #ifndef PRODUCT |
3123 if( PrintCompactFieldsSavings ) { | 3112 if( PrintCompactFieldsSavings ) { |
3124 if( nonstatic_field_size < orig_nonstatic_field_size ) { | 3113 if( nonstatic_field_size < orig_nonstatic_field_size ) { |
3125 tty->print("[Saved %d of %3d words in %s]\n", | 3114 tty->print("[Saved %d of %d bytes in %s]\n", |
3126 orig_nonstatic_field_size - nonstatic_field_size, | 3115 (orig_nonstatic_field_size - nonstatic_field_size)*heapOopSize, |
3127 orig_nonstatic_field_size, this_klass->external_name()); | 3116 orig_nonstatic_field_size*heapOopSize, |
3117 this_klass->external_name()); | |
3128 } else if( nonstatic_field_size > orig_nonstatic_field_size ) { | 3118 } else if( nonstatic_field_size > orig_nonstatic_field_size ) { |
3129 tty->print("[Wasted %d over %3d words in %s]\n", | 3119 tty->print("[Wasted %d over %d bytes in %s]\n", |
3130 nonstatic_field_size - orig_nonstatic_field_size, | 3120 (nonstatic_field_size - orig_nonstatic_field_size)*heapOopSize, |
3131 orig_nonstatic_field_size, this_klass->external_name()); | 3121 orig_nonstatic_field_size*heapOopSize, |
3122 this_klass->external_name()); | |
3132 } | 3123 } |
3133 } | 3124 } |
3134 #endif | 3125 #endif |
3135 | 3126 |
3136 // preserve result across HandleMark | 3127 // preserve result across HandleMark |