1 /*
   2  * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoaderDataGraph.hpp"
  27 #include "classfile/dictionary.hpp"
  28 #include "classfile/stringTable.hpp"
  29 #include "classfile/symbolTable.hpp"
  30 #include "code/codeCache.hpp"
  31 #include "code/icBuffer.hpp"
  32 #include "code/nmethod.hpp"
  33 #include "code/pcDesc.hpp"
  34 #include "code/scopeDesc.hpp"
  35 #include "compiler/compilationPolicy.hpp"
  36 #include "gc/shared/collectedHeap.hpp"
  37 #include "gc/shared/gcLocker.hpp"
  38 #include "gc/shared/oopStorage.hpp"
  39 #include "gc/shared/strongRootsScope.hpp"
  40 #include "gc/shared/workgroup.hpp"
  41 #include "interpreter/interpreter.hpp"
  42 #include "jfr/jfrEvents.hpp"
  43 #include "logging/log.hpp"
  44 #include "logging/logStream.hpp"
  45 #include "memory/resourceArea.hpp"
  46 #include "memory/universe.hpp"
  47 #include "oops/oop.inline.hpp"
  48 #include "oops/symbol.hpp"

  49 #include "runtime/atomic.hpp"
  50 #include "runtime/deoptimization.hpp"
  51 #include "runtime/frame.inline.hpp"
  52 #include "runtime/handles.inline.hpp"
  53 #include "runtime/interfaceSupport.inline.hpp"
  54 #include "runtime/mutexLocker.hpp"
  55 #include "runtime/orderAccess.hpp"
  56 #include "runtime/osThread.hpp"
  57 #include "runtime/safepoint.hpp"
  58 #include "runtime/safepointMechanism.inline.hpp"
  59 #include "runtime/signature.hpp"
  60 #include "runtime/stackWatermarkSet.inline.hpp"
  61 #include "runtime/stubCodeGenerator.hpp"
  62 #include "runtime/stubRoutines.hpp"
  63 #include "runtime/sweeper.hpp"
  64 #include "runtime/synchronizer.hpp"
  65 #include "runtime/thread.inline.hpp"
  66 #include "runtime/threadSMR.hpp"
  67 #include "runtime/threadWXSetters.inline.hpp"
  68 #include "runtime/timerTrace.hpp"
  69 #include "services/runtimeService.hpp"
  70 #include "utilities/events.hpp"
  71 #include "utilities/macros.hpp"
  72 
  73 static void post_safepoint_begin_event(EventSafepointBegin& event,
  74                                        uint64_t safepoint_id,
  75                                        int thread_count,
  76                                        int critical_thread_count) {
  77   if (event.should_commit()) {
  78     event.set_safepointId(safepoint_id);
  79     event.set_totalThreadCount(thread_count);
  80     event.set_jniCriticalThreadCount(critical_thread_count);
  81     event.commit();
  82   }
  83 }
  84 
  85 static void post_safepoint_cleanup_event(EventSafepointCleanup& event, uint64_t safepoint_id) {
  86   if (event.should_commit()) {
  87     event.set_safepointId(safepoint_id);
  88     event.commit();
  89   }
  90 }
  91 
  92 static void post_safepoint_synchronize_event(EventSafepointStateSynchronization& event,
  93                                              uint64_t safepoint_id,
  94                                              int initial_number_of_threads,
  95                                              int threads_waiting_to_block,
  96                                              uint64_t iterations) {
  97   if (event.should_commit()) {
  98     event.set_safepointId(safepoint_id);
  99     event.set_initialThreadCount(initial_number_of_threads);
 100     event.set_runningThreadCount(threads_waiting_to_block);
 101     event.set_iterations(iterations);
 102     event.commit();
 103   }
 104 }
 105 
 106 static void post_safepoint_cleanup_task_event(EventSafepointCleanupTask& event,
 107                                               uint64_t safepoint_id,
 108                                               const char* name) {
 109   if (event.should_commit()) {
 110     event.set_safepointId(safepoint_id);
 111     event.set_name(name);
 112     event.commit();
 113   }
 114 }
 115 
 116 static void post_safepoint_end_event(EventSafepointEnd& event, uint64_t safepoint_id) {
 117   if (event.should_commit()) {
 118     event.set_safepointId(safepoint_id);
 119     event.commit();
 120   }
 121 }
 122 
 123 // SafepointCheck
 124 SafepointStateTracker::SafepointStateTracker(uint64_t safepoint_id, bool at_safepoint)
 125   : _safepoint_id(safepoint_id), _at_safepoint(at_safepoint) {}
 126 
 127 bool SafepointStateTracker::safepoint_state_changed() {
 128   return _safepoint_id != SafepointSynchronize::safepoint_id() ||
 129     _at_safepoint != SafepointSynchronize::is_at_safepoint();
 130 }
 131 
 132 // --------------------------------------------------------------------------------------------------
 133 // Implementation of Safepoint begin/end
 134 
 135 SafepointSynchronize::SynchronizeState volatile SafepointSynchronize::_state = SafepointSynchronize::_not_synchronized;
 136 int SafepointSynchronize::_waiting_to_block = 0;
 137 volatile uint64_t SafepointSynchronize::_safepoint_counter = 0;
 138 uint64_t SafepointSynchronize::_safepoint_id = 0;
 139 const uint64_t SafepointSynchronize::InactiveSafepointCounter = 0;
 140 int SafepointSynchronize::_current_jni_active_count = 0;
 141 
 142 WaitBarrier* SafepointSynchronize::_wait_barrier;
 143 
 144 static bool timeout_error_printed = false;
 145 
 146 // Statistic related
 147 static jlong _safepoint_begin_time = 0;
 148 static volatile int _nof_threads_hit_polling_page = 0;
 149 
 150 void SafepointSynchronize::init(Thread* vmthread) {
 151   // WaitBarrier should never be destroyed since we will have
 152   // threads waiting on it while exiting.
 153   _wait_barrier = new WaitBarrier(vmthread);
 154   SafepointTracing::init();
 155 }
 156 
 157 void SafepointSynchronize::increment_jni_active_count() {
 158   assert(Thread::current()->is_VM_thread(), "Only VM thread may increment");
 159   ++_current_jni_active_count;
 160 }
 161 
 162 void SafepointSynchronize::decrement_waiting_to_block() {
 163   assert(_waiting_to_block > 0, "sanity check");
 164   assert(Thread::current()->is_VM_thread(), "Only VM thread may decrement");
 165   --_waiting_to_block;
 166 }
 167 
 168 bool SafepointSynchronize::thread_not_running(ThreadSafepointState *cur_state) {
 169   if (!cur_state->is_running()) {
 170     return true;
 171   }
 172   cur_state->examine_state_of_thread(SafepointSynchronize::safepoint_counter());
 173   if (!cur_state->is_running()) {
 174     return true;
 175   }
 176   LogTarget(Trace, safepoint) lt;
 177   if (lt.is_enabled()) {
 178     ResourceMark rm;
 179     LogStream ls(lt);
 180     cur_state->print_on(&ls);
 181   }
 182   return false;
 183 }
 184 
 185 #ifdef ASSERT
 186 static void assert_list_is_valid(const ThreadSafepointState* tss_head, int still_running) {
 187   int a = 0;
 188   const ThreadSafepointState *tmp_tss = tss_head;
 189   while (tmp_tss != NULL) {
 190     ++a;
 191     assert(tmp_tss->is_running(), "Illegal initial state");
 192     tmp_tss = tmp_tss->get_next();
 193   }
 194   assert(a == still_running, "Must be the same");
 195 }
 196 #endif // ASSERT
 197 
 198 static void back_off(int64_t start_time) {
 199   // We start with fine-grained nanosleeping until a millisecond has
 200   // passed, at which point we resort to plain naked_short_sleep.
 201   if (os::javaTimeNanos() - start_time < NANOSECS_PER_MILLISEC) {
 202     os::naked_short_nanosleep(10 * (NANOUNITS / MICROUNITS));
 203   } else {
 204     os::naked_short_sleep(1);
 205   }
 206 }
 207 
 208 int SafepointSynchronize::synchronize_threads(jlong safepoint_limit_time, int nof_threads, int* initial_running)
 209 {
 210   JavaThreadIteratorWithHandle jtiwh;
 211 
 212 #ifdef ASSERT
 213   for (; JavaThread *cur = jtiwh.next(); ) {
 214     assert(cur->safepoint_state()->is_running(), "Illegal initial state");
 215   }
 216   jtiwh.rewind();
 217 #endif // ASSERT
 218 
 219   // Iterate through all threads until it has been determined how to stop them all at a safepoint.
 220   int still_running = nof_threads;
 221   ThreadSafepointState *tss_head = NULL;
 222   ThreadSafepointState **p_prev = &tss_head;
 223   for (; JavaThread *cur = jtiwh.next(); ) {
 224     ThreadSafepointState *cur_tss = cur->safepoint_state();
 225     assert(cur_tss->get_next() == NULL, "Must be NULL");
 226     if (thread_not_running(cur_tss)) {
 227       --still_running;
 228     } else {
 229       *p_prev = cur_tss;
 230       p_prev = cur_tss->next_ptr();
 231     }
 232   }
 233   *p_prev = NULL;
 234 
 235   DEBUG_ONLY(assert_list_is_valid(tss_head, still_running);)
 236 
 237   *initial_running = still_running;
 238 
 239   // If there is no thread still running, we are already done.
 240   if (still_running <= 0) {
 241     assert(tss_head == NULL, "Must be empty");
 242     return 1;
 243   }
 244 
 245   int iterations = 1; // The first iteration is above.
 246   int64_t start_time = os::javaTimeNanos();
 247 
 248   do {
 249     // Check if this has taken too long:
 250     if (SafepointTimeout && safepoint_limit_time < os::javaTimeNanos()) {
 251       print_safepoint_timeout();
 252     }
 253 
 254     p_prev = &tss_head;
 255     ThreadSafepointState *cur_tss = tss_head;
 256     while (cur_tss != NULL) {
 257       assert(cur_tss->is_running(), "Illegal initial state");
 258       if (thread_not_running(cur_tss)) {
 259         --still_running;
 260         *p_prev = NULL;
 261         ThreadSafepointState *tmp = cur_tss;
 262         cur_tss = cur_tss->get_next();
 263         tmp->set_next(NULL);
 264       } else {
 265         *p_prev = cur_tss;
 266         p_prev = cur_tss->next_ptr();
 267         cur_tss = cur_tss->get_next();
 268       }
 269     }
 270 
 271     DEBUG_ONLY(assert_list_is_valid(tss_head, still_running);)
 272 
 273     if (still_running > 0) {
 274       back_off(start_time);
 275     }
 276 
 277     iterations++;
 278   } while (still_running > 0);
 279 
 280   assert(tss_head == NULL, "Must be empty");
 281 
 282   return iterations;
 283 }
 284 
 285 void SafepointSynchronize::arm_safepoint() {
 286   // Begin the process of bringing the system to a safepoint.
 287   // Java threads can be in several different states and are
 288   // stopped by different mechanisms:
 289   //
 290   //  1. Running interpreted
 291   //     When executing branching/returning byte codes interpreter
 292   //     checks if the poll is armed, if so blocks in SS::block().
 293   //  2. Running in native code
 294   //     When returning from the native code, a Java thread must check
 295   //     the safepoint _state to see if we must block.  If the
 296   //     VM thread sees a Java thread in native, it does
 297   //     not wait for this thread to block.  The order of the memory
 298   //     writes and reads of both the safepoint state and the Java
 299   //     threads state is critical.  In order to guarantee that the
 300   //     memory writes are serialized with respect to each other,
 301   //     the VM thread issues a memory barrier instruction.
 302   //  3. Running compiled Code
 303   //     Compiled code reads the local polling page that
 304   //     is set to fault if we are trying to get to a safepoint.
 305   //  4. Blocked
 306   //     A thread which is blocked will not be allowed to return from the
 307   //     block condition until the safepoint operation is complete.
 308   //  5. In VM or Transitioning between states
 309   //     If a Java thread is currently running in the VM or transitioning
 310   //     between states, the safepointing code will poll the thread state
 311   //     until the thread blocks itself when it attempts transitions to a
 312   //     new state or locking a safepoint checked monitor.
 313 
 314   // We must never miss a thread with correct safepoint id, so we must make sure we arm
 315   // the wait barrier for the next safepoint id/counter.
 316   // Arming must be done after resetting _current_jni_active_count, _waiting_to_block.
 317   _wait_barrier->arm(static_cast<int>(_safepoint_counter + 1));
 318 
 319   assert((_safepoint_counter & 0x1) == 0, "must be even");
 320   // The store to _safepoint_counter must happen after any stores in arming.
 321   Atomic::release_store(&_safepoint_counter, _safepoint_counter + 1);
 322 
 323   // We are synchronizing
 324   OrderAccess::storestore(); // Ordered with _safepoint_counter
 325   _state = _synchronizing;
 326 
 327   // Arming the per thread poll while having _state != _not_synchronized means safepointing
 328   log_trace(safepoint)("Setting thread local yield flag for threads");
 329   OrderAccess::storestore(); // storestore, global state -> local state
 330   for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur = jtiwh.next(); ) {
 331     // Make sure the threads start polling, it is time to yield.
 332     SafepointMechanism::arm_local_poll(cur);
 333   }
 334 
 335   OrderAccess::fence(); // storestore|storeload, global state -> local state
 336 }
 337 
 338 // Roll all threads forward to a safepoint and suspend them all
 339 void SafepointSynchronize::begin() {
 340   assert(Thread::current()->is_VM_thread(), "Only VM thread may execute a safepoint");
 341 
 342   EventSafepointBegin begin_event;
 343   SafepointTracing::begin(VMThread::vm_op_type());
 344 
 345   Universe::heap()->safepoint_synchronize_begin();
 346 
 347   // By getting the Threads_lock, we assure that no threads are about to start or
 348   // exit. It is released again in SafepointSynchronize::end().
 349   Threads_lock->lock();
 350 
 351   assert( _state == _not_synchronized, "trying to safepoint synchronize with wrong state");
 352 
 353   int nof_threads = Threads::number_of_threads();
 354 
 355   _nof_threads_hit_polling_page = 0;
 356 
 357   log_debug(safepoint)("Safepoint synchronization initiated using %s wait barrier. (%d threads)", _wait_barrier->description(), nof_threads);
 358 
 359   // Reset the count of active JNI critical threads
 360   _current_jni_active_count = 0;
 361 
 362   // Set number of threads to wait for
 363   _waiting_to_block = nof_threads;
 364 
 365   jlong safepoint_limit_time = 0;
 366   if (SafepointTimeout) {
 367     // Set the limit time, so that it can be compared to see if this has taken
 368     // too long to complete.
 369     safepoint_limit_time = SafepointTracing::start_of_safepoint() + (jlong)SafepointTimeoutDelay * (NANOUNITS / MILLIUNITS);
 370     timeout_error_printed = false;
 371   }
 372 
 373   EventSafepointStateSynchronization sync_event;
 374   int initial_running = 0;
 375 
 376   // Arms the safepoint, _current_jni_active_count and _waiting_to_block must be set before.
 377   arm_safepoint();
 378 
 379   // Will spin until all threads are safe.
 380   int iterations = synchronize_threads(safepoint_limit_time, nof_threads, &initial_running);
 381   assert(_waiting_to_block == 0, "No thread should be running");
 382 
 383 #ifndef PRODUCT
 384   // Mark all threads
 385   if (VerifyCrossModifyFence) {
 386     JavaThreadIteratorWithHandle jtiwh;
 387     for (; JavaThread *cur = jtiwh.next(); ) {
 388       cur->set_requires_cross_modify_fence(true);
 389     }
 390   }
 391 
 392   if (safepoint_limit_time != 0) {
 393     jlong current_time = os::javaTimeNanos();
 394     if (safepoint_limit_time < current_time) {
 395       log_warning(safepoint)("# SafepointSynchronize: Finished after "
 396                     INT64_FORMAT_W(6) " ms",
 397                     (int64_t)(current_time - SafepointTracing::start_of_safepoint()) / (NANOUNITS / MILLIUNITS));
 398     }
 399   }
 400 #endif
 401 
 402   assert(Threads_lock->owned_by_self(), "must hold Threads_lock");
 403 
 404   // Record state
 405   _state = _synchronized;
 406 
 407   OrderAccess::fence();
 408 
 409   // Set the new id
 410   ++_safepoint_id;
 411 
 412 #ifdef ASSERT
 413   // Make sure all the threads were visited.
 414   for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur = jtiwh.next(); ) {
 415     assert(cur->was_visited_for_critical_count(_safepoint_counter), "missed a thread");
 416   }
 417 #endif // ASSERT
 418 
 419   // Update the count of active JNI critical regions
 420   GCLocker::set_jni_lock_count(_current_jni_active_count);
 421 
 422   post_safepoint_synchronize_event(sync_event,
 423                                    _safepoint_id,
 424                                    initial_running,
 425                                    _waiting_to_block, iterations);
 426 
 427   SafepointTracing::synchronized(nof_threads, initial_running, _nof_threads_hit_polling_page);
 428 
 429   // We do the safepoint cleanup first since a GC related safepoint
 430   // needs cleanup to be completed before running the GC op.
 431   EventSafepointCleanup cleanup_event;
 432   do_cleanup_tasks();
 433   post_safepoint_cleanup_event(cleanup_event, _safepoint_id);
 434 
 435   post_safepoint_begin_event(begin_event, _safepoint_id, nof_threads, _current_jni_active_count);
 436   SafepointTracing::cleanup();
 437 }
 438 
 439 void SafepointSynchronize::disarm_safepoint() {
 440   uint64_t active_safepoint_counter = _safepoint_counter;
 441   {
 442     JavaThreadIteratorWithHandle jtiwh;
 443 #ifdef ASSERT
 444     // A pending_exception cannot be installed during a safepoint.  The threads
 445     // may install an async exception after they come back from a safepoint into
 446     // pending_exception after they unblock.  But that should happen later.
 447     for (; JavaThread *cur = jtiwh.next(); ) {
 448       assert (!(cur->has_pending_exception() &&
 449                 cur->safepoint_state()->is_at_poll_safepoint()),
 450               "safepoint installed a pending exception");
 451     }
 452 #endif // ASSERT
 453 
 454     OrderAccess::fence(); // keep read and write of _state from floating up
 455     assert(_state == _synchronized, "must be synchronized before ending safepoint synchronization");
 456 
 457     // Change state first to _not_synchronized.
 458     // No threads should see _synchronized when running.
 459     _state = _not_synchronized;
 460 
 461     // Set the next dormant (even) safepoint id.
 462     assert((_safepoint_counter & 0x1) == 1, "must be odd");
 463     Atomic::release_store(&_safepoint_counter, _safepoint_counter + 1);
 464 
 465     OrderAccess::fence(); // Keep the local state from floating up.
 466 
 467     jtiwh.rewind();
 468     for (; JavaThread *current = jtiwh.next(); ) {
 469       // Clear the visited flag to ensure that the critical counts are collected properly.
 470       DEBUG_ONLY(current->reset_visited_for_critical_count(active_safepoint_counter);)
 471       ThreadSafepointState* cur_state = current->safepoint_state();
 472       assert(!cur_state->is_running(), "Thread not suspended at safepoint");
 473       cur_state->restart(); // TSS _running
 474       assert(cur_state->is_running(), "safepoint state has not been reset");
 475     }
 476   } // ~JavaThreadIteratorWithHandle
 477 
 478   // Release threads lock, so threads can be created/destroyed again.
 479   Threads_lock->unlock();
 480 
 481   // Wake threads after local state is correctly set.
 482   _wait_barrier->disarm();
 483 }
 484 
 485 // Wake up all threads, so they are ready to resume execution after the safepoint
 486 // operation has been carried out
 487 void SafepointSynchronize::end() {
 488   assert(Threads_lock->owned_by_self(), "must hold Threads_lock");
 489   EventSafepointEnd event;
 490   assert(Thread::current()->is_VM_thread(), "Only VM thread can execute a safepoint");
 491 
 492   disarm_safepoint();
 493 
 494   Universe::heap()->safepoint_synchronize_end();
 495 
 496   SafepointTracing::end();
 497 
 498   post_safepoint_end_event(event, safepoint_id());
 499 }
 500 
 501 bool SafepointSynchronize::is_cleanup_needed() {
 502   // Need a safepoint if some inline cache buffers is non-empty
 503   if (!InlineCacheBuffer::is_empty()) return true;
 504   if (StringTable::needs_rehashing()) return true;
 505   if (SymbolTable::needs_rehashing()) return true;
 506   return false;
 507 }
 508 
 509 class ParallelSPCleanupThreadClosure : public ThreadClosure {
 510 public:
 511   void do_thread(Thread* thread) {
 512     if (thread->is_Java_thread()) {
 513       StackWatermarkSet::start_processing(JavaThread::cast(thread), StackWatermarkKind::gc);
 514     }
 515   }
 516 };
 517 
 518 class ParallelSPCleanupTask : public AbstractGangTask {
 519 private:
 520   SubTasksDone _subtasks;
 521   uint _num_workers;
 522   bool _do_lazy_roots;
 523 
 524   class Tracer {
 525   private:
 526     const char*               _name;
 527     EventSafepointCleanupTask _event;
 528     TraceTime                 _timer;
 529 
 530   public:
 531     Tracer(const char* name) :
 532         _name(name),
 533         _event(),
 534         _timer(name, TRACETIME_LOG(Info, safepoint, cleanup)) {}
 535     ~Tracer() {
 536       post_safepoint_cleanup_task_event(_event, SafepointSynchronize::safepoint_id(), _name);
 537     }
 538   };
 539 
 540 public:
 541   ParallelSPCleanupTask(uint num_workers) :
 542     AbstractGangTask("Parallel Safepoint Cleanup"),
 543     _subtasks(SafepointSynchronize::SAFEPOINT_CLEANUP_NUM_TASKS),
 544     _num_workers(num_workers),
 545     _do_lazy_roots(!VMThread::vm_operation()->skip_thread_oop_barriers() &&
 546                    Universe::heap()->uses_stack_watermark_barrier()) {}
 547 
 548   void work(uint worker_id) {
 549     if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_LAZY_ROOT_PROCESSING)) {
 550       if (_do_lazy_roots) {
 551         Tracer t("lazy partial thread root processing");
 552         ParallelSPCleanupThreadClosure cl;
 553         Threads::threads_do(&cl);
 554       }
 555     }
 556 
 557     if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_UPDATE_INLINE_CACHES)) {
 558       Tracer t("updating inline caches");
 559       InlineCacheBuffer::update_inline_caches();
 560     }
 561 
 562     if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_COMPILATION_POLICY)) {
 563       Tracer t("compilation policy safepoint handler");
 564       CompilationPolicy::do_safepoint_work();
 565     }
 566 
 567     if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_SYMBOL_TABLE_REHASH)) {
 568       if (SymbolTable::needs_rehashing()) {
 569         Tracer t("rehashing symbol table");
 570         SymbolTable::rehash_table();
 571       }
 572     }
 573 
 574     if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_STRING_TABLE_REHASH)) {
 575       if (StringTable::needs_rehashing()) {
 576         Tracer t("rehashing string table");
 577         StringTable::rehash_table();
 578       }
 579     }
 580 
 581     if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_SYSTEM_DICTIONARY_RESIZE)) {
 582       if (Dictionary::does_any_dictionary_needs_resizing()) {
 583         Tracer t("resizing system dictionaries");
 584         ClassLoaderDataGraph::resize_dictionaries();
 585       }
 586     }
 587 
 588     if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_REQUEST_OOPSTORAGE_CLEANUP)) {
 589       // Don't bother reporting event or time for this very short operation.
 590       // To have any utility we'd also want to report whether needed.
 591       OopStorage::trigger_cleanup_if_needed();
 592     }
 593 
 594     _subtasks.all_tasks_claimed();
 595   }
 596 };
 597 
 598 // Various cleaning tasks that should be done periodically at safepoints.
 599 void SafepointSynchronize::do_cleanup_tasks() {
 600 
 601   TraceTime timer("safepoint cleanup tasks", TRACETIME_LOG(Info, safepoint, cleanup));
 602 
 603   CollectedHeap* heap = Universe::heap();
 604   assert(heap != NULL, "heap not initialized yet?");
 605   WorkGang* cleanup_workers = heap->safepoint_workers();
 606   if (cleanup_workers != NULL) {
 607     // Parallel cleanup using GC provided thread pool.
 608     uint num_cleanup_workers = cleanup_workers->active_workers();
 609     ParallelSPCleanupTask cleanup(num_cleanup_workers);
 610     cleanup_workers->run_task(&cleanup);
 611   } else {
 612     // Serial cleanup using VMThread.
 613     ParallelSPCleanupTask cleanup(1);
 614     cleanup.work(0);
 615   }
 616 
 617   assert(InlineCacheBuffer::is_empty(), "should have cleaned up ICBuffer");
 618 
 619   if (log_is_enabled(Debug, monitorinflation)) {
 620     // The VMThread calls do_final_audit_and_print_stats() which calls
 621     // audit_and_print_stats() at the Info level at VM exit time.
 622     ObjectSynchronizer::audit_and_print_stats(false /* on_exit */);
 623   }
 624 }
 625 
 626 // Methods for determining if a JavaThread is safepoint safe.
 627 
 628 // False means unsafe with undetermined state.
 629 // True means a determined state, but it may be an unsafe state.
 630 // If called from a non-safepoint context safepoint_count MUST be InactiveSafepointCounter.
 631 bool SafepointSynchronize::try_stable_load_state(JavaThreadState *state, JavaThread *thread, uint64_t safepoint_count) {
 632   assert((safepoint_count != InactiveSafepointCounter &&
 633           Thread::current() == (Thread*)VMThread::vm_thread() &&
 634           SafepointSynchronize::_state != _not_synchronized)
 635          || safepoint_count == InactiveSafepointCounter, "Invalid check");
 636 
 637   // To handle the thread_blocked state on the backedge of the WaitBarrier from
 638   // previous safepoint and reading the reset value (0/InactiveSafepointCounter) we
 639   // re-read state after we read thread safepoint id. The JavaThread changes its
 640   // thread state from thread_blocked before resetting safepoint id to 0.
 641   // This guarantees the second read will be from an updated thread state. It can
 642   // either be different state making this an unsafe state or it can see blocked
 643   // again. When we see blocked twice with a 0 safepoint id, either:
 644   // - It is normally blocked, e.g. on Mutex, TBIVM.
 645   // - It was in SS:block(), looped around to SS:block() and is blocked on the WaitBarrier.
 646   // - It was in SS:block() but now on a Mutex.
 647   // All of these cases are safe.
 648 
 649   *state = thread->thread_state();
 650   OrderAccess::loadload();
 651   uint64_t sid = thread->safepoint_state()->get_safepoint_id();  // Load acquire
 652   if (sid != InactiveSafepointCounter && sid != safepoint_count) {
 653     // In an old safepoint, state not relevant.
 654     return false;
 655   }
 656   return *state == thread->thread_state();
 657 }
 658 
 659 static bool safepoint_safe_with(JavaThread *thread, JavaThreadState state) {
 660   switch(state) {
 661   case _thread_in_native:
 662     // native threads are safe if they have no java stack or have walkable stack
 663     return !thread->has_last_Java_frame() || thread->frame_anchor()->walkable();
 664 
 665   case _thread_blocked:
 666     // On wait_barrier or blocked.
 667     // Blocked threads should already have walkable stack.
 668     assert(!thread->has_last_Java_frame() || thread->frame_anchor()->walkable(), "blocked and not walkable");
 669     return true;
 670 
 671   default:
 672     return false;
 673   }
 674 }
 675 
 676 bool SafepointSynchronize::handshake_safe(JavaThread *thread) {
 677   if (thread->is_terminated()) {
 678     return true;
 679   }
 680   JavaThreadState stable_state;
 681   if (try_stable_load_state(&stable_state, thread, InactiveSafepointCounter)) {
 682     return safepoint_safe_with(thread, stable_state);
 683   }
 684   return false;
 685 }
 686 
 687 
 688 // -------------------------------------------------------------------------------------------------------
 689 // Implementation of Safepoint blocking point
 690 
 691 void SafepointSynchronize::block(JavaThread *thread) {
 692   assert(thread != NULL, "thread must be set");
 693 
 694   // Threads shouldn't block if they are in the middle of printing, but...
 695   ttyLocker::break_tty_lock_for_safepoint(os::current_thread_id());
 696 
 697   // Only bail from the block() call if the thread is gone from the
 698   // thread list; starting to exit should still block.
 699   if (thread->is_terminated()) {
 700      // block current thread if we come here from native code when VM is gone
 701      thread->block_if_vm_exited();
 702 
 703      // otherwise do nothing
 704      return;
 705   }
 706 
 707   JavaThreadState state = thread->thread_state();
 708   assert(is_a_block_safe_state(state), "Illegal threadstate encountered: %d", state);
 709   thread->frame_anchor()->make_walkable(thread);
 710 
 711   uint64_t safepoint_id = SafepointSynchronize::safepoint_counter();
 712 
 713   // We have no idea where the VMThread is, it might even be at next safepoint.
 714   // So we can miss this poll, but stop at next.
 715 
 716   // Load dependent store, it must not pass loading of safepoint_id.
 717   thread->safepoint_state()->set_safepoint_id(safepoint_id); // Release store
 718 
 719   // This part we can skip if we notice we miss or are in a future safepoint.
 720   OrderAccess::storestore();
 721   // Load in wait barrier should not float up
 722   thread->set_thread_state_fence(_thread_blocked);
 723 
 724   _wait_barrier->wait(static_cast<int>(safepoint_id));
 725   assert(_state != _synchronized, "Can't be");
 726 
 727   // If barrier is disarmed stop store from floating above loads in barrier.
 728   OrderAccess::loadstore();
 729   thread->set_thread_state(state);
 730 
 731   // Then we reset the safepoint id to inactive.
 732   thread->safepoint_state()->reset_safepoint_id(); // Release store
 733 
 734   OrderAccess::fence();
 735 
 736   guarantee(thread->safepoint_state()->get_safepoint_id() == InactiveSafepointCounter,
 737             "The safepoint id should be set only in block path");
 738 
 739   // cross_modify_fence is done by SafepointMechanism::process_if_requested
 740   // which is the only caller here.
 741 }
 742 
 743 // ------------------------------------------------------------------------------------------------------
 744 // Exception handlers
 745 
 746 
 747 void SafepointSynchronize::handle_polling_page_exception(JavaThread *thread) {
 748   assert(thread->thread_state() == _thread_in_Java, "should come from Java code");
 749 
 750   // Enable WXWrite: the function is called implicitly from java code.
 751   MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, thread));
 752 
 753   if (log_is_enabled(Info, safepoint, stats)) {
 754     Atomic::inc(&_nof_threads_hit_polling_page);
 755   }
 756 
 757   ThreadSafepointState* state = thread->safepoint_state();
 758 
 759   state->handle_polling_page_exception();
 760 }
 761 
 762 
 763 void SafepointSynchronize::print_safepoint_timeout() {
 764   if (!timeout_error_printed) {
 765     timeout_error_printed = true;
 766     // Print out the thread info which didn't reach the safepoint for debugging
 767     // purposes (useful when there are lots of threads in the debugger).
 768     LogTarget(Warning, safepoint) lt;
 769     if (lt.is_enabled()) {
 770       ResourceMark rm;
 771       LogStream ls(lt);
 772 
 773       ls.cr();
 774       ls.print_cr("# SafepointSynchronize::begin: Timeout detected:");
 775       ls.print_cr("# SafepointSynchronize::begin: Timed out while spinning to reach a safepoint.");
 776       ls.print_cr("# SafepointSynchronize::begin: Threads which did not reach the safepoint:");
 777       for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur_thread = jtiwh.next(); ) {
 778         if (cur_thread->safepoint_state()->is_running()) {
 779           ls.print("# ");
 780           cur_thread->print_on(&ls);
 781           ls.cr();
 782         }
 783       }
 784       ls.print_cr("# SafepointSynchronize::begin: (End of list)");
 785     }
 786   }
 787 
 788   // To debug the long safepoint, specify both AbortVMOnSafepointTimeout &
 789   // ShowMessageBoxOnError.
 790   if (AbortVMOnSafepointTimeout) {
 791     // Send the blocking thread a signal to terminate and write an error file.
 792     for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur_thread = jtiwh.next(); ) {
 793       if (cur_thread->safepoint_state()->is_running()) {
 794         if (!os::signal_thread(cur_thread, SIGILL, "blocking a safepoint")) {
 795           break; // Could not send signal. Report fatal error.
 796         }
 797         // Give cur_thread a chance to report the error and terminate the VM.
 798         os::naked_sleep(3000);
 799       }
 800     }
 801     fatal("Safepoint sync time longer than " INTX_FORMAT "ms detected when executing %s.",
 802           SafepointTimeoutDelay, VMThread::vm_operation()->name());
 803   }
 804 }
 805 
 806 // -------------------------------------------------------------------------------------------------------
 807 // Implementation of ThreadSafepointState
 808 
 809 ThreadSafepointState::ThreadSafepointState(JavaThread *thread)
 810   : _at_poll_safepoint(false), _thread(thread), _safepoint_safe(false),
 811     _safepoint_id(SafepointSynchronize::InactiveSafepointCounter), _next(NULL) {
 812 }
 813 
 814 void ThreadSafepointState::create(JavaThread *thread) {
 815   ThreadSafepointState *state = new ThreadSafepointState(thread);
 816   thread->set_safepoint_state(state);
 817 }
 818 
 819 void ThreadSafepointState::destroy(JavaThread *thread) {
 820   if (thread->safepoint_state()) {
 821     delete(thread->safepoint_state());
 822     thread->set_safepoint_state(NULL);
 823   }
 824 }
 825 
 826 uint64_t ThreadSafepointState::get_safepoint_id() const {
 827   return Atomic::load_acquire(&_safepoint_id);
 828 }
 829 
 830 void ThreadSafepointState::reset_safepoint_id() {
 831   Atomic::release_store(&_safepoint_id, SafepointSynchronize::InactiveSafepointCounter);
 832 }
 833 
 834 void ThreadSafepointState::set_safepoint_id(uint64_t safepoint_id) {
 835   Atomic::release_store(&_safepoint_id, safepoint_id);
 836 }
 837 
 838 void ThreadSafepointState::examine_state_of_thread(uint64_t safepoint_count) {
 839   assert(is_running(), "better be running or just have hit safepoint poll");
 840 
 841   JavaThreadState stable_state;
 842   if (!SafepointSynchronize::try_stable_load_state(&stable_state, _thread, safepoint_count)) {
 843     // We could not get stable state of the JavaThread.
 844     // Consider it running and just return.
 845     return;
 846   }
 847 
 848   if (safepoint_safe_with(_thread, stable_state)) {
 849     account_safe_thread();
 850     return;
 851   }
 852 
 853   // All other thread states will continue to run until they
 854   // transition and self-block in state _blocked
 855   // Safepoint polling in compiled code causes the Java threads to do the same.
 856   // Note: new threads may require a malloc so they must be allowed to finish
 857 
 858   assert(is_running(), "examine_state_of_thread on non-running thread");
 859   return;
 860 }
 861 
 862 void ThreadSafepointState::account_safe_thread() {
 863   SafepointSynchronize::decrement_waiting_to_block();
 864   if (_thread->in_critical()) {
 865     // Notice that this thread is in a critical section
 866     SafepointSynchronize::increment_jni_active_count();
 867   }
 868   DEBUG_ONLY(_thread->set_visited_for_critical_count(SafepointSynchronize::safepoint_counter());)
 869   assert(!_safepoint_safe, "Must be unsafe before safe");
 870   _safepoint_safe = true;
 871 }
 872 
 873 void ThreadSafepointState::restart() {
 874   assert(_safepoint_safe, "Must be safe before unsafe");
 875   _safepoint_safe = false;
 876 }
 877 
 878 void ThreadSafepointState::print_on(outputStream *st) const {
 879   const char *s = _safepoint_safe ? "_at_safepoint" : "_running";
 880 
 881   st->print_cr("Thread: " INTPTR_FORMAT
 882               "  [0x%2x] State: %s _at_poll_safepoint %d",
 883                p2i(_thread), _thread->osthread()->thread_id(), s, _at_poll_safepoint);
 884 
 885   _thread->print_thread_state_on(st);
 886 }
 887 
 888 // ---------------------------------------------------------------------------------------------------------------------
 889 
 890 // Process pending operation.
 891 void ThreadSafepointState::handle_polling_page_exception() {
 892   JavaThread* self = thread();
 893   assert(self == JavaThread::current(), "must be self");
 894 
 895   // Step 1: Find the nmethod from the return address
 896   address real_return_addr = self->saved_exception_pc();
 897 
 898   CodeBlob *cb = CodeCache::find_blob(real_return_addr);
 899   assert(cb != NULL && cb->is_compiled(), "return address should be in nmethod");
 900   CompiledMethod* nm = (CompiledMethod*)cb;
 901 
 902   // Find frame of caller
 903   frame stub_fr = self->last_frame();
 904   CodeBlob* stub_cb = stub_fr.cb();
 905   assert(stub_cb->is_safepoint_stub(), "must be a safepoint stub");
 906   RegisterMap map(self, true, false);
 907   frame caller_fr = stub_fr.sender(&map);
 908 
 909   // Should only be poll_return or poll
 910   assert( nm->is_at_poll_or_poll_return(real_return_addr), "should not be at call" );
 911 
 912   // This is a poll immediately before a return. The exception handling code
 913   // has already had the effect of causing the return to occur, so the execution
 914   // will continue immediately after the call. In addition, the oopmap at the
 915   // return point does not mark the return value as an oop (if it is), so
 916   // it needs a handle here to be updated.
 917   if( nm->is_at_poll_return(real_return_addr) ) {

 918     // See if return type is an oop.
 919     bool return_oop = nm->method()->is_returning_oop();

 920     HandleMark hm(self);
 921     Handle return_value;















 922     if (return_oop) {
 923       // The oop result has been saved on the stack together with all
 924       // the other registers. In order to preserve it over GCs we need
 925       // to keep it in a handle.
 926       oop result = caller_fr.saved_oop_result(&map);
 927       assert(oopDesc::is_oop_or_null(result), "must be oop");
 928       return_value = Handle(self, result);
 929       assert(Universe::heap()->is_in_or_null(result), "must be heap pointer");
 930     }
 931 
 932     // We get here if compiled return polls found a reason to call into the VM.
 933     // One condition for that is that the top frame is not yet safe to use.
 934     // The following stack watermark barrier poll will catch such situations.
 935     StackWatermarkSet::after_unwind(self);
 936 
 937     // Process pending operation
 938     SafepointMechanism::process_if_requested_with_exit_check(self, true /* check asyncs */);
 939 
 940     // restore oop result, if any
 941     if (return_oop) {
 942       caller_fr.set_saved_oop_result(&map, return_value());



 943     }
 944   }
 945 
 946   // This is a safepoint poll. Verify the return address and block.
 947   else {
 948 
 949     // verify the blob built the "return address" correctly
 950     assert(real_return_addr == caller_fr.pc(), "must match");
 951 
 952     set_at_poll_safepoint(true);
 953     // Process pending operation
 954     // We never deliver an async exception at a polling point as the
 955     // compiler may not have an exception handler for it. The polling
 956     // code will notice the pending async exception, deoptimize and
 957     // the exception will be delivered. (Polling at a return point
 958     // is ok though). Sure is a lot of bother for a deprecated feature...
 959     SafepointMechanism::process_if_requested_with_exit_check(self, false /* check asyncs */);
 960     set_at_poll_safepoint(false);
 961 
 962     // If we have a pending async exception deoptimize the frame
 963     // as otherwise we may never deliver it.
 964     if (self->has_async_exception_condition()) {
 965       ThreadInVMfromJava __tiv(self, false /* check asyncs */);
 966       Deoptimization::deoptimize_frame(self, caller_fr.id());
 967     }
 968 
 969     // If an exception has been installed we must check for a pending deoptimization
 970     // Deoptimize frame if exception has been thrown.
 971 
 972     if (self->has_pending_exception() ) {
 973       RegisterMap map(self, true, false);
 974       frame caller_fr = stub_fr.sender(&map);
 975       if (caller_fr.is_deoptimized_frame()) {
 976         // The exception patch will destroy registers that are still
 977         // live and will be needed during deoptimization. Defer the
 978         // Async exception should have deferred the exception until the
 979         // next safepoint which will be detected when we get into
 980         // the interpreter so if we have an exception now things
 981         // are messed up.
 982 
 983         fatal("Exception installed and deoptimization is pending");
 984       }
 985     }
 986   }
 987 }
 988 
 989 
 990 // -------------------------------------------------------------------------------------------------------
 991 // Implementation of SafepointTracing
 992 
 993 jlong SafepointTracing::_last_safepoint_begin_time_ns = 0;
 994 jlong SafepointTracing::_last_safepoint_sync_time_ns = 0;
 995 jlong SafepointTracing::_last_safepoint_cleanup_time_ns = 0;
 996 jlong SafepointTracing::_last_safepoint_end_time_ns = 0;
 997 jlong SafepointTracing::_last_app_time_ns = 0;
 998 int SafepointTracing::_nof_threads = 0;
 999 int SafepointTracing::_nof_running = 0;
1000 int SafepointTracing::_page_trap = 0;
1001 VM_Operation::VMOp_Type SafepointTracing::_current_type;
1002 jlong     SafepointTracing::_max_sync_time = 0;
1003 jlong     SafepointTracing::_max_vmop_time = 0;
1004 uint64_t  SafepointTracing::_op_count[VM_Operation::VMOp_Terminating] = {0};
1005 
1006 void SafepointTracing::init() {
1007   // Application start
1008   _last_safepoint_end_time_ns = os::javaTimeNanos();
1009 }
1010 
1011 // Helper method to print the header.
1012 static void print_header(outputStream* st) {
1013   // The number of spaces is significant here, and should match the format
1014   // specifiers in print_statistics().
1015 
1016   st->print("VM Operation                 "
1017             "[ threads: total initial_running ]"
1018             "[ time:       sync    cleanup       vmop      total ]");
1019 
1020   st->print_cr(" page_trap_count");
1021 }
1022 
1023 // This prints a nice table.  To get the statistics to not shift due to the logging uptime
1024 // decorator, use the option as: -Xlog:safepoint+stats:[outputfile]:none
1025 void SafepointTracing::statistics_log() {
1026   LogTarget(Info, safepoint, stats) lt;
1027   assert (lt.is_enabled(), "should only be called when printing statistics is enabled");
1028   LogStream ls(lt);
1029 
1030   static int _cur_stat_index = 0;
1031 
1032   // Print header every 30 entries
1033   if ((_cur_stat_index % 30) == 0) {
1034     print_header(&ls);
1035     _cur_stat_index = 1;  // wrap
1036   } else {
1037     _cur_stat_index++;
1038   }
1039 
1040   ls.print("%-28s [       "
1041            INT32_FORMAT_W(8) "        " INT32_FORMAT_W(8) " "
1042            "]",
1043            VM_Operation::name(_current_type),
1044            _nof_threads,
1045            _nof_running);
1046   ls.print("[       "
1047            INT64_FORMAT_W(10) " " INT64_FORMAT_W(10) " "
1048            INT64_FORMAT_W(10) " " INT64_FORMAT_W(10) " ]",
1049            (int64_t)(_last_safepoint_sync_time_ns - _last_safepoint_begin_time_ns),
1050            (int64_t)(_last_safepoint_cleanup_time_ns - _last_safepoint_sync_time_ns),
1051            (int64_t)(_last_safepoint_end_time_ns - _last_safepoint_cleanup_time_ns),
1052            (int64_t)(_last_safepoint_end_time_ns - _last_safepoint_begin_time_ns));
1053 
1054   ls.print_cr(INT32_FORMAT_W(16), _page_trap);
1055 }
1056 
1057 // This method will be called when VM exits. This tries to summarize the sampling.
1058 // Current thread may already be deleted, so don't use ResourceMark.
1059 void SafepointTracing::statistics_exit_log() {
1060   if (!log_is_enabled(Info, safepoint, stats)) {
1061     return;
1062   }
1063   for (int index = 0; index < VM_Operation::VMOp_Terminating; index++) {
1064     if (_op_count[index] != 0) {
1065       log_info(safepoint, stats)("%-28s" UINT64_FORMAT_W(10), VM_Operation::name(index),
1066                _op_count[index]);
1067     }
1068   }
1069 
1070   log_info(safepoint, stats)("Maximum sync time  " INT64_FORMAT" ns",
1071                               (int64_t)(_max_sync_time));
1072   log_info(safepoint, stats)("Maximum vm operation time (except for Exit VM operation)  "
1073                               INT64_FORMAT " ns",
1074                               (int64_t)(_max_vmop_time));
1075 }
1076 
1077 void SafepointTracing::begin(VM_Operation::VMOp_Type type) {
1078   _op_count[type]++;
1079   _current_type = type;
1080 
1081   // update the time stamp to begin recording safepoint time
1082   _last_safepoint_begin_time_ns = os::javaTimeNanos();
1083   _last_safepoint_sync_time_ns = 0;
1084   _last_safepoint_cleanup_time_ns = 0;
1085 
1086   _last_app_time_ns = _last_safepoint_begin_time_ns - _last_safepoint_end_time_ns;
1087   _last_safepoint_end_time_ns = 0;
1088 
1089   RuntimeService::record_safepoint_begin(_last_app_time_ns);
1090 }
1091 
1092 void SafepointTracing::synchronized(int nof_threads, int nof_running, int traps) {
1093   _last_safepoint_sync_time_ns = os::javaTimeNanos();
1094   _nof_threads = nof_threads;
1095   _nof_running = nof_running;
1096   _page_trap   = traps;
1097   RuntimeService::record_safepoint_synchronized(_last_safepoint_sync_time_ns - _last_safepoint_begin_time_ns);
1098 }
1099 
1100 void SafepointTracing::cleanup() {
1101   _last_safepoint_cleanup_time_ns = os::javaTimeNanos();
1102 }
1103 
1104 void SafepointTracing::end() {
1105   _last_safepoint_end_time_ns = os::javaTimeNanos();
1106 
1107   if (_max_sync_time < (_last_safepoint_sync_time_ns - _last_safepoint_begin_time_ns)) {
1108     _max_sync_time = _last_safepoint_sync_time_ns - _last_safepoint_begin_time_ns;
1109   }
1110   if (_max_vmop_time < (_last_safepoint_end_time_ns - _last_safepoint_sync_time_ns)) {
1111     _max_vmop_time = _last_safepoint_end_time_ns - _last_safepoint_sync_time_ns;
1112   }
1113   if (log_is_enabled(Info, safepoint, stats)) {
1114     statistics_log();
1115   }
1116 
1117   log_info(safepoint)(
1118      "Safepoint \"%s\", "
1119      "Time since last: " JLONG_FORMAT " ns, "
1120      "Reaching safepoint: " JLONG_FORMAT " ns, "
1121      "At safepoint: " JLONG_FORMAT " ns, "
1122      "Total: " JLONG_FORMAT " ns",
1123       VM_Operation::name(_current_type),
1124       _last_app_time_ns,
1125       _last_safepoint_cleanup_time_ns - _last_safepoint_begin_time_ns,
1126       _last_safepoint_end_time_ns     - _last_safepoint_cleanup_time_ns,
1127       _last_safepoint_end_time_ns     - _last_safepoint_begin_time_ns
1128      );
1129 
1130   RuntimeService::record_safepoint_end(_last_safepoint_end_time_ns - _last_safepoint_cleanup_time_ns);
1131 }
--- EOF ---