comparison src/share/vm/code/dependencies.cpp @ 20666:bee8095780db

8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer Summary: Ignore non-instance Klasses in the subclass hierarchy. Reviewed-by: kvn, iignatyev, jrose
author thartmann
date Thu, 20 Nov 2014 11:06:26 +0100
parents 3c048df3ef8b
children c4f1e23c4139 41c3c456e326
comparison
equal deleted inserted replaced
20665:b62a321c4d2e 20666:bee8095780db
877 } 877 }
878 878
879 bool is_witness(Klass* k) { 879 bool is_witness(Klass* k) {
880 if (doing_subtype_search()) { 880 if (doing_subtype_search()) {
881 return Dependencies::is_concrete_klass(k); 881 return Dependencies::is_concrete_klass(k);
882 } else if (!k->oop_is_instance()) {
883 return false; // no methods to find in an array type
882 } else { 884 } else {
883 Method* m = InstanceKlass::cast(k)->find_method(_name, _signature); 885 Method* m = InstanceKlass::cast(k)->find_method(_name, _signature);
884 if (m == NULL || !Dependencies::is_concrete_method(m)) return false; 886 if (m == NULL || !Dependencies::is_concrete_method(m)) return false;
885 _found_methods[_num_participants] = m; 887 _found_methods[_num_participants] = m;
886 // Note: If add_participant(k) is called, 888 // Note: If add_participant(k) is called,
1083 Klass* chains[CHAINMAX]; 1085 Klass* chains[CHAINMAX];
1084 int chaini = 0; // index into worklist 1086 int chaini = 0; // index into worklist
1085 Klass* chain; // scratch variable 1087 Klass* chain; // scratch variable
1086 #define ADD_SUBCLASS_CHAIN(k) { \ 1088 #define ADD_SUBCLASS_CHAIN(k) { \
1087 assert(chaini < CHAINMAX, "oob"); \ 1089 assert(chaini < CHAINMAX, "oob"); \
1088 chain = InstanceKlass::cast(k)->subklass(); \ 1090 chain = k->subklass(); \
1089 if (chain != NULL) chains[chaini++] = chain; } 1091 if (chain != NULL) chains[chaini++] = chain; }
1090 1092
1091 // Look for non-abstract subclasses. 1093 // Look for non-abstract subclasses.
1092 // (Note: Interfaces do not have subclasses.) 1094 // (Note: Interfaces do not have subclasses.)
1093 ADD_SUBCLASS_CHAIN(context_type); 1095 ADD_SUBCLASS_CHAIN(context_type);
1094 1096
1095 // If it is an interface, search its direct implementors. 1097 // If it is an interface, search its direct implementors.
1096 // (Their subclasses are additional indirect implementors. 1098 // (Their subclasses are additional indirect implementors.
1097 // See InstanceKlass::add_implementor.) 1099 // See InstanceKlass::add_implementor.)
1098 // (Note: nof_implementors is always zero for non-interfaces.) 1100 // (Note: nof_implementors is always zero for non-interfaces.)
1099 int nof_impls = InstanceKlass::cast(context_type)->nof_implementors(); 1101 if (top_level_call) {
1100 if (nof_impls > 1) { 1102 int nof_impls = InstanceKlass::cast(context_type)->nof_implementors();
1101 // Avoid this case: *I.m > { A.m, C }; B.m > C 1103 if (nof_impls > 1) {
1102 // Here, I.m has 2 concrete implementations, but m appears unique 1104 // Avoid this case: *I.m > { A.m, C }; B.m > C
1103 // as A.m, because the search misses B.m when checking C. 1105 // Here, I.m has 2 concrete implementations, but m appears unique
1104 // The inherited method B.m was getting missed by the walker 1106 // as A.m, because the search misses B.m when checking C.
1105 // when interface 'I' was the starting point. 1107 // The inherited method B.m was getting missed by the walker
1106 // %%% Until this is fixed more systematically, bail out. 1108 // when interface 'I' was the starting point.
1107 // (Old CHA had the same limitation.) 1109 // %%% Until this is fixed more systematically, bail out.
1108 return context_type; 1110 // (Old CHA had the same limitation.)
1109 } 1111 return context_type;
1110 if (nof_impls > 0) { 1112 }
1111 Klass* impl = InstanceKlass::cast(context_type)->implementor(); 1113 if (nof_impls > 0) {
1112 assert(impl != NULL, "just checking"); 1114 Klass* impl = InstanceKlass::cast(context_type)->implementor();
1113 // If impl is the same as the context_type, then more than one 1115 assert(impl != NULL, "just checking");
1114 // implementor has seen. No exact info in this case. 1116 // If impl is the same as the context_type, then more than one
1115 if (impl == context_type) { 1117 // implementor has seen. No exact info in this case.
1116 return context_type; // report an inexact witness to this sad affair 1118 if (impl == context_type) {
1117 } 1119 return context_type; // report an inexact witness to this sad affair
1118 if (do_counts) 1120 }
1119 { NOT_PRODUCT(deps_find_witness_steps++); } 1121 if (do_counts)
1120 if (is_participant(impl)) { 1122 { NOT_PRODUCT(deps_find_witness_steps++); }
1121 if (!participants_hide_witnesses) { 1123 if (is_participant(impl)) {
1124 if (!participants_hide_witnesses) {
1125 ADD_SUBCLASS_CHAIN(impl);
1126 }
1127 } else if (is_witness(impl) && !ignore_witness(impl)) {
1128 return impl;
1129 } else {
1122 ADD_SUBCLASS_CHAIN(impl); 1130 ADD_SUBCLASS_CHAIN(impl);
1123 } 1131 }
1124 } else if (is_witness(impl) && !ignore_witness(impl)) {
1125 return impl;
1126 } else {
1127 ADD_SUBCLASS_CHAIN(impl);
1128 } 1132 }
1129 } 1133 }
1130 1134
1131 // Recursively process each non-trivial sibling chain. 1135 // Recursively process each non-trivial sibling chain.
1132 while (chaini > 0) { 1136 while (chaini > 0) {