396 op->evaluate_at_safepoint() ? 0 : 1);
397
398 EventExecuteVMOperation event;
399 op->evaluate();
400 if (event.should_commit()) {
401 post_vm_operation_event(&event, op);
402 }
403
404 HOTSPOT_VMOPS_END(
405 (char *) op->name(), strlen(op->name()),
406 op->evaluate_at_safepoint() ? 0 : 1);
407 }
408
409 // Mark as completed
410 op->calling_thread()->increment_vm_operation_completed_count();
411 }
412
413 static VM_None safepointALot_op("SafepointALot");
414 static VM_Cleanup cleanup_op;
415
416 class HandshakeALotTC : public ThreadClosure {
417 public:
418 virtual void do_thread(Thread* thread) {
419 #ifdef ASSERT
420 assert(thread->is_Java_thread(), "must be");
421 JavaThread* jt = (JavaThread*)thread;
422 jt->verify_states_for_handshake();
423 #endif
424 }
425 };
426
427 void VMThread::check_for_forced_cleanup() {
428 MonitorLocker mq(VMOperationQueue_lock, Mutex::_no_safepoint_check_flag);
429 mq.notify();
430 }
431
432 VM_Operation* VMThread::no_op_safepoint() {
433 // Check for handshakes first since we may need to return a VMop.
434 if (HandshakeALot) {
435 HandshakeALotTC haltc;
436 Handshake::execute(&haltc);
437 }
438 // Check for a cleanup before SafepointALot to keep stats correct.
439 long interval_ms = SafepointTracing::time_since_last_safepoint_ms();
440 bool max_time_exceeded = GuaranteedSafepointInterval != 0 &&
441 (interval_ms >= GuaranteedSafepointInterval);
442 if ((max_time_exceeded && SafepointSynchronize::is_cleanup_needed()) ||
443 SafepointSynchronize::is_forced_cleanup_needed()) {
444 return &cleanup_op;
445 }
446 if (SafepointALot) {
447 return &safepointALot_op;
448 }
449 // Nothing to be done.
450 return NULL;
451 }
452
453 void VMThread::loop() {
454 assert(_cur_vm_operation == NULL, "no current one should be executing");
455
456 SafepointSynchronize::init(_vm_thread);
|
396 op->evaluate_at_safepoint() ? 0 : 1);
397
398 EventExecuteVMOperation event;
399 op->evaluate();
400 if (event.should_commit()) {
401 post_vm_operation_event(&event, op);
402 }
403
404 HOTSPOT_VMOPS_END(
405 (char *) op->name(), strlen(op->name()),
406 op->evaluate_at_safepoint() ? 0 : 1);
407 }
408
409 // Mark as completed
410 op->calling_thread()->increment_vm_operation_completed_count();
411 }
412
413 static VM_None safepointALot_op("SafepointALot");
414 static VM_Cleanup cleanup_op;
415
416 class HandshakeALotClosure : public HandshakeClosure {
417 public:
418 HandshakeALotClosure() : HandshakeClosure("HandshakeALot") {}
419 void do_thread(Thread* thread) {
420 #ifdef ASSERT
421 assert(thread->is_Java_thread(), "must be");
422 JavaThread* jt = (JavaThread*)thread;
423 jt->verify_states_for_handshake();
424 #endif
425 }
426 };
427
428 void VMThread::check_for_forced_cleanup() {
429 MonitorLocker mq(VMOperationQueue_lock, Mutex::_no_safepoint_check_flag);
430 mq.notify();
431 }
432
433 VM_Operation* VMThread::no_op_safepoint() {
434 // Check for handshakes first since we may need to return a VMop.
435 if (HandshakeALot) {
436 HandshakeALotClosure hal_cl;
437 Handshake::execute(&hal_cl);
438 }
439 // Check for a cleanup before SafepointALot to keep stats correct.
440 long interval_ms = SafepointTracing::time_since_last_safepoint_ms();
441 bool max_time_exceeded = GuaranteedSafepointInterval != 0 &&
442 (interval_ms >= GuaranteedSafepointInterval);
443 if ((max_time_exceeded && SafepointSynchronize::is_cleanup_needed()) ||
444 SafepointSynchronize::is_forced_cleanup_needed()) {
445 return &cleanup_op;
446 }
447 if (SafepointALot) {
448 return &safepointALot_op;
449 }
450 // Nothing to be done.
451 return NULL;
452 }
453
454 void VMThread::loop() {
455 assert(_cur_vm_operation == NULL, "no current one should be executing");
456
457 SafepointSynchronize::init(_vm_thread);
|