@@ -156,17 +156,33 @@ int StubInfo::span(EntryId second, EntryId first) {
156
156
}
157
157
158
158
int StubInfo::span (StubId second, StubId first) {
159
+ // normally when the two ids are equal the entry span is 1 but we
160
+ // have a special case when the base and max are both NO_STUBID in
161
+ // which case the entry count is 0. n.b. that only happens in the
162
+ // case where a stub group is empty e.g. when either C1 or C2 is
163
+ // omitted from the build
159
164
int idx1 = static_cast <int >(first);
160
165
int idx2 = static_cast <int >(second);
161
- assert (idx2 >= 0 && idx2 >= idx1, " bad stub ids first %d and second %d" , idx1, idx2);
166
+ assert ((idx1 < 0 && idx2 < 0 ) || (idx1 >= 0 && idx2 >= idx1), " bad stub ids first %d and second %d" , idx1, idx2);
167
+ if (idx1 < 0 ) {
168
+ return 0 ;
169
+ }
162
170
// span is inclusive of first and second
163
171
return idx2 + 1 - idx1;
164
172
}
165
173
166
174
int StubInfo::span (BlobId second, BlobId first) {
175
+ // normally when the two ids are equal the entry span is 1 but we
176
+ // have a special case when the base and max are both NO_BLOBID in
177
+ // which case the entry count is 0. n.b. that only happens in the
178
+ // case where a stub group is empty e.g. when either C1 or C2 is
179
+ // omitted from the build
167
180
int idx1 = static_cast <int >(first);
168
181
int idx2 = static_cast <int >(second);
169
- assert (idx2 >= 0 && idx2 >= idx1, " bad blob ids first %d and second %d" , idx1, idx2);
182
+ assert ((idx1 < 0 && idx2 < 0 ) || (idx1 >= 0 && idx2 >= idx1), " bad blob ids first %d and second %d" , idx1, idx2);
183
+ if (idx1 < 0 ) {
184
+ return 0 ;
185
+ }
170
186
// span is inclusive of first and second
171
187
return idx2 + 1 - idx1;
172
188
}
@@ -777,9 +793,16 @@ void StubInfo::dump_group_table(LogStream& ls) {
777
793
GroupDetails& g = _group_table[i];
778
794
ls.print_cr (" %1d: %-8s" , i, g._name );
779
795
if (g._base == g._max ) {
780
- ls.print_cr (" blobs: %s(%d)" ,
781
- blob_details (g._base )._name ,
782
- static_cast <int >(g._base ));
796
+ // some groups don't have a blob
797
+ if (g._base == BlobId::NO_BLOBID) {
798
+ ls.print_cr (" blobs: %s(%d)" ,
799
+ " no_blobs" ,
800
+ static_cast <int >(g._base ));
801
+ } else {
802
+ ls.print_cr (" blobs: %s(%d)" ,
803
+ blob_details (g._base )._name ,
804
+ static_cast <int >(g._base ));
805
+ }
783
806
} else {
784
807
ls.print_cr (" blobs: %s(%d) ... %s(%d)" ,
785
808
blob_details (g._base )._name ,
@@ -796,9 +819,16 @@ void StubInfo::dump_blob_table(LogStream& ls) {
796
819
BlobDetails& b = _blob_table[i];
797
820
ls.print_cr (" %-3d: %s" , i, b._name );
798
821
if (b._base == b._max ) {
799
- ls.print_cr (" stubs: %s(%d)" ,
800
- stub_details (b._base )._name ,
801
- static_cast <int >(b._base ));
822
+ // some blobs don't have a stub
823
+ if (b._base == StubId::NO_STUBID) {
824
+ ls.print_cr (" stubs: %s(%d)" ,
825
+ " no_stubs" ,
826
+ static_cast <int >(b._base ));
827
+ } else {
828
+ ls.print_cr (" stubs: %s(%d)" ,
829
+ stub_details (b._base )._name ,
830
+ static_cast <int >(b._base ));
831
+ }
802
832
} else {
803
833
ls.print_cr (" stubs: %s(%d) ... %s(%d)" ,
804
834
stub_details (b._base )._name ,
@@ -905,13 +935,13 @@ int StubInfo::blob_count(StubGroup stub_group) {
905
935
}
906
936
907
937
StubId StubInfo::stub_base (StubGroup stub_group) {
908
- // delegate
909
- return stub_base (blob_base (stub_group ));
938
+ BlobId base = blob_base (stub_group);
939
+ return (base == BlobId::NO_BLOBID ? StubId::NO_STUBID : stub_base (base ));
910
940
}
911
941
912
942
StubId StubInfo::stub_max (StubGroup stub_group) {
913
- // delegate
914
- return stub_max (blob_max (stub_group ));
943
+ BlobId base = blob_max (stub_group);
944
+ return (base == BlobId::NO_BLOBID ? StubId::NO_STUBID : stub_max (base ));
915
945
}
916
946
917
947
int StubInfo::stub_count (StubGroup stub_group) {
0 commit comments