Code Review for 7196242

Prepared by:twisti on Mon Sep 10 16:17:25 PDT 2012
Workspace:/home/twisti/7196242
Compare against: http://hg.openjdk.java.net/hsx/hotspot-gc/hotspot
Summary of changes: 33 lines changed: 13 ins; 10 del; 10 mod; 2235 unchg
Patch of changes: 7196242.patch
Printable review: 7196242.pdf
Author comments:
7196242: vm/mlvm/indy/stress/java/loopsAndThreads crashed
Reviewed-by: jrose, coleenp, jmasa, kvn

The current code in ConstantPoolCacheEntry::set_method_handle_common uses
a CAS to find out who's the winning thread in the race about linking an
invokehandle/invokedynamic call site. The winning thread does the linking
while the other threads are waiting in a loop until the winning thread
finishes. The waiting threads enter the Patching_lock and call os::yield
to give the winning thread more CPU time.

Unfortunately the implementation of os::yield on Solaris uses the
Threads_lock and we hit this assert:

# fatal error: acquiring lock Threads_lock/15 out of order with lock Patching_lock/1 -- possible deadlock

Even worse, the CAS might fail spuriously and we don't have a winning
thread because we don't loop around the CAS. This may lead to hangs.

Bug id: 7196242 vm/mlvm/indy/stress/java/loopsAndThreads crashes on client
Legend: Modified file
Deleted file
New file

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/interpreterRuntime.cpp

2 lines changed: 2 ins; 0 del; 0 mod; 1212 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw src/share/vm/oops/cpCache.cpp

28 lines changed: 8 ins; 10 del; 10 mod; 584 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw src/share/vm/oops/cpCache.hpp

3 lines changed: 3 ins; 0 del; 0 mod; 439 unchg

This code review page was prepared using /home/twisti/bin/webrev (vers 23.18-hg-never).