comparison src/share/vm/interpreter/interpreterRuntime.cpp @ 2194:face83fc8882

7012088: jump to 0 address because of lack of memory ordering in SignatureHandlerLibrary::add Summary: Write method signature handler under lock to prevent race with growable array resizing Reviewed-by: dsamersoff, dholmes
author coleenp
date Wed, 02 Feb 2011 18:38:40 -0500
parents b92c45f2bc75
children 8033953d67ff
comparison
equal deleted inserted replaced
2193:9cd8a2c2d584 2194:face83fc8882
1182 // set handler index 1182 // set handler index
1183 assert(_fingerprints->length() == _handlers->length(), "sanity check"); 1183 assert(_fingerprints->length() == _handlers->length(), "sanity check");
1184 handler_index = _fingerprints->length() - 1; 1184 handler_index = _fingerprints->length() - 1;
1185 } 1185 }
1186 } 1186 }
1187 } else { 1187 // Set handler under SignatureHandlerLibrary_lock
1188 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
1189 }
1190 if (handler_index < 0) { 1188 if (handler_index < 0) {
1191 // use generic signature handler 1189 // use generic signature handler
1192 method->set_signature_handler(Interpreter::slow_signature_handler()); 1190 method->set_signature_handler(Interpreter::slow_signature_handler());
1193 } else { 1191 } else {
1194 // set handler 1192 // set handler
1195 method->set_signature_handler(_handlers->at(handler_index)); 1193 method->set_signature_handler(_handlers->at(handler_index));
1196 } 1194 }
1195 } else {
1196 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
1197 // use generic signature handler
1198 method->set_signature_handler(Interpreter::slow_signature_handler());
1199 }
1197 } 1200 }
1198 #ifdef ASSERT 1201 #ifdef ASSERT
1199 int handler_index, fingerprint_index; 1202 int handler_index = -1;
1203 int fingerprint_index = -2;
1200 { 1204 {
1201 // '_handlers' and '_fingerprints' are 'GrowableArray's and are NOT synchronized 1205 // '_handlers' and '_fingerprints' are 'GrowableArray's and are NOT synchronized
1202 // in any way if accessed from multiple threads. To avoid races with another 1206 // in any way if accessed from multiple threads. To avoid races with another
1203 // thread which may change the arrays in the above, mutex protected block, we 1207 // thread which may change the arrays in the above, mutex protected block, we
1204 // have to protect this read access here with the same mutex as well! 1208 // have to protect this read access here with the same mutex as well!
1205 MutexLocker mu(SignatureHandlerLibrary_lock); 1209 MutexLocker mu(SignatureHandlerLibrary_lock);
1210 if (_handlers != NULL) {
1206 handler_index = _handlers->find(method->signature_handler()); 1211 handler_index = _handlers->find(method->signature_handler());
1207 fingerprint_index = _fingerprints->find(Fingerprinter(method).fingerprint()); 1212 fingerprint_index = _fingerprints->find(Fingerprinter(method).fingerprint());
1208 } 1213 }
1214 }
1209 assert(method->signature_handler() == Interpreter::slow_signature_handler() || 1215 assert(method->signature_handler() == Interpreter::slow_signature_handler() ||
1210 handler_index == fingerprint_index, "sanity check"); 1216 handler_index == fingerprint_index, "sanity check");
1211 #endif 1217 #endif // ASSERT
1212 } 1218 }
1213 1219
1214 1220
1215 BufferBlob* SignatureHandlerLibrary::_handler_blob = NULL; 1221 BufferBlob* SignatureHandlerLibrary::_handler_blob = NULL;
1216 address SignatureHandlerLibrary::_handler = NULL; 1222 address SignatureHandlerLibrary::_handler = NULL;