147 } |
147 } |
148 } |
148 } |
149 |
149 |
150 //----------------------------------------------------------------- |
150 //----------------------------------------------------------------- |
151 // High-level interface |
151 // High-level interface |
152 bool VMOperationQueue::add(VM_Operation *op) { |
152 void VMOperationQueue::add(VM_Operation *op) { |
153 |
153 |
154 HOTSPOT_VMOPS_REQUEST( |
154 HOTSPOT_VMOPS_REQUEST( |
155 (char *) op->name(), strlen(op->name()), |
155 (char *) op->name(), strlen(op->name()), |
156 op->evaluation_mode()); |
156 op->evaluation_mode()); |
157 |
157 |
158 // Encapsulates VM queue policy. Currently, that |
158 // Encapsulates VM queue policy. Currently, that |
159 // only involves putting them on the right list |
159 // only involves putting them on the right list |
160 if (op->evaluate_at_safepoint()) { |
160 queue_add_back(op->evaluate_at_safepoint() ? SafepointPriority : MediumPriority, op); |
161 queue_add_back(SafepointPriority, op); |
|
162 return true; |
|
163 } |
|
164 |
|
165 queue_add_back(MediumPriority, op); |
|
166 return true; |
|
167 } |
161 } |
168 |
162 |
169 VM_Operation* VMOperationQueue::remove_next() { |
163 VM_Operation* VMOperationQueue::remove_next() { |
170 // Assuming VMOperation queue is two-level priority queue. If there are |
164 // Assuming VMOperation queue is two-level priority queue. If there are |
171 // more than two priorities, we need a different scheduling algorithm. |
165 // more than two priorities, we need a different scheduling algorithm. |
700 // VMOperationQueue_lock, so we can block without a safepoint check. This allows vm operation requests |
694 // VMOperationQueue_lock, so we can block without a safepoint check. This allows vm operation requests |
701 // to be queued up during a safepoint synchronization. |
695 // to be queued up during a safepoint synchronization. |
702 { |
696 { |
703 VMOperationQueue_lock->lock_without_safepoint_check(); |
697 VMOperationQueue_lock->lock_without_safepoint_check(); |
704 log_debug(vmthread)("Adding VM operation: %s", op->name()); |
698 log_debug(vmthread)("Adding VM operation: %s", op->name()); |
705 bool ok = _vm_queue->add(op); |
699 _vm_queue->add(op); |
706 op->set_timestamp(os::javaTimeMillis()); |
700 op->set_timestamp(os::javaTimeMillis()); |
707 VMOperationQueue_lock->notify(); |
701 VMOperationQueue_lock->notify(); |
708 VMOperationQueue_lock->unlock(); |
702 VMOperationQueue_lock->unlock(); |
709 // VM_Operation got skipped |
|
710 if (!ok) { |
|
711 assert(concurrent, "can only skip concurrent tasks"); |
|
712 if (op->is_cheap_allocated()) delete op; |
|
713 return; |
|
714 } |
|
715 } |
703 } |
716 |
704 |
717 if (!concurrent) { |
705 if (!concurrent) { |
718 // Wait for completion of request (non-concurrent) |
706 // Wait for completion of request (non-concurrent) |
719 // Note: only a JavaThread triggers the safepoint check when locking |
707 // Note: only a JavaThread triggers the safepoint check when locking |