- Loading...
...
When this function returns true, the next field in 'mid_p' is marked and any parallel callers of mark_list_head() on the same list will be looping until the next field in the list head's ObjectMonitor is no longer marked. The caller that just got the 'true' return needs to finish up its work with 'mid_p' quickly.
ObjectSynchronizer::om_alloc() is responsible for allocating an ObjectMonitor and returning it to the caller. It has a three step algorithm:
1) Try to allocate from self's local free-list:
2) Try to allocate from the global free list (up to self→om_free_provision times):
3) Allocate a block of new ObjectMonitors:
ObjectSynchronizer::om_release() is responsible for putting an ObjectMonitor on self's free list. If 'from_per_thread_alloc' is true, then om_release() is also responsible for extracting the ObjectMonitor from self's in-use list. The extraction from self's in-use list must happen first:
L01: mark_list_head(&self->om_in_use_list, &mid, &next);
L02: while (true) {
L03: if (m == mid) {
L04: if (Atomic::cmpxchg(next, &self->om_in_use_list, mid) != mid) {
L05: ObjectMonitor* marked_mid = mark_om_ptr(mid);
L06: Atomic::cmpxchg(next, &cur_mid_in_use->_next_om, marked_mid);
L07: }
L08: extracted = true;
L09: Atomic::dec(&self->om_in_use_count);
L10: set_next(mid, next);
L11: break;
L12: }
L13: if (cur_mid_in_use != NULL) {
L14: set_next(cur_mid_in_use, mid); // umark cur_mid_in_use
L15: }
L16: cur_mid_in_use = mid;
L17: mid = next;
L18: next = mark_next_loop(mid);
L19: }
The above code block extracts 'm' from self's in-use list; it is not an exact quote from om_release(), but it is the highlights:
mark_next_loop() is next interesting helper function:
L1: static ObjectMonitor* mark_next_loop(ObjectMonitor* om) {
L2: ObjectMonitor* next;
L3: while (true) {
L4: if (mark_next(om, &next)) {
L5: // Marked om's next field so return the unmarked value.
L6: return next;
L7: }
L8: }
L9: }
The above function loops until it marks the next field of the target ObjectMonitor. The unmarked value of the next field is returned by the function. There is nothing particularly special about this function so we don't need any line specific annotations.
...