Loading... (original) (raw)

During working on 8031320 I found few C2 problems and fixed them as part of 8031320.
Dan suggested to backport them in previous releases.
8031320 was backported into 8u20. We need to backport these fixes into 7u and 6u.

1. Move disabling UseOptoBiasInlining after the last change to UseBiasedLocking:

src/share/vm/runtime/arguments.cpp
@@ -3748,9 +3748,6 @@
#endif // CC_INTERP

#ifdef COMPILER2
- if (!UseBiasedLocking || EmitSync != 0) {
- UseOptoBiasInlining = false;
- }
if (!EliminateLocks) {
EliminateNestedLocks = false;
}
@@ -3811,6 +3808,11 @@
UseBiasedLocking = false;
}
}
+#ifdef COMPILER2
+ if (!UseBiasedLocking || EmitSync != 0) {
+ UseOptoBiasInlining = false;
+ }
+#endif

2. cmpxchg may fail first time when new named counter is added. It triggers assert in set_next() because _next is set already.
Fix it by resetting _next for each attempt:

src/share/vm/opto/runtime.cpp
@@ -1346,6 +1356,7 @@
// add counters so this is safe.
NamedCounter* head;
do {
+ c->set_next(NULL);
head = _named_counters;
c->set_next(head);
} while (Atomic::cmpxchg_ptr(c, &_named_counters, head) != head);

src/share/vm/opto/runtime.hpp
@@ -85,7 +87,7 @@

NamedCounter* next() const { return _next; }
void set_next(NamedCounter* next) {
- assert(_next == NULL, "already set");
+ assert(_next == NULL || next == NULL, "already set");
_next = next;
}